Compare commits

..

No commits in common. "439cf7fe2db1d6df3d9ae719a3749d37ee2de34f" and "21f1526891b3f924457acd7b0c9bd27c35d5005a" have entirely different histories.

6 changed files with 24 additions and 40 deletions

View file

@ -1,9 +1,3 @@
## 1.2.0a41 (2025-11-06)
### Feat
- choice if invalid value or unknown variable in user data is a fatal error or not
## 1.2.0a40 (2025-11-03) ## 1.2.0a40 (2025-11-03)
### Feat ### Feat

View file

@ -1,6 +1,6 @@
[project] [project]
name = "rougail" name = "rougail"
version = "1.2.0a41" version = "1.2.0a40"
[tool.commitizen] [tool.commitizen]
name = "cz_conventional_commits" name = "cz_conventional_commits"

View file

@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
[project] [project]
name = "rougail-base" name = "rougail-base"
version = "1.2.0a41" version = "1.2.0a40"
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}] authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
readme = "README.md" readme = "README.md"
description = "A consistency handling system that was initially designed in the configuration management" description = "A consistency handling system that was initially designed in the configuration management"

View file

@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
[project] [project]
name = "rougail" name = "rougail"
version = "1.2.0a41" version = "1.2.0a40"
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}] authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
description = "A consistency handling system that was initially designed in the configuration management" description = "A consistency handling system that was initially designed in the configuration management"
classifiers = [ classifiers = [
@ -18,7 +18,7 @@ classifiers = [
dependencies = [ dependencies = [
"ruamel.yaml ~= 0.18.6", "ruamel.yaml ~= 0.18.6",
"pydantic ~= 2.9.2", "pydantic ~= 2.9.2",
"rougail-base == 1.2.0a41", "rougail-base == 1.2.0a40",
] ]
[tool.flit.sdist] [tool.flit.sdist]

View file

@ -1 +1 @@
__version__ = "1.2.0a41" __version__ = "1.2.0a40"

View file

@ -49,22 +49,16 @@ class UserDatas:
self, self,
user_datas: List[dict], user_datas: List[dict],
*, *,
invalid_user_datas_error: bool = False, user_datas_type: str = "user_datas",
unknown_user_datas_error: bool = False,
): ):
self.values = {} self.values = {}
self.errors = [] self.errors = []
self.warnings = [] self.warnings = []
if invalid_user_datas_error:
self.invalids = self.errors
else:
self.invalids = self.warnings
if unknown_user_datas_error:
self.unknowns = self.errors
else:
self.unknowns = self.warnings
self.show_secrets = False self.show_secrets = False
self._populate_values(user_datas) if user_datas_type == "user_datas":
self._populate_values(user_datas)
else:
self.values = user_datas
self._auto_configure_dynamics() self._auto_configure_dynamics()
self._populate_config() self._populate_config()
self.properties_to_string = get_properties_to_string() self.properties_to_string = get_properties_to_string()
@ -132,7 +126,7 @@ class UserDatas:
lists = config.list(uncalculated=True) lists = config.list(uncalculated=True)
except PropertiesOptionError: except PropertiesOptionError:
lists = [] lists = []
for tconfig in lists: for tconfig in []:
if not tconfig.isdynamic(only_self=True): if not tconfig.isdynamic(only_self=True):
# it's not a dynamic variable # it's not a dynamic variable
continue continue
@ -145,7 +139,7 @@ class UserDatas:
msg = _( msg = _(
'cannot load variable path "{0}", the identifier "{1}" is not valid in {2}' 'cannot load variable path "{0}", the identifier "{1}" is not valid in {2}'
).format(path, identifier, data["source"]) ).format(path, identifier, data["source"])
self.invalids.append(msg) self.warnings.append(msg)
continue continue
if identifier is None: if identifier is None:
# it's a dynamic variable but doesn't match the current name # it's a dynamic variable but doesn't match the current name
@ -304,7 +298,7 @@ class UserDatas:
try: try:
if option.isoptiondescription(): if option.isoptiondescription():
if value: if value:
self.invalids.append( self.warnings.append(
_( _(
'cannot set the value "{0}" to the family {1}, it will be ignored when loading from {2}' 'cannot set the value "{0}" to the family {1}, it will be ignored when loading from {2}'
).format( ).format(
@ -314,25 +308,21 @@ class UserDatas:
) )
) )
continue continue
except PropertiesOptionError as err:
self.unknowns.append(
_("{0} loaded from {1}").format(err, options["source"])
)
except AttributeOptionError as err: except AttributeOptionError as err:
if err.code == "option-not-found": if err.code == "option-not-found":
self.unknowns.append( self.warnings.append(
_( _(
'variable or family "{0}" does not exist, it will be ignored when loading from {1}' 'variable or family "{0}" does not exist, it will be ignored when loading from {1}'
).format(err.path, options["source"]) ).format(err.path, options["source"])
) )
elif err.code == "option-dynamic": elif err.code == "option-dynamic":
self.invalids.append( self.warnings.append(
_( _(
'"{0}" is the name of a dynamic family, it will be ignored when loading from {1}' '"{0}" is the name of a dynamic family, it will be ignored when loading from {1}'
).format(option.description(with_quote=True), options["source"]) ).format(option.description(with_quote=True), options["source"])
) )
else: else:
self.invalids.append( self.warnings.append(
_("{0} loaded from {1}").format(err, options["source"]) _("{0} loaded from {1}").format(err, options["source"])
) )
continue continue
@ -360,7 +350,7 @@ class UserDatas:
display_name = option.description(with_quote=True) display_name = option.description(with_quote=True)
if index is not None: if index is not None:
if path == err_path: if path == err_path:
self.unknowns.append( self.warnings.append(
_( _(
'variable {0} at index "{1}" is {2}, it will be ignored when loading from {3}' 'variable {0} at index "{1}" is {2}, it will be ignored when loading from {3}'
).format( ).format(
@ -371,7 +361,7 @@ class UserDatas:
) )
) )
else: else:
self.unknowns.append( self.warnings.append(
_( _(
'family {0} is {1}, {2} at index "{3}" will be ignored when loading from {4}' 'family {0} is {1}, {2} at index "{3}" will be ignored when loading from {4}'
).format( ).format(
@ -384,7 +374,7 @@ class UserDatas:
) )
else: else:
if path == err_path: if path == err_path:
self.unknowns.append( self.warnings.append(
_( _(
"variable {0} is {1}, it will be ignored when loading from {2}" "variable {0} is {1}, it will be ignored when loading from {2}"
).format( ).format(
@ -392,7 +382,7 @@ class UserDatas:
) )
) )
else: else:
self.unknowns.append( self.warnings.append(
_( _(
"family {0} is {1}, {2} will be ignored when loading from {3}" "family {0} is {1}, {2} will be ignored when loading from {3}"
).format( ).format(
@ -403,16 +393,16 @@ class UserDatas:
) )
) )
else: else:
self.unknowns.append( self.warnings.append(
_("{0} in {1}").format(err, options["source"]) _("{0} in {1}").format(err, options["source"])
) )
except LeadershipError as err: except LeadershipError as err:
self.unknowns.append(_("{0} in {1}").format(err, options["source"])) self.warnings.append(_("{0} in {1}").format(err, options["source"]))
except ValueError as err: except ValueError as err:
err.prefix = "" err.prefix = ""
if index is not None: if index is not None:
type_ = option.type(translation=True) type_ = option.type(translation=True)
self.invalids.append( self.warnings.append(
_( _(
'the value "{0}" is an invalid {1} for {2} at index "{3}", {4}, it will be ignored when loading from {5}' 'the value "{0}" is an invalid {1} for {2} at index "{3}", {4}, it will be ignored when loading from {5}'
).format( ).format(
@ -426,7 +416,7 @@ class UserDatas:
) )
else: else:
type_ = option.type(translation=True) type_ = option.type(translation=True)
self.invalids.append( self.warnings.append(
_( _(
'the value "{0}" is an invalid {1} for {2}, {3}, it will be ignored when loading from {4}' 'the value "{0}" is an invalid {1} for {2}, {3}, it will be ignored when loading from {4}'
).format( ).format(