add 'restrict-filenames' option (#348)

This commit is contained in:
Mike Fährmann
2019-07-23 17:36:07 +02:00
parent 60cf40380a
commit b1bea8aaeb
5 changed files with 42 additions and 44 deletions

View File

@@ -83,22 +83,6 @@ def nameext_from_url(url, data=None):
return data
def clean_path_windows(path):
"""Remove illegal characters from a path-segment (Windows)"""
try:
return re.sub(r'[<>:"\\/|?*]', "_", path)
except TypeError:
return ""
def clean_path_posix(path):
"""Remove illegal characters from a path-segment (Posix)"""
try:
return path.replace("/", "_")
except AttributeError:
return ""
def extract(txt, begin, end, pos=0):
"""Extract the text between 'begin' and 'end' from 'txt'
@@ -266,12 +250,6 @@ def parse_datetime(date_string, format="%Y-%m-%dT%H:%M:%S%z"):
return date_string
if os.name == "nt":
clean_path = clean_path_windows
else:
clean_path = clean_path_posix
urljoin = urllib.parse.urljoin
quote = urllib.parse.quote