Skip to content

Commit

Permalink
Merge pull request #21 from lichenbo/patch-1
Browse files Browse the repository at this point in the history
add long type support
  • Loading branch information
quandyfactory committed Jun 16, 2014
2 parents 2650239 + 60a0231 commit bc60436
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dicttoxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def key_is_valid_xml(key):
def convert(obj, ids, attr_type, parent='root'):
"""Routes the elements of an object to the right function to convert them based on their data type"""
logging.info('Inside convert(). obj type is: %s, obj=%s' % (type(obj).__name__, obj))
if type(obj) in (int, float, str, unicode):
if type(obj) in (int, float, long, str, unicode):
return convert_kv('item', obj, attr_type)
if hasattr(obj, 'isoformat'):
return convert_kv('item', obj.isoformat(), attr_type)
Expand Down Expand Up @@ -145,7 +145,7 @@ def convert_list(items, ids, parent, attr_type):
attr = {} if ids == False else {
'id': '%s_%s' % (this_id, i+1)
}
if type(item) in (int, float, str, unicode):
if type(item) in (int, float, long, str, unicode):
addline(convert_kv('item', item, attr_type, attr))
elif hasattr(item, 'isoformat'): # datetime
addline(convert_kv('item', item.isoformat(), attr_type, attr))
Expand Down

0 comments on commit bc60436

Please sign in to comment.