1 from xml.dom.minidom
import parse
2 from collections
import OrderedDict
25 for el
in tree.getElementsByTagName(
'library'):
26 path = el.getAttribute(
'path').replace(
'lib/lib',
'')
30 for clstag
in el.getElementsByTagName(
'class'):
32 d[
'base_class_type'] = clstag.getAttribute(
'base_class_type')
33 self.parent_pkgs.add(d[
'base_class_type'].split(
'::')[0])
34 d[
'type'] = clstag.getAttribute(
'type')
35 d[
'name'] = clstag.getAttribute(
'name')
38 for tag
in clstag.getElementsByTagName(
'description'):
39 if len(tag.childNodes) == 0:
41 desc += str(tag.childNodes[0].nodeValue)
42 d[
'description'] = desc
49 full_name = NS_PATTERN % (pkg, name)
50 return full_name
in self.
libraries[library_name]
52 def insert_new_class(self, library_name, pkg, name, base_pkg, base_name, description=''):
54 self.
libraries[library_name] = OrderedDict()
56 full_name = NS_PATTERN % (pkg, name)
57 library[full_name] = {
'base_class_type': NS_PATTERN % (base_pkg, base_name),
59 'description': description}
72 if need_class_libraries_tag:
73 s +=
'<class_libraries>\n' 76 for name, lib
in self.libraries.iteritems():
77 s +=
' ' * indent +
'<library path="lib/lib%s">\n' % name
78 for t, clib
in lib.iteritems():
80 s +=
' ' * indent +
'</library>\n' 82 if need_class_libraries_tag:
83 s +=
'</class_libraries>\n' 87 s =
' ' * indent +
'<class' 88 for at
in [
'name',
'type',
'base_class_type']:
89 if at
in lib
and len(lib[at]) > 0:
90 s +=
' %s="%s"' % (at, lib[at])
91 s +=
'>\n' + (
' ' * (indent + 2))
92 s +=
'<description>%s</description>' % lib.get(
'description',
'')
94 s +=
'\n' + (
' ' * indent) +
'</class>\n'
def __init__(self, rel_fn, file_path)
def insert_new_class(self, library_name, pkg, name, base_pkg, base_name, description='')
def contains_library(self, library_name, pkg, name)
def class_str(self, lib, indent)