From 1f1d8a0b83b6359e31cfab3a49b2b66260519658 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Wed, 15 Aug 2018 00:08:13 -0400 Subject: [PATCH] Add more documentation to README and inline --- README.md | 5 ++--- pass2csv.py | 12 +++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 1289194..10047fb 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,9 @@ Needs [python-gnupg](https://pypi.python.org/pypi/python-gnupg). Run with path to password store as argument. -The csv is written to `pass.csv`. The format for the KeePass Generic CSV -Importer is: +The csv is written to `pass.csv`. The format for KeePassXC importer is: -`Group(/),Title,Password,Notes` +`Group(/),Title,User,Password,URL,Notes` Where 'Password' is the first line of the entry in `pass` and 'Notes' are all subsequent lines. '\\' should not be interpreted as an escape character. diff --git a/pass2csv.py b/pass2csv.py index 8ff8daf..da67ee5 100644 --- a/pass2csv.py +++ b/pass2csv.py @@ -23,12 +23,14 @@ def traverse(path): for name in files: yield os.path.join(root, name) -def getMetadata(notes): - lines = notes.split('\n') +def getMetadata(notes_raw): + lines = notes_raw.split('\n') # A list of lines to keep as notes (will be joined by newline) - ret = [] + notes = [] + # The extracted user field user = '' + # The extracted URL field url = '' # This will extract each field name (for example, if a line in notes was `user: user1`, fields should contain 'user') @@ -64,9 +66,9 @@ def getMetadata(notes): # The url was matched, don't add it to notes continue - ret.append(line) + notes.append(line) - return (user, url, '\n'.join(ret).strip()) + return (user, url, '\n'.join(notes).strip()) def parse(basepath, path, data): name = os.path.splitext(os.path.basename(path))[0]