[Erp5-report] r17068 - /erp5/trunk/products/ERP5Type/patches/ppml.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Sun Oct 21 20:43:11 CEST 2007
Author: yo
Date: Sun Oct 21 20:43:10 2007
New Revision: 17068
URL: http://svn.erp5.org?rev=17068&view=rev
Log:
Some optimization.
Modified:
erp5/trunk/products/ERP5Type/patches/ppml.py
Modified: erp5/trunk/products/ERP5Type/patches/ppml.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/patches/ppml.py?rev=17068&r1=17067&r2=17068&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/patches/ppml.py (original)
+++ erp5/trunk/products/ERP5Type/patches/ppml.py Sun Oct 21 20:43:10 2007
@@ -15,6 +15,18 @@
# Import everything right now, not after
# or new patch will not work
from Shared.DC.xml.ppml import *
+from Shared.DC.xml import ppml
+
+# For optimization.
+def unconvert(encoding,S):
+ if encoding == 'base64':
+ original = base64.decodestring(S)
+ else:
+ x = S.replace('\n', '')
+ original = eval("'"+x+"'")
+ return original
+
+ppml.unconvert = unconvert
class Global:
@@ -31,7 +43,6 @@
return '%s<%s%s name="%s" module="%s"/>\n' % (
' '*indent, name, id, self.name, self.module)
-from Shared.DC.xml import ppml
ppml.Global = Global
class Scalar:
@@ -233,6 +244,14 @@
def __setstate__(self, v): self.append(State(v, self.mapping))
ppml.Object = Object
+
+# For optmization.
+class NoBlanks:
+
+ def handle_data(self, data):
+ if data.strip(): self.append(data)
+
+ppml.NoBlanks = NoBlanks
class IdentityMapping:
@@ -603,8 +622,7 @@
v=''
a=data[1]
if len(data)>2:
- for x in data[2:]:
- v=v+x
+ v = ''.join(data[2:])
encoding=a.get('encoding','repr') # JPS: repr is default encoding
if encoding is not '':
v=unconvert(encoding,v)
More information about the Erp5-report
mailing list