Skip to content

Commit

Permalink
* S3/Utils.py: getDictFromTree() now recurses into sub-trees.
Browse files Browse the repository at this point in the history
git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@472 830e0280-6d2a-0410-9c65-932aecc39d9d
  • Loading branch information
mludvig committed Apr 8, 2011
1 parent 2a0d89d commit 323a4ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2011-04-10 Michal Ludvig <mludvig@logix.net.nz>

* S3/Utils.py: getDictFromTree() now recurses into
sub-trees.

2011-03-30 Michal Ludvig <mludvig@logix.net.nz>

* S3/CloudFront.py: Fix warning with Python 2.7
Expand Down
10 changes: 6 additions & 4 deletions S3/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,16 @@ def getDictFromTree(tree):
ret_dict = {}
for child in tree.getchildren():
if child.getchildren():
## Complex-type child. We're not interested
continue
## Complex-type child. Recurse
content = getDictFromTree(child)
else:
content = child.text
if ret_dict.has_key(child.tag):
if not type(ret_dict[child.tag]) == list:
ret_dict[child.tag] = [ret_dict[child.tag]]
ret_dict[child.tag].append(child.text or "")
ret_dict[child.tag].append(content or "")
else:
ret_dict[child.tag] = child.text or ""
ret_dict[child.tag] = content or ""
return ret_dict
__all__.append("getDictFromTree")

Expand Down

0 comments on commit 323a4ca

Please sign in to comment.