diff options
-rw-r--r-- | gemato/cli.py | 7 | ||||
-rw-r--r-- | gemato/compression.py | 3 | ||||
-rw-r--r-- | gemato/exceptions.py | 1 | ||||
-rw-r--r-- | gemato/find_top_level.py | 3 | ||||
-rw-r--r-- | gemato/hash.py | 5 | ||||
-rw-r--r-- | gemato/manifest.py | 1 | ||||
-rw-r--r-- | gemato/openpgp.py | 3 | ||||
-rw-r--r-- | gemato/profile.py | 9 | ||||
-rw-r--r-- | gemato/recursiveloader.py | 1 | ||||
-rw-r--r-- | gemato/util.py | 3 | ||||
-rw-r--r-- | gemato/verify.py | 1 | ||||
-rw-r--r-- | tests/keydata.py | 3 | ||||
-rw-r--r-- | tests/test_compression.py | 3 | ||||
-rw-r--r-- | tests/test_find_top_level.py | 3 | ||||
-rw-r--r-- | tests/test_hash.py | 3 | ||||
-rw-r--r-- | tests/test_manifest.py | 3 | ||||
-rw-r--r-- | tests/test_openpgp.py | 17 | ||||
-rw-r--r-- | tests/test_profile.py | 16 | ||||
-rw-r--r-- | tests/test_recursiveloader.py | 22 | ||||
-rw-r--r-- | tests/test_util.py | 3 | ||||
-rw-r--r-- | tests/test_verify.py | 1 | ||||
-rw-r--r-- | tests/testutil.py | 9 | ||||
-rwxr-xr-x | utils/benchmark-verify.py | 6 | ||||
-rwxr-xr-x | utils/benchmark.py | 8 | ||||
-rwxr-xr-x | utils/fuzzy-hash-tester.py | 4 | ||||
-rwxr-xr-x | utils/gen-test-manifest.py | 4 | ||||
-rwxr-xr-x | utils/gen_fast_manifest.py | 5 | ||||
-rwxr-xr-x | utils/gen_fast_metamanifest.py | 9 |
28 files changed, 63 insertions, 93 deletions
diff --git a/gemato/cli.py b/gemato/cli.py index 382e961..6ecf017 100644 --- a/gemato/cli.py +++ b/gemato/cli.py @@ -1,9 +1,7 @@ # gemato: CLI routines -# vim:fileencoding=utf-8 # (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license -from __future__ import print_function import argparse import datetime @@ -533,8 +531,7 @@ class HashCommand(GematoCommand): sz = h.pop('__size__') e = ManifestFileEntry( p, sz, - dict((mh, h[hh]) for mh, hh - in zip(self.hashes, hashlib_hashes))) + {mh: h[hh] for mh, hh in zip(self.hashes, hashlib_hashes)}) print(' '.join(e.to_list('DATA' if p != '-' else 'STDIN'))) @@ -565,7 +562,7 @@ class OpenPGPVerifyCommand(VerifyingOpenPGPMixin, GematoCommand): if p == '-': f = sys.stdin else: - f = open(p, 'r') + f = open(p) try: try: diff --git a/gemato/compression.py b/gemato/compression.py index e3d86fe..fbb2da9 100644 --- a/gemato/compression.py +++ b/gemato/compression.py @@ -1,6 +1,5 @@ # gemato: compressed file support -# vim:fileencoding=utf-8 -# (c) 2017-2020 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license import bz2 diff --git a/gemato/exceptions.py b/gemato/exceptions.py index 62c8ac8..51b9763 100644 --- a/gemato/exceptions.py +++ b/gemato/exceptions.py @@ -1,5 +1,4 @@ # gemato: exceptions -# vim:fileencoding=utf-8 # (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license diff --git a/gemato/find_top_level.py b/gemato/find_top_level.py index 5c71ddd..af79982 100644 --- a/gemato/find_top_level.py +++ b/gemato/find_top_level.py @@ -1,6 +1,5 @@ # gemato: Top-level Manifest finding routine -# vim:fileencoding=utf-8 -# (c) 2017-2020 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license import os diff --git a/gemato/hash.py b/gemato/hash.py index e46ea75..184324f 100644 --- a/gemato/hash.py +++ b/gemato/hash.py @@ -1,6 +1,5 @@ # gemato: hash support -# vim:fileencoding=utf-8 -# (c) 2017-2020 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license import hashlib @@ -73,7 +72,7 @@ def hash_file(f, hash_names, _apparent_size=0): for block in iter(lambda: f.read1(HASH_BUFFER_SIZE), b''): for h in hashes.values(): h.update(block) - return dict((k, h.hexdigest()) for k, h in hashes.items()) + return {k: h.hexdigest() for k, h in hashes.items()} def hash_path(path, hash_names): diff --git a/gemato/manifest.py b/gemato/manifest.py index d62fa14..e19c155 100644 --- a/gemato/manifest.py +++ b/gemato/manifest.py @@ -1,5 +1,4 @@ # gemato: Manifest file objects -# vim:fileencoding=utf-8 # (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license diff --git a/gemato/openpgp.py b/gemato/openpgp.py index a6fbfa8..460de11 100644 --- a/gemato/openpgp.py +++ b/gemato/openpgp.py @@ -1,6 +1,5 @@ # gemato: OpenPGP verification support -# vim:fileencoding=utf-8 -# (c) 2017-2020 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license import base64 diff --git a/gemato/profile.py b/gemato/profile.py index e5b063e..a599ee5 100644 --- a/gemato/profile.py +++ b/gemato/profile.py @@ -1,6 +1,5 @@ # gemato: Profile support -# vim:fileencoding=utf-8 -# (c) 2017 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license import os.path @@ -170,12 +169,12 @@ class BackwardsCompatEbuildRepositoryProfile(EbuildRepositoryProfile): compress_watermark)) -PROFILE_MAPPING = dict( - (getattr(profile, 'name'), profile) +PROFILE_MAPPING = { + getattr(profile, 'name'): profile for profile in (DefaultProfile, EbuildRepositoryProfile, BackwardsCompatEbuildRepositoryProfile, - )) + )} def get_profile_by_name(name): diff --git a/gemato/recursiveloader.py b/gemato/recursiveloader.py index 93acb84..5e5878b 100644 --- a/gemato/recursiveloader.py +++ b/gemato/recursiveloader.py @@ -1,5 +1,4 @@ # gemato: Recursive loader for Manifests -# vim:fileencoding=utf-8 # (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license diff --git a/gemato/util.py b/gemato/util.py index fa60e45..ebcc92b 100644 --- a/gemato/util.py +++ b/gemato/util.py @@ -1,6 +1,5 @@ # gemato: Utility functions -# vim:fileencoding=utf-8 -# (c) 2017-2020 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license diff --git a/gemato/verify.py b/gemato/verify.py index 56ffe64..a99d355 100644 --- a/gemato/verify.py +++ b/gemato/verify.py @@ -1,5 +1,4 @@ # gemato: File verification routines -# vim:fileencoding=utf-8 # (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license diff --git a/tests/keydata.py b/tests/keydata.py index 2f51af5..1be5fdb 100644 --- a/tests/keydata.py +++ b/tests/keydata.py @@ -1,6 +1,5 @@ # gemato: OpenPGP key data for tests -# vim:fileencoding=utf-8 -# (c) 2017-2020 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license import base64 diff --git a/tests/test_compression.py b/tests/test_compression.py index d5700e1..43e218e 100644 --- a/tests/test_compression.py +++ b/tests/test_compression.py @@ -1,6 +1,5 @@ # gemato: compressed file tests -# vim:fileencoding=utf-8 -# (c) 2017-2020 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license import base64 diff --git a/tests/test_find_top_level.py b/tests/test_find_top_level.py index 47b3f1e..aefa72d 100644 --- a/tests/test_find_top_level.py +++ b/tests/test_find_top_level.py @@ -1,6 +1,5 @@ # gemato: Top-level Manifest finding tests -# vim:fileencoding=utf-8 -# (c) 2017-2020 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license import gzip diff --git a/tests/test_hash.py b/tests/test_hash.py index e237ca4..1741b20 100644 --- a/tests/test_hash.py +++ b/tests/test_hash.py @@ -1,6 +1,5 @@ # gemato: hash support tests -# vim:fileencoding=utf-8 -# (c) 2017 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license import io diff --git a/tests/test_manifest.py b/tests/test_manifest.py index 7bed4d5..81414d4 100644 --- a/tests/test_manifest.py +++ b/tests/test_manifest.py @@ -1,6 +1,5 @@ # gemato: Manifest file support tests -# vim:fileencoding=utf-8 -# (c) 2017-2020 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license import datetime diff --git a/tests/test_openpgp.py b/tests/test_openpgp.py index 602379e..e4f47e5 100644 --- a/tests/test_openpgp.py +++ b/tests/test_openpgp.py @@ -1,5 +1,4 @@ # gemato: OpenPGP signature support tests -# vim:fileencoding=utf-8 # (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license @@ -79,7 +78,7 @@ jCvJNJ7pU8YnJSRTQDH0PZEupAdzDU/AhGSrBz5+Jr7N0pQIxq4duE/Q -----END PGP PUBLIC KEY BLOCK----- ''' -SIGNED_MANIFEST = u''' +SIGNED_MANIFEST = ''' -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 @@ -106,7 +105,7 @@ mkkhTd2Auao4D2K74BePBuiZ9+eDQA== -----END PGP SIGNATURE----- ''' -DASH_ESCAPED_SIGNED_MANIFEST = u''' +DASH_ESCAPED_SIGNED_MANIFEST = ''' -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 @@ -133,7 +132,7 @@ mkkhTd2Auao4D2K74BePBuiZ9+eDQA== -----END PGP SIGNATURE----- ''' -MODIFIED_SIGNED_MANIFEST = u''' +MODIFIED_SIGNED_MANIFEST = ''' -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 @@ -159,7 +158,7 @@ mkkhTd2Auao4D2K74BePBuiZ9+eDQA== -----END PGP SIGNATURE----- ''' -EXPIRED_SIGNED_MANIFEST = u''' +EXPIRED_SIGNED_MANIFEST = ''' -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 @@ -201,7 +200,7 @@ VALID_KEY_SUBKEY = (PUBLIC_KEY + UID + PUBLIC_KEY_SIG + PUBLIC_SUBKEY + SUBKEY_FINGERPRINT = '7E9DDE3CBE47E437418DF74038B9D2F76CC833CC' SUBKEY_SIG_TIMESTAMP = datetime.datetime(2020, 8, 25, 12, 40, 12) -SUBKEY_SIGNED_MANIFEST = u''' +SUBKEY_SIGNED_MANIFEST = ''' -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 @@ -317,7 +316,7 @@ def test_noverify_recursive_manifest_loader(tmp_path, write_back): if write_back: m.save_manifest('Manifest') - with open(tmp_path / 'Manifest', 'r') as f: + with open(tmp_path / 'Manifest') as f: assert f.read() == strip_openpgp(MODIFIED_SIGNED_MANIFEST) @@ -651,7 +650,7 @@ def privkey_env(request): env.close() -TEST_STRING = u'The quick brown fox jumps over the lazy dog' +TEST_STRING = 'The quick brown fox jumps over the lazy dog' @pytest.mark.parametrize('keyid', [None, PRIVATE_KEY_ID]) @@ -729,7 +728,7 @@ def test_recursive_manifest_loader_save_submanifest(tmp_path, privkey_env): m.save_manifest('eclass/Manifest') m2 = ManifestFile() - with open(tmp_path / 'eclass' / 'Manifest', 'r') as f: + with open(tmp_path / 'eclass' / 'Manifest') as f: m2.load(f, openpgp_env=privkey_env) assert not m2.openpgp_signed assert m2.openpgp_signature is None diff --git a/tests/test_profile.py b/tests/test_profile.py index 1d15561..1d4a7df 100644 --- a/tests/test_profile.py +++ b/tests/test_profile.py @@ -1,6 +1,5 @@ # gemato: Profile behavior tests -# vim:fileencoding=utf-8 -# (c) 2017-2020 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license import itertools @@ -196,8 +195,7 @@ def test_update_entries_for_directory(test_repo, profile): for path in EXPECTED_MANIFESTS + PACKAGE_MANIFESTS] + [(path, make_expect_match(path, 'IGNORE')) for path in EXPECTED_IGNORE]) - found = dict((path, make_entry_match(m, path)) - for path in expected) + found = {path: make_entry_match(m, path) for path in expected} assert found == expected m.save_manifests() @@ -208,8 +206,8 @@ def test_update_entries_for_directory(test_repo, profile): ((path + PKG_MANIFEST_SUFFIX[profile], make_expect_match(path, 'MANIFEST')) for path in PACKAGE_MANIFESTS))) - manifests_found = dict((path, make_entry_match(m, path)) - for path in manifests_expected) + manifests_found = {path: make_entry_match(m, path) + for path in manifests_expected} assert manifests_found == manifests_expected m.assert_directory_verifies('') @@ -232,8 +230,7 @@ def test_cli_update(test_repo, profile): for path in PACKAGE_MANIFESTS] + [(path, make_expect_match(path, 'IGNORE')) for path in EXPECTED_IGNORE]) - found = dict((path, make_entry_match(m, path)) - for path in expected) + found = {path: make_entry_match(m, path) for path in expected} assert found == expected assert gemato.cli.main(['gemato', 'verify', str(test_repo)]) == 0 @@ -266,6 +263,5 @@ def test_regression_top_level_ignore_in_all_manifests(test_repo, profile): 'dev-foo/Manifest': ('MANIFEST', False), 'dev-foo/distfiles': None, } - found = dict((path, make_entry_match(m, path)) - for path in expected) + found = {path: make_entry_match(m, path) for path in expected} assert found == expected diff --git a/tests/test_recursiveloader.py b/tests/test_recursiveloader.py index f0c5673..4a562bd 100644 --- a/tests/test_recursiveloader.py +++ b/tests/test_recursiveloader.py @@ -1,5 +1,4 @@ # gemato: Recursive loader tests -# vim:fileencoding=utf-8 # (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license @@ -633,7 +632,7 @@ MD5 d41d8cd98f00b204e9800998ecf8427e FILENAME: '', } - MANIFESTS_REWRITTEN = dict((k, v.lstrip()) for k, v in MANIFESTS.items()) + MANIFESTS_REWRITTEN = {k: v.lstrip() for k, v in MANIFESTS.items()} class FilenameBackslashLayout(BaseLayout): @@ -647,7 +646,7 @@ DATA foo\\x5Cbar 0 MD5 d41d8cd98f00b204e9800998ecf8427e FILENAME: '', } - MANIFESTS_REWRITTEN = dict((k, v.lstrip()) for k, v in MANIFESTS.items()) + MANIFESTS_REWRITTEN = {k: v.lstrip() for k, v in MANIFESTS.items()} class NewManifestLayout(BaseLayout): @@ -1208,10 +1207,9 @@ def test_get_file_entry_dict(layout_factory, layout, path, only_types, if only_types is not None: only_types = [only_types] entries = m.get_file_entry_dict(path, only_types=only_types) - assert (dict((subdir, dict((k, get_entry(v)) - for k, v in files.items())) - for subdir, files in entries.items()) == - expected) + assert ({subdir: {k: get_entry(v) for k, v in files.items()} + for subdir, files in entries.items() + } == expected) @pytest.mark.parametrize( @@ -1275,8 +1273,8 @@ def test_get_deduplicated_file_entry_dict_for_update(layout_factory, m = ManifestRecursiveLoader(tmp_path / layout.TOP_MANIFEST, allow_xdev=False) entries = m.get_deduplicated_file_entry_dict_for_update(path) - assert dict((k, (v[0],) + get_entry(v[1])) - for k, v in entries.items()) == expected + assert {k: (v[0],) + get_entry(v[1]) + for k, v in entries.items()} == expected @pytest.mark.parametrize( @@ -2056,7 +2054,7 @@ def test_update_entry_new_aux(layout_factory): assert (get_entry(m.find_path_entry('files/test.patch')) == ('AUX', 'files/test.patch', ['MD5'])) m.save_manifests() - with open(tmp_path / layout.TOP_MANIFEST, 'r') as f: + with open(tmp_path / layout.TOP_MANIFEST) as f: contents = f.read() assert (contents == 'AUX test.patch 0 MD5 d41d8cd98f00b204e9800998ecf8427e\n') @@ -2155,7 +2153,7 @@ def test_cli_update(layout_factory, layout, args, update, if replace_timestamp is not None: m = gemato.manifest.ManifestFile() - with open(tmp_path / layout.TOP_MANIFEST, 'r') as f: + with open(tmp_path / layout.TOP_MANIFEST) as f: m.load(f) ts = m.find_timestamp() assert ts is not None @@ -2362,7 +2360,7 @@ def test_new_manifest_cli(layout_factory, args): assert gemato.cli.main(['gemato', 'create', '--hashes=MD5'] + args.split() + [str(tmp_path)]) == 0 - with open(tmp_path / 'Manifest', 'r') as f: + with open(tmp_path / 'Manifest') as f: contents = f.read() expected = ''' DATA test 0 MD5 d41d8cd98f00b204e9800998ecf8427e diff --git a/tests/test_util.py b/tests/test_util.py index e802ea9..7a0974f 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -1,6 +1,5 @@ # gemato: Utility function tests -# vim:fileencoding=utf-8 -# (c) 2017-2020 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license import pytest diff --git a/tests/test_verify.py b/tests/test_verify.py index 0c3fba9..32e30c8 100644 --- a/tests/test_verify.py +++ b/tests/test_verify.py @@ -1,5 +1,4 @@ # gemato: Verification tests -# vim:fileencoding=utf-8 # (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license diff --git a/tests/testutil.py b/tests/testutil.py index bde84f7..2becb23 100644 --- a/tests/testutil.py +++ b/tests/testutil.py @@ -1,6 +1,5 @@ # gemato: Test utility functions -# vim:fileencoding=utf-8 -# (c) 2017-2020 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license import errno @@ -49,17 +48,17 @@ class TempDirTestCase(LoggingTestCase): FILES = {} def setUp(self): - super(TempDirTestCase, self).setUp() + super().setUp() self.dir = tempfile.mkdtemp() for k in self.DIRS: os.mkdir(os.path.join(self.dir, k)) for k, v in self.FILES.items(): - with io.open(os.path.join(self.dir, k), 'w', encoding='utf8') as f: + with open(os.path.join(self.dir, k), 'w', encoding='utf8') as f: f.write(v) def tearDown(self): shutil.rmtree(self.dir) - super(TempDirTestCase, self).tearDown() + super().tearDown() class HKPServerRequestHandler(BaseHTTPRequestHandler): diff --git a/utils/benchmark-verify.py b/utils/benchmark-verify.py index d0b2259..e2fb00f 100755 --- a/utils/benchmark-verify.py +++ b/utils/benchmark-verify.py @@ -11,13 +11,13 @@ import gemato.recursiveloader def benchmark(path): m = gemato.recursiveloader.ManifestRecursiveLoader(path) - print('load-dict: {}'.format(timeit.timeit(m.get_file_entry_dict, number=1))) - print('verify: {}'.format(timeit.timeit(m.assert_directory_verifies, number=1))) + print(f'load-dict: {timeit.timeit(m.get_file_entry_dict, number=1)}') + print(f'verify: {timeit.timeit(m.assert_directory_verifies, number=1)}') if __name__ == '__main__': if len(sys.argv) != 2: - print('Usage: {} <top-level-manifest>'.format(sys.argv[0])) + print(f'Usage: {sys.argv[0]} <top-level-manifest>') sys.exit(1) benchmark(sys.argv[1]) diff --git a/utils/benchmark.py b/utils/benchmark.py index 5eb4d8d..8bca803 100755 --- a/utils/benchmark.py +++ b/utils/benchmark.py @@ -11,12 +11,12 @@ import gemato.hash def benchmark_one(path, hashes): f = lambda: gemato.hash.hash_path(path, hashes) - print("{} -> [ ".format(hashes), end='', flush=True) + print(f"{hashes} -> [ ", end='', flush=True) results = [] for t in (timeit.timeit(f, number=1) for i in range(5)): - print("{:.4}".format(t), end=" ", flush=True) + print(f"{t:.4}", end=" ", flush=True) results.append(t) - print("] -> min: {:.4}".format(min(results))) + print(f"] -> min: {min(results):.4}") def benchmark(path, hash_sets): @@ -35,7 +35,7 @@ def benchmark(path, hash_sets): if __name__ == '__main__': if len(sys.argv) < 2: - print('Usage: {} <test-file> [<hash-set>...]'.format(sys.argv[0])) + print(f'Usage: {sys.argv[0]} <test-file> [<hash-set>...]') sys.exit(1) benchmark(sys.argv[1], sys.argv[2:]) diff --git a/utils/fuzzy-hash-tester.py b/utils/fuzzy-hash-tester.py index 1988852..c96742b 100755 --- a/utils/fuzzy-hash-tester.py +++ b/utils/fuzzy-hash-tester.py @@ -66,14 +66,14 @@ def main(algo_name, min_size, max_size=None): print('Inconsistent hash values found!') print('Hash values:') for a, v in digests.items(): - print(' {}: {}'.format(a, v)) + print(f' {a}: {v}') print('Data block as base64:') print(base64.encodebytes(data).decode()) sys.exit(1) i += 1 if i % 1000 == 0: - print('{} blocks tested.'.format(i)) + print(f'{i} blocks tested.') if __name__ == '__main__': diff --git a/utils/gen-test-manifest.py b/utils/gen-test-manifest.py index b7c4530..33e2635 100755 --- a/utils/gen-test-manifest.py +++ b/utils/gen-test-manifest.py @@ -46,7 +46,7 @@ def write_manifest_entries_for_dir(manifest_file, topdir, hashes): def gen_metamanifests(top_dir, hashes): - with open(os.path.join(top_dir, 'profiles/categories'), 'r') as f: + with open(os.path.join(top_dir, 'profiles/categories')) as f: categories = [x.strip() for x in f] alldirs = [] @@ -73,7 +73,7 @@ def gen_metamanifests(top_dir, hashes): if __name__ == '__main__': if len(sys.argv) != 3: - print('Usage: {} <rsync-path> <hashes>'.format(sys.argv[0])) + print(f'Usage: {sys.argv[0]} <rsync-path> <hashes>') sys.exit(1) gen_metamanifests(sys.argv[1], sys.argv[2].split()) diff --git a/utils/gen_fast_manifest.py b/utils/gen_fast_manifest.py index d7c8c51..002f8c5 100755 --- a/utils/gen_fast_manifest.py +++ b/utils/gen_fast_manifest.py @@ -1,7 +1,6 @@ #!/usr/bin/env python -# vim:fileencoding=utf-8 # Ultra-optimized Manifest writing. -# (c) 2017-2020 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license import errno @@ -110,7 +109,7 @@ def gen_manifest(top_dir): if __name__ == '__main__': if len(sys.argv) < 2: - print('Usage: {} <directory>...'.format(sys.argv[0])) + print(f'Usage: {sys.argv[0]} <directory>...') sys.exit(1) for path in sys.argv[1:]: diff --git a/utils/gen_fast_metamanifest.py b/utils/gen_fast_metamanifest.py index 97368d8..0d6922d 100755 --- a/utils/gen_fast_metamanifest.py +++ b/utils/gen_fast_metamanifest.py @@ -1,7 +1,6 @@ #!/usr/bin/env python -# vim:fileencoding=utf-8 # Ultra-optimized Meta-Manifest writing. -# (c) 2017-2020 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license import datetime @@ -19,7 +18,7 @@ import gen_fast_manifest def manifest_dir_generator(iter_n): - with open('profiles/categories', 'r') as f: + with open('profiles/categories') as f: categories = [x.strip() for x in f] for c in categories: @@ -80,7 +79,7 @@ def make_toplevel(d, ts, pgp_key): stderr=subprocess.PIPE) sout, serr = p.communicate(data) if p.wait() != 0: - raise ValueError('GPG error: {}'.format(serr)) + raise ValueError(f'GPG error: {serr}') data = sout with open(dsttop, 'wb') as f: @@ -139,7 +138,7 @@ IGNORE packages if __name__ == '__main__': if len(sys.argv) not in (2, 3): - print('Usage: {} <top-directory> [<openpgp-key>]'.format(sys.argv[0])) + print(f'Usage: {sys.argv[0]} <top-directory> [<openpgp-key>]') sys.exit(1) gen_metamanifest(sys.argv[1], sys.argv[2] if len(sys.argv) == 3 else None) |