a bit more pythonic
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 1 Nov 2011 09:55:59 +0000 (10:55 +0100)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 1 Nov 2011 09:55:59 +0000 (10:55 +0100)
sfa/util/xml.py

index 8f51ce3..25f1656 100755 (executable)
@@ -1,4 +1,5 @@
 #!/usr/bin/python 
+from types import StringTypes
 from lxml import etree
 from StringIO import StringIO
 
@@ -101,6 +102,8 @@ class XML:
         # element.attrib.update will explode if DateTimes are in the
         # dcitionary.
         d=d.copy()
+        for (k,v) in d.iteritems():
+            if not isinstance(v,StringTypes): del d[k]
         for k in d.keys():
             if (type(d[k]) != str) and (type(d[k]) != unicode):
                 del d[k]