allow 'variable' in dynamic family in 1.1
This commit is contained in:
parent
8b52232d6a
commit
d1db967dd5
2 changed files with 5 additions and 5 deletions
|
@ -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:
|
||||
|
|
|
@ -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 _
|
||||
|
|
Loading…
Reference in a new issue