family name could containe an integer
This commit is contained in:
parent
d139862568
commit
5c3ab2ae17
3 changed files with 12 additions and 11 deletions
|
@ -168,7 +168,7 @@ class ServiceAnnotator:
|
|||
else:
|
||||
type_ = 'string'
|
||||
dtd_key_type = true_key + '_type'
|
||||
|
||||
|
||||
if hasattr(elt, dtd_key_type):
|
||||
type_ = KEY_TYPE[getattr(elt, dtd_key_type)]
|
||||
multi = isinstance(value, list)
|
||||
|
|
|
@ -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 a new issue