katana.units.esoteric.ook — Ook

Unit for the Ook esoteric language.

This unit will map the Ook operations to their Brainfuck equivalant, and then pass along the actual execution to the Brainfuck unit’s evaluate_brainfuck function.

class katana.units.esoteric.ook.Unit(*args, **kwargs)

Bases: katana.unit.NotEnglishUnit

GROUPS = ['esoteric', 'ook']

These are “tags” for a unit. Considering it is a Esoteric unit, “esoteric” is included, as well as the unit name “ook”.

PRIORITY = 50

Priority works with 0 being the highest priority, and 100 being the lowest priority. 50 is the default priorty. This unit has default priority

evaluate(case: Any) → None

Evaluate the target. Run the target as Ook code and give the standard output results to Katana.

Parameters:case – A case returned by enumerate. For this unit, the enumerate function is not used.
Returns:None. This function should not return any data.
katana.units.esoteric.ook.evaluate_ook(code, input_file, timeout=1)

This function will actually evaluate the Ook code, by translating it to Brainfuck character mapping and then passing it to the evaluate_brainfuck unit.

This function also verifies that the Ook code is not an odd-length string. That would result in improper Ook code.

Parameters:
  • code – A byte string of the Ook code.
  • input_file – A file to for the Ook program to read as standard input. If this is not provided, it will yield a newline.
  • timeout – A timeout value in seconds. After this time has elapsed, the Ook code will stop executing.
Returns:

The standard output for the Ook program,