Skip to content

Commit

Permalink
Run latest black improvements on Python files
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieucan committed Apr 17, 2024
1 parent a8fdeb6 commit fea4e33
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion lib/debsources/archiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def add_suite(conf, session, suite, archive):
if updater.STAGE_SUITES in conf["stages"]:
suitemap_q = sql.insert(Suite.__table__)
suitemaps = []
for (pkg, version) in archive.suites[suite]:
for pkg, version in archive.suites[suite]:
db_package = db_storage.lookup_package(session, pkg, version)
if not db_package:
logging.warn(
Expand Down
2 changes: 1 addition & 1 deletion lib/debsources/db_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def add_package(session, pkg, pkgdir, sticky=False):

# add individual source files to the File table
file_table = {}
for (relpath, _abspath) in fs_storage.walk_pkg_files(pkgdir):
for relpath, _abspath in fs_storage.walk_pkg_files(pkgdir):
file = File(db_package, relpath)
session.add(file)
session.flush()
Expand Down
4 changes: 2 additions & 2 deletions lib/debsources/mainlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def _to_path(key, value):
def parse_conf_infra(items):
"""returns correct typing for the [infra] section"""
typed = {}
for (key, value) in items:
for key, value in items:
if key == "expire_days":
value = int(value)
elif key == "dry_run":
Expand All @@ -123,7 +123,7 @@ def parse_conf_infra(items):
def parse_conf_webapp(items):
"""returns correct typing for the [webapp] section"""
typed = {}
for (key, value) in items:
for key, value in items:
if value.lower() == "false":
value = False
elif value.lower() == "true":
Expand Down
2 changes: 1 addition & 1 deletion lib/debsources/plugins/hook_checksums.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def emit_checksum(out, relpath, abspath):
# ASSUMPTION: if *a* checksum of this package has already
# been added to the db in the past, then *all* of them have,
# as additions are part of the same transaction
for (sha256, relpath) in parse_checksums(sumsfile):
for sha256, relpath in parse_checksums(sumsfile):
params = {"package_id": db_package.id, "sha256": sha256}
if file_table:
try:
Expand Down
2 changes: 1 addition & 1 deletion lib/debsources/plugins/hook_copyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def emit_license(out, package, version, relpath, copyright):
# added to the db in the past, then *all* of them have, as
# additions are part of the same transaction
licenses = parse_license_file(license_file)
for (synopsis, path) in licenses:
for synopsis, path in licenses:
if file_table:
try:
file_id = file_table[path]
Expand Down
2 changes: 1 addition & 1 deletion lib/debsources/plugins/hook_sloccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def add_package(session, pkg, pkgdir, file_table):
# ASSUMPTION: if *a* loc count of this package has already been
# added to the db in the past, then *all* of them have, as
# additions are part of the same transaction
for (lang, locs) in slocs.items():
for lang, locs in slocs.items():
sloccount = SlocCount(db_package, lang, locs)
session.add(sloccount)

Expand Down
7 changes: 3 additions & 4 deletions lib/debsources/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ def location_get_path_links(endpoint, path_to: Path):
# This hack is similar to the one in helper.py in redirect_to_url function

if endpoint == ".versions":
for (i, p) in enumerate(path_dict):
for i, p in enumerate(path_dict):
pathl.append(
(p, url_for(endpoint, packagename="/".join(path_dict[: i + 1])))
)
else:
for (i, p) in enumerate(path_dict):
for i, p in enumerate(path_dict):
pathl.append((p, url_for(endpoint, path_to="/".join(path_dict[: i + 1]))))
return pathl

Expand Down Expand Up @@ -216,7 +216,7 @@ def location_get_stat(sources_path):
file_type = sign
break
file_perms = ""
for (flag, do_true, do_false) in perm_flags:
for flag, do_true, do_false in perm_flags:
file_perms += do_true if (sources_mode & flag) else do_false

file_size = sources_size
Expand Down Expand Up @@ -353,7 +353,6 @@ def get_files_by_checksum(session, checksum, package=None, suite=None):
)

if package is not None and package != "":

results = results.filter(PackageName.name == package)

if suite is not None and suite != "":
Expand Down
1 change: 0 additions & 1 deletion lib/debsources/tests/test_archiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
@attr("infra")
@attr("postgres")
class Archiver(unittest.TestCase, DbTestFixture):

TEST_STAGES = set([updater.STAGE_EXTRACT, updater.STAGE_SUITES, updater.STAGE_GC])

def setUp(self):
Expand Down
2 changes: 1 addition & 1 deletion lib/debsources/tests/test_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def tearDownClass(cls):
cls.db_teardown_cls()

def test_sqlalchemy_path(self):
for (path, path_bytes) in [
for path, path_bytes in [
(Path("/hello") / "world", b"/hello/world"),
(Path("\udcff"), b"\xff"), # non utf8, surrogateescape
]:
Expand Down
12 changes: 6 additions & 6 deletions lib/debsources/tests/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_list_versions(self):

# Test returning suites without suit as parameter
self.assertTrue(
{"suites": [u"wheezy"], "version": u"0.90+20120429-1", "area": u"main"}
{"suites": ["wheezy"], "version": "0.90+20120429-1", "area": "main"}
in qry.pkg_names_list_versions_w_suites(self.session, "gnubg")
)

Expand All @@ -94,9 +94,9 @@ def test_list_versions(self):
qry.pkg_names_list_versions_w_suites(self.session, "gnubg", "jessie"),
[
{
"suites": [u"jessie", u"sid"],
"version": u"1.02.000-2",
"area": u"main",
"suites": ["jessie", "sid"],
"version": "1.02.000-2",
"area": "main",
}
],
)
Expand All @@ -110,8 +110,8 @@ def test_find_ctag(self):
{
"path": Path("eval.c"),
"line": 1747,
"version": u"0.90+20091206-4",
"package": u"gnubg",
"version": "0.90+20091206-4",
"package": "gnubg",
}
in ctags[1]
)
Expand Down
10 changes: 5 additions & 5 deletions lib/debsources/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def notify_plugins(
If triggers is not None, only Python hooks whose names are listed in them
will be triggered. Note: shell hooks will not be triggered in that case.
"""
for (title, action) in observers[event]:
for title, action in observers[event]:
try:
if triggers is None:
action(session, pkg, pkgdir, file_table)
Expand Down Expand Up @@ -386,7 +386,7 @@ def update_suites(status, conf, session, mirror):
if not conf["dry_run"] and "db" in conf["backends"]:
session.query(SuiteAlias).delete()

for (suite, pkgs) in mirror.suites.items():
for suite, pkgs in mirror.suites.items():
if not conf["dry_run"] and "db" in conf["backends"]:
session.query(Suite).filter_by(suite=suite).delete()
for pkg_id in pkgs:
Expand Down Expand Up @@ -632,7 +632,7 @@ def update_charts(status, conf, session, suites=None):

# size charts, various metrics
for metric in ["source_packages", "disk_usage", "source_files", "ctags"]:
for (period, granularity) in CHARTS:
for period, granularity in CHARTS:
for suite in suites + ["ALL"]:
series = getattr(statistics, "history_size_" + granularity)(
session, metric, interval=period, suite=suite
Expand All @@ -643,7 +643,7 @@ def update_charts(status, conf, session, suites=None):
charts.size_plot(series, chart_file)

# sloccount: historical histograms
for (period, granularity) in CHARTS:
for period, granularity in CHARTS:
for suite in suites + ["ALL"]:
# historical histogram
mseries = getattr(statistics, "history_sloc_" + granularity)(
Expand Down Expand Up @@ -678,7 +678,7 @@ def update_charts(status, conf, session, suites=None):

def update_license_charts():
# License: historical histogramms
for (period, granularity) in CHARTS:
for period, granularity in CHARTS:
for suite in suites + ["ALL"]:
mseries = getattr(statistics, "history_copyright_" + granularity)(
session, interval=period, suite=suite
Expand Down

0 comments on commit fea4e33

Please sign in to comment.