Skip to content

Commit

Permalink
cater for a non existent directory in the new case insensitive file f…
Browse files Browse the repository at this point in the history
…inder
  • Loading branch information
AnEnglishmanInNorway committed Aug 14, 2024
1 parent 8ce389c commit 0568609
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cewe2pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ def findFileByExtInDirs(filebase, extList, paths):
# locate files in a directory with a pattern, with optional case sensitivity
# eg: findFilesInDir(fontdir, '*.ttf')
def findFilesInDir(dirpath: str, glob_pat: str, ignore_case: bool = True):
if not os.path.exists(dirpath):
return []
rule = re.compile(fnmatch.translate(glob_pat), re.IGNORECASE) if ignore_case \
else re.compile(fnmatch.translate(glob_pat))
return [os.path.join(dirpath, n) for n in os.listdir(dirpath) if rule.match(n)]
Expand Down

0 comments on commit 0568609

Please sign in to comment.