diff --git a/src/rougail/convert.py b/src/rougail/convert.py index 6f04a7b2c..8386c5f42 100644 --- a/src/rougail/convert.py +++ b/src/rougail/convert.py @@ -467,7 +467,7 @@ class ParserVariable: return family_obj = {} subfamily_obj = {} - force_to_attrs = list(self.list_attributes(obj)) + force_to_attrs = list(self.list_attributes(obj, version)) for key, value in obj.items(): if key in force_to_attrs: if key.startswith("_"): @@ -545,6 +545,7 @@ class ParserVariable: def list_attributes( self, obj: Dict[str, Any], + version: str, ) -> Iterator[str]: """List attributes""" force_to_variable = [] @@ -567,8 +568,7 @@ class ParserVariable: ): # it's a dict, so a new variables! continue - # FIXME should be remove with 1.0 format - if key == "variable" and obj.get("type") != "dynamic": + if version == '1.0' and key == "variable" and obj.get("type") != "dynamic" and obj.get("_type") != "dynamic": continue if key in self.family_attrs: yield key @@ -595,13 +595,14 @@ class ParserVariable: raise DictConsistencyError(f'dynamic family must have "variable" attribute for "{path}"', 101, family["xmlfiles"]) if 'dynamic' in family: raise DictConsistencyError('variable and dynamic cannot be set together in the dynamic family "{path}"', 100, family['xmlfiles']) + #FIXME compatibility to 1.0 + if "variable" in family: family['dynamic'] = {'type': 'variable', 'variable': family['variable'], 'propertyerror': False, 'allow_none': True, } del family['variable'] - #FIXME only for 1.0 if "variable" in family: raise Exception(f'dynamic family must not have "variable" attribute for "{family["path"]}" in {family["xmlfiles"]}') else: diff --git a/src/rougail/update.py b/src/rougail/update.py index bd30ea881..5960d0cda 100644 --- a/src/rougail/update.py +++ b/src/rougail/update.py @@ -36,7 +36,6 @@ except ModuleNotFoundError as err: # from ast import parse as ast_parse from json import dumps from ruamel.yaml import YAML -from yaml import dump, SafeDumper from pathlib import Path from .i18n import _