extend 'path-restrict' option
Allow its value to be a JSON object / Python dict that specifies
a mapping from invalid/unwanted input characters to specific
output characters.
For example {"/": "-", "*": "+"} will transform
"foo / ***bar***" into "foo - +++bar+++"
(closes #662, #755)
This commit is contained in:
@@ -690,6 +690,9 @@ class PathFormat():
|
||||
def _build_cleanfunc(chars, repl):
|
||||
if not chars:
|
||||
return lambda x: x
|
||||
elif isinstance(chars, dict):
|
||||
def func(x, table=str.maketrans(chars)):
|
||||
return x.translate(table)
|
||||
elif len(chars) == 1:
|
||||
def func(x, c=chars, r=repl):
|
||||
return x.replace(c, r)
|
||||
|
||||
Reference in New Issue
Block a user