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):
|
class ConvertDynOptionDescription(DynOptionDescription):
|
||||||
def convert_suffix_to_path(self, suffix):
|
def convert_suffix_to_path(self, suffix):
|
||||||
|
if not isinstance(suffix, str):
|
||||||
|
suffix = str(suffix)
|
||||||
return normalize_family(suffix,
|
return normalize_family(suffix,
|
||||||
check_name=False)
|
check_name=False)
|
||||||
|
|
||||||
|
|
|
@ -10,15 +10,14 @@ def normalize_family(family_name: str,
|
||||||
allow_dot: bool=False) -> str:
|
allow_dot: bool=False) -> str:
|
||||||
"""replace space, accent, uppercase, ... by valid character
|
"""replace space, accent, uppercase, ... by valid character
|
||||||
"""
|
"""
|
||||||
f = family_name
|
family_name = family_name.replace('-', '_')
|
||||||
f = f.replace('-', '_')
|
|
||||||
if not allow_dot:
|
if not allow_dot:
|
||||||
f = f.replace('.', '_')
|
family_name = family_name.replace('.', '_')
|
||||||
f = f.replace(' ', '_')
|
family_name = family_name.replace(' ', '_')
|
||||||
nfkd_form = unicodedata.normalize('NFKD', f)
|
nfkd_form = unicodedata.normalize('NFKD', family_name)
|
||||||
f = ''.join([c for c in nfkd_form if not unicodedata.combining(c)])
|
family_name = ''.join([c for c in nfkd_form if not unicodedata.combining(c)])
|
||||||
f = f.lower()
|
family_name = family_name.lower()
|
||||||
if check_name and f == 'containers':
|
if check_name and family_name == 'containers':
|
||||||
raise ValueError(_('"{0}" is a forbidden family name'.format(f)))
|
raise ValueError(_(f'"{family_name}" is a forbidden family name'))
|
||||||
return f
|
return family_name
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue