blob: 44c58d8bd1b3bc5766de57e3dfcdd1a29cfc1004 [file] [log] [blame]
import copy
import reclass.values.parser_funcs
from reclass.defaults import *
class Settings(object):
def __init__(self, options={}):
self.allow_scalar_over_dict = options.get('allow_scalar_over_dict', OPT_ALLOW_SCALAR_OVER_DICT)
self.allow_scalar_over_list = options.get('allow_scalar_over_list', OPT_ALLOW_SCALAR_OVER_LIST)
self.allow_list_over_scalar = options.get('allow_list_over_scalar', OPT_ALLOW_LIST_OVER_SCALAR)
self.allow_dict_over_scalar = options.get('allow_dict_over_scalar', OPT_ALLOW_DICT_OVER_SCALAR)
self.allow_none_override = options.get('allow_none_override', OPT_ALLOW_NONE_OVERRIDE)
self.automatic_parameters = options.get('automatic_parameters', AUTOMATIC_RECLASS_PARAMETERS)
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.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_class_notfound_regexp = options.get('ignore_class_notfound_regexp', OPT_IGNORE_CLASS_NOTFOUND_REGEXP)
if isinstance(self.ignore_class_notfound_regexp, basestring):
self.ignore_class_notfound_regexp = [ self.ignore_class_notfound_regexp ]
self.ignore_class_notfound_warning = options.get('ignore_class_notfound_warning', OPT_IGNORE_CLASS_NOTFOUND_WARNING)
self.ignore_overwritten_missing_references = options.get('ignore_overwritten_missing_references', OPT_IGNORE_OVERWRITTEN_MISSING_REFERENCES)
self.group_errors = options.get('group_errors', OPT_GROUP_ERRORS)
self.ref_parser = reclass.values.parser_funcs.get_ref_parser(self.escape_character, self.reference_sentinels, self.export_sentinels)
self.simple_ref_parser = reclass.values.parser_funcs.get_simple_ref_parser(self.escape_character, self.reference_sentinels, self.export_sentinels)
def __eq__(self, other):
return isinstance(other, type(self)) \
and self.allow_scalar_over_dict == other.allow_scalar_over_dict \
and self.allow_scalar_over_list == other.allow_scalar_over_list \
and self.allow_list_over_scalar == other.allow_list_over_scalar \
and self.allow_dict_over_scalar == other.allow_dict_over_scalar \
and self.allow_none_override == other.allow_none_override \
and self.automatic_parameters == other.automatic_parameters \
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.escape_character == other.escape_character \
and self.export_sentinels == other.export_sentinels \
and self.inventory_ignore_failed_node == other.inventory_ignore_failed_node \
and self.inventory_ignore_failed_render == other.inventory_ignore_failed_render \
and self.reference_sentinels == other.reference_sentinels \
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
def __copy__(self):
cls = self.__class__
result = cls.__new__(cls)
result.__dict__.update(self.__dict__)
return result
def __deepcopy__(self, memo):
return self.__copy__()