From ffbe20f528aaa923c420b77391a47b3976a71f86 Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Mon, 28 Apr 2008 22:37:23 +0000 Subject: [PATCH] Calculate the line length properly, include the provided extra indentation 2008-04-28 Johan Dahlin * giscanner/xmlwriter.py: Calculate the line length properly, include the provided extra indentation in the calculation, really. svn path=/trunk/; revision=256 --- ChangeLog | 5 +++++ giscanner/xmlwriter.py | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index b379166..b5d82c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-04-28 Johan Dahlin + + * giscanner/xmlwriter.py: Calculate the line length properly, + include the provided extra indentation in the calculation, really. + 2008-04-28 Johan Dahlin * giscanner/ast.py: diff --git a/giscanner/xmlwriter.py b/giscanner/xmlwriter.py index 2063106..4dee3e2 100644 --- a/giscanner/xmlwriter.py +++ b/giscanner/xmlwriter.py @@ -38,15 +38,15 @@ class XMLWriter(object): return -1 attr_length = 0 for attr, value in attributes: - attr_length += 1 + len(attr) + len(quoteattr(value)) + attr_length += 2 + len(attr) + len(quoteattr(value)) return attr_length + indent - def _collect_attributes(self, attributes, indent=-1): + def _collect_attributes(self, attributes, extra_indent=-1): if not attributes: return '' - - if self._calc_attrs_length(attributes, indent) > 79: - indent_len = self._indent + indent + extra_indent += len(self._indent_char) * self._indent + if self._calc_attrs_length(attributes, extra_indent) > 79: + indent_len = extra_indent else: indent_len = 0 first = True @@ -62,7 +62,7 @@ class XMLWriter(object): def _open_tag(self, tag_name, attributes=None): attrs = self._collect_attributes( - attributes, len(tag_name) + 1) + attributes, len(tag_name) + 2) self.write_line('<%s%s>' % (tag_name, attrs)) def _close_tag(self, tag_name): -- 2.7.4