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,
|
||||
IdentifierParam,
|
||||
IndexCalculation,
|
||||
VariableCalculation,
|
||||
IndexParam,
|
||||
NamespaceParam,
|
||||
Param,
|
||||
AnyParam,
|
||||
)
|
||||
from rougail.tiramisu import normalize_family, RENAME_TYPE
|
||||
from rougail.utils import undefined
|
||||
|
|
@ -197,7 +199,7 @@ class RougailOutputFormatter:
|
|||
continue
|
||||
if isinstance(obj, Family):
|
||||
self.parse_family(path, obj)
|
||||
if isinstance(obj, Variable):
|
||||
elif isinstance(obj, Variable):
|
||||
self.parse_variable(path, obj)
|
||||
if list(self.families[self.main_namespace]) != [self.version_name]:
|
||||
self.families[self.main_namespace].yaml_value_comment_extend(
|
||||
|
|
@ -283,6 +285,25 @@ class RougailOutputFormatter:
|
|||
type_ = obj.type
|
||||
if type_ in RENAME_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(
|
||||
self.rougail.variable, ["name", "path", "namespace", "version", "xmlfiles"]
|
||||
).items():
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ 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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue