summaryrefslogtreecommitdiff
path: root/contrib/importers/keepassx2pass.py
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/importers/keepassx2pass.py')
-rwxr-xr-xcontrib/importers/keepassx2pass.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/contrib/importers/keepassx2pass.py b/contrib/importers/keepassx2pass.py
index dc4b1e5..1505edc 100755
--- a/contrib/importers/keepassx2pass.py
+++ b/contrib/importers/keepassx2pass.py
@@ -44,13 +44,18 @@ def password_data(element):
ret = passwd + "\n" if passwd else "\n"
for field in ['username', 'url', 'comment']:
fel = element.find(field)
- if fel.text is not None:
- ret = "%s%s: %s\n" % (ret, fel.tag, fel.text)
+ children = [str(e.text or '') + str(e.tail or '') for e in list(fel)]
+ if len(children) > 0:
+ children.insert(0, '')
+ text = (fel.text or '') + "\n".join(children)
+ if len(text) > 0:
+ ret = "%s%s: %s\n" % (ret, fel.tag, text)
return ret
def import_entry(element, path=''):
""" Import new password entry to password-store using pass insert
command """
+ print "Importing " + path_for(element, path)
proc = Popen(['pass', 'insert', '--multiline', '--force',
path_for(element, path)],
stdin=PIPE, stdout=PIPE)
@@ -68,9 +73,8 @@ def import_group(element, path=''):
def main(xml_file):
""" Parse given KeepassX XML file and import password groups from it """
- with open(xml_file) as xml:
- for group in ElementTree.XML(xml.read()).findall('group'):
- import_group(group)
+ for group in ElementTree.parse(xml_file).findall('group'):
+ import_group(group)
if __name__ == '__main__':
main(sys.argv[1])
1fe580357b92e65d7f269&follow=1'>Better sorting of the database types in the preferences.René 'Necoro' Neumann2-6/+6 2010-04-15Add notify-python dependency for the version checkerRené 'Necoro' Neumann1-1/+1 2010-04-15Make the database type choice an info messageRené 'Necoro' Neumann2-7/+13 2010-04-15Renamed es_ES to esRené 'Necoro' Neumann1-0/+0 2010-04-15Fixed dependancy of the new_version plugin from "dev-util/git" to "dev-vcs/gi...Clement Bourgeois1-1/+1 2010-04-14Make some useless info messages being debug statementsRené 'Necoro' Neumann2-34/+17 2010-04-14Improve the C modulesRené 'Necoro' Neumann3-37/+52 2010-04-14Small modifications made to the French translation (typos, grammar).Clement Bourgeois1-69/+69 2010-04-14Fixed the unicode support and stuff ... and also made eix faster :)René 'Necoro' Neumann1-20/+22 2010-04-14Disable debug messages by defaultRené 'Necoro' Neumann1-1/+1 2010-04-13Better eix error inheritance and handlingRené 'Necoro' Neumann1-2/+9 2010-04-13Fix the handling of FilterSets. Fixes bug #558887.René 'Necoro' Neumann2-56/+64 2010-04-12Updated newsRené 'Necoro' Neumann1-0/+1 2010-04-13Added my name to translators list.Clement Bourgeois1-0/+1