Add more documentation to README and inline

This commit is contained in:
Austen Adler 2018-08-15 00:08:13 -04:00
parent 355ec2b183
commit 1f1d8a0b83
2 changed files with 9 additions and 8 deletions

View File

@ -2,10 +2,9 @@
Needs [python-gnupg](https://pypi.python.org/pypi/python-gnupg). Run with path Needs [python-gnupg](https://pypi.python.org/pypi/python-gnupg). Run with path
to password store as argument. to password store as argument.
The csv is written to `pass.csv`. The format for the KeePass Generic CSV The csv is written to `pass.csv`. The format for KeePassXC importer is:
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 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. subsequent lines. '\\' should not be interpreted as an escape character.

View File

@ -23,12 +23,14 @@ def traverse(path):
for name in files: for name in files:
yield os.path.join(root, name) yield os.path.join(root, name)
def getMetadata(notes): def getMetadata(notes_raw):
lines = notes.split('\n') lines = notes_raw.split('\n')
# A list of lines to keep as notes (will be joined by newline) # A list of lines to keep as notes (will be joined by newline)
ret = [] notes = []
# The extracted user field
user = '' user = ''
# The extracted URL field
url = '' url = ''
# This will extract each field name (for example, if a line in notes was `user: user1`, fields should contain 'user') # 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 # The url was matched, don't add it to notes
continue 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): def parse(basepath, path, data):
name = os.path.splitext(os.path.basename(path))[0] name = os.path.splitext(os.path.basename(path))[0]