diff options
author | Aarni Koskela <akx@iki.fi> | 2024-01-04 00:16:58 +0200 |
---|---|---|
committer | Aarni Koskela <akx@iki.fi> | 2024-01-04 00:26:30 +0200 |
commit | d9034b48a526f0a0c3e8f0dbf7c171bf4f0597fd (patch) | |
tree | b01be238a08893afe6c5e5ebb58715c3860a2299 /modules/util.py | |
parent | e4dcdcc9554d7ff56993f5019eb90fe4ddf1e2e7 (diff) |
Avoid unnecessary `isfile`/`exists` calls
Diffstat (limited to 'modules/util.py')
-rw-r--r-- | modules/util.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/modules/util.py b/modules/util.py index 4861bcb0..d503f267 100644 --- a/modules/util.py +++ b/modules/util.py @@ -21,11 +21,11 @@ def html_path(filename): def html(filename):
path = html_path(filename)
- if os.path.exists(path):
+ try:
with open(path, encoding="utf8") as file:
return file.read()
-
- return ""
+ except OSError:
+ return ""
def walk_files(path, allowed_extensions=None):
|