Skip to content

Commit

Permalink
Use f-string instead of format function
Browse files Browse the repository at this point in the history
  • Loading branch information
wkentaro committed Feb 1, 2024
1 parent ae122f4 commit 9582215
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions gdown/cached_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def md5sum(filename, blocksize=None):

def assert_md5sum(filename, md5, quiet=False, blocksize=None):
if not (isinstance(md5, str) and len(md5) == 32):
raise ValueError("MD5 must be 32 chars: {}".format(md5))
raise ValueError(f"MD5 must be 32 chars: {md5}")

md5_actual = md5sum(filename)

Expand All @@ -40,7 +40,7 @@ def assert_md5sum(filename, md5, quiet=False, blocksize=None):
return True

raise AssertionError(
"MD5 doesn't match:\nactual: {}\nexpected: {}".format(md5_actual, md5)
f"MD5 doesn't match:\nactual: {md5_actual}\nexpected: {md5}"
)


Expand Down Expand Up @@ -81,7 +81,7 @@ def cached_download(
# check existence
if osp.exists(path) and not md5:
if not quiet:
print("File exists: {}".format(path), file=sys.stderr)
print(f"File exists: {path}", file=sys.stderr)
return path
elif osp.exists(path) and md5:
try:
Expand All @@ -104,9 +104,9 @@ def cached_download(
if not quiet:
msg = "Cached Downloading"
if path:
msg = "{}: {}".format(msg, path)
msg = f"{msg}: {path}"
else:
msg = "{}...".format(msg)
msg = f"{msg}..."
print(msg, file=sys.stderr)

download(url, temp_path, quiet=quiet, **kwargs)
Expand Down

0 comments on commit 9582215

Please sign in to comment.