diff options
author | Fabio Zanini <fabio.zanini@fastmail.fm> | 2016-12-23 02:47:26 -0800 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-02-25 13:51:57 +0100 |
commit | 250207d21474fb8e6e86fc47722ce516ba81b74f (patch) | |
tree | b6ed17b23925b4a5bde11d8b16d267af7d3b73ae /contrib/importers | |
parent | 314b38642928484dd7641a150a683be9279712ab (diff) | |
download | pass-250207d21474fb8e6e86fc47722ce516ba81b74f.tar.gz pass-250207d21474fb8e6e86fc47722ce516ba81b74f.tar.bz2 pass-250207d21474fb8e6e86fc47722ce516ba81b74f.zip |
keepassx2pass: port to python3
Diffstat (limited to 'contrib/importers')
-rwxr-xr-x | contrib/importers/keepassx2pass.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/contrib/importers/keepassx2pass.py b/contrib/importers/keepassx2pass.py index 54d9fbc..197375f 100755 --- a/contrib/importers/keepassx2pass.py +++ b/contrib/importers/keepassx2pass.py @@ -1,8 +1,9 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +#!/usr/bin/env python3 # # Copyright (C) 2012 Juhamatti Niemelä <iiska@iki.fi>. All Rights Reserved. # This file is licensed under the GPLv2+. Please see COPYING for more information. +# +# Usage ./keepassx2pass.py export.xml import sys import re @@ -44,10 +45,10 @@ def password_data(element): """ Return password data and additional info if available from password entry element. """ passwd = element.find('password').text - ret = passwd + "\n" if passwd else "\n" + ret = (passwd + "\n") if passwd else "\n" for field in ['username', 'url', 'comment']: fel = element.find(field) - children = [unicode(e.text or '') + unicode(e.tail or '') for e in list(fel)] + children = [(e.text or '') + (e.tail or '') for e in list(fel)] if len(children) > 0: children.insert(0, '') text = (fel.text or '') + "\n".join(children) @@ -58,11 +59,11 @@ def password_data(element): def import_entry(element, path=''): """ Import new password entry to password-store using pass insert command """ - print "Importing " + path_for(element, path) + print("Importing " + path_for(element, path)) proc = Popen(['pass', 'insert', '--multiline', '--force', path_for(element, path)], - stdin=PIPE, stdout=PIPE) - proc.communicate(password_data(element).encode('utf8')) + stdin=PIPE, stdout=PIPE) + proc.communicate(password_data(element).encode()) proc.wait() def import_group(element, path=''): |