TAL interpreter.
Some notes on source annotations. They are HTML/XML comments added to the output whenever sourceFile is changed by a setSourceFile bytecode. Source annotations are disabled by default, but you can turn them on by passing a sourceAnnotations argument to the constructor. You can change the format of the annotations by overriding formatSourceAnnotation in a subclass.
The output of the annotation is delayed until some actual text is output for two reasons:
For performance reasons (TODO: premature optimization?) instead of checking the value of _pending_source_annotation on every write to the output stream, the _stream_write attribute is changed to point to _annotated_stream_write method whenever _pending_source_annotation is set to True, and to _stream.write when it is False. The following invariant always holds:
if self._pending_source_annotation: assert self._stream_write is self._annotated_stream_write else: assert self._stream_write is self.stream.write
There are no implemented interfaces.
bytecode_handlers
(type:
dict
)
{'insertText': <function do_insertText at 0x40d7c9cc>, 'startTag': <function do_startTag at 0x40d7c64c>, 'extendMacro': <function do_extendMacro at 0x40d7ce2c>, 'setSourceFile': <function do_setSourceFile at 0x40d7c5a4>, '<attrAction>': <function attrAction at 0x40d7c684>, 'setLocal': <function do_setLocal at 0x40d7c8b4>, 'startEndTag': <function do_startEndTag at 0x40d7c614>, 'beginScope': <function do_beginScope at 0x40d7c80c>, 'useMacro': <function do_useMacro at 0x40d7cdf4>, 'onError': <function do_onError at 0x40d7ced4>, 'rawtextColumn': <function do_rawtextColumn at 0x40d7cd14>, 'version': <function do_version at 0x40d7c534>, 'insertI18nText': <function do_insertText at 0x40d7c9cc>, 'insertTranslation': <function do_insertTranslation at 0x40d7cae4>, 'endScope': <function do_endScope at 0x40d7c87c>, 'optTag': <function do_optTag at 0x40d7c72c>, 'insertI18nStructure': <function do_insertStructure at 0x40d7cb1c>, 'endI18nContext': <function do_endI18nContext at 0x40d7c994>, 'insertStructure': <function do_insertStructure at 0x40d7cb1c>, 'defineMacro': <function do_defineMacro at 0x40d7cdbc>, 'evaluateCode': <function do_evaluateCode at 0x40d7cc34>, 'rawtextOffset': <function do_rawtextOffset at 0x40d7cd4c>, 'defineSlot': <function do_defineSlot at 0x40d7ce9c>, 'i18nVariable': <function do_i18nVariable at 0x40d7caac>, 'setPosition': <function do_setPosition at 0x40d7c5dc>, 'rawtextBeginScope': <function do_rawtextBeginScope at 0x40d7c79c>, 'condition': <function do_condition at 0x40d7cd84>, 'setGlobal': <function do_setLocal at 0x40d7c8b4>, 'fillSlot': <function do_fillSlot at 0x40d7ce64>, 'mode': <function do_mode at 0x40d7c56c>, 'beginI18nContext': <function do_beginI18nContext at 0x40d7c95c>, 'loop': <function do_loop at 0x40d7cc6c>}
bytecode_handlers_tal
(type:
dict
)
{'insertText': <function do_insertText_tal at 0x40d7ca3c>, 'startTag': <function do_startTag at 0x40d7c64c>, 'extendMacro': <function do_extendMacro at 0x40d7ce2c>, 'setSourceFile': <function do_setSourceFile at 0x40d7c5a4>, '<attrAction>': <function attrAction_tal at 0x40d7c6bc>, 'setLocal': <function do_setLocal_tal at 0x40d7c8ec>, 'startEndTag': <function do_startEndTag at 0x40d7c614>, 'beginScope': <function do_beginScope_tal at 0x40d7c844>, 'onError': <function do_onError_tal at 0x40d7cf0c>, 'rawtextColumn': <function do_rawtextColumn at 0x40d7cd14>, 'version': <function do_version at 0x40d7c534>, 'insertI18nText': <function do_insertI18nText_tal at 0x40d7ca74>, 'mode': <function do_mode at 0x40d7c56c>, 'endScope': <function do_endScope at 0x40d7c87c>, 'optTag': <function do_optTag_tal at 0x40d7c764>, 'insertI18nStructure': <function do_insertI18nStructure_tal at 0x40d7cb8c>, 'endI18nContext': <function do_endI18nContext at 0x40d7c994>, 'insertStructure': <function do_insertStructure_tal at 0x40d7cb54>, 'defineMacro': <function do_defineMacro at 0x40d7cdbc>, 'beginI18nContext': <function do_beginI18nContext at 0x40d7c95c>, 'evaluateCode': <function do_evaluateCode at 0x40d7cc34>, 'rawtextOffset': <function do_rawtextOffset at 0x40d7cd4c>, 'defineSlot': <function do_defineSlot at 0x40d7ce9c>, 'i18nVariable': <function do_i18nVariable at 0x40d7caac>, 'setPosition': <function do_setPosition at 0x40d7c5dc>, 'useMacro': <function do_useMacro at 0x40d7cdf4>, 'condition': <function do_condition at 0x40d7cd84>, 'setGlobal': <function do_setGlobal_tal at 0x40d7c924>, 'fillSlot': <function do_fillSlot at 0x40d7ce64>, 'insertTranslation': <function do_insertTranslation at 0x40d7cae4>, 'rawtextBeginScope': <function do_rawtextBeginScope_tal at 0x40d7c7d4>, 'loop': <function do_loop_tal at 0x40d7cca4>}
StringIO()
attrAction(item)
attrAction_tal(item)
do_beginI18nContext(settings)
do_beginScope(dict)
do_beginScope_tal(dict)
do_condition((condition, block))
do_defineMacro((macroName, macro))
do_defineSlot((slotName, block))
do_endI18nContext(notused=None)
do_endScope(notused=None)
do_evaluateCode(stuff)
do_extendMacro((macroName, macroExpr, compiledSlots, block, definingName))
do_fillSlot((slotName, block))
do_i18nVariable(stuff)
do_insertI18nStructure_tal((expr, repldict, block))
do_insertI18nText_tal(stuff)
do_insertStructure(stuff)
do_insertStructure_tal((expr, repldict, block))
do_insertText(stuff)
do_insertText_tal(stuff)
do_insertTranslation(stuff)
do_loop((name, expr, block))
do_loop_tal((name, expr, block))
do_mode(mode)
do_onError((block, handler))
do_onError_tal((block, handler))
do_optTag((name, cexpr, tag_ns, isend, start, program), omit=0)
do_optTag_tal(stuff)
do_rawtextBeginScope((s, col, position, closeprev, dict))
do_rawtextBeginScope_tal((s, col, position, closeprev, dict))
do_rawtextColumn((s, col))
do_rawtextOffset((s, offset))
do_setGlobal_tal((name, expr))
do_setLocal(notused)
do_setLocal_tal((name, expr))
do_setPosition(position)
do_setSourceFile(source_file)
do_startEndTag(stuff)
do_startTag((name, attrList), end='>', endlen=1, _len=<built-in function len>)
do_useMacro((macroName, macroExpr, compiledSlots, block), definingName=None, extending=False)
do_version(version)
formatSourceAnnotation()
insertHTMLStructure(text, repldict)
insertXMLStructure(text, repldict)
interpret(program)
no_tag(start, program)
popMacro()
popStream()
pushMacro(macroName, slots, definingName, extending)
pushStream(newstream)
restoreOutputState(state)
restoreState(state)
saveState()
stream_write(s, len=<built-in function len>)
translate(msgid, default=None, i18ndict=None, obj=None, domain=None)
There are no known subclasses.