self.fields = fields
self.field_name = field_name
-def factory(tag, attrib = {}, *args, **kwargs):
- return tag_to_class.get(tag, element.Element)(tag, attrib, *args, **kwargs)
+def factory(tag, *args, **kwargs):
+ return tag_to_class.get(tag, element.Element)(tag, *args, **kwargs)
@method(AST.Section2.ClassOrFieldDef)
def generate_class_or_field_def(self, context):
'''{0:s}def __init__(
{1:s} self,
{2:s} tag = '{3:s}',
-{4:s} attrib = {{}},
-{5:s} text = '',
-{6:s} children = []{7:s}
-{8:s}):
-{9:s} {10:s}.__init__(
-{11:s} self,
-{12:s} tag,
-{13:s} attrib,
-{14:s} text,
-{15:s} children{16:s}
-{17:s} )
-{18:s}'''.format(
+{4:s} text = '',
+{5:s} children = []{6:s}
+{7:s}):
+{8:s} {9:s}.__init__(
+{10:s} self,
+{11:s} tag,
+{12:s} text,
+{13:s} children{14:s}
+{15:s} )
+{16:s}'''.format(
context.indent,
context.indent,
context.indent,
'_'.join(context.stack),
context.indent,
context.indent,
- context.indent,
''.join(
[
',\n{0:s} {1:s}{2:s}'.format(
context.indent,
context.indent,
context.indent,
- context.indent,
''.join(
[
',\n{0:s} {1:s}'.format(
# self.children = []
# self.text = self.tail = None
- def get(self, key, default=None):
- return self.attrib.get(key, default)
+ #def get(self, key, default=None):
+ # return self.attrib.get(key, default)
- def set(self, key, value):
- self.attrib[key] = value
+ #def set(self, key, value):
+ # self.attrib[key] = value
#def keys(self):
# return self.attrib.keys()
- def items(self):
- return self.attrib.items()
+ #def items(self):
+ # return self.attrib.items()
- def iter(self, tag=None):
- if tag == "*":
- tag = None
- if tag is None or self.tag == tag:
- yield self
- for e in self.children:
- yield from e.iter(tag)
+ #def iter(self, tag=None):
+ # if tag == "*":
+ # tag = None
+ # if tag is None or self.tag == tag:
+ # yield self
+ # for e in self.children:
+ # yield from e.iter(tag)
## compatibility
#def getiterator(self, tag=None):
# if t:
# yield t
- def __init__(self, tag = 'Element', attrib = {}, text = '', children = []):
+ def __init__(self, tag = 'Element', text = '', children = []):
self.tag = tag
- self.attrib = attrib.copy()
self.tail = None
self.visited = None # (element, ref, seen)
set_text(self, 0, text)