fix: black
This commit is contained in:
parent
7d673766c8
commit
360ce32d18
2 changed files with 49 additions and 32 deletions
|
|
@ -172,10 +172,16 @@ class RougailOutputFormatter:
|
||||||
filenames = self.rougailconfig["main_structural_directories"]
|
filenames = self.rougailconfig["main_structural_directories"]
|
||||||
extra = False
|
extra = False
|
||||||
if len(filenames) > 1:
|
if len(filenames) > 1:
|
||||||
raise ExtensionError(_('only one filename is allowed, not "{0}"').format(filenames))
|
raise ExtensionError(
|
||||||
|
_('only one filename is allowed, not "{0}"').format(filenames)
|
||||||
|
)
|
||||||
filename = Path(filenames[0])
|
filename = Path(filenames[0])
|
||||||
if not filename.is_file():
|
if not filename.is_file():
|
||||||
raise ExtensionError(_('"{0}" is not a valid file, but only a file is allowed').format(filename))
|
raise ExtensionError(
|
||||||
|
_('"{0}" is not a valid file, but only a file is allowed').format(
|
||||||
|
filename
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
self.version_name, self.original_yaml = RougailUpgrade(self.rougailconfig).run(
|
self.version_name, self.original_yaml = RougailUpgrade(self.rougailconfig).run(
|
||||||
filename
|
filename
|
||||||
|
|
@ -272,19 +278,19 @@ class RougailOutputFormatter:
|
||||||
for child_path in self.rougail.parents[path]:
|
for child_path in self.rougail.parents[path]:
|
||||||
child = self.rougail.objects
|
child = self.rougail.objects
|
||||||
if self.rougail.has_namespace:
|
if self.rougail.has_namespace:
|
||||||
split_path = child_path.split('.')[1:]
|
split_path = child_path.split(".")[1:]
|
||||||
else:
|
else:
|
||||||
split_path = child_path.split('.')
|
split_path = child_path.split(".")
|
||||||
for cpath in split_path:
|
for cpath in split_path:
|
||||||
if cpath not in child and '{{ identifier }}' in cpath:
|
if cpath not in child and "{{ identifier }}" in cpath:
|
||||||
# support format 1.0
|
# support format 1.0
|
||||||
if cpath.replace('{{ identifier }}', '') in child:
|
if cpath.replace("{{ identifier }}", "") in child:
|
||||||
cpath = cpath.replace('{{ identifier }}', '')
|
cpath = cpath.replace("{{ identifier }}", "")
|
||||||
elif cpath.replace('{{ identifier }}', '{{ suffix }}') in child:
|
elif cpath.replace("{{ identifier }}", "{{ suffix }}") in child:
|
||||||
cpath = cpath.replace('{{ identifier }}', '{{ suffix }}')
|
cpath = cpath.replace("{{ identifier }}", "{{ suffix }}")
|
||||||
child = child[cpath]
|
child = child[cpath]
|
||||||
tmp_family[cpath] = child
|
tmp_family[cpath] = child
|
||||||
#family_type = self.rougail.is_family_or_variable("", tmp_family, False, "")
|
# family_type = self.rougail.is_family_or_variable("", tmp_family, False, "")
|
||||||
collect = Collect(
|
collect = Collect(
|
||||||
self.rougail,
|
self.rougail,
|
||||||
name,
|
name,
|
||||||
|
|
@ -299,7 +305,7 @@ class RougailOutputFormatter:
|
||||||
if family_type == "family":
|
if family_type == "family":
|
||||||
family_type = collect.user_type
|
family_type = collect.user_type
|
||||||
if family_type is None:
|
if family_type is None:
|
||||||
family_type = 'family'
|
family_type = "family"
|
||||||
if family_type == type_:
|
if family_type == type_:
|
||||||
if "_type" in family:
|
if "_type" in family:
|
||||||
del family["_type"]
|
del family["_type"]
|
||||||
|
|
@ -346,26 +352,26 @@ 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" or type_ == "network_cidr":
|
||||||
if type_ == 'cidr':
|
if type_ == "cidr":
|
||||||
type_ = 'ip'
|
type_ = "ip"
|
||||||
else:
|
else:
|
||||||
type_ = 'network'
|
type_ = "network"
|
||||||
if not obj.params:
|
if not obj.params:
|
||||||
obj.params = []
|
obj.params = []
|
||||||
key = 'cidr'
|
key = "cidr"
|
||||||
param = AnyParam(
|
param = AnyParam(
|
||||||
key='cidr',
|
key="cidr",
|
||||||
value=True,
|
value=True,
|
||||||
type="any",
|
type="any",
|
||||||
path=None,
|
path=None,
|
||||||
attribute=None,
|
attribute=None,
|
||||||
family_is_dynamic=None,
|
family_is_dynamic=None,
|
||||||
namespace=self.rougail.namespace,
|
namespace=self.rougail.namespace,
|
||||||
xmlfiles=obj.xmlfiles,
|
xmlfiles=obj.xmlfiles,
|
||||||
)
|
)
|
||||||
obj.params.append(param)
|
obj.params.append(param)
|
||||||
if type_ == 'choice':
|
if type_ == "choice":
|
||||||
variable_obj = self.rougail.choices
|
variable_obj = self.rougail.choices
|
||||||
elif type_ == "regexp":
|
elif type_ == "regexp":
|
||||||
variable_obj = self.rougail.regexp
|
variable_obj = self.rougail.regexp
|
||||||
|
|
@ -385,7 +391,9 @@ class RougailOutputFormatter:
|
||||||
continue
|
continue
|
||||||
value = self.object_to_yaml(attr, type_, value, multi, path)
|
value = self.object_to_yaml(attr, type_, value, multi, path)
|
||||||
if isinstance(value, dict) and "identifier" in value:
|
if isinstance(value, dict) and "identifier" in value:
|
||||||
value["identifier"] = self.object_to_yaml("identifier", type_, value["identifier"], True, path)
|
value["identifier"] = self.object_to_yaml(
|
||||||
|
"identifier", type_, value["identifier"], True, path
|
||||||
|
)
|
||||||
variable[attr] = value
|
variable[attr] = value
|
||||||
if variable.get("mandatory") is True and None not in variable.get(
|
if variable.get("mandatory") is True and None not in variable.get(
|
||||||
"choices", []
|
"choices", []
|
||||||
|
|
@ -395,14 +403,20 @@ class RougailOutputFormatter:
|
||||||
if isinstance(obj.default, VariableCalculation):
|
if isinstance(obj.default, VariableCalculation):
|
||||||
is_multi = "multi" in variable and variable["multi"] is True
|
is_multi = "multi" in variable and variable["multi"] is True
|
||||||
if "type" in variable or is_multi:
|
if "type" in variable or is_multi:
|
||||||
other_path = self.rougail.paths.get_full_path(obj.default.variable, path)
|
other_path = self.rougail.paths.get_full_path(
|
||||||
|
obj.default.variable, path
|
||||||
|
)
|
||||||
if other_path in self.rougail.paths:
|
if other_path in self.rougail.paths:
|
||||||
other_obj = self.rougail.paths[other_path]
|
other_obj = self.rougail.paths[other_path]
|
||||||
if "type" in variable and variable["type"] == other_obj.type:
|
if "type" in variable and variable["type"] == other_obj.type:
|
||||||
del variable["type"]
|
del variable["type"]
|
||||||
if is_multi and obj.multi:
|
if is_multi and obj.multi:
|
||||||
del variable["multi"]
|
del variable["multi"]
|
||||||
if "type" in variable and isinstance(obj.default, IndexCalculation) and variable["type"] == "integer":
|
if (
|
||||||
|
"type" in variable
|
||||||
|
and isinstance(obj.default, IndexCalculation)
|
||||||
|
and variable["type"] == "integer"
|
||||||
|
):
|
||||||
del variable["type"]
|
del variable["type"]
|
||||||
if "type" in variable and variable["type"] in [
|
if "type" in variable and variable["type"] in [
|
||||||
"string",
|
"string",
|
||||||
|
|
@ -555,7 +569,9 @@ class RougailOutputFormatter:
|
||||||
jinja["return_type"] = return_type
|
jinja["return_type"] = return_type
|
||||||
if value.description:
|
if value.description:
|
||||||
if "\n" in value.description:
|
if "\n" in value.description:
|
||||||
jinja["description"] = LiteralScalarString(value.description.strip())
|
jinja["description"] = LiteralScalarString(
|
||||||
|
value.description.strip()
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
jinja["description"] = value.description.strip()
|
jinja["description"] = value.description.strip()
|
||||||
if value.warnings:
|
if value.warnings:
|
||||||
|
|
@ -598,7 +614,9 @@ class RougailOutputFormatter:
|
||||||
del variable["type"]
|
del variable["type"]
|
||||||
if value.description:
|
if value.description:
|
||||||
if "\n" in value.description:
|
if "\n" in value.description:
|
||||||
variable["description"] = LiteralScalarString(value.description.strip())
|
variable["description"] = LiteralScalarString(
|
||||||
|
value.description.strip()
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
variable["description"] = value.description.strip()
|
variable["description"] = value.description.strip()
|
||||||
return variable
|
return variable
|
||||||
|
|
|
||||||
|
|
@ -24,4 +24,3 @@ t = translation(
|
||||||
)
|
)
|
||||||
|
|
||||||
_ = t.gettext
|
_ = t.gettext
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue