Skip to content
Snippets Groups Projects
Commit b3bf080e authored by nkour's avatar nkour
Browse files

intro helpers.sanitize_filename() to make sure we do not run, use it where it is appropriate

parent 7418be23
No related branches found
No related tags found
No related merge requests found
......@@ -695,3 +695,16 @@ def get_os_info():
if uname_output is not None:
return uname_output[0] # only first line
return 'N/A'
def sanitize_filename(filename):
'''makes sure the filename we try to write does not contain
unacceptable characters'''
filename = filename.replace('/', '_')
if os.name == 'nt':
filename = filename.replace('?', '').replace(':', '').replace('!', '')\
.replace('"', "'")
# 48 is the limit; 44 is used to account for the extenstion.
if len(filename) > 44:
filename = filename[0:44]
return filename
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment