Avoid unnecessary isfile/exists calls

This commit is contained in:
Aarni Koskela
2024-01-04 00:16:58 +02:00
parent e4dcdcc955
commit d9034b48a5
10 changed files with 41 additions and 35 deletions

View File

@@ -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):