chore(keyringctl): apply black formatter

This commit is contained in:
Levente Polyak 2021-10-19 21:11:37 +02:00
parent 930b5896a0
commit 37d0a5f633
No known key found for this signature in database
GPG Key ID: FC1B547C8D8172C8

View File

@ -33,10 +33,9 @@ from typing import Set
from typing import Tuple from typing import Tuple
from typing import Union from typing import Union
Fingerprint = NewType("Fingerprint", str)
Fingerprint = NewType('Fingerprint', str) Uid = NewType("Uid", str)
Uid = NewType('Uid', str) Username = NewType("Username", str)
Username = NewType('Username', str)
@contextmanager @contextmanager
@ -279,8 +278,11 @@ def convert_certificate( # noqa: ignore=C901
if not pubkey: if not pubkey:
raise Exception("missing certificate public-key") raise Exception("missing certificate public-key")
name_override = name_override or derive_username_from_fingerprint(keyring_dir=keyring_dir, name_override = (
certificate_fingerprint=certificate_fingerprint) or Username(certificate.stem) name_override
or derive_username_from_fingerprint(keyring_dir=keyring_dir, certificate_fingerprint=certificate_fingerprint)
or Username(certificate.stem)
)
user_dir = working_dir / name_override user_dir = working_dir / name_override
key_dir = user_dir / certificate_fingerprint key_dir = user_dir / certificate_fingerprint
@ -723,14 +725,18 @@ def derive_username_from_fingerprint(keyring_dir: Path, certificate_fingerprint:
if len(matches) > 1: if len(matches) > 1:
raise Exception( raise Exception(
f"More than one username found in {keyring_dir} when probing for fingerprint '{certificate_fingerprint}': {matches}" f"More than one username found in {keyring_dir} when probing for fingerprint '{certificate_fingerprint}': "
f"{matches}"
) )
elif not matches: elif not matches:
debug(f"Can not derive username from target directory for fingerprint {certificate_fingerprint}") debug(f"Can not derive username from target directory for fingerprint {certificate_fingerprint}")
return None return None
else: else:
username = matches[0].parent.stem username = matches[0].parent.stem
debug(f"Successfully derived username '{username}' from target directory for fingerprint {certificate_fingerprint}") debug(
f"Successfully derived username '{username}' from target directory for fingerprint "
f"{certificate_fingerprint}"
)
return Username(username) return Username(username)