summaryrefslogtreecommitdiff
path: root/giscanner/xmlwriter.py
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2008-04-28 00:15:16 +0000
committerJohan Dahlin <johan@src.gnome.org>2008-04-28 00:15:16 +0000
commitffdd14a60438db558819ab12134e7ea7d8472566 (patch)
treed809aa599d4a6bab92c845b9dff24b1ab8c03b2d /giscanner/xmlwriter.py
parentf2a0e75f10da2840079e443798f413fb44027a30 (diff)
downloadgobject-introspection-ffdd14a60438db558819ab12134e7ea7d8472566.tar.gz
Wrap attributes for lines which are wider than 79 characters
2008-04-27 Johan Dahlin <johan@gnome.org> * giscanner/xmlwriter.py: Wrap attributes for lines which are wider than 79 characters svn path=/trunk/; revision=235
Diffstat (limited to 'giscanner/xmlwriter.py')
-rw-r--r--giscanner/xmlwriter.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/giscanner/xmlwriter.py b/giscanner/xmlwriter.py
index ccb75c6a..c80c90d4 100644
--- a/giscanner/xmlwriter.py
+++ b/giscanner/xmlwriter.py
@@ -40,8 +40,25 @@ class XMLWriter(object):
return attr_value
+ def _collect_attributes_wrapped(self, tag_name, attributes):
+ assert attributes
+ attr_value = ''
+ indent_len = 0
+ for attr, value in attributes:
+ if indent_len:
+ attr_value += '\n%s' % (' ' * indent_len)
+ assert value is not None, attr
+ attr_value += ' %s=%s' % (attr, quoteattr(value))
+ if not indent_len:
+ indent_len = (self._indent +
+ len(tag_name) + 1)
+
+ return attr_value
+
def _open_tag(self, tag_name, attributes=None):
attrs = self._collect_attributes(attributes)
+ if (len(attrs) + len(tag_name) + 2) > 79:
+ attrs = self._collect_attributes_wrapped(tag_name, attributes)
self.write_line('<%s%s>' % (tag_name, attrs))
def _close_tag(self, tag_name):