diff --git a/README.markdown b/README.markdown index e5132e1..de000b2 100644 --- a/README.markdown +++ b/README.markdown @@ -233,12 +233,19 @@ Author Version ======= -* Version: 1.5.6 -* Release Date: 2014-08-18 +* Version: 1.5.7 +* Release Date: 2014-12-09 Revision History ================ +Version 1.5.7 +------------- + +* Release Date: 2014-12-09 +* Changes: + * Fixed [issue #29](https://github.com/quandyfactory/dicttoxml/issues/24) + Version 1.5.6 ------------- diff --git a/dicttoxml.py b/dicttoxml.py index 6338ac5..129f779 100755 --- a/dicttoxml.py +++ b/dicttoxml.py @@ -7,7 +7,7 @@ from __future__ import unicode_literals -__version__ = '1.5.6' +__version__ = '1.5.7' version = __version__ from random import randint @@ -136,11 +136,8 @@ def convert_dict(obj, ids, parent, attr_type): for key, val in obj.items(): logging.info('Looping inside convert_dict(): key="%s", val="%s", type(val)="%s"' % (key, val, type(val).__name__)) - if not ids: - attr = {} - else: - attr = {'id': '%s' % get_unique_id(parent)} - + attr = {} if not ids else {'id': '%s' % (get_unique_id(parent)) } + key, attr = make_valid_xml_name(key, attr) if type(val) in (int, float, long, str, unicode): @@ -175,12 +172,13 @@ def convert_list(items, ids, parent, attr_type): logging.info('Inside convert_list()') output = [] addline = output.append - this_id = get_unique_id(parent) + + if ids: + this_id = get_unique_id(parent) + for i, item in enumerate(items): logging.info('Looping inside convert_list(): item="%s", type="%s"' % (item, type(item).__name__)) - attr = {} if ids == False else { - 'id': '%s_%s' % (this_id, i+1) - } + attr = {} if not ids else { 'id': '%s_%s' % (this_id, i+1) } if type(item) in (int, float, long, str, unicode): addline(convert_kv('item', item, attr_type, attr)) elif hasattr(item, 'isoformat'): # datetime diff --git a/dist/dict2xml-0.1.tar.gz b/dist/dict2xml-0.1.tar.gz deleted file mode 100644 index ec92dd2..0000000 Binary files a/dist/dict2xml-0.1.tar.gz and /dev/null differ diff --git a/dist/dict2xml-0.2.tar.gz b/dist/dict2xml-0.2.tar.gz deleted file mode 100644 index 4a26cde..0000000 Binary files a/dist/dict2xml-0.2.tar.gz and /dev/null differ diff --git a/dist/dict2xml-0.3.tar.gz b/dist/dict2xml-0.3.tar.gz deleted file mode 100644 index 023149a..0000000 Binary files a/dist/dict2xml-0.3.tar.gz and /dev/null differ diff --git a/dist/dict2xml-0.4.tar.gz b/dist/dict2xml-0.4.tar.gz deleted file mode 100644 index 1f44313..0000000 Binary files a/dist/dict2xml-0.4.tar.gz and /dev/null differ diff --git a/setup.py b/setup.py index 9544cca..3f18706 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from distutils.core import setup -version = '1.5.6' +version = '1.5.7' with open('README.markdown') as readme: long_description = readme.read()