Compare commits

..

No commits in common. "81028d1539af27473e972e3c351b4c8ed61bc325" and "881b551f477b475fc76c01d3f1d701e8d1d49a84" have entirely different histories.

5 changed files with 37 additions and 45 deletions

View File

@ -58,10 +58,10 @@
<!ATTLIST action actionlist CDATA #IMPLIED> <!ATTLIST action actionlist CDATA #IMPLIED>
<!-- for apache action --> <!-- for apache action -->
<!ATTLIST action apache_path CDATA #IMPLIED> <!ATTLIST action apache_path CDATA #IMPLIED>
<!ATTLIST action apache_path_type (FilenameOption|SymLinkOption|variable) "FilenameOption"> <!ATTLIST action apache_path_type (FilenameOption|SymLinkOption) "FilenameOption">
<!-- for external action --> <!-- for external action -->
<!ATTLIST action url CDATA #IMPLIED> <!ATTLIST action url CDATA #IMPLIED>
<!ATTLIST action url_type (URLOption|SymLinkOption|variable) "URLOption"> <!ATTLIST action url_type (URLOption|SymLinkOption) "URLOption">
<!-- for form action --> <!-- for form action -->
<!ATTLIST action save (True|False) "False"> <!ATTLIST action save (True|False) "False">
@ -89,12 +89,12 @@
<!ATTLIST service_access service CDATA #REQUIRED > <!ATTLIST service_access service CDATA #REQUIRED >
<!ELEMENT port (#PCDATA)> <!--port_type--> <!ELEMENT port (#PCDATA)> <!--port_type-->
<!ATTLIST port port_type (PortOption|SymLinkOption|variable) "PortOption"> <!ATTLIST port port_type (PortOption|SymLinkOption) "PortOption">
<!ATTLIST port service_accesslist CDATA #IMPLIED > <!ATTLIST port service_accesslist CDATA #IMPLIED >
<!ATTLIST port protocol (tcp|udp) "tcp"> <!ATTLIST port protocol (tcp|udp) "tcp">
<!ELEMENT tcpwrapper (#PCDATA)> <!--tcpwrapper_type--> <!ELEMENT tcpwrapper (#PCDATA)> <!--tcpwrapper_type-->
<!ATTLIST tcpwrapper tcpwrapper_type (UnicodeOption|SymLinkOption|variable) "UnicodeOption"> <!ATTLIST tcpwrapper tcpwrapper_type (UnicodeOption|SymLinkOption) "UnicodeOption">
<!ATTLIST tcpwrapper service_accesslist CDATA #IMPLIED > <!ATTLIST tcpwrapper service_accesslist CDATA #IMPLIED >
<!ELEMENT service_restriction (ip*)> <!ELEMENT service_restriction (ip*)>
@ -102,42 +102,42 @@
<!ELEMENT ip (#PCDATA)> <!--ip_type--> <!ELEMENT ip (#PCDATA)> <!--ip_type-->
<!ATTLIST ip service_restrictionlist CDATA #IMPLIED > <!ATTLIST ip service_restrictionlist CDATA #IMPLIED >
<!ATTLIST ip ip_type (NetworkOption|SymLinkOption|variable) "NetworkOption"> <!ATTLIST ip ip_type (NetworkOption|SymLinkOption) "NetworkOption">
<!ATTLIST ip interface_type (UnicodeOption|SymLinkOption|variable) "UnicodeOption"> <!ATTLIST ip interface_type (UnicodeOption|SymLinkOption) "UnicodeOption">
<!ATTLIST ip interface CDATA #REQUIRED> <!--interface_type--> <!ATTLIST ip interface CDATA #REQUIRED> <!--interface_type-->
<!ATTLIST ip netmask_type (NetmaskOption|SymLinkOption|variable) "NetmaskOption"> <!ATTLIST ip netmask_type (NetmaskOption|SymLinkOption) "NetmaskOption">
<!ATTLIST ip netmask CDATA "255.255.255.255"> <!--netmask_type--> <!ATTLIST ip netmask CDATA "255.255.255.255"> <!--netmask_type-->
<!ELEMENT interface (#PCDATA)> <!ELEMENT interface (#PCDATA)>
<!ATTLIST interface interfacelist CDATA #IMPLIED > <!ATTLIST interface interfacelist CDATA #IMPLIED >
<!ATTLIST interface linkto CDATA #REQUIRED > <!ATTLIST interface linkto CDATA #REQUIRED >
<!ATTLIST interface ip CDATA #REQUIRED> <!--variable--> <!ATTLIST interface ip CDATA #REQUIRED> <!--SymLinkOption-->
<!ATTLIST interface ip_type (SymLinkOption|variable) "variable"> <!ATTLIST interface ip_type (SymLinkOption) "SymLinkOption">
<!ATTLIST interface mask CDATA #REQUIRED> <!--variable--> <!ATTLIST interface mask CDATA #REQUIRED> <!--SymLinkOption-->
<!ATTLIST interface mask_type (SymLinkOption|variable) "variable"> <!ATTLIST interface mask_type (SymLinkOption) "SymLinkOption">
<!ATTLIST interface bcast CDATA #IMPLIED> <!--variable--> <!ATTLIST interface bcast CDATA #IMPLIED> <!--SymLinkOption-->
<!ATTLIST interface bcast_type (SymLinkOption|variable) "variable"> <!ATTLIST interface bcast_type (SymLinkOption) "SymLinkOption">
<!ATTLIST interface gateway CDATA #IMPLIED> <!--variable--> <!ATTLIST interface gateway CDATA #IMPLIED> <!--SymLinkOption-->
<!ATTLIST interface gateway_type (variable) "variable"> <!ATTLIST interface gateway_type (SymLinkOption) "SymLinkOption">
<!ATTLIST interface method (bridge|macvlan) "macvlan" > <!ATTLIST interface method (bridge|macvlan) "macvlan" >
<!ATTLIST interface redefine (True|False) "False"> <!ATTLIST interface redefine (True|False) "False">
<!ELEMENT host EMPTY > <!ELEMENT host EMPTY >
<!ATTLIST host hostlist CDATA #IMPLIED > <!ATTLIST host hostlist CDATA #IMPLIED >
<!ATTLIST host name CDATA #REQUIRED > <!--variable--> <!ATTLIST host name CDATA #REQUIRED > <!--SymLinkOption-->
<!ATTLIST host name_type (SymLinkOption|variable) "variable"> <!ATTLIST host name_type (SymLinkOption) "SymLinkOption">
<!ATTLIST host ip CDATA #REQUIRED > <!--variable--> <!ATTLIST host ip CDATA #REQUIRED > <!--SymLinkOption-->
<!ATTLIST host ip_type (SymLinkOption|variable) "variable"> <!ATTLIST host ip_type (SymLinkOption) "SymLinkOption">
<!ATTLIST host crossed (True|False) "True" > <!ATTLIST host crossed (True|False) "True" >
<!ATTLIST host comment CDATA #IMPLIED > <!ATTLIST host comment CDATA #IMPLIED >
<!ELEMENT fstab EMPTY > <!ELEMENT fstab EMPTY >
<!ATTLIST fstab name CDATA #REQUIRED> <!--name_type--> <!ATTLIST fstab name CDATA #REQUIRED> <!--name_type-->
<!ATTLIST fstab name_type (FilenameOption|SymLinkOption|variable) "FilenameOption"> <!ATTLIST fstab name_type (FilenameOption|SymLinkOption) "FilenameOption">
<!ATTLIST fstab type (bind|normal) "bind"> <!ATTLIST fstab type (bind|normal) "bind">
<!ATTLIST fstab fstype (auto|ext3|ext4|nfs|smb) "auto"> <!ATTLIST fstab fstype (auto|ext3|ext4|nfs|smb) "auto">
<!ATTLIST fstab mount_point CDATA #IMPLIED> <!--mount_point_type--> <!ATTLIST fstab mount_point CDATA #IMPLIED> <!--mount_point_type-->
<!ATTLIST fstab mount_point_type (FilenameOption|SymLinkOption|variable) "FilenameOption"> <!ATTLIST fstab mount_point_type (FilenameOption|SymLinkOption) "FilenameOption">
<!ATTLIST fstab options CDATA #IMPLIED> <!ATTLIST fstab options CDATA #IMPLIED>
<!ATTLIST fstab checks CDATA #IMPLIED> <!ATTLIST fstab checks CDATA #IMPLIED>
<!ATTLIST fstab fstablist CDATA #IMPLIED> <!ATTLIST fstab fstablist CDATA #IMPLIED>
@ -149,7 +149,7 @@
<!ELEMENT file EMPTY> <!ELEMENT file EMPTY>
<!ATTLIST file name CDATA #REQUIRED > <!ATTLIST file name CDATA #REQUIRED >
<!ATTLIST file name_type (UnicodeOption|SymLinkOption|variable) "UnicodeOption"> <!ATTLIST file name_type (UnicodeOption|SymLinkOption) "UnicodeOption">
<!ATTLIST file source CDATA #IMPLIED> <!ATTLIST file source CDATA #IMPLIED>
<!ATTLIST file mode CDATA #IMPLIED > <!ATTLIST file mode CDATA #IMPLIED >
<!ATTLIST file owner CDATA #IMPLIED > <!ATTLIST file owner CDATA #IMPLIED >

View File

@ -64,8 +64,7 @@ FORCE_CHOICE = {'oui/non': ['oui', 'non'],
'schedule': ['none', 'daily', 'weekly', 'monthly'], 'schedule': ['none', 'daily', 'weekly', 'monthly'],
'schedulemod': ['pre', 'post']} 'schedulemod': ['pre', 'post']}
KEY_TYPE = {'variable': 'symlink', KEY_TYPE = {'SymLinkOption': 'symlink',
'SymLinkOption': 'symlink',
'PortOption': 'port', 'PortOption': 'port',
'UnicodeOption': 'string', 'UnicodeOption': 'string',
'NetworkOption': 'network', 'NetworkOption': 'network',

View File

@ -21,16 +21,9 @@ from .i18n import _
from .xmlreflector import HIGH_COMPATIBILITY from .xmlreflector import HIGH_COMPATIBILITY
#from . import eosfunc #from . import eosfunc
from .objspace import CreoleObjSpace from .objspace import CreoleObjSpace
from .utils import normalize_family
import imp import imp
class ConvertDynOptionDescription(DynOptionDescription):
def convert_suffix_to_path(self, suffix):
return normalize_family(suffix,
check_name=False)
class CreoleLoaderError(Exception): class CreoleLoaderError(Exception):
pass pass
@ -546,7 +539,7 @@ class Family(Common):
del self.attrib['dynamic'] del self.attrib['dynamic']
self.attrib['suffixes'] = Calculation(self.eosfunc.calc_value, self.attrib['suffixes'] = Calculation(self.eosfunc.calc_value,
Params((ParamOption(dynamic),))) Params((ParamOption(dynamic),)))
option = ConvertDynOptionDescription(**self.attrib) option = DynOptionDescription(**self.attrib)
elif not self.is_leader: elif not self.is_leader:
option = OptionDescription(**self.attrib) option = OptionDescription(**self.attrib)
else: else:

View File

@ -601,9 +601,7 @@ 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, dico = self.families[normalize_family(name, check_name=False)]
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(

View File

@ -2,23 +2,25 @@
utilitaires créole utilitaires créole
""" """
import unicodedata import unicodedata
from .i18n import _
def normalize_family(family_name: str, # définition des classes d'adresse IP existantes
check_name: bool=True, def normalize_family(family_name, check_name=True):
allow_dot: bool=False) -> str: """
"""replace space, accent, uppercase, ... by valid character il ne faut pas d'espace, d'accent, de majuscule, de tiré, ...
dans le nom des familles
""" """
f = family_name f = family_name
f = f.replace('-', '_') f = f.replace('-', '_')
if not allow_dot: #f = f.replace(u'é', 'e')
f = f.replace('.', '_') #f = f.replace(u'è', 'e')
f = f.replace(' ', '_')
nfkd_form = unicodedata.normalize('NFKD', f) nfkd_form = unicodedata.normalize('NFKD', f)
f = ''.join([c for c in nfkd_form if not unicodedata.combining(c)]) f = u"".join([c for c in nfkd_form if not unicodedata.combining(c)])
f = f.replace(' ', '_')
f = f.lower() f = f.lower()
if f[0].isnumeric():
raise ValueError(u'Le nom de la famille ne doit pas commencer par un chiffre : {0}'.format(f))
if check_name and f == 'containers': if check_name and f == 'containers':
raise ValueError(_('"{0}" is a forbidden family name'.format(f))) raise ValueError(u'nom de la famille interdit {0}'.format(f))
return f return f