Return original path if not matched

main
Bob Mottram 2020-05-04 19:29:30 +01:00
parent 2625a7083b
commit e8b5a26189
1 changed files with 6 additions and 5 deletions

View File

@ -771,12 +771,13 @@ def searchBoxPosts(baseDir: str, nickname: str, domain: str,
return res
def getFileCaseInsensitive(filename: str) -> str:
def getFileCaseInsensitive(path: str) -> str:
"""Returns a case specific filename given a case insensitive version of it
"""
directory, filename = os.path.split(filename)
directory, filename = os.path.split(path)
directory, filename = (directory or '.'), filename.lower()
for f in os.listdir(directory):
newFilename = os.path.join(directory, f)
if os.path.isfile(newFilename) and f.lower() == filename:
return newFilename
newpath = os.path.join(directory, f)
if os.path.isfile(newpath) and f.lower() == filename:
return newpath
return path