mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2024-12-26 10:24:14 +08:00
23 lines
467 B
Python
23 lines
467 B
Python
|
|
||
|
import re
|
||
|
|
||
|
|
||
|
ALLOWED_CHARS = set([
|
||
|
'`', '~', '!', '@',
|
||
|
'#', '$', '%', '&',
|
||
|
'(', ')', '-', '_',
|
||
|
'=', '+', '[', '{',
|
||
|
']', '}', ';', '\'',
|
||
|
',', '.', ' ', '\t',
|
||
|
'®', '™',
|
||
|
])
|
||
|
|
||
|
def create_safe_name(app_name : str):
|
||
|
safe_name = ''.join(c for c in f'{app_name}' if c.isalnum() or c in ALLOWED_CHARS)\
|
||
|
.rstrip()\
|
||
|
.rstrip('.')\
|
||
|
.replace('\t', ' ')
|
||
|
safe_name = re.sub('\s\s+', ' ', safe_name)
|
||
|
return safe_name
|
||
|
|