m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Günther <martin.guenther@dfki.de>2016-02-05 20:58:18 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2016-02-05 20:58:43 +0100
commit62e703f5a71fcc2470aaac85c0ec39f4976cf914 (patch)
tree0354d6560dedb0a1f803f38d21ae4d0ece47bffd
parentd2677f66eb127aa92cf032a925944dd0b44f15ef (diff)
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.
-rwxr-xr-xcontrib/importers/keepass2pass.py11
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"))