chore(keyringctl): apply black formatter
This commit is contained in:
parent
930b5896a0
commit
37d0a5f633
22
keyringctl
22
keyringctl
@ -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)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user