Parse @config to setup @self state.
194247
def parse_toplevel_config(self, config):
        """"""
        if not Formatter.initialized:
            html_theme = config.get('html_theme', 'default')

            if html_theme != 'default':
                uri = urllib.parse.urlparse(html_theme)
                if not uri.scheme:
                    html_theme = config.get_path('html_theme')
                    debug("Using theme located at %s" % html_theme)
                elif uri.scheme.startswith('http'):
                    html_theme = self.__download_theme(uri)

            if html_theme == 'default':
                default_theme = os.path.join(HERE, os.pardir,
                                             'hotdoc_bootstrap_theme', 'dist')

                html_theme = os.path.abspath(default_theme)
                debug("Using default theme")

            theme_meta_path = os.path.join(html_theme, 'theme.json')

            if os.path.exists(theme_meta_path):
                with open(theme_meta_path, 'r') as _:
                    Formatter.theme_meta = json.loads(_.read())

            searchpath = []
            self.__load_theme_templates(searchpath, HERE)

            Formatter.theme_path = html_theme
            if html_theme:
                self.__load_theme_templates(searchpath, html_theme)

            Formatter.extra_theme_path = config.get_path('html_extra_theme')
            if Formatter.extra_theme_path:
                self.__load_theme_templates(searchpath,
                                            Formatter.extra_theme_path)

            Formatter.engine = Engine(
                loader=FileLoader(searchpath, encoding='UTF-8'),
                extensions=[CoreExtension(), CodeExtension()])
            Formatter.engine.global_vars.update({'e': html.escape})

            Formatter.initialized = True
1043339
def state(self, state: str) -> None:
        """"""
        self._state = state
        for callback in self._callbacks:
            callback()
82418
def _parse_config(self, requires_cfg=True):
        
        if len(self.config_paths) > 0:
            try:
                self._find_config()
            except BisonError:
                if not requires_cfg:
                    return
                raise
            try:
                with open(self.config_file, 'r') as f:
                    parsed = self._fmt_to_parser[self.config_format](f)
            except Exception as e:
                raise BisonError(
                    'Failed to parse config file: {}'.format(self.config_file)
                ) from e

            # the configuration changes, so we invalidate the cached config
            self._full_config = None
            self._config = parsed
1092648
def config(env=DEFAULT_ENV, default=None):
    """"""

    conf = {}

    s = os.environ.get(env, default)

    if s:
        conf = parse(s)

    return conf
1243095
def parse_config
      defaults = load_default_config
      overrides = load_config "#{@dir}/cucumber_lint.yml"

      overrides.each_pair do |style, style_overrides|
        style_overrides.each_pair do |key, value|
          if key == 'enforced_style'
            supported = defaults[style]['supported_styles']
            fail UnsupportedStyle.new style, supported, value unless supported.include?(value)
          end

          defaults[style][key] = value
        end
      end

      defaults.to_open_struct
    end
1067203
def load_config(self):
        
        for key in self.settings:
            value = self.config(key)
            # Parse true/false
            if value == '' or value is None:
                continue  # Not set by user, go on
            if value.lower() == 'true':
                value = True
            elif value.lower() == 'false':
                value = False
            elif value:
                pass  # A user-defined string, store the value later

            self.settings[key] = value
481182
def merge!(hash)
      hash.each do |key, value|
        if config_contexts.key?(key)
          # Grab the config context and let internal_get cache it if so desired
          config_contexts[key].restore(value)
        else
          configuration[key] = value
        end
      end
      self
    end
913059
def init_config(self, app):
        """"""
        for k in dir(config):
            if k.startswith('JSONSCHEMAS_'):
                app.config.setdefault(k, getattr(config, k))

        host_setting = app.config['JSONSCHEMAS_HOST']
        if not host_setting or host_setting == 'localhost':
            app.logger.warning('JSONSCHEMAS_HOST is set to {0}'.format(
                host_setting))
740373
def setup_argument_parser():
    
    default_config_path = filesystem.get_default_config_path()
    filesystem.create_path(default_config_path)

    parser = core_singletons.argument_parser
    parser.add_argument('-o', '--open', type=parse_state_machine_path, dest='state_machine_path', metavar='path',
                        nargs='+', help="specify directories of state-machines that shall be opened. The path must "
                                        "contain a statemachine.json file")
    parser.add_argument('-c', '--config', type=config_path, metavar='path', dest='config_path',
                        default=default_config_path, nargs='?', const=default_config_path,
                        help="path to the configuration file config.yaml. Use 'None' to prevent the generation of "
                             "a config file and use the default configuration. Default: {0}".format(default_config_path))
    parser.add_argument('-r', '--remote', action='store_true', help="remote control mode")
    parser.add_argument('-s', '--start_state_path', metavar='path', dest='start_state_path', default=None, nargs='?',
                        help="path within a state machine to the state that should be launched. The state path "
                             "consists of state ids (e.g. QPOXGD/YVWJKZ whereof QPOXGD is the root state and YVWJKZ "
                             "it's child state to start from).")
    return parser
662895
def _setup_states(state_definitions, prev=()):
    """"""
    states = list(prev)
    for state_def in state_definitions:
        if len(state_def) != 2:
            raise TypeError(
                "The 'state' attribute of a workflow should be "
                "a two-tuple of strings; got %r instead." % (state_def,)
            )
        name, title = state_def
        state = State(name, title)
        if any(st.name == name for st in states):
            # Replacing an existing state
            states = [state if st.name == name else st for st in states]
        else:
            states.append(state)
    return StateList(states)
679715
public function parseConfig(array $configs)
    {
        foreach ($configs as &$config) {
            $config['states'] = $this->parseStates($config['states']);

            if (isset($config['callbacks'])) {
                $config['callbacks'] = $this->parseCallbacks($config['callbacks']);
            }
        }

        return $configs;
    }
763362
def cli(config, configfile, verbose):
    """"""
    config.verbose = verbose
    config.configfile = configfile
    if not os.path.isfile(configfile):
        state.write(configfile, {})
131202
def state(self, state):
        """"""
        state = state.lower()
        if state not in valid_states:
            raise ValueError("Build state must have a value from:\n{}".format(", ".join(valid_state)))

        self.obj['state'] = state
        self.changes.append("Updating build:{}.state={}"
                            .format(self.obj['name'], state))
        return self
1333588
def setup(self, app):
        """"""
        super().setup(app)

        self.enabled = len(self.cfg.backends)

        self.default = self.cfg.default
        if not self.default and self.enabled:
            self.default = self.cfg.backends[0][0]

        self.backends_hash = {name: parse.urlparse(loc) for (name, loc) in self.cfg.backends}
        if self.default and self.default not in self.backends_hash:
            raise PluginException('Backend not found: %s' % self.default)
1010259
def init_config(self, app):
        """"""
        for k in dir(config):
            if k.startswith('OAUTHCLIENT_'):
                app.config.setdefault(k, getattr(config, k))

        @app.before_first_request
        def override_template_configuration():
            """Override template configuration."""
            template_key = app.config.get(
                'OAUTHCLIENT_TEMPLATE_KEY',
                'SECURITY_LOGIN_USER_TEMPLATE'  # default template key
            )
            if template_key is not None:
                template = app.config[template_key]  # keep the old value
                app.config['OAUTHCLIENT_LOGIN_USER_TEMPLATE_PARENT'] = template
                app.config[template_key] = app.config.get(
                    'OAUTHCLIENT_LOGIN_USER_TEMPLATE',
                    'invenio_oauthclient/login_user.html'
                )
227780
def setConfiguration(self, configuration):
        
        """
        if isinstance(configuration, Configuration):
           configuration = configuration.value

        self.dev.set_configuration(configuration)
1020482
def _gather_config_parms(self, is_provider_vlan, vlan_id):
        """"""
        if is_provider_vlan:
            auto_create = cfg.CONF.ml2_cisco.provider_vlan_auto_create
            auto_trunk = cfg.CONF.ml2_cisco.provider_vlan_auto_trunk
        else:
            auto_create = True
            auto_trunk = True
        return auto_create, auto_trunk