Given either a dictionary or a `ConfigSource` object, return
        a `ConfigSource` object. This lets a function accept either type
        of object as an argument.
421425
def of(cls, value):
        
        if isinstance(value, ConfigSource):
            return value
        elif isinstance(value, dict):
            return ConfigSource(value)
        else:
            raise TypeError(u'source value must be a dict')
16282
def from_dict(cls, d):
        
        conf = {}
        for k in d["config"]:
            v = d["config"][k]
            if isinstance(v, dict):
                conf[str(k)] = get_dict_handler(d["config"]["type"])(v)
            else:
                conf[str(k)] = v
        return get_class(str(d["class"]))(config=conf)
1215916
def __substitute_objects(self, value, context_dict):
        
        if type(value) == dict:
            return dict([(k, self.__substitute_objects(v, context_dict)) for k, v in value.items()])
        elif type(value) == str:
            try:
                return value % context_dict
            except KeyError:
                e = sys.exc_info()[1]
                logger.warn("Could not specialize %s! Error: %s" % (value, e))
                return value
        else:
            return value
328096
function get(obj, fn) {
  if (typeof obj === 'object') return fn(null, obj);
  if (typeof obj === 'undefined') return fn(null, {});
  if (typeof obj !== 'function') return fn(new Error('cannot read conf:\n' + obj));
  if (obj.length === 1) return obj(fn);
  var val;
  try {
    val = obj();
  } catch(err) {
    return fn(err);
  }
  fn(null, val);
}
1160508
def with_legacy_dict(self, legacy_dict_object):
        """"""
        warnings.warn(DeprecationWarning('Legacy configuration object has been used '
                                         'to load the ConfigResolver.'))
        return self.with_config_source(LegacyDictConfigSource(legacy_dict_object))
26111
def pass_config(func=None, **config_kw):
    """"""

    def decorate(func):
        def new_func(*args, **kw):
            config = load_config(**config_kw)
            func(config, *args, **kw)

        return functools.update_wrapper(new_func, func)

    if func is None:
        return decorate
    else:
        return decorate(func)
756303
def use(self, plugin, arguments={}):
    
    self.plugins[plugin] = dict(arguments)
    return self.plugins
735525
def get_or_create(self, **kwargs):
        
        assert kwargs, "get_or_create() must be passed at least one keyword argument"

        defaults = kwargs.pop("defaults", {})
        lookup = kwargs.copy()

        try:
            return self.get(**lookup), False
        except self.resource.DoesNotExist:
            params = dict([(k, v) for k, v in kwargs.items()])
            params.update(defaults)

            obj = self.create(**params)
            return obj, True
242933
def _make_parser(**kwargs):
    
    # Optional arguements for configparser.SafeConfigParser{,readfp}
    kwargs_0 = filter_options(("defaults", "dict_type", "allow_no_value"),
                              kwargs)
    kwargs_1 = filter_options(("filename", ), kwargs)

    try:
        parser = configparser.SafeConfigParser(**kwargs_0)
    except TypeError:
        # .. note::
        #    It seems ConfigParser.*ConfigParser in python 2.6 does not support
        #    'allow_no_value' option parameter, and TypeError will be thrown.
        kwargs_0 = filter_options(("defaults", "dict_type"), kwargs)
        parser = configparser.SafeConfigParser(**kwargs_0)

    return (kwargs_1, parser)
1328680
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'key' in _dict:
            args['key'] = Key._from_dict(_dict.get('key'))
        if 'value' in _dict:
            args['value'] = Value._from_dict(_dict.get('value'))
        return cls(**args)
909090
def instance(*args, **kwargs):
        

        if not hasattr(Config, "_instance") or Config._instance is None:
            Config._instance = Config(*args, **kwargs)
        return Config._instance
492584
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'configuration_id' in _dict:
            args['configuration_id'] = _dict.get('configuration_id')
        if 'name' in _dict:
            args['name'] = _dict.get('name')
        else:
            raise ValueError(
                'Required property \'name\' not present in Configuration JSON')
        if 'created' in _dict:
            args['created'] = string_to_datetime(_dict.get('created'))
        if 'updated' in _dict:
            args['updated'] = string_to_datetime(_dict.get('updated'))
        if 'description' in _dict:
            args['description'] = _dict.get('description')
        if 'conversions' in _dict:
            args['conversions'] = Conversions._from_dict(
                _dict.get('conversions'))
        if 'enrichments' in _dict:
            args['enrichments'] = [
                Enrichment._from_dict(x) for x in (_dict.get('enrichments'))
            ]
        if 'normalizations' in _dict:
            args['normalizations'] = [
                NormalizationOperation._from_dict(x)
                for x in (_dict.get('normalizations'))
            ]
        if 'source' in _dict:
            args['source'] = Source._from_dict(_dict.get('source'))
        return cls(**args)
787229
def config(config_dict: typing.Mapping) -> Config:
    
    logger.debug(f"Updating with {config_dict}")
    _cfg.update(config_dict)
    return _cfg
21395
def _config_parser_to_defaultdict(config_parser):
    
    config = defaultdict(defaultdict)
    for section, section_content in config_parser.items():
        if section != 'DEFAULT':
            for option, option_value in section_content.items():
                config[section][option] = option_value
    return config
1080634
def using_config(_func=None):
    
    def decorator(func):
        @wraps(func)
        def inner_dec(*args, **kwargs):
            g = func.__globals__
            var_name = 'config'
            sentinel = object()

            oldvalue = g.get(var_name, sentinel)
            g[var_name] = apps.get_app_config('django_summernote').config

            try:
                res = func(*args, **kwargs)
            finally:
                if oldvalue is sentinel:
                    del g[var_name]
                else:
                    g[var_name] = oldvalue

            return res
        return inner_dec

    if _func is None:
        return decorator
    else:
        return decorator(_func)
972876
def from_config(cls, config, prefix="postmark_", is_uppercase=False):
        
        kwargs = {}
        for arg in get_args(cls):
            key = prefix + arg
            if is_uppercase:
                key = key.upper()
            else:
                key = key.lower()
            if key in config:
                kwargs[arg] = config[key]
        return cls(**kwargs)
648725
def config_get(self, parameter='*'):
        
        if not isinstance(parameter, str):
            raise TypeError("parameter must be str")
        fut = self.execute(b'CONFIG', b'GET', parameter, encoding='utf-8')
        return wait_make_dict(fut)