Instead of using magic marker, use "in" check if key exists instead.
@@ -35,8 +35,6 @@ __all__ = [
LOG = logging.getLogger(__name__)
-DEFAULT_VALUE_MAGIC_MARKER = '~~***---%%--%%--%--%%%***~~~+++'
-
class ContentPackConfigLoader(object):
"""
@@ -155,13 +153,14 @@ class ContentPackConfigLoader(object):
:rtype: ``dict``
"""
for schema_item_key, schema_item in six.iteritems(schema):
- default_value = schema_item.get('default', DEFAULT_VALUE_MAGIC_MARKER)
+ has_default_value = 'default' in schema_item
+ has_config_value = schema_item_key in config
+
+ default_value = schema_item.get('default', None)
is_object = schema_item.get('type', None) == 'object'
has_properties = schema_item.get('properties', None)
- config_value = config.get(schema_item_key, DEFAULT_VALUE_MAGIC_MARKER)
- if (default_value != DEFAULT_VALUE_MAGIC_MARKER and
- config_value == DEFAULT_VALUE_MAGIC_MARKER):
+ if has_default_value and not has_config_value:
# Config value is not provided, but default value is, use a default value
config[schema_item_key] = default_value
