Given a configuration specification, initializes all the net
        definitions in it so they can be used comfortably

        Args:
            conf (dict): Configuration specification

        Returns:
            dict: the adapted new conf
513270
def _init_net_specs(conf):
        
        for net_name, net_spec in conf.get('nets', {}).items():
            net_spec['name'] = net_name
            net_spec['mapping'] = {}
            net_spec.setdefault('type', 'nat')

        return conf
605526
def initialize(self, init_value, context=None, force=False):
        

        if not force and self._instance is not None:
            raise ConfigurationAlreadyInitializedError(
                'Configuration manager object is already initialized.'
            )

        self.__class__._instance = Root(init_value, context=context)
502239
def __init(self):
        
        params = {
            "f" : "json",
        }
        json_dict = self._get(self._url, params,
                                 securityHandler=self._securityHandler,
                                 proxy_url=self._proxy_url,
                                 proxy_port=self._proxy_port)
        self._json_dict = json_dict
        self._json = json.dumps(self._json_dict)
        attributes = [attr for attr in dir(self)
                      if not attr.startswith('__') and \
                      not attr.startswith('_')]

        for k,v in json_dict.items():
            if k in attributes:
                if k == "routeLayers" and json_dict[k]:
                    self._routeLayers = []
                    for rl in v:
                        self._routeLayers.append(
                            RouteNetworkLayer(url=self._url + "/%s" % rl,
                                              securityHandler=self._securityHandler,
                                              proxy_url=self._proxy_url,
                                              proxy_port=self._proxy_port,
                                              initialize=False))

                elif k == "serviceAreaLayers" and json_dict[k]:
                    self._serviceAreaLayers = []
                    for sal in v:
                        self._serviceAreaLayers.append(
                            ServiceAreaNetworkLayer(url=self._url + "/%s" % sal,
                                                    securityHandler=self._securityHandler,
                                                    proxy_url=self._proxy_url,
                                                    proxy_port=self._proxy_port,
                                                    initialize=False))

                elif k == "closestFacilityLayers" and json_dict[k]:
                    self._closestFacilityLayers = []
                    for cf in v:
                        self._closestFacilityLayers.append(
                            ClosestFacilityNetworkLayer(url=self._url + "/%s" % cf,
                                                    securityHandler=self._securityHandler,
                                                    proxy_url=self._proxy_url,
                                                    proxy_port=self._proxy_port,
                                                    initialize=False))
                else:
                    setattr(self, "_"+ k, v)
            else:
                print ("attribute %s is not implemented." % k)
346725
def config(self):
        
        if self._full_config is None:
            self._full_config = DotDict()
            self._full_config.merge(self._default)
            self._full_config.merge(self._config)
            self._full_config.merge(self._environment)
            self._full_config.merge(self._override)
        return self._full_config
1012952
def _get_existing_conf(config):
    
    try:
        with open(os.path.join(config, 'local.conf'), 'r') as f:
            lines = [line for line in f.readlines()
                     if not (line.startswith('service_id') or line.startswith('client_secret'))]
    except IOError:
        lines = []
    return lines
51928
def initialize(self, stormconf, context):
        
        self.terms = get_config()['TermCycleSpout']['terms']
        self.term_seq = itertools.cycle(self.terms)
45837
def load_from_dict(self, conf_dict=None):
        
        self.set_to_default()
        self._update_dict(self._config, conf_dict)
        self._update_python_paths()
1178815
def __init(self):
        
        params = {
            "f" : "json"
        }
        json_dict = self._get(url=self._url, param_dict=params,
                                 securityHandler=self._securityHandler,
                                 proxy_url=self._proxy_url,
                                 proxy_port=self._proxy_port)
        attributes = [attr for attr in dir(self)
                      if not attr.startswith('__') and \
                      not attr.startswith('_')]
        for k,v in json_dict.items():
            if k in attributes:
                setattr(self, "_"+ k, json_dict[k])
            else:
                print( k, " - attribute not implemented in RouteNetworkLayer.")
            del k,v
1226266
def load_conf(yml_file, conf={}):
    
    with open(yml_file) as f:
        data = yaml.load(f)
        if conf:
            data.update(conf)
        return dictdot(data)
1279057
def generate_config(conf):
    

    c = {}
    def to_key(key, default):
        if conf.get(key):
            c[key] = '{} = {}'.format(key, conf.get(key))
        else:
            c[key] = default

    to_key('username', '# username = u1234...')
    to_key('password', '# password = secret...')
    to_key('from', '# from = elkme')
    to_key('to', '# to = +46700000000')
    return (True, c)
187551
def configure(cls, global_, key, val):
        
        # first retrieve current configuration
        scope = 'global' if global_ else 'local'
        if scope not in cls._conffiles:
            cls._conffiles[scope] = {}
        config = cls._conffiles.get(scope, {})
        # apply modification to fields
        cls._set(scope, key, val)
        conf_file = cls.home_config if global_ else cls.local_config
        # save configuration to file
        cls.save(os.path.expanduser(conf_file), config)
792955
def init_config(self, app):
        
        config_apps = ['REST_', 'CORS_', ]
        for k in dir(config):
            if any([k.startswith(prefix) for prefix in config_apps]):
                app.config.setdefault(k, getattr(config, k))
625076
def config(conf, confdefs):
    '''
    
    '''
    conf = conf.copy()

    # for now just populate defval
    for name, info in confdefs:
        conf.setdefault(name, info.get('defval'))

    return conf
620088
def initialise(self, args=None, env=None, file=None, cwd=None):
        
        self.spec_file = args and args.specs or None
        self.cwd = cwd or os.getcwd()
        self.file = file
        return self.spec_file is not None
1274181
def config(self):
        """"""
        conf = config.Configuration()
        for namespace in self.namespaces:

            if not hasattr(conf, namespace):

                if not self._strict:

                    continue

                raise exc.NamespaceNotRegistered(
                    "The namespace {0} is not registered.".format(namespace)
                )

            name = getattr(conf, namespace)

            for item, value in compat.iteritems(self.items(namespace)):

                if not hasattr(name, item):

                    if not self._strict:

                        continue

                    raise exc.OptionNotRegistered(
                        "The option {0} is not registered.".format(item)
                    )

                setattr(name, item, value)

        return conf
68158
def create(cls, config_file=None):
        
        if cls.instance is None:
            cls.instance = cls(config_file)

            # Load config file, possibly overwriting the defaults
            cls.instance.load_ini()

        if config_file and config_file != cls.instance.config_file:
            raise RuntimeError("Configuration initialized a second time with a different file!")

        return cls.instance
742817
def _parse_env(self):
        
        env_cfg = DotDict()

        # if the env prefix doesn't end with '_', we'll append it here
        if self.env_prefix and not self.env_prefix.endswith('_'):
            self.env_prefix = self.env_prefix + '_'

        # if there is no scheme, we won't know what to look for so only parse
        # config if there is a scheme.
        if self.scheme:
            for k, v in self.scheme.flatten().items():
                value = v.parse_env(k, self.env_prefix, self.auto_env)
                if value is not None:
                    env_cfg[k] = value

        if len(env_cfg) > 0:
            # the configuration changes, so we invalidate the cached config
            self._full_config = None
            self._environment.update(env_cfg)