Make default quiet for underscores
This commit is contained in:
parent
81b381e031
commit
e8348dfa75
@ -254,7 +254,7 @@ class Library(Mapping[str, 'Pattern'], metaclass=ABCMeta):
|
|||||||
name: str = '__',
|
name: str = '__',
|
||||||
sanitize: bool = True,
|
sanitize: bool = True,
|
||||||
max_length: int = 32,
|
max_length: int = 32,
|
||||||
quiet: bool = False,
|
quiet: Optional[bool] = None,
|
||||||
) -> str:
|
) -> str:
|
||||||
"""
|
"""
|
||||||
Find a unique name for the pattern.
|
Find a unique name for the pattern.
|
||||||
@ -265,11 +265,15 @@ class Library(Mapping[str, 'Pattern'], metaclass=ABCMeta):
|
|||||||
name: Preferred name for the pattern. Default '__'.
|
name: Preferred name for the pattern. Default '__'.
|
||||||
sanitize: Allows only alphanumeric charaters and _?$. Replaces invalid characters with underscores.
|
sanitize: Allows only alphanumeric charaters and _?$. Replaces invalid characters with underscores.
|
||||||
max_length: Names longer than this will be truncated.
|
max_length: Names longer than this will be truncated.
|
||||||
quiet: If `True`, suppress log messages.
|
quiet: If `True`, suppress log messages. Default `None` suppresses messages only if
|
||||||
|
the name starts with an underscore.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Name, unique within this library.
|
Name, unique within this library.
|
||||||
"""
|
"""
|
||||||
|
if quiet is None:
|
||||||
|
quiet = name.startswith('_')
|
||||||
|
|
||||||
if sanitize:
|
if sanitize:
|
||||||
# Remove invalid characters
|
# Remove invalid characters
|
||||||
sanitized_name = re.compile(r'[^A-Za-z0-9_\?\$]').sub('_', name)
|
sanitized_name = re.compile(r'[^A-Za-z0-9_\?\$]').sub('_', name)
|
||||||
|
Loading…
Reference in New Issue
Block a user