aboutsummaryrefslogtreecommitdiff
path: root/modules/extensions.py
diff options
context:
space:
mode:
authorAarni Koskela <akx@iki.fi>2024-01-04 00:16:58 +0200
committerAarni Koskela <akx@iki.fi>2024-01-04 00:26:30 +0200
commitd9034b48a526f0a0c3e8f0dbf7c171bf4f0597fd (patch)
treeb01be238a08893afe6c5e5ebb58715c3860a2299 /modules/extensions.py
parente4dcdcc9554d7ff56993f5019eb90fe4ddf1e2e7 (diff)
Avoid unnecessary `isfile`/`exists` calls
Diffstat (limited to 'modules/extensions.py')
-rw-r--r--modules/extensions.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/modules/extensions.py b/modules/extensions.py
index 1899cd52..99e7ee60 100644
--- a/modules/extensions.py
+++ b/modules/extensions.py
@@ -32,11 +32,12 @@ class ExtensionMetadata:
self.config = configparser.ConfigParser()
filepath = os.path.join(path, self.filename)
- if os.path.isfile(filepath):
- try:
- self.config.read(filepath)
- except Exception:
- errors.report(f"Error reading {self.filename} for extension {canonical_name}.", exc_info=True)
+ # `self.config.read()` will quietly swallow OSErrors (which FileNotFoundError is),
+ # so no need to check whether the file exists beforehand.
+ try:
+ self.config.read(filepath)
+ except Exception:
+ errors.report(f"Error reading {self.filename} for extension {canonical_name}.", exc_info=True)
self.canonical_name = self.config.get("Extension", "Name", fallback=canonical_name)
self.canonical_name = canonical_name.lower().strip()