commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

r5266 - trunk/gnue-common/src/definitions


From: jan
Subject: r5266 - trunk/gnue-common/src/definitions
Date: Mon, 8 Mar 2004 12:50:14 -0600 (CST)

Author: jan
Date: 2004-03-08 12:50:14 -0600 (Mon, 08 Mar 2004)
New Revision: 5266

Modified:
   trunk/gnue-common/src/definitions/GObjects.py
Log:
allow the definition of an output encoding for dumpXML


Modified: trunk/gnue-common/src/definitions/GObjects.py
===================================================================
--- trunk/gnue-common/src/definitions/GObjects.py       2004-03-08 17:36:46 UTC 
(rev 5265)
+++ trunk/gnue-common/src/definitions/GObjects.py       2004-03-08 18:50:14 UTC 
(rev 5266)
@@ -215,9 +215,12 @@
   def getXmlTag(self):
     return string.lower(string.replace(self._type[2:],'_','-'))
 
-  def dumpXML(self, lookupDict, treeDump=None, gap="  ", xmlnamespaces={}):
+  def dumpXML(self, lookupDict, treeDump=None, gap="  ", xmlnamespaces={},
+              textEncoding='<locale>'):
     xmlns = ""
     xmlnsdef = ""
+    if textEncoding=='<locale>':
+      textEncoding=gConfig('textEncoding')
     try:
       if self._xmlnamespace:
         try:
@@ -288,14 +291,14 @@
               addl = ' %s="N"' % (attribute)
           elif typecast == GTypecast.names:
             if type(val) == types.StringType:
-              #addl = ' %s="%s"' % (attribute, 
string.join(val.decode(gConfig('textEncoding')),','))
-              addl = ' %s="%s"' % (attribute, 
string.join(unicode(val,gConfig('textEncoding')),','))
+              #addl = ' %s="%s"' % (attribute, 
string.join(val.decode(textEncoding),','))
+              addl = ' %s="%s"' % (attribute, 
string.join(unicode(val,textEncoding),','))
             else:
               addl = ' %s="%s"' % (attribute, string.join(val,','))
           else:
             if type(val) == types.StringType:
-              #addl = ' %s="%s"' % (attribute, saxutils.escape('%s' % 
val.decode(gConfig('textEncoding'))))
-              addl = ' %s="%s"' % (attribute, saxutils.escape('%s' % 
unicode(val,gConfig('textEncoding'))))
+              #addl = ' %s="%s"' % (attribute, saxutils.escape('%s' % 
val.decode(textEncoding)))
+              addl = ' %s="%s"' % (attribute, saxutils.escape('%s' % 
unicode(val,textEncoding)))
             else:
               addl = ' %s="%s"' % (attribute, saxutils.escape('%s' % val))
           if len(addl) + pos > 78:
@@ -307,7 +310,7 @@
       if attribute.find('__') > 0 and attribute.split('__')[0] in 
xmlnamespaces.keys():
         if val != None:
           if type(val) == types.StringType:
-            addl = ' %s="%s"' % (attribute.replace('__',':'), 
saxutils.escape('%s' % unicode(val,gConfig('textEncoding'))))
+            addl = ' %s="%s"' % (attribute.replace('__',':'), 
saxutils.escape('%s' % unicode(val,textEncoding)))
           else:
             try:
               if val == int(val):





reply via email to

[Prev in Thread] Current Thread [Next in Thread]