Skip to content

Instantly share code, notes, and snippets.

@tubaman
Last active June 30, 2021 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tubaman/a2bcbc07a69ea2c4a7353291760755b4 to your computer and use it in GitHub Desktop.
Save tubaman/a2bcbc07a69ea2c4a7353291760755b4 to your computer and use it in GitHub Desktop.
Python module to get password data from password-store.org(pass)
"""Python module to get password data from password-store.org(pass)
ex:
from pwstore import pwstore
password, data = pwstore("example.org")
username = data['Username']
"""
import re
from subprocess import check_output
def pwstore(name):
out = check_output(['pass', name])
lines = out.decode('utf-8').splitlines()
pword = lines[0]
data = dict([re.split(r":\s*", line, 1) for line in lines[1:]])
return pword, data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment