Skip to content
Snippets Groups Projects
Commit 5f41afe4 authored by Chris Lamb's avatar Chris Lamb 👀
Browse files

Replace some simple usages of str.format with f-strings.

parent 065a7e4e
No related branches found
No related tags found
No related merge requests found
......@@ -130,7 +130,7 @@ class ComparatorManager:
try:
mod = importlib.import_module(
"diffoscope.comparators.{}".format(package)
f"diffoscope.comparators.{package}",
)
except ModuleNotFoundError as e:
python_module_missing(e.name)
......
......@@ -86,7 +86,7 @@ class ApkContainer(Archive):
"-d",
self._unpacked,
self.source.path,
"classes{}.dex".format(x),
f"classes{x}.dex",
),
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
......
......@@ -156,7 +156,7 @@ class ReadelfDebugDump(Readelf):
READELF_DEBUG_DUMP_COMMANDS = [
type(
"ReadelfDebugDump_{}".format(x),
f"ReadelfDebugDump_{x}",
(ReadelfDebugDump,),
{"_debug_section_group": x},
)
......
......@@ -92,7 +92,7 @@ class JSONFile(File):
similarity = jsondiff.similarity(a, b)
if similarity:
difference.add_comment("Similarity: {}%".format(similarity))
difference.add_comment(f"Similarity: {similarity}%")
difference.add_comment(
"Differences: {}".format(
......
......@@ -43,7 +43,7 @@ class Otool(Command):
def filter(self, line):
# Strip filename
prefix = "{}:".format(self._path)
prefix = f"{self._path}:"
if line.decode("utf-8", "ignore").startswith(prefix):
return line[len(prefix) :].strip()
return line
......
......@@ -82,7 +82,7 @@ class PdfFile(File):
pdf = PyPDF2.PdfFileReader(file.path)
document_info = pdf.getDocumentInfo()
except PyPDF2.utils.PdfReadError as e:
return "(Could not extract metadata: {})".format(e)
return f"(Could not extract metadata: {e})"
if document_info is None:
return ""
......
......@@ -111,8 +111,8 @@ def get_module_path_for_rdb(rdb):
prefix = os.path.join(temp_dir, "temp")
logger.debug("Copying %s and %s to %s", rdx.path, rdb.path, temp_dir)
shutil.copy(rdb.path, "{}.rdb".format(prefix))
shutil.copy(rdx.path, "{}.rdx".format(prefix))
shutil.copy(rdb.path, f"{prefix}.rdb")
shutil.copy(rdx.path, f"{prefix}.rdx")
# Return the "module" path, ie. without an extension
return os.path.join(temp_dir, "temp")
......
......@@ -107,7 +107,7 @@ class Zipnote(Command):
if line.startswith(b"@ "):
filename = line[2:-1].decode()
self.flag = True
return "Filename: {}\nComment: ".format(filename).encode()
return f"Filename: {filename}\nComment: ".encode()
return line[:-1] if self.flag else b""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment