5. Reference¶
-
pathvalidate.
sanitize_filename
(filename, replacement_text='')[source]¶ Replace invalid characters for a file path within the
filename
with thereplacement_text
. Invalid characters are as follows:\
,:
,*
,?
,"
,<
,>
,|
.Parameters: - filename (str) – Filename to validate.
- replacement_text (str) – Replacement text.
Returns: A replacement string.
Return type: str
-
pathvalidate.
sanitize_python_var_name
(var_name, replacement_text='')[source]¶ Replace invalid characters for a python variable name within the
var_name
with thereplacement_text
. Invalid characters are as follows:\
,:
,*
,?
,"
,<
,>
,|
."
,!
,#
,$
,&
,'
,=
,~
,^
,@
,`
,[
,]
,+
,-
,;
,{
,}
,,
,.
,(
,)
,%
.Parameters: - filename (str) – Filename to validate.
- replacement_text (str) – Replacement text.
Returns: A replacement string.
Return type: str