From 580688558c5fba3dbb827cc23441731e8fcb7e43 Mon Sep 17 00:00:00 2001 From: "rmlibre@riseup.net" Date: Fri, 13 Dec 2019 06:47:30 -0500 Subject: [PATCH] v0.3.5 update - working pip installations! --- tiny_gnupg/tiny_gnupg.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tiny_gnupg/tiny_gnupg.py b/tiny_gnupg/tiny_gnupg.py index 13430e6..dad4502 100644 --- a/tiny_gnupg/tiny_gnupg.py +++ b/tiny_gnupg/tiny_gnupg.py @@ -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) @@ -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 = [ @@ -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"): @@ -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("")] async def network_import(self, uid=""): @@ -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)