!19013 fix check file name log format
Merge pull request !19013 from changzherui/fix_file_name_check
This commit is contained in:
commit
f9c7d743a0
|
@ -441,12 +441,12 @@ class Validator:
|
|||
reg = r"^\w+[0-9a-zA-Z\_\.]*$"
|
||||
if re.match(reg, target, flag) is None:
|
||||
prim_name = f'in `{prim_name}`' if prim_name else ""
|
||||
raise ValueError("'{}' {} is illegal, it should be match regular'{}' by flags'{}'".format(
|
||||
raise ValueError("'{}' {} is illegal, it should be match regular'{}' by flags'{}.'".format(
|
||||
target, prim_name, reg, flag))
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def check_file_name_by_regular(target, reg=None, flag=re.ASCII, prim_name=None):
|
||||
def check_file_name_by_regular(target, reg=None, prim_name=None):
|
||||
"""Check whether file name is legitimate."""
|
||||
if not isinstance(target, str):
|
||||
raise ValueError("Args file_name {} must be string, please check it".format(target))
|
||||
|
@ -454,10 +454,10 @@ class Validator:
|
|||
raise ValueError("File name cannot be a directory path.")
|
||||
if reg is None:
|
||||
reg = r"^[0-9a-zA-Z\_\-\.\:\/\\]+$"
|
||||
if re.match(reg, target, flag) is None:
|
||||
if re.match(reg, target) is None:
|
||||
prim_name = f'in `{prim_name}`' if prim_name else ""
|
||||
raise ValueError("'{}' {} is illegal, it should be match regular'{}' by flags'{}'".format(
|
||||
target, prim_name, reg, flag))
|
||||
raise ValueError("'{}' {} is illegal, it should be match regular'{}'.".format(
|
||||
target, prim_name, reg))
|
||||
|
||||
return True
|
||||
|
||||
|
|
Loading…
Reference in New Issue