normalize_family can allow dot
This commit is contained in:
parent
2f8fc054d0
commit
81028d1539
|
@ -28,7 +28,7 @@ import imp
|
||||||
class ConvertDynOptionDescription(DynOptionDescription):
|
class ConvertDynOptionDescription(DynOptionDescription):
|
||||||
def convert_suffix_to_path(self, suffix):
|
def convert_suffix_to_path(self, suffix):
|
||||||
return normalize_family(suffix,
|
return normalize_family(suffix,
|
||||||
check=False)
|
check_name=False)
|
||||||
|
|
||||||
|
|
||||||
class CreoleLoaderError(Exception):
|
class CreoleLoaderError(Exception):
|
||||||
|
|
|
@ -601,7 +601,9 @@ class Path(object):
|
||||||
def get_family_path(self, name, current_namespace): # pylint: disable=C0111
|
def get_family_path(self, name, current_namespace): # pylint: disable=C0111
|
||||||
if current_namespace is None: # pragma: no cover
|
if current_namespace is None: # pragma: no cover
|
||||||
raise CreoleOperationError('current_namespace must not be None')
|
raise CreoleOperationError('current_namespace must not be None')
|
||||||
dico = self.families[normalize_family(name, check_name=False)]
|
dico = self.families[normalize_family(name,
|
||||||
|
check_name=False,
|
||||||
|
allow_dot=True)]
|
||||||
if dico['namespace'] != 'creole' and current_namespace != dico['namespace']:
|
if dico['namespace'] != 'creole' and current_namespace != dico['namespace']:
|
||||||
raise CreoleDictConsistencyError(_('A family located in the {} namespace '
|
raise CreoleDictConsistencyError(_('A family located in the {} namespace '
|
||||||
'shall not be used in the {} namespace').format(
|
'shall not be used in the {} namespace').format(
|
||||||
|
|
|
@ -6,11 +6,13 @@ from .i18n import _
|
||||||
|
|
||||||
|
|
||||||
def normalize_family(family_name: str,
|
def normalize_family(family_name: str,
|
||||||
check_name=True) -> str:
|
check_name: bool=True,
|
||||||
|
allow_dot: bool=False) -> str:
|
||||||
"""replace space, accent, uppercase, ... by valid character
|
"""replace space, accent, uppercase, ... by valid character
|
||||||
"""
|
"""
|
||||||
f = family_name
|
f = family_name
|
||||||
f = f.replace('-', '_')
|
f = f.replace('-', '_')
|
||||||
|
if not allow_dot:
|
||||||
f = f.replace('.', '_')
|
f = f.replace('.', '_')
|
||||||
f = f.replace(' ', '_')
|
f = f.replace(' ', '_')
|
||||||
nfkd_form = unicodedata.normalize('NFKD', f)
|
nfkd_form = unicodedata.normalize('NFKD', f)
|
||||||
|
|
Loading…
Reference in New Issue