feat(#26): convert cidr and network_cidr format
This commit is contained in:
parent
3c33c1927a
commit
f2259653f7
2 changed files with 23 additions and 2 deletions
|
|
@ -47,9 +47,11 @@ from rougail.convert.object_model import (
|
||||||
NamespaceCalculation,
|
NamespaceCalculation,
|
||||||
IdentifierParam,
|
IdentifierParam,
|
||||||
IndexCalculation,
|
IndexCalculation,
|
||||||
|
VariableCalculation,
|
||||||
IndexParam,
|
IndexParam,
|
||||||
NamespaceParam,
|
NamespaceParam,
|
||||||
Param,
|
Param,
|
||||||
|
AnyParam,
|
||||||
)
|
)
|
||||||
from rougail.tiramisu import normalize_family, RENAME_TYPE
|
from rougail.tiramisu import normalize_family, RENAME_TYPE
|
||||||
from rougail.utils import undefined
|
from rougail.utils import undefined
|
||||||
|
|
@ -197,7 +199,7 @@ class RougailOutputFormatter:
|
||||||
continue
|
continue
|
||||||
if isinstance(obj, Family):
|
if isinstance(obj, Family):
|
||||||
self.parse_family(path, obj)
|
self.parse_family(path, obj)
|
||||||
if isinstance(obj, Variable):
|
elif isinstance(obj, Variable):
|
||||||
self.parse_variable(path, obj)
|
self.parse_variable(path, obj)
|
||||||
if list(self.families[self.main_namespace]) != [self.version_name]:
|
if list(self.families[self.main_namespace]) != [self.version_name]:
|
||||||
self.families[self.main_namespace].yaml_value_comment_extend(
|
self.families[self.main_namespace].yaml_value_comment_extend(
|
||||||
|
|
@ -283,6 +285,25 @@ class RougailOutputFormatter:
|
||||||
type_ = obj.type
|
type_ = obj.type
|
||||||
if type_ in RENAME_TYPE:
|
if type_ in RENAME_TYPE:
|
||||||
type_ = RENAME_TYPE[type_]
|
type_ = RENAME_TYPE[type_]
|
||||||
|
if type_ == 'cidr' or type_ == 'network_cidr':
|
||||||
|
if type_ == 'cidr':
|
||||||
|
type_ = 'ip'
|
||||||
|
else:
|
||||||
|
type_ = 'network'
|
||||||
|
if not obj.params:
|
||||||
|
obj.params = []
|
||||||
|
key = 'cidr'
|
||||||
|
param = AnyParam(
|
||||||
|
key='cidr',
|
||||||
|
value=True,
|
||||||
|
type="any",
|
||||||
|
path=None,
|
||||||
|
attribute=None,
|
||||||
|
family_is_dynamic=None,
|
||||||
|
namespace=self.rougail.namespace,
|
||||||
|
xmlfiles=obj.xmlfiles,
|
||||||
|
)
|
||||||
|
obj.params.append(param)
|
||||||
for attr, default_value in self.get_attributes(
|
for attr, default_value in self.get_attributes(
|
||||||
self.rougail.variable, ["name", "path", "namespace", "version", "xmlfiles"]
|
self.rougail.variable, ["name", "path", "namespace", "version", "xmlfiles"]
|
||||||
).items():
|
).items():
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ excludes = [
|
||||||
]
|
]
|
||||||
|
|
||||||
test_ok = get_structures_list(excludes)
|
test_ok = get_structures_list(excludes)
|
||||||
# test_ok = [Path('../rougail-tests/structures/04_0type_param')]
|
test_ok = [Path('../rougail-tests/structures/00_2default_calculated_variable')]
|
||||||
|
|
||||||
|
|
||||||
def idfn(fixture_value):
|
def idfn(fixture_value):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue