handle non string-like arguemnts for clean_path

This commit is contained in:
Mike Fährmann
2015-10-11 16:21:55 +02:00
parent 4cb419b5d9
commit 89f938ee55

View File

@@ -28,11 +28,17 @@ def filename_from_url(url):
def clean_path_windows(path):
"""Remove illegal characters from a path-segment (Windows)"""
return re.sub(r'[<>:"\\/|?*]', "_", path)
try:
return re.sub(r'[<>:"\\/|?*]', "_", path)
except TypeError:
return path
def clean_path_posix(path):
"""Remove illegal characters from a path-segment (Posix)"""
return path.replace("/", "_")
try:
return path.replace("/", "_")
except AttributeError:
return path
def extract(txt, begin, end, pos=0):
try: