Rename fixed/immutable parameters to constant parameters
This updates the docs, code and options to use the name constant
parameters for parameters using the '=' prefix
diff --git a/README-extentions.rst b/README-extentions.rst
index 8223348..ec10e48 100644
--- a/README-extentions.rst
+++ b/README-extentions.rst
@@ -124,19 +124,19 @@
three: ${one}
-Fixed/Immutable Parameters
+Constant Parameters
--------------------------
-Parameters can be labeled as fixed or immutable by using the prefix ``=``
+Parameters can be labeled as constant by using the prefix ``=``
.. code-block:: yaml
parameters:
=one: 1
-If in the normal parameter merging a fixed parameter would be changed then depending
-on the setting of ``ignore_merging_onto_fixed`` either an exception is raised (``ignore_merging_onto_fixed`` false)
-or the parameter is left unchanged and no notification or error is given (``ignore_merging_onto_fixed`` true)
+If in the normal parameter merging a constant parameter would be changed then depending
+on the setting of ``strict_constant_parameters`` either an exception is raised (``strict_constant_parameters`` true)
+or the parameter is left unchanged and no notification or error is given (``strict_constant_parameters`` false)
For example with:
@@ -155,8 +155,8 @@
parameters:
one: 2
-``reclass.py --nodeinfo node1`` then gives an ''Attempt to change fixed value'' error if ``ignore_merging_onto_fixed``
-is false or gives:
+``reclass.py --nodeinfo node1`` then gives an ''Attempt to change constant value'' error if ``strict_constant_parameters``
+is true or gives:
.. code-block:: yaml
@@ -164,13 +164,13 @@
alpha:
one: 1
-if ``ignore_merging_onto_fixed`` is true
+if ``strict_constant_parameters`` is false
-Default value for ``ignore_merging_onto_fixed`` is False
+Default value for ``strict_constant_parameters`` is True
.. code-block:: yaml
- ignore_merging_onto_fixed: False
+ strict_constant_parameters: True
Nested References
diff --git a/reclass/datatypes/parameters.py b/reclass/datatypes/parameters.py
index e40ded1..fa0f379 100644
--- a/reclass/datatypes/parameters.py
+++ b/reclass/datatypes/parameters.py
@@ -183,8 +183,8 @@
value = Value(value, self._settings, self._uri, parse_string=self._parse_strings)
if key[0] == self._settings.dict_key_override_prefix:
value.overwrite = True
- elif key[0] == self._settings.dict_key_fixed_prefix:
- value.fixed = True
+ elif key[0] == self._settings.dict_key_constant_prefix:
+ value.constant = True
value = self._merge_recurse(cur.get(newkey), value)
key = newkey
else:
diff --git a/reclass/datatypes/tests/test_parameters.py b/reclass/datatypes/tests/test_parameters.py
index 013bd88..5959197 100644
--- a/reclass/datatypes/tests/test_parameters.py
+++ b/reclass/datatypes/tests/test_parameters.py
@@ -20,7 +20,7 @@
from reclass.utils.parameterdict import ParameterDict
from reclass.values.value import Value
from reclass.values.scaitem import ScaItem
-from reclass.errors import ChangedFixedError, InfiniteRecursionError, InterpolationError, ResolveError, ResolveErrorList, TypeMergeError
+from reclass.errors import ChangedConstantError, InfiniteRecursionError, InterpolationError, ResolveError, ResolveErrorList, TypeMergeError
import unittest
try:
@@ -755,18 +755,18 @@
p1.interpolate()
self.assertEqual(p1.as_dict(), r)
- def test_fixed_parameter(self):
+ def test_strict_constant_parameter(self):
p1 = Parameters({'one': { 'a': 1} }, SETTINGS, 'first')
p2 = Parameters({'one': { '=a': 2} }, SETTINGS, 'second')
p3 = Parameters({'one': { 'a': 3} }, SETTINGS, 'third')
- with self.assertRaises(ChangedFixedError) as e:
+ with self.assertRaises(ChangedConstantError) as e:
p1.merge(p2)
p1.merge(p3)
p1.interpolate()
- self.assertEqual(e.exception.message, "-> \n Attempt to change fixed value, at one:a, in second; third")
+ self.assertEqual(e.exception.message, "-> \n Attempt to change constant value, at one:a, in second; third")
- def test_fixed_parameter_allow(self):
- settings = Settings({'ignore_merging_onto_fixed': True})
+ def test_constant_parameter(self):
+ settings = Settings({'strict_constant_parameters': False})
p1 = Parameters({'one': { 'a': 1} }, settings, 'first')
p2 = Parameters({'one': { '=a': 2} }, settings, 'second')
p3 = Parameters({'one': { 'a': 3} }, settings, 'third')
diff --git a/reclass/defaults.py b/reclass/defaults.py
index afae213..1e50c0e 100644
--- a/reclass/defaults.py
+++ b/reclass/defaults.py
@@ -29,7 +29,7 @@
OPT_IGNORE_CLASS_NOTFOUND_WARNING = True
OPT_IGNORE_OVERWRITTEN_MISSING_REFERENCES = True
-OPT_IGNORE_MERGING_ONTO_FIXED = False
+OPT_STRICT_CONSTANT_PARAMETERS = True
OPT_ALLOW_SCALAR_OVER_DICT = False
OPT_ALLOW_SCALAR_OVER_LIST = False
@@ -51,7 +51,7 @@
EXPORT_SENTINELS = ('$[', ']')
PARAMETER_INTERPOLATION_DELIMITER = ':'
PARAMETER_DICT_KEY_OVERRIDE_PREFIX = '~'
-PARAMETER_DICT_KEY_FIXED_PREFIX = '='
+PARAMETER_DICT_KEY_CONSTANT_PREFIX = '='
ESCAPE_CHARACTER = '\\'
AUTOMATIC_RECLASS_PARAMETERS = True
diff --git a/reclass/errors.py b/reclass/errors.py
index 1a3790c..0c9d48f 100644
--- a/reclass/errors.py
+++ b/reclass/errors.py
@@ -306,13 +306,13 @@
return msg
-class ChangedFixedError(InterpolationError):
+class ChangedConstantError(InterpolationError):
def __init__(self, uri):
- super(ChangedFixedError, self).__init__(msg=None, uri=uri, tbFlag=False)
+ super(ChangedConstantError, self).__init__(msg=None, uri=uri, tbFlag=False)
def _get_error_message(self):
- msg = [ 'Attempt to change fixed value' + self._add_context_and_uri() ]
+ msg = [ 'Attempt to change constant value' + self._add_context_and_uri() ]
return msg
diff --git a/reclass/settings.py b/reclass/settings.py
index 01166a9..51c518f 100644
--- a/reclass/settings.py
+++ b/reclass/settings.py
@@ -23,15 +23,15 @@
self.default_environment = options.get('default_environment', DEFAULT_ENVIRONMENT)
self.delimiter = options.get('delimiter', PARAMETER_INTERPOLATION_DELIMITER)
self.dict_key_override_prefix = options.get('dict_key_override_prefix', PARAMETER_DICT_KEY_OVERRIDE_PREFIX)
- self.dict_key_fixed_prefix = options.get('dict_key_fixed_prefix', PARAMETER_DICT_KEY_FIXED_PREFIX)
- self.dict_key_prefixes = [ str(self.dict_key_override_prefix), str(self.dict_key_fixed_prefix) ]
+ self.dict_key_constant_prefix = options.get('dict_key_constant_prefix', PARAMETER_DICT_KEY_CONSTANT_PREFIX)
+ self.dict_key_prefixes = [ str(self.dict_key_override_prefix), str(self.dict_key_constant_prefix) ]
self.escape_character = options.get('escape_character', ESCAPE_CHARACTER)
self.export_sentinels = options.get('export_sentinels', EXPORT_SENTINELS)
self.inventory_ignore_failed_node = options.get('inventory_ignore_failed_node', OPT_INVENTORY_IGNORE_FAILED_NODE)
self.inventory_ignore_failed_render = options.get('inventory_ignore_failed_render', OPT_INVENTORY_IGNORE_FAILED_RENDER)
self.reference_sentinels = options.get('reference_sentinels', REFERENCE_SENTINELS)
self.ignore_class_notfound = options.get('ignore_class_notfound', OPT_IGNORE_CLASS_NOTFOUND)
- self.ignore_merging_onto_fixed = options.get('ignore_merging_onto_fixed', OPT_IGNORE_MERGING_ONTO_FIXED)
+ self.strict_constant_parameters = options.get('strict_constant_parameters', OPT_STRICT_CONSTANT_PARAMETERS)
self.ignore_class_notfound_regexp = options.get('ignore_class_notfound_regexp', OPT_IGNORE_CLASS_NOTFOUND_REGEXP)
if isinstance(self.ignore_class_notfound_regexp, string_types):
@@ -56,7 +56,7 @@
and self.default_environment == other.default_environment \
and self.delimiter == other.delimiter \
and self.dict_key_override_prefix == other.dict_key_override_prefix \
- and self.dict_key_fixed_prefix == other.dict_key_fixed_prefix \
+ and self.dict_key_constant_prefix == other.dict_key_constant_prefix \
and self.escape_character == other.escape_character \
and self.export_sentinels == other.export_sentinels \
and self.inventory_ignore_failed_node == other.inventory_ignore_failed_node \
@@ -65,7 +65,7 @@
and self.ignore_class_notfound == other.ignore_class_notfound \
and self.ignore_class_notfound_regexp == other.ignore_class_notfound_regexp \
and self.ignore_class_notfound_warning == other.ignore_class_notfound_warning \
- and self.ignore_merging_onto_fixed == other.ignore_merging_onto_fixed
+ and self.strict_constant_parameters == other.strict_constant_parameters
def __copy__(self):
cls = self.__class__
diff --git a/reclass/values/value.py b/reclass/values/value.py
index ffb116f..4e86274 100644
--- a/reclass/values/value.py
+++ b/reclass/values/value.py
@@ -24,7 +24,7 @@
self._settings = settings
self._uri = uri
self._overwrite = False
- self._fixed = False
+ self._constant = False
if isinstance(value, string_types):
if parse_string:
try:
@@ -50,12 +50,12 @@
self._overwrite = overwrite
@property
- def fixed(self):
- return self._fixed
+ def constant(self):
+ return self._constant
- @fixed.setter
- def fixed(self, fixed):
- self._fixed = fixed
+ @constant.setter
+ def constant(self, constant):
+ self._constant = constant
@property
def uri(self):
diff --git a/reclass/values/valuelist.py b/reclass/values/valuelist.py
index aa7ac70..9c1e1fa 100644
--- a/reclass/values/valuelist.py
+++ b/reclass/values/valuelist.py
@@ -13,7 +13,7 @@
import copy
import sys
-from reclass.errors import ChangedFixedError, ResolveError, TypeMergeError
+from reclass.errors import ChangedConstantError, ResolveError, TypeMergeError
@@ -48,7 +48,7 @@
self._is_complex = False
item_type = self._values[0].item_type()
for v in self._values:
- if v.is_complex() or v.fixed or v.overwrite or v.item_type() != item_type:
+ if v.is_complex() or v.constant or v.overwrite or v.item_type() != item_type:
self._is_complex = True
def has_references(self):
@@ -109,7 +109,7 @@
output = None
deepCopied = False
last_error = None
- fixed = False
+ constant = False
for n, value in enumerate(self._values):
try:
new = value.render(context, inventory)
@@ -123,11 +123,11 @@
else:
raise e
- if fixed:
- if self._settings.ignore_merging_onto_fixed:
- continue
+ if constant:
+ if self._settings.strict_constant_parameters:
+ raise ChangedConstantError('{0}; {1}'.format(self._values[n-1].uri, self._values[n].uri))
else:
- raise ChangedFixedError('{0}; {1}'.format(self._values[n-1].uri, self._values[n].uri))
+ continue
if output is None or value.overwrite:
output = new
@@ -179,8 +179,8 @@
output = new
deepCopied = False
- if value.fixed:
- fixed = True
+ if value.constant:
+ constant = True
if isinstance(output, (dict, list)) and last_error is not None:
raise last_error