diff --git a/src/rougail/output_formatter/__init__.py b/src/rougail/output_formatter/__init__.py index 949d404..b4e46be 100644 --- a/src/rougail/output_formatter/__init__.py +++ b/src/rougail/output_formatter/__init__.py @@ -172,10 +172,16 @@ class RougailOutputFormatter: filenames = self.rougailconfig["main_structural_directories"] extra = False 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]) 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( filename @@ -272,19 +278,19 @@ class RougailOutputFormatter: for child_path in self.rougail.parents[path]: child = self.rougail.objects if self.rougail.has_namespace: - split_path = child_path.split('.')[1:] + split_path = child_path.split(".")[1:] else: - split_path = child_path.split('.') + split_path = child_path.split(".") 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 - if cpath.replace('{{ identifier }}', '') in child: - cpath = cpath.replace('{{ identifier }}', '') - elif cpath.replace('{{ identifier }}', '{{ suffix }}') in child: - cpath = cpath.replace('{{ identifier }}', '{{ suffix }}') + if cpath.replace("{{ identifier }}", "") in child: + cpath = cpath.replace("{{ identifier }}", "") + elif cpath.replace("{{ identifier }}", "{{ suffix }}") in child: + cpath = cpath.replace("{{ identifier }}", "{{ suffix }}") child = child[cpath] 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( self.rougail, name, @@ -299,7 +305,7 @@ class RougailOutputFormatter: if family_type == "family": family_type = collect.user_type if family_type is None: - family_type = 'family' + family_type = "family" if family_type == type_: if "_type" in family: del family["_type"] @@ -346,26 +352,26 @@ 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' + if type_ == "cidr" or type_ == "network_cidr": + if type_ == "cidr": + type_ = "ip" else: - type_ = 'network' + type_ = "network" if not obj.params: obj.params = [] - key = 'cidr' + 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, - ) + 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) - if type_ == 'choice': + if type_ == "choice": variable_obj = self.rougail.choices elif type_ == "regexp": variable_obj = self.rougail.regexp @@ -385,7 +391,9 @@ class RougailOutputFormatter: continue value = self.object_to_yaml(attr, type_, value, multi, path) 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 if variable.get("mandatory") is True and None not in variable.get( "choices", [] @@ -395,14 +403,20 @@ class RougailOutputFormatter: if isinstance(obj.default, VariableCalculation): is_multi = "multi" in variable and variable["multi"] is True 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: other_obj = self.rougail.paths[other_path] if "type" in variable and variable["type"] == other_obj.type: del variable["type"] if is_multi and obj.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"] if "type" in variable and variable["type"] in [ "string", @@ -555,7 +569,9 @@ class RougailOutputFormatter: jinja["return_type"] = return_type if value.description: if "\n" in value.description: - jinja["description"] = LiteralScalarString(value.description.strip()) + jinja["description"] = LiteralScalarString( + value.description.strip() + ) else: jinja["description"] = value.description.strip() if value.warnings: @@ -598,7 +614,9 @@ class RougailOutputFormatter: del variable["type"] if value.description: if "\n" in value.description: - variable["description"] = LiteralScalarString(value.description.strip()) + variable["description"] = LiteralScalarString( + value.description.strip() + ) else: variable["description"] = value.description.strip() return variable diff --git a/src/rougail/output_formatter/i18n.py b/src/rougail/output_formatter/i18n.py index 612295e..9c7b095 100644 --- a/src/rougail/output_formatter/i18n.py +++ b/src/rougail/output_formatter/i18n.py @@ -24,4 +24,3 @@ t = translation( ) _ = t.gettext -