[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/gnue-common/src GObjects.py
From: |
Jason Cater |
Subject: |
gnue/gnue-common/src GObjects.py |
Date: |
Thu, 05 Jul 2001 10:52:42 -0700 |
CVSROOT: /home/cvs
Module name: gnue
Changes by: Jason Cater <address@hidden> 01/07/05 10:52:42
Modified files:
gnue-common/src: GObjects.py
Log message:
Added intelligent line wrapping when saving XML elements w/many
attributes
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/GObjects.py.diff?cvsroot=OldCVS&tr1=1.14&tr2=1.15&r1=text&r2=text
Patches:
Index: gnue/gnue-common/src/GObjects.py
diff -u gnue/gnue-common/src/GObjects.py:1.14
gnue/gnue-common/src/GObjects.py:1.15
--- gnue/gnue-common/src/GObjects.py:1.14 Wed Jul 4 17:24:11 2001
+++ gnue/gnue-common/src/GObjects.py Thu Jul 5 10:52:42 2001
@@ -139,6 +139,8 @@
xmlEntity = string.lower(string.replace(self._type[2:],'_','-'))
xmlString = "%s<%s" % (gap[:-2],xmlEntity)
+ indent = len(xmlString)
+ pos = indent
for attribute in self.__dict__.keys():
# skip keys beginning with _
if attribute[0] == "_":
@@ -152,13 +154,19 @@
typecast = lookupDict[xmlEntity]['Attributes'][attribute]['Typecast']
if typecast == GTypecast.boolean \
and val == 1:
- xmlString = xmlString + ' %s=""' % (attribute)
+ addl = ' %s=""' % (attribute)
elif typecast == GTypecast.names:
- xmlString = xmlString + ' %s="%s"' % \
+ addl = ' %s="%s"' % \
(attribute, string.join(val,','))
else:
- xmlString = xmlString + ' %s="%s"' % (attribute,
saxutils.escape('%s' % val))
-
+ addl = ' %s="%s"' % (attribute, saxutils.escape('%s' % val))
+ if len(addl) + pos > 78:
+ xmlString = xmlString + "\n" + " " * indent + addl
+ pos = indent
+ else:
+ xmlString = xmlString + addl
+ pos = pos + len(addl)
+
if len(self._children):
hasContent = 0
for child in self._children:
@@ -179,7 +187,6 @@
else:
xmlString = xmlString + "/>\n"
return xmlString
-
def walk(self, function):
- gnue/gnue-common/src GObjects.py,
Jason Cater <=