feature(keyringctl): improve packet_join to optionally return the result
This commit is contained in:
parent
deaa312b7d
commit
52178f38d5
13
keyringctl
13
keyringctl
@ -668,17 +668,22 @@ def packet_split(working_dir: Path, certificate: Path) -> Iterable[Path]:
|
|||||||
return natural_sort_path(packet_dir.iterdir())
|
return natural_sort_path(packet_dir.iterdir())
|
||||||
|
|
||||||
|
|
||||||
def packet_join(packets: List[Path], output: Path, force: bool = False) -> None:
|
def packet_join(packets: List[Path], output: Optional[Path] = None, force: bool = False) -> str:
|
||||||
"""Join PGP packet data in files to a single output file
|
"""Join PGP packet data in files to a single output file
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
packets: List[Path]
|
packets: List[Path]
|
||||||
A list of paths to files that contain PGP packet data
|
A list of paths to files that contain PGP packet data
|
||||||
output: Path
|
output: Optional[Path]
|
||||||
A file to which all PGP packet data is written
|
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 the execution of sq (defaults to False)
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
str
|
||||||
|
The result if no output file has been used
|
||||||
"""
|
"""
|
||||||
|
|
||||||
cmd = ["sq", "packet", "join"]
|
cmd = ["sq", "packet", "join"]
|
||||||
@ -687,7 +692,7 @@ def packet_join(packets: List[Path], output: Path, force: bool = False) -> None:
|
|||||||
packets_str = list(map(lambda path: str(path), packets))
|
packets_str = list(map(lambda path: str(path), packets))
|
||||||
cmd.extend(packets_str)
|
cmd.extend(packets_str)
|
||||||
cmd.extend(["--output", str(output)])
|
cmd.extend(["--output", str(output)])
|
||||||
system(cmd, exit_on_error=False)
|
return system(cmd, exit_on_error=False)
|
||||||
|
|
||||||
|
|
||||||
def simplify_user_id(user_id: Uid) -> Uid:
|
def simplify_user_id(user_id: Uid) -> Uid:
|
||||||
|
Loading…
Reference in New Issue
Block a user