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:
|
else:
|
||||||
type_ = 'string'
|
type_ = 'string'
|
||||||
dtd_key_type = true_key + '_type'
|
dtd_key_type = true_key + '_type'
|
||||||
|
|
||||||
if hasattr(elt, dtd_key_type):
|
if hasattr(elt, dtd_key_type):
|
||||||
type_ = KEY_TYPE[getattr(elt, dtd_key_type)]
|
type_ = KEY_TYPE[getattr(elt, dtd_key_type)]
|
||||||
multi = isinstance(value, list)
|
multi = isinstance(value, list)
|
||||||
|
|
|
@ -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 a new issue