Skip to content

Commit 037f9fc

Browse files
pombredanneJonoYang
authored andcommitted
Format code
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent aae1a28 commit 037f9fc

File tree

6 files changed

+50
-97
lines changed

6 files changed

+50
-97
lines changed

etc/scripts/check_thirdparty.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
@click.option(
1717
"-d",
1818
"--dest",
19-
type=click.Path(exists=True, readable=True,
20-
path_type=str, file_okay=False),
19+
type=click.Path(exists=True, readable=True, path_type=str, file_okay=False),
2120
required=True,
2221
help="Path to the thirdparty directory to check.",
2322
)

etc/scripts/fetch_thirdparty.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@
5555
"-d",
5656
"--dest",
5757
"dest_dir",
58-
type=click.Path(exists=True, readable=True,
59-
path_type=str, file_okay=False),
58+
type=click.Path(exists=True, readable=True, path_type=str, file_okay=False),
6059
metavar="DIR",
6160
default=utils_thirdparty.THIRDPARTY_DIR,
6261
show_default=True,
@@ -121,7 +120,7 @@
121120
show_default=False,
122121
multiple=True,
123122
help="Package name(s) that come only in sdist format (no wheels). "
124-
"The command will not fail and exit if no wheel exists for these names",
123+
"The command will not fail and exit if no wheel exists for these names",
125124
)
126125
@click.option(
127126
"--wheel-only",
@@ -132,7 +131,7 @@
132131
show_default=False,
133132
multiple=True,
134133
help="Package name(s) that come only in wheel format (no sdist). "
135-
"The command will not fail and exit if no sdist exists for these names",
134+
"The command will not fail and exit if no sdist exists for these names",
136135
)
137136
@click.option(
138137
"--no-dist",
@@ -143,7 +142,7 @@
143142
show_default=False,
144143
multiple=True,
145144
help="Package name(s) that do not come either in wheel or sdist format. "
146-
"The command will not fail and exit if no distribution exists for these names",
145+
"The command will not fail and exit if no distribution exists for these names",
147146
)
148147
@click.help_option("-h", "--help")
149148
def fetch_thirdparty(
@@ -225,8 +224,7 @@ def fetch_thirdparty(
225224
environments = None
226225
if wheels:
227226
evts = itertools.product(python_versions, operating_systems)
228-
environments = [utils_thirdparty.Environment.from_pyver_and_os(
229-
pyv, os) for pyv, os in evts]
227+
environments = [utils_thirdparty.Environment.from_pyver_and_os(pyv, os) for pyv, os in evts]
230228

231229
# Collect PyPI repos
232230
repos = []
@@ -250,7 +248,6 @@ def fetch_thirdparty(
250248
print(f"Processing: {name} @ {version}")
251249
if wheels:
252250
for environment in environments:
253-
254251
if TRACE:
255252
print(f" ==> Fetching wheel for envt: {environment}")
256253

@@ -262,14 +259,11 @@ def fetch_thirdparty(
262259
repos=repos,
263260
)
264261
if not fetched:
265-
wheels_or_sdist_not_found[f"{name}=={version}"].append(
266-
environment)
262+
wheels_or_sdist_not_found[f"{name}=={version}"].append(environment)
267263
if TRACE:
268264
print(f" NOT FOUND")
269265

270-
if (sdists or
271-
(f"{name}=={version}" in wheels_or_sdist_not_found and name in sdist_only)
272-
):
266+
if sdists or (f"{name}=={version}" in wheels_or_sdist_not_found and name in sdist_only):
273267
if TRACE:
274268
print(f" ==> Fetching sdist: {name}=={version}")
275269

@@ -292,8 +286,7 @@ def fetch_thirdparty(
292286
sdist_missing = sdists and "sdist" in dists and not name in wheel_only
293287
if sdist_missing:
294288
mia.append(f"SDist missing: {nv} {dists}")
295-
wheels_missing = wheels and any(
296-
d for d in dists if d != "sdist") and not name in sdist_only
289+
wheels_missing = wheels and any(d for d in dists if d != "sdist") and not name in sdist_only
297290
if wheels_missing:
298291
mia.append(f"Wheels missing: {nv} {dists}")
299292

@@ -303,8 +296,7 @@ def fetch_thirdparty(
303296
raise Exception(mia)
304297

305298
print(f"==> FETCHING OR CREATING ABOUT AND LICENSE FILES")
306-
utils_thirdparty.fetch_abouts_and_licenses(
307-
dest_dir=dest_dir, use_cached_index=use_cached_index)
299+
utils_thirdparty.fetch_abouts_and_licenses(dest_dir=dest_dir, use_cached_index=use_cached_index)
308300
utils_thirdparty.clean_about_files(dest_dir=dest_dir)
309301

310302
# check for problems

etc/scripts/gen_pypi_simple.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ def get_package_name_from_filename(filename):
6969
raise InvalidDistributionFilename(filename)
7070

7171
elif filename.endswith(wheel_ext):
72-
7372
wheel_info = get_wheel_from_filename(filename)
7473

7574
if not wheel_info:
@@ -200,11 +199,10 @@ def build_pypi_index(directory, base_url="https://thirdparty.aboutcode.org/pypi"
200199
simple_html_index = [
201200
"<!DOCTYPE html>",
202201
"<html><head><title>PyPI Simple Index</title>",
203-
'<meta charset="UTF-8">' '<meta name="api-version" value="2" /></head><body>',
202+
'<meta charset="UTF-8"><meta name="api-version" value="2" /></head><body>',
204203
]
205204

206205
for pkg_file in directory.iterdir():
207-
208206
pkg_filename = pkg_file.name
209207

210208
if (

etc/scripts/utils_dejacode.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232

3333
def can_do_api_calls():
3434
if not DEJACODE_API_KEY and DEJACODE_API_URL:
35-
print(
36-
"DejaCode DEJACODE_API_KEY and DEJACODE_API_URL not configured. Doing nothing")
35+
print("DejaCode DEJACODE_API_KEY and DEJACODE_API_URL not configured. Doing nothing")
3736
return False
3837
else:
3938
return True
@@ -68,8 +67,7 @@ def get_package_data(distribution):
6867
return results[0]
6968

7069
elif len_results > 1:
71-
print(
72-
f"More than 1 entry exists, review at: {DEJACODE_API_URL_PACKAGES}")
70+
print(f"More than 1 entry exists, review at: {DEJACODE_API_URL_PACKAGES}")
7371
else:
7472
print("Could not find package:", distribution.download_url)
7573

@@ -150,12 +148,11 @@ def find_latest_dejacode_package(distribution):
150148
# there was no exact match, find the latest version
151149
# TODO: consider the closest version rather than the latest
152150
# or the version that has the best data
153-
with_versions = [(packaging_version.parse(p["version"]), p)
154-
for p in packages]
151+
with_versions = [(packaging_version.parse(p["version"]), p) for p in packages]
155152
with_versions = sorted(with_versions)
156153
latest_version, latest_package_version = sorted(with_versions)[-1]
157154
print(
158-
f"Found DejaCode latest version: {latest_version} " f"for dist: {distribution.package_url}",
155+
f"Found DejaCode latest version: {latest_version} for dist: {distribution.package_url}",
159156
)
160157

161158
return latest_package_version
@@ -181,7 +178,7 @@ def create_dejacode_package(distribution):
181178
}
182179

183180
fields_to_carry_over = [
184-
"download_url" "type",
181+
"download_urltype",
185182
"namespace",
186183
"name",
187184
"version",
@@ -209,5 +206,5 @@ def create_dejacode_package(distribution):
209206
if response.status_code != 201:
210207
raise Exception(f"Error, cannot create package for: {distribution}")
211208

212-
print(f'New Package created at: {new_package_data["absolute_url"]}')
209+
print(f"New Package created at: {new_package_data['absolute_url']}")
213210
return new_package_data

etc/scripts/utils_requirements.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ def lock_dev_requirements(
106106
all_req_nvs = get_required_name_versions(all_req_lines)
107107
dev_only_req_nvs = {n: v for n, v in all_req_nvs if n not in main_names}
108108

109-
new_reqs = "\n".join(
110-
f"{n}=={v}" for n, v in sorted(dev_only_req_nvs.items()))
109+
new_reqs = "\n".join(f"{n}=={v}" for n, v in sorted(dev_only_req_nvs.items()))
111110
with open(dev_requirements_file, "w") as fo:
112111
fo.write(new_reqs)
113112

@@ -118,12 +117,10 @@ def get_installed_reqs(site_packages_dir):
118117
as a text.
119118
"""
120119
if not os.path.exists(site_packages_dir):
121-
raise Exception(
122-
f"site_packages directory: {site_packages_dir!r} does not exists")
120+
raise Exception(f"site_packages directory: {site_packages_dir!r} does not exists")
123121
# Also include these packages in the output with --all: wheel, distribute,
124122
# setuptools, pip
125-
args = ["pip", "freeze", "--exclude-editable",
126-
"--all", "--path", site_packages_dir]
123+
args = ["pip", "freeze", "--exclude-editable", "--all", "--path", site_packages_dir]
127124
return subprocess.check_output(args, encoding="utf-8") # noqa: S603
128125

129126

0 commit comments

Comments
 (0)