summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Dahlin <johan@src.gnome.org>2008-04-28 00:07:57 +0000
committerJohan Dahlin <johan@src.gnome.org>2008-04-28 00:07:57 +0000
commitf2a0e75f10da2840079e443798f413fb44027a30 (patch)
tree18ee1ddeb727448844d60eceebb96d0aeabd086a
parentbc995eb2d5af650e33ec6dc5c8722ae27aa124b7 (diff)
downloadgobject-introspection-f2a0e75f10da2840079e443798f413fb44027a30.tar.gz
Simplify & Remove a bit of unused code
svn path=/trunk/; revision=234
-rw-r--r--giscanner/xmlwriter.py33
1 files changed, 22 insertions, 11 deletions
diff --git a/giscanner/xmlwriter.py b/giscanner/xmlwriter.py
index 2cb66c62..ccb75c6a 100644
--- a/giscanner/xmlwriter.py
+++ b/giscanner/xmlwriter.py
@@ -32,12 +32,13 @@ class XMLWriter(object):
# Private
def _collect_attributes(self, attributes):
- attrValue = ''
+ attr_value = ''
if attributes:
for attr, value in attributes:
assert value is not None, attr
- attrValue += ' %s=%s' % (attr, quoteattr(value))
- return attrValue
+ attr_value += ' %s=%s' % (attr, quoteattr(value))
+
+ return attr_value
def _open_tag(self, tag_name, attributes=None):
attrs = self._collect_attributes(attributes)
@@ -46,6 +47,17 @@ class XMLWriter(object):
def _close_tag(self, tag_name):
self.write_line('</%s>' % (tag_name,))
+ def _rewrap_line(self, line, attrs):
+ # assume we have an xml tag here
+ assert line[0] == '<' and line[-1] == '>'
+ if not line.endswith('/>'):
+ tagname = line[1:].split(None, 1)[0]
+ line += "</%s>" % (tagname,)
+ from xml.etree.ElementTree import parse
+ doc = parseString(line)
+ print doc
+ return line
+
# Public API
def get_xml(self):
@@ -54,15 +66,14 @@ class XMLWriter(object):
def write_line(self, line=''):
self._data.write('%s%s\n' % (' ' * self._indent, line))
- def write_tag(self, tag_name, attributes):
- attrs = self._collect_attributes(attributes)
- self.write_line('<%s%s/>' % (tag_name, attrs))
-
- def write_tag_with_data(self, tag_name, data, attributes=None):
- if data is None:
- self.write_tag(tag_name, attributes)
+ def write_tag(self, tag_name, attributes, data=None):
attrs = self._collect_attributes(attributes)
- self.write_line('<%s%s>%s</%s>' % (tag_name, attrs, data, tag_name))
+ output = '<%s%s' % (tag_name, attrs)
+ if data:
+ output = '>%s</%s>' % (data, tag_name)
+ else:
+ output += '/>'
+ self.write_line(output)
def push_tag(self, tag_name, attributes=None):
self._open_tag(tag_name, attributes)