Skip to content

Commit db2dd61

Browse files
committed
Reformat the code to comply with Ruff's check #341
Signed-off-by: Chin Yeung Li <[email protected]>
1 parent 83a6bd8 commit db2dd61

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

build_deb_docker.py

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,27 @@
2626

2727
def build_deb_with_docker():
2828
# Load the pyproject.toml file
29-
with open('pyproject.toml') as f:
30-
project = toml.load(f)['project']
29+
with open("pyproject.toml") as f:
30+
project = toml.load(f)["project"]
3131

32-
pkg_name = project['name']
32+
pkg_name = project["name"]
3333
# Insert "python3-"" prefix that follows a common convention
3434
deb_name = f"python3-{pkg_name.lower()}"
3535

3636
# Debian version conventions replace hyphens with tildes
37-
deb_version = project['version'].replace("-dev", "~dev")
37+
deb_version = project["version"].replace("-dev", "~dev")
3838

3939
docker_cmd = [
40-
'docker', 'run', '--rm',
41-
'-v', f"{os.getcwd()}:/workspace",
42-
'-w', '/workspace',
43-
'ubuntu:22.04',
44-
'/bin/bash', '-c',
40+
"docker",
41+
"run",
42+
"--rm",
43+
"-v",
44+
f"{os.getcwd()}:/workspace",
45+
"-w",
46+
"/workspace",
47+
"ubuntu:22.04",
48+
"/bin/bash",
49+
"-c",
4550
f"""set -ex
4651
# Install build dependencies
4752
apt-get update
@@ -78,12 +83,17 @@ def build_deb_with_docker():
7883
Package: {deb_name}
7984
Version: {deb_version}
8085
Architecture: all
81-
Maintainer: {project.get('authors', [{}])[0].get('name', 'nexB Inc.')}
82-
Description: {project.get('description', 'Automate open source license compliance and ensure supply chain integrity')}
86+
Maintainer: {project.get("authors", [{}])[0].get("name", "nexB Inc.")}
87+
Description: {
88+
project.get(
89+
"description",
90+
"Automate open source license compliance andensure supply chain integrity",
91+
)
92+
}
8393
Depends: python3
8494
Section: python
8595
Priority: optional
86-
Homepage: {project.get('urls', '').get('Homepage', 'https://github.com/aboutcode-org/dejacode')}
96+
Homepage: {project.get("urls", "").get("Homepage", "https://github.com/aboutcode-org/dejacode")}
8797
EOF
8898
8999
# Build the .deb package
@@ -94,13 +104,13 @@ def build_deb_with_docker():
94104
95105
# Fix permissions for Windows host
96106
chmod -R u+rwX dist/debian/
97-
"""
107+
""",
98108
]
99109

100110
try:
101-
subprocess.run(docker_cmd, check=True)
111+
subprocess.run(docker_cmd, check=True, shell=False) # noqa: S603
102112
# Verify the existence of the .deb
103-
deb_file = next(Path('dist/debian').glob('*.deb'), None)
113+
deb_file = next(Path("dist/debian").glob("*.deb"), None)
104114
if deb_file:
105115
print(f"\nSuccess! Debian package built: {deb_file}")
106116
else:
@@ -111,9 +121,9 @@ def build_deb_with_docker():
111121
sys.exit(1)
112122

113123

114-
if __name__ == '__main__':
124+
if __name__ == "__main__":
115125
# Check if "docker" is available
116-
if not shutil.which('docker'):
126+
if not shutil.which("docker"):
117127
print("Error: Docker not found. Please install Docker first.", file=sys.stderr)
118128
sys.exit(1)
119129

0 commit comments

Comments
 (0)