diff options
author | Aarni Koskela <akx@iki.fi> | 2022-07-13 14:30:45 +0300 |
---|---|---|
committer | Aarni Koskela <akx@iki.fi> | 2022-07-13 14:30:45 +0300 |
commit | 3dbbeecc18730aca17b2fb183f62724027f44dd8 (patch) | |
tree | 3105b48c570b77e7fb10f46522335dfebd0198c2 /scripts | |
parent | 681550eb2c2fe790b17d2c79590f8f5097eb8557 (diff) | |
download | babel-3dbbeecc18730aca17b2fb183f62724027f44dd8.tar.gz |
Downloader: use f-strings
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/download_import_cldr.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/scripts/download_import_cldr.py b/scripts/download_import_cldr.py index 3ddd9b4..57995b5 100755 --- a/scripts/download_import_cldr.py +++ b/scripts/download_import_cldr.py @@ -28,15 +28,13 @@ def reporthook(block_count, block_size, total_size): sys.stdout.flush() -def log(message, *args): - if args: - message = message % args - sys.stderr.write(message + '\n') +def log(message): + sys.stderr.write(f'{message}\n') def is_good_file(filename): if not os.path.isfile(filename): - log('Local copy \'%s\' not found', filename) + log(f"Local copy '{filename}' not found") return False h = hashlib.sha512() with open(filename, 'rb') as f: @@ -47,8 +45,7 @@ def is_good_file(filename): h.update(blk) digest = h.hexdigest() if digest != FILESUM: - raise RuntimeError('Checksum mismatch: %r != %r' - % (digest, FILESUM)) + raise RuntimeError(f'Checksum mismatch: {digest!r} != {FILESUM!r}') else: return True @@ -63,7 +60,7 @@ def main(): show_progress = (False if os.environ.get("BABEL_CLDR_NO_DOWNLOAD_PROGRESS") else sys.stdout.isatty()) while not is_good_file(zip_path): - log("Downloading '%s' from %s", FILENAME, URL) + log(f"Downloading '{FILENAME}' from {URL}") tmp_path = f"{zip_path}.tmp" urlretrieve(URL, tmp_path, (reporthook if show_progress else None)) os.replace(tmp_path, zip_path) @@ -73,10 +70,10 @@ def main(): if changed or not os.path.isdir(common_path): if os.path.isdir(common_path): - log('Deleting old CLDR checkout in \'%s\'', cldr_path) + log(f"Deleting old CLDR checkout in '{cldr_path}'") shutil.rmtree(common_path) - log('Extracting CLDR to \'%s\'', cldr_path) + log(f"Extracting CLDR to '{cldr_path}'") with contextlib.closing(zipfile.ZipFile(zip_path)) as z: z.extractall(cldr_path) |