Pulled glob_quote from another branch

This commit is contained in:
tcely 2024-12-25 00:43:44 -05:00 committed by GitHub
parent 22a46315a1
commit 3ac661cd1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -93,6 +93,20 @@ def resize_image_to_height(image, width, height):
return image
def glob_quote(filestr):
_glob_specials = {
'?': '[?]',
'*': '[*]',
'[': '[[]',
']': '[]]', # probably not needed, but it won't hurt
}
if not isinstance(filestr, str):
raise TypeError(f'filestr must be a str, got "{type(filestr)}"')
return filestr.translate(str.maketrans(_glob_specials))
def file_is_editable(filepath):
'''
Checks that a file exists and the file is in an allowed predefined tuple of