family name could containe an integer
This commit is contained in:
parent
d139862568
commit
5c3ab2ae17
|
@ -30,6 +30,8 @@ FUNC_TO_DICT = ['valid_not_equal']
|
|||
|
||||
class ConvertDynOptionDescription(DynOptionDescription):
|
||||
def convert_suffix_to_path(self, suffix):
|
||||
if not isinstance(suffix, str):
|
||||
suffix = str(suffix)
|
||||
return normalize_family(suffix,
|
||||
check_name=False)
|
||||
|
||||
|
|
|
@ -10,15 +10,14 @@ def normalize_family(family_name: str,
|
|||
allow_dot: bool=False) -> str:
|
||||
"""replace space, accent, uppercase, ... by valid character
|
||||
"""
|
||||
f = family_name
|
||||
f = f.replace('-', '_')
|
||||
family_name = family_name.replace('-', '_')
|
||||
if not allow_dot:
|
||||
f = f.replace('.', '_')
|
||||
f = f.replace(' ', '_')
|
||||
nfkd_form = unicodedata.normalize('NFKD', f)
|
||||
f = ''.join([c for c in nfkd_form if not unicodedata.combining(c)])
|
||||
f = f.lower()
|
||||
if check_name and f == 'containers':
|
||||
raise ValueError(_('"{0}" is a forbidden family name'.format(f)))
|
||||
return f
|
||||
family_name = family_name.replace('.', '_')
|
||||
family_name = family_name.replace(' ', '_')
|
||||
nfkd_form = unicodedata.normalize('NFKD', family_name)
|
||||
family_name = ''.join([c for c in nfkd_form if not unicodedata.combining(c)])
|
||||
family_name = family_name.lower()
|
||||
if check_name and family_name == 'containers':
|
||||
raise ValueError(_(f'"{family_name}" is a forbidden family name'))
|
||||
return family_name
|
||||
|
||||
|
|
Loading…
Reference in New Issue