1
0
Fork 0

🎨 Format Python code with Black

This commit is contained in:
Psycojoker 2024-03-30 00:05:33 +00:00 committed by Bram
parent b353a317db
commit f893203fd7

View file

@ -32,7 +32,12 @@ async def git(cmd, in_folder=None):
cmd = " ".join(map(shlex.quote, cmd)) cmd = " ".join(map(shlex.quote, cmd))
print(cmd) print(cmd)
command = await asyncio.create_subprocess_shell(cmd, env=my_env, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.STDOUT) command = await asyncio.create_subprocess_shell(
cmd,
env=my_env,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.STDOUT,
)
data = await command.stdout.read() data = await command.stdout.read()
return data.decode().strip() return data.decode().strip()
@ -45,27 +50,50 @@ async def regen_readme(repository, branch):
print("=" * len(f"{repository} -> branch '{branch}'")) print("=" * len(f"{repository} -> branch '{branch}'"))
with tempfile.TemporaryDirectory() as folder: with tempfile.TemporaryDirectory() as folder:
await git(["clone", f"https://{login}:{token}@github.com/{repository}", "--single-branch", "--branch", branch, folder]) await git(
[
"clone",
f"https://{login}:{token}@github.com/{repository}",
"--single-branch",
"--branch",
branch,
folder,
]
)
generate_READMEs(Path(folder)) generate_READMEs(Path(folder))
await git(["add", "README*.md"], in_folder=folder) await git(["add", "README*.md"], in_folder=folder)
await git(["add", "ALL_README.md"], in_folder=folder) await git(["add", "ALL_README.md"], in_folder=folder)
diff_not_empty = await asyncio.create_subprocess_shell(" ".join(["git", "diff", "HEAD", "--compact-summary"]), cwd=folder, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.STDOUT) diff_not_empty = await asyncio.create_subprocess_shell(
" ".join(["git", "diff", "HEAD", "--compact-summary"]),
cwd=folder,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.STDOUT,
)
diff_not_empty = await diff_not_empty.stdout.read() diff_not_empty = await diff_not_empty.stdout.read()
diff_not_empty = diff_not_empty.decode().strip() diff_not_empty = diff_not_empty.decode().strip()
if not diff_not_empty: if not diff_not_empty:
print("nothing to do") print("nothing to do")
return return
await git(["commit", "-a", "-m", "Auto-update README", "--author='yunohost-bot <yunohost@yunohost.org>'"], in_folder=folder) await git(
[
"commit",
"-a",
"-m",
"Auto-update README",
"--author='yunohost-bot <yunohost@yunohost.org>'",
],
in_folder=folder,
)
await git(["push", "origin", branch, "--quiet"], in_folder=folder) await git(["push", "origin", branch, "--quiet"], in_folder=folder)
print(f"Updated https://github.com/{repository}") print(f"Updated https://github.com/{repository}")
if __name__ == '__main__': if __name__ == "__main__":
skip = True skip = True
apps = json.load(open("../../builds/default/v3/apps.json"))["apps"] apps = json.load(open("../../builds/default/v3/apps.json"))["apps"]
@ -80,4 +108,9 @@ if __name__ == '__main__':
continue continue
time.sleep(2) time.sleep(2)
asyncio.run(regen_readme(infos["git"]["url"].replace("https://github.com/", ""), infos["git"]["branch"])) asyncio.run(
regen_readme(
infos["git"]["url"].replace("https://github.com/", ""),
infos["git"]["branch"],
)
)