aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/contrib
diff options
context:
space:
mode:
authorSam Mason <sam@samason.uk>2017-02-25 11:22:05 +0000
committerJason A. Donenfeld <Jason@zx2c4.com>2017-02-25 14:09:01 +0100
commit03424643466ccb3abafc6e9b4a609625e41c8b2e (patch)
tree3c09a9dcf434369cc61bed7f59991d6a8f3b6638 /contrib
parentSupport git worktree. (diff)
downloadpassword-store-03424643466ccb3abafc6e9b4a609625e41c8b2e.tar.xz
password-store-03424643466ccb3abafc6e9b4a609625e41c8b2e.zip
pwsafe2pass: add importer
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/importers/pwsafe2pass.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/contrib/importers/pwsafe2pass.py b/contrib/importers/pwsafe2pass.py
new file mode 100755
index 0000000..db6e027
--- /dev/null
+++ b/contrib/importers/pwsafe2pass.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python3
+
+# Copyright (C) 2017 Sam Mason <sam@samason.uk>. All Rights Reserved.
+# This file is licensed under the GPLv2+. Please see COPYING for more information.
+
+import sys
+import subprocess
+
+import pandas as pd
+
+# assumes STDIN is generated via File=>Export from the Mac version of
+# pwsafe, available from https://pwsafe.info/
+df = pd.read_table(sys.stdin)
+df.sort_values(['Group/Title','Username'], inplace=True)
+
+tr = {
+ ord('.'): '/',
+ ord('ยป'): '.'
+}
+
+for i,row in df.iterrows():
+ na = row.notnull()
+
+ path = 'pwsafe/{}'.format(row['Group/Title'].strip().translate(tr))
+ value = '{}\n'.format(row['Password'])
+
+ if na['Username']:
+ path = '{}/{}'.format(path,row['Username'].strip())
+
+ if na['e-mail']:
+ value = 'email: {}\n'.format(value,row['e-mail'].strip())
+
+ if na['Notes']:
+ value = '\n{}\n'.format(value, row['Notes'].strip())
+
+ with subprocess.Popen(['pass','add','-m',path],stdin=subprocess.PIPE) as proc:
+ proc.communicate(value.encode('utf8'))
+ if proc.returncode:
+ print('failure with {}, returned {}'.format(
+ path, proc.returncode))