Skip to content

Commit 744aad0

Browse files
committed
style: reformatting python
1 parent bf32644 commit 744aad0

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

.github/scripts/PrintDockerTagURL.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,32 @@
99
# ░▒▓███████▓▒░░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░
1010
#
1111
# ======================================================================================
12-
1312
# This script is used to print the Dockerhub URL of a specific tag to a GHA step output variable.
1413
# Pipe this script's output into $GITHUB_OUTPUT.
1514
# This script is needed because Dockerhub image tag URLs contain the SHA of the image.
1615
# We obtain this via docker inspect.
17-
18-
import sys
1916
import subprocess
17+
import sys
2018

2119
TAG_NAME = sys.argv[1]
2220

2321
result = subprocess.run(
24-
['docker', 'inspect', '--format="{{.RepoDigests}}"', f'benvining/benbot-lichess:{TAG_NAME}'],
22+
[
23+
"docker",
24+
"inspect",
25+
'--format="{{.RepoDigests}}"',
26+
f"benvining/benbot-lichess:{TAG_NAME}",
27+
],
2528
capture_output=True,
26-
text=True
29+
text=True,
2730
)
2831

2932
# string format is:
3033
# [benvining/benbot-lichess@sha256:9e94ea05cbc5b84509beca6c5ab54e176907cf6d5c67f81e2f977149cc086ce1]
3134
output = result.stdout
3235

33-
hash_str = output[output.find('@')+1:output.find(']')]
36+
hash_str = output[output.find("@") + 1 : output.find("]")]
3437

35-
print(f'url=https://hub.docker.com/repository/docker/benvining/benbot-lichess/tags/{TAG_NAME}/{hash_str}')
38+
print(
39+
f"url=https://hub.docker.com/repository/docker/benvining/benbot-lichess/tags/{TAG_NAME}/{hash_str}"
40+
)

.github/scripts/ReZipArtifacts.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
# ░▒▓███████▓▒░░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░
1010
#
1111
# ======================================================================================
12-
1312
# The download-artifact action will unzip the artifacts by default (and this can't be disabled).
1413
# However, we want to upload a zip for each platform because on SO platforms, this zip will include
1514
# any shared libraries that the ben_bot executable relies on, and we wouldn't want each of those
@@ -18,29 +17,28 @@
1817
# and re-zips them into a .zip file with the same filename as the artifact. This zip file is created
1918
# in the specified output directory:
2019
# python3 ReZipArtifacts.py <downloadsRoot> <outputDirectory>
21-
22-
from pathlib import Path
23-
import sys
2420
import os
2521
import shutil
22+
import sys
23+
from pathlib import Path
2624

2725
DOWNLOADS_ROOT = Path(sys.argv[1])
2826
OUTPUT_DIR = Path(sys.argv[2])
2927

3028
for dirpath, dirnames, filenames in os.walk(DOWNLOADS_ROOT):
3129
for subdir_name in dirnames:
3230
# the docs artifact is a special case
33-
if subdir_name == 'BenBot-docs':
31+
if subdir_name == "BenBot-docs":
3432
os.rename(
35-
DOWNLOADS_ROOT / subdir_name / 'artifact.tar',
36-
OUTPUT_DIR / 'BenBot-docs.tar'
33+
DOWNLOADS_ROOT / subdir_name / "artifact.tar",
34+
OUTPUT_DIR / "BenBot-docs.tar",
3735
)
3836
else:
3937
shutil.make_archive(
4038
OUTPUT_DIR / subdir_name,
41-
'zip',
39+
"zip",
4240
root_dir=DOWNLOADS_ROOT,
43-
base_dir=subdir_name
41+
base_dir=subdir_name,
4442
)
4543

4644
# we only want the outer loop to run once, to process just the top-level subdirectories

.github/scripts/SetupLichessConfig.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,21 @@
99
# ░▒▓███████▓▒░░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░
1010
#
1111
# ======================================================================================
12-
1312
# The lichess-bot Docker image expects the config file to contain the Lichess token.
1413
# We don't want to hardcode it into the config file in the repo, so this script injects
1514
# it by replacing the @LICHESS_TOKEN@ placeholder with the secret (which is an environment
1615
# secret). This script writes to the config file in-place in the source tree.
1716
# python3 SetupLichessConfig.py <configFilePath> <lichessToken>
18-
19-
from pathlib import Path
2017
import sys
18+
from pathlib import Path
2119

2220
CONFIG_FILE = Path(sys.argv[1])
2321
LICHESS_TOKEN = sys.argv[2]
2422

25-
with open(CONFIG_FILE, 'r') as file:
23+
with open(CONFIG_FILE) as file:
2624
file_content = file.read()
2725

28-
new_content = file_content.replace('@LICHESS_TOKEN@', LICHESS_TOKEN)
26+
new_content = file_content.replace("@LICHESS_TOKEN@", LICHESS_TOKEN)
2927

30-
with open(CONFIG_FILE, 'w') as file:
28+
with open(CONFIG_FILE, "w") as file:
3129
file.write(new_content)

0 commit comments

Comments
 (0)