pytwine.processors.PythonProcessor

class pytwine.processors.PythonProcessor(sink: typing.TextIO, log: typing.TextIO = <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>)[source]

Bases: pytwine.processors.Processor

Processor that tries to run all code blocks as Python.

Uncompileable code blocks just get omitted from the output.

TODO: put an error into the output

__init__(sink: typing.TextIO, log: typing.TextIO = <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>)[source]
Parameters

sink – a file-like object to be written to.

Methods

__init__(sink[, log])

param sink

a file-like object to be written to.

twine(chunks)

WORK IN PROGRESS - process chunks and write to sink.

twine(chunks: List[pytwine.core.Chunk]) pytwine.core.TwineExitStatus[source]

WORK IN PROGRESS - process chunks and write to sink.

in case of errors, returns a TwineExitStatus; its .value attribute is either int or None, and can be passed to sys.exit as a status code.

Effects:
  • output is written to the sink arrgument passed to the constructor.