diff options
author | Martin Günther <martin.guenther@dfki.de> | 2016-02-05 20:58:18 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-02-05 20:58:43 +0100 |
commit | 62e703f5a71fcc2470aaac85c0ec39f4976cf914 (patch) | |
tree | 0354d6560dedb0a1f803f38d21ae4d0ece47bffd /contrib/importers | |
parent | d2677f66eb127aa92cf032a925944dd0b44f15ef (diff) | |
download | pass-62e703f5a71fcc2470aaac85c0ec39f4976cf914.tar.gz pass-62e703f5a71fcc2470aaac85c0ec39f4976cf914.tar.bz2 pass-62e703f5a71fcc2470aaac85c0ec39f4976cf914.zip |
keepass2pass.py: Don't import all entries twice
Without this patch, all entries are processed twice: once in the first
call to import_group (which recursively processes all entries), then in
the following import_group on all subgroups.
This leads to spurious warnings ("Duplicate needs merging") and extra
text added to each entry.
Diffstat (limited to '')
-rwxr-xr-x | contrib/importers/keepass2pass.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/contrib/importers/keepass2pass.py b/contrib/importers/keepass2pass.py index 80a2ad9..f4147fc 100755 --- a/contrib/importers/keepass2pass.py +++ b/contrib/importers/keepass2pass.py @@ -72,9 +72,10 @@ def import_entry(entries, element, path=''): entries[element_path] = data -def import_group(entries, element, path=''): +def import_group(entries, element, path='', npath=None): """ Import all entries and sub-groups from given group """ - npath = path_for(element, path) + if npath is None: + npath = path_for(element, path) for group in element.findall('Group'): import_group(entries, group, npath) for entry in element.findall('Entry'): @@ -90,11 +91,7 @@ def import_passwords(xml_file, root_path=None): xml_tree = ElementTree.XML(text) root = xml_tree.find('Root') root_group = root.find('Group') - import_group(entries,root_group,'') - if root_path is None: root_path = root_group.find('Name').text - groups = root_group.findall('Group') - for group in groups: - import_group(entries, group, root_path) + import_group(entries, root_group, '', root_path) password_count = 0 for path, data in sorted(entries.iteritems()): sys.stdout.write("[>>>>] Importing %s ... " % path.encode("utf-8")) |