From 81028d1539af27473e972e3c351b4c8ed61bc325 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Sun, 22 Dec 2019 08:45:03 +0100 Subject: [PATCH] normalize_family can allow dot --- src/rougail/loader.py | 2 +- src/rougail/objspace.py | 4 +++- src/rougail/utils.py | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/rougail/loader.py b/src/rougail/loader.py index 46d5e1f2..39541fc7 100644 --- a/src/rougail/loader.py +++ b/src/rougail/loader.py @@ -28,7 +28,7 @@ import imp class ConvertDynOptionDescription(DynOptionDescription): def convert_suffix_to_path(self, suffix): return normalize_family(suffix, - check=False) + check_name=False) class CreoleLoaderError(Exception): diff --git a/src/rougail/objspace.py b/src/rougail/objspace.py index 5969ac99..49f2a424 100644 --- a/src/rougail/objspace.py +++ b/src/rougail/objspace.py @@ -601,7 +601,9 @@ class Path(object): def get_family_path(self, name, current_namespace): # pylint: disable=C0111 if current_namespace is None: # pragma: no cover 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']: raise CreoleDictConsistencyError(_('A family located in the {} namespace ' 'shall not be used in the {} namespace').format( diff --git a/src/rougail/utils.py b/src/rougail/utils.py index 8445528d..6d68fee1 100644 --- a/src/rougail/utils.py +++ b/src/rougail/utils.py @@ -6,12 +6,14 @@ from .i18n import _ 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 """ f = family_name f = f.replace('-', '_') - f = f.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)])