summaryrefslogtreecommitdiff
path: root/giscanner/xmlwriter.py
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2013-01-31 19:10:11 -0500
committerJasper St. Pierre <jstpierre@mecheye.net>2013-02-01 19:47:41 -0500
commitb4ce0aec3b74adbe996ea0489d9dd5dfe91ba11d (patch)
treef5fcbc34f53b6d7622c76df2420c6da714ed00ba /giscanner/xmlwriter.py
parentae6f1592d4e423abc749e8d9f9a27191bcb1b85b (diff)
downloadgobject-introspection-b4ce0aec3b74adbe996ea0489d9dd5dfe91ba11d.tar.gz
mallardwriter: Use xmlwriter for xrefs
Diffstat (limited to 'giscanner/xmlwriter.py')
-rwxr-xr-xgiscanner/xmlwriter.py34
1 files changed, 19 insertions, 15 deletions
diff --git a/giscanner/xmlwriter.py b/giscanner/xmlwriter.py
index fb34adf1..11f84859 100755
--- a/giscanner/xmlwriter.py
+++ b/giscanner/xmlwriter.py
@@ -68,6 +68,23 @@ def collect_attributes(tag_name, attributes, self_indent,
first = False
return attr_value
+def build_xml_tag(tag_name, attributes=None, data=None, self_indent=0,
+ self_indent_char=' '):
+ if attributes is None:
+ attributes = []
+ prefix = u'<%s' % (tag_name, )
+ if data is not None:
+ if isinstance(data, str):
+ data = data.decode('UTF-8')
+ suffix = u'>%s</%s>' % (escape(data), tag_name)
+ else:
+ suffix = u'/>'
+ attrs = collect_attributes(
+ tag_name, attributes,
+ self_indent,
+ self_indent_char,
+ len(prefix) + len(suffix))
+ return prefix + attrs + suffix
with LibtoolImporter(None, None):
if 'UNINSTALLED_INTROSPECTION_SRCDIR' in os.environ:
@@ -131,21 +148,8 @@ class XMLWriter(object):
self.write_line('<!-- %s -->' % (text, ))
def write_tag(self, tag_name, attributes, data=None):
- if attributes is None:
- attributes = []
- prefix = u'<%s' % (tag_name, )
- if data is not None:
- if isinstance(data, str):
- data = data.decode('UTF-8')
- suffix = u'>%s</%s>' % (escape(data), tag_name)
- else:
- suffix = u'/>'
- attrs = collect_attributes(
- tag_name, attributes,
- self._indent,
- self._indent_char,
- len(prefix) + len(suffix))
- self.write_line(prefix + attrs + suffix)
+ self.write_line(build_xml_tag(tag_name, attributes, data,
+ self._indent, self._indent_char))
def push_tag(self, tag_name, attributes=None):
if attributes is None: