|
OpenQuizz
Une application de gestion des contenus pédagogiques
|


Public Member Functions | |
| def | __init__ (self, tree) |
| def | __iter__ (self) |
| def | error (self, msg) |
| def | emptyTag (self, namespace, name, attrs, hasChildren=False) |
| def | startTag (self, namespace, name, attrs) |
| def | endTag (self, namespace, name) |
| def | text (self, data) |
| def | comment (self, data) |
| def | doctype (self, name, publicId=None, systemId=None) |
| def | entity (self, name) |
| def | unknown (self, nodeType) |
Data Fields | |
| tree | |
Walks a tree yielding tokens Tokens are dicts that all have a ``type`` field specifying the type of the token.
| def __init__ | ( | self, | |
| tree | |||
| ) |
Creates a TreeWalker :arg tree: the tree to walk
Reimplemented in TreeWalker.
| def __iter__ | ( | self | ) |
Reimplemented in NonRecursiveTreeWalker, and TreeWalker.
| def comment | ( | self, | |
| data | |||
| ) |
Generates a Comment token :arg data: the comment :returns: Comment token
| def doctype | ( | self, | |
| name, | |||
publicId = None, |
|||
systemId = None |
|||
| ) |
Generates a Doctype token :arg name: :arg publicId: :arg systemId: :returns: the Doctype token
| def emptyTag | ( | self, | |
| namespace, | |||
| name, | |||
| attrs, | |||
hasChildren = False |
|||
| ) |
Generates an EmptyTag token
:arg namespace: the namespace of the token--can be ``None``
:arg name: the name of the element
:arg attrs: the attributes of the element as a dict
:arg hasChildren: whether or not to yield a SerializationError because
this tag shouldn't have children
:returns: EmptyTag token
| def endTag | ( | self, | |
| namespace, | |||
| name | |||
| ) |
Generates an EndTag token :arg namespace: the namespace of the token--can be ``None`` :arg name: the name of the element :returns: EndTag token
| def entity | ( | self, | |
| name | |||
| ) |
Generates an Entity token :arg name: the entity name :returns: an Entity token
| def error | ( | self, | |
| msg | |||
| ) |
Generates an error token with the given message :arg msg: the error message :returns: SerializeError token
| def startTag | ( | self, | |
| namespace, | |||
| name, | |||
| attrs | |||
| ) |
Generates a StartTag token :arg namespace: the namespace of the token--can be ``None`` :arg name: the name of the element :arg attrs: the attributes of the element as a dict :returns: StartTag token
| def text | ( | self, | |
| data | |||
| ) |
Generates SpaceCharacters and Characters tokens
Depending on what's in the data, this generates one or more
``SpaceCharacters`` and ``Characters`` tokens.
For example:
>>> from html5lib.treewalkers.base import TreeWalker
>>> # Give it an empty tree just so it instantiates
>>> walker = TreeWalker([])
>>> list(walker.text(''))
[]
>>> list(walker.text(' '))
[{u'data': ' ', u'type': u'SpaceCharacters'}]
>>> list(walker.text(' abc ')) # doctest: +NORMALIZE_WHITESPACE
[{u'data': ' ', u'type': u'SpaceCharacters'},
{u'data': u'abc', u'type': u'Characters'},
{u'data': u' ', u'type': u'SpaceCharacters'}]
:arg data: the text data
:returns: one or more ``SpaceCharacters`` and ``Characters`` tokens
| def unknown | ( | self, | |
| nodeType | |||
| ) |
Handles unknown node types
| tree |