Skip to content

Commit

Permalink
fix misses in syntax linting
Browse files Browse the repository at this point in the history
  • Loading branch information
blankdots committed Feb 22, 2023
1 parent 27f2cc9 commit b31d0e6
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions crypt4gh_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ def __init__(self, window: tk.Tk) -> None:
self.my_key_field.grid(column=0, row=1, sticky=tk.W)
self.my_key_field.config(state="disabled")
# Auto-load generated private key if such exists: username_crypt4gh.key (can be changed in UI)
default_private_key_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), f"{getpass.getuser()}_crypt4gh.key")
default_private_key_path = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
f"{getpass.getuser()}_crypt4gh.key",
)
if os.path.isfile(default_private_key_path):
self.my_key_value.set(default_private_key_path)

Expand Down Expand Up @@ -103,7 +106,12 @@ def __init__(self, window: tk.Tk) -> None:
)
self.load_their_key_button.grid(column=1, row=2, sticky=tk.E, columnspan=2)

self.select_file_button = tk.Button(window, text="Select File", width=OS_CONFIG["config_button_width"], command=partial(self.open_file, "file"))
self.select_file_button = tk.Button(
window,
text="Select File",
width=OS_CONFIG["config_button_width"],
command=partial(self.open_file, "file"),
)
self.select_file_button.grid(column=1, row=3, sticky=tk.E, columnspan=2)

self.encrypt_button = tk.Button(
Expand Down Expand Up @@ -156,7 +164,11 @@ def password_prompt(self, action: Optional[str]) -> None:
# This if-clause is for preventing error messages
if password1 is None:
return
password2 = askstring("Private Key Passphrase", "Re-type Private Key Passphrase to Confirm", show="*")
password2 = askstring(
"Private Key Passphrase",
"Re-type Private Key Passphrase to Confirm",
show="*",
)
if password2 is None:
return
if password1 != password2:
Expand Down Expand Up @@ -191,7 +203,11 @@ def password_prompt(self, action: Optional[str]) -> None:
if password is None:
return
while len(password) == 0:
password = askstring("Private Key Passphrase", "Passphrase can't be empty", show="*")
password = askstring(
"Private Key Passphrase",
"Passphrase can't be empty",
show="*",
)
# This if-clause is for preventing error messages
if password is None:
return
Expand All @@ -207,7 +223,7 @@ def password_prompt(self, action: Optional[str]) -> None:
if private_key is not None:
their_key = get_public_key(self.their_key_value.get())
print("Encrypting...")
encrypted_file: Union[BufferedWriter, BufferedReader]
encrypted_file_wb: Union[BufferedWriter, BufferedReader]
original_file = open(self.file_value.get(), "rb")
encrypted_file_wb = open(f"{self.file_value.get()}.c4gh", "wb")
encrypt([(0, private_key, their_key)], original_file, encrypted_file_wb)
Expand All @@ -230,7 +246,11 @@ def password_prompt(self, action: Optional[str]) -> None:
if password is None:
return
while len(password) == 0:
password = askstring("Private Key Passphrase", "Passphrase can't be empty", show="*")
password = askstring(
"Private Key Passphrase",
"Passphrase can't be empty",
show="*",
)
# This if-clause is for preventing error messages
if password is None:
return
Expand Down

0 comments on commit b31d0e6

Please sign in to comment.