1
0
Fork 0
mirror of https://github.com/YunoHost/apps.git synced 2024-09-03 20:06:07 +02:00

🎨 Format Python code with Black

This commit is contained in:
Salamandar 2024-06-02 19:21:52 +00:00
parent 26e8eb74b3
commit eb9f116bc5

View file

@ -25,7 +25,9 @@ def app_cache_folder(app: str) -> Path:
return APPS_CACHE_DIR / app return APPS_CACHE_DIR / app
def app_cache_clone(app: str, infos: dict[str, str], all_branches: bool = False) -> None: def app_cache_clone(
app: str, infos: dict[str, str], all_branches: bool = False
) -> None:
logging.info("Cloning %s...", app) logging.info("Cloning %s...", app)
git_depths = { git_depths = {
"notworking": 5, "notworking": 5,
@ -47,7 +49,8 @@ def app_cache_clone_or_update(
app: str, app: str,
infos: dict[str, str], infos: dict[str, str],
ssh_clone: bool = False, ssh_clone: bool = False,
fetch_all_branches: bool = False) -> None: fetch_all_branches: bool = False,
) -> None:
app_path = app_cache_folder(app) app_path = app_cache_folder(app)
# Patch url for ssh clone # Patch url for ssh clone
@ -97,10 +100,13 @@ def apps_cache_update_all(
apps: dict[str, dict[str, Any]], apps: dict[str, dict[str, Any]],
parallel: int = 8, parallel: int = 8,
ssh_clone: bool = False, ssh_clone: bool = False,
all_branches: bool = False) -> None: all_branches: bool = False,
) -> None:
with Pool(processes=parallel) as pool: with Pool(processes=parallel) as pool:
tasks = pool.imap_unordered(__app_cache_clone_or_update_mapped, tasks = pool.imap_unordered(
zip(apps.keys(), apps.values(), repeat(ssh_clone), repeat(all_branches))) __app_cache_clone_or_update_mapped,
zip(apps.keys(), apps.values(), repeat(ssh_clone), repeat(all_branches)),
)
for _ in tqdm.tqdm(tasks, total=len(apps.keys()), ascii=" ·#"): for _ in tqdm.tqdm(tasks, total=len(apps.keys()), ascii=" ·#"):
pass pass
@ -119,8 +125,20 @@ def __run_for_catalog():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("-v", "--verbose", action="store_true") parser.add_argument("-v", "--verbose", action="store_true")
parser.add_argument("-j", "--processes", type=int, default=8) parser.add_argument("-j", "--processes", type=int, default=8)
parser.add_argument("-s", "--ssh", action=argparse.BooleanOptionalAction, default=False, help="Use ssh clones instead of https") parser.add_argument(
parser.add_argument("-b", "--all-branches", action=argparse.BooleanOptionalAction, default=False, help="Download all branches from repo") "-s",
"--ssh",
action=argparse.BooleanOptionalAction,
default=False,
help="Use ssh clones instead of https",
)
parser.add_argument(
"-b",
"--all-branches",
action=argparse.BooleanOptionalAction,
default=False,
help="Download all branches from repo",
)
parser.add_argument( parser.add_argument(
"-c", "-c",
"--cleanup", "--cleanup",
@ -134,8 +152,12 @@ def __run_for_catalog():
if args.cleanup: if args.cleanup:
apps_cache_cleanup(get_catalog()) apps_cache_cleanup(get_catalog())
apps_cache_update_all(get_catalog(), parallel=args.processes, apps_cache_update_all(
ssh_clone=args.ssh, all_branches=args.all_branches) get_catalog(),
parallel=args.processes,
ssh_clone=args.ssh,
all_branches=args.all_branches,
)
if __name__ == "__main__": if __name__ == "__main__":