feature(keyringctl): add force parameter to keyring_merge

This commit is contained in:
Levente Polyak 2021-10-21 21:03:02 +02:00
parent 86747ecab7
commit 77e5b36872
No known key found for this signature in database
GPG Key ID: FC1B547C8D8172C8

View File

@ -643,7 +643,7 @@ def keyring_split(working_dir: Path, keyring: Path) -> Iterable[Path]:
return keyrings return keyrings
def keyring_merge(certificates: List[Path], output: Optional[Path] = None) -> str: def keyring_merge(certificates: List[Path], output: Optional[Path] = None, force: bool = False) -> str:
"""Merge multiple certificates into a keyring """Merge multiple certificates into a keyring
Parameters Parameters
@ -652,6 +652,8 @@ def keyring_merge(certificates: List[Path], output: Optional[Path] = None) -> st
List of paths to certificates to merge into a keyring List of paths to certificates to merge into a keyring
output: Optional[Path] output: Optional[Path]
Path to a file which the keyring is written, return the result instead if None Path to a file which the keyring is written, return the result instead if None
force: bool
Whether to force overwriting existing files (defaults to False)
Returns Returns
------- -------
@ -660,6 +662,8 @@ def keyring_merge(certificates: List[Path], output: Optional[Path] = None) -> st
""" """
cmd = ["sq", "keyring", "merge"] cmd = ["sq", "keyring", "merge"]
if force:
cmd.insert(1, "--force")
if output: if output:
cmd += ["--output", str(output)] cmd += ["--output", str(output)]
cmd += [str(cert) for cert in sorted(certificates)] cmd += [str(cert) for cert in sorted(certificates)]
@ -702,7 +706,7 @@ def packet_join(packets: List[Path], output: Optional[Path] = None, force: bool
output: Optional[Path] output: Optional[Path]
Path to a file to which all PGP packet data is written, return the result instead if None Path to a file to which all PGP packet data is written, return the result instead if None
force: bool force: bool
Whether to force the execution of sq (defaults to False) Whether to force overwriting existing files (defaults to False)
Returns Returns
------- -------