Browse Source
Update sharedfunctions.py
added get_valid_filename
master
Gerry Nelson
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
12 additions and
1 deletions
-
sharedfunctions.py
|
|
|
@ -670,12 +670,23 @@ def simplejsonresults(resultdata): |
|
|
|
print(json.dumps(resultdata,indent=2)) |
|
|
|
|
|
|
|
|
|
|
|
#The get_valid_filename function is taken from https://github.com/django/django/blob/master/django/utils/text.py. |
|
|
|
#The function replaces the characters that are not valid for Linux filsystem in the input string. |
|
|
|
#The comment in the source says: |
|
|
|
# |
|
|
|
# Return the given string converted to a string that can be used for a clean |
|
|
|
# filename. Remove leading and trailing spaces; convert other spaces to |
|
|
|
# underscores; and remove anything that is not an alphanumeric, dash, |
|
|
|
# underscore, or dot. |
|
|
|
|
|
|
|
|
|
|
|
def get_valid_filename(s): |
|
|
|
s = str(s).strip().replace(' ', '_') |
|
|
|
return re.sub(r'(?u)[^-\w.]', '', s) |
|
|
|
|
|
|
|
# getapplicationproperties |
|
|
|
# 20nov2020 initial development |
|
|
|
|
|
|
|
|
|
|
|
def getapplicationproperties(): |
|
|
|
|
|
|
|
# get the path for the script file this is where the properties file will bbe |
|
|
|
|