From b653edfcdc8352ba19c6e6b16fa7038059fb91e9 Mon Sep 17 00:00:00 2001 From: Levente Polyak Date: Thu, 18 Nov 2021 22:38:47 +0100 Subject: [PATCH] feature(keyringctl): add trust and colors to inspect output --- libkeyringctl/keyring.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libkeyringctl/keyring.py b/libkeyringctl/keyring.py index 670b5af..c4d929b 100644 --- a/libkeyringctl/keyring.py +++ b/libkeyringctl/keyring.py @@ -27,6 +27,7 @@ from .trust import certificate_trust from .trust import certificate_trust_from_paths from .trust import filter_by_trust from .trust import format_trust_label +from .trust import trust_color from .types import Fingerprint from .types import Trust from .types import TrustFilter @@ -1176,6 +1177,19 @@ def inspect_keyring(working_dir: Path, keyring_root: Path, sources: Optional[Lis paths=[keyring_root / "packager"] ) | get_fingerprints_from_certificate_directory(paths=[keyring_root / "main"], postfix=" (main)") + main_keys = get_fingerprints_from_paths([keyring_root / "main"]) + all_fingerprints = get_fingerprints_from_paths([keyring_root]) + + trusts: Dict[Fingerprint, Trust] = certificate_trust_from_paths( + sources=[keyring_root], main_keys=main_keys, all_fingerprints=all_fingerprints + ) + + for fingerprint in fingerprints.keys(): + trust = trusts[fingerprint] + fingerprints[fingerprint] = Username( + f"{trust_color(trust=trust).value}{fingerprints[fingerprint]} {format_trust_label(trust=trust)}" + ) + return inspect( packet=keyring_path, certifications=True,