Skip to content

Commit

Permalink
v0.3.5 update - working pip installations!
Browse files Browse the repository at this point in the history
  • Loading branch information
rmlibre committed Dec 13, 2019
1 parent 56d5939 commit 5806885
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions tiny_gnupg/tiny_gnupg.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ def __init__(self, username="", email="", passphrase=""):
def set_homedir(self, path=HOME_PATH):
self.home = self.format_homedir(path)
self.executable = self.home + "/gpg2"
if not Path(self.home).exists():
Path(self.home).touch()
command = ["chmod", "-R", "700", self.home]
return self.read_output(command)

Expand Down Expand Up @@ -277,9 +275,6 @@ def raw_list_keys(self, uid=""):
command = self.command("--list-keys")
return self.read_output(command)

def list_keys(self, uid=""):
return self.format_list_keys(self.raw_list_keys(uid))

def format_list_keys(self, raw_list_keys_terminal_output):
keys = raw_list_keys_terminal_output.split("\npub ")
fingerprints = [
Expand All @@ -293,6 +288,9 @@ def format_list_keys(self, raw_list_keys_terminal_output):
]
return dict(zip(fingerprints, emails))

def list_keys(self, uid=""):
return self.format_list_keys(self.raw_list_keys(uid))

def key_email(self, uid=""):
parts = self.raw_list_keys(uid).replace(" ", "")
for part in parts.split("\nuid"):
Expand Down Expand Up @@ -337,7 +335,7 @@ async def search(self, query=""):
response = await self.raw_search(query)
if "We found an entry" not in response:
return ""
part = response[response.find(f">{self._keyserver}") + 1:]
part = response[response.find(f">{self._keyserver}") + 1 :]
return part[: part.find("</a>")]

async def network_import(self, uid=""):
Expand All @@ -347,13 +345,12 @@ async def network_import(self, uid=""):
print(f"key location: {key_url}")
async with self.network_get(key_url) as response:
key = await response.text()
if not key:
if not key or " " in key.strip():
raise IOError("Failure to download key from server.")
print(f"downloaded:\n{key}")
return self.text_import(key)

async def file_import(self, path="", mode="r"):
path = Path(path).absolute()
async with aiofiles.open(path, mode) as keyfile:
key = await keyfile.read()
return self.text_import(key)
Expand Down

0 comments on commit 5806885

Please sign in to comment.