chore(keyringctl): deduplicate iteration and split code in convert()

This commit is contained in:
Levente Polyak 2021-10-12 19:42:22 +02:00
parent ac798eeeab
commit 6299f6416e
No known key found for this signature in database
GPG Key ID: FC1B547C8D8172C8

View File

@ -753,19 +753,13 @@ def convert(
"""
directories: List[Path] = []
if source.is_dir():
for key in source.iterdir():
name = name_override or key.stem
for cert in keyring_split(working_dir=working_dir, keyring=key):
directories.append(
convert_certificate(working_dir=working_dir, certificate=cert, name_override=name)
)
else:
name = name_override or source.stem
for cert in keyring_split(working_dir=working_dir, keyring=source):
keys: Iterable[Path] = source.iterdir() if source.is_dir() else [source]
for key in keys:
name = name_override or key.stem
for cert in keyring_split(working_dir=working_dir, keyring=key):
directories.append(
convert_certificate(working_dir=working_dir, certificate=cert, name_override=name)
)
convert_certificate(working_dir=working_dir, certificate=cert, name_override=name))
for path in directories:
(target_dir / path.name).mkdir(exist_ok=True)