72 |
|
|
73 |
class Element: |
class Element: |
74 |
""" |
""" |
75 |
cd The general element for all subelements. |
The general element for all subelements. |
76 |
""" |
""" |
77 |
def __init__(self, list): |
list = None |
78 |
self.list = list |
linkpackage = None |
79 |
|
|
80 |
class NamedElement (Element): |
class NamedElement (Element): |
81 |
""" |
""" |
82 |
Element with name and linking features. |
Element with name and linking features. |
83 |
""" |
""" |
84 |
def do_contents(self, list): |
def do_contents(self, list): |
85 |
|
dbg_parser = config.dbg.shorthand('parser') |
86 |
|
|
87 |
for el in list: |
for el in list: |
88 |
self.handle_contained(el) |
self.handle_contained(el) |
89 |
dbg("Link: "+self.link) |
dbg_parser("Link: "+self.link) |
90 |
def handle_contained(self, el): |
def handle_contained(self, el): |
91 |
if link_types.has_key(el[0]): |
if self.list.link_factor.is_type(el[0]): |
92 |
link = el[1:] |
link = el[1:] |
93 |
if len(link): |
if len(link): |
94 |
self.link = link_types[el[0]](link[0][0]) |
self.link = self.list.link_factor.create_new(el[0], link[0][0]) |
95 |
else: |
else: |
96 |
self.link = self.defaultlink(link[0][0]) |
self.link = self.list.link_factor.create_new('link', link[0][0]) |
97 |
else: |
else: |
98 |
self.list.add_sub_element(self.name, el) |
self.list.add_sub_element(self.name, el) |
|
def defaultlink(self, link): |
|
|
return link.Link(link) |
|