Initialize and create dry config file(s) inside current directory
764667
def init_current_directory():
    """"""
    settings_directory=project_path+'/.dry'
    settings_file=settings_directory+'/config.py'
    if os.path.isdir(settings_directory):
	# already initialized
	print("directory already initialized.")
	return
    # init
    os.makedirs(settings_directory)
    f = open(settings_file,'w')
    print(sample_config_file, file=f)
    f.close()
118871
def _setup_fun_config(self, fun_conf):
        '''
        
        '''
        conf = copy.deepcopy(self.config)
        conf['file_client'] = 'local'
        conf['fun'] = ''
        conf['arg'] = []
        conf['kwarg'] = {}
        conf['cache_jobs'] = False
        conf['print_metadata'] = False
        conf.update(fun_conf)
        conf['fun'] = conf['fun'].split(':')[-1]  # Discard typing prefix

        return conf
656110
def create_conf_file (self):
        """"""
        cmd_obj = self.distribution.get_command_obj("install")
        cmd_obj.ensure_finalized()
        # we have to write a configuration file because we need the
        # <install_data> directory (and other stuff like author, url, ...)
        # all paths are made absolute by cnormpath()
        data = []
        for d in ['purelib', 'platlib', 'lib', 'headers', 'scripts', 'data']:
            attr = 'install_%s' % d
            if cmd_obj.root:
                # cut off root path prefix
                cutoff = len(cmd_obj.root)
                # don't strip the path separator
                if cmd_obj.root.endswith(os.sep):
                    cutoff -= 1
                val = getattr(cmd_obj, attr)[cutoff:]
            else:
                val = getattr(cmd_obj, attr)
            if attr == 'install_data':
                cdir = os.path.join(val, "share", "linkchecker")
                data.append('config_dir = %r' % cnormpath(cdir))
            elif attr == 'install_lib':
                if cmd_obj.root:
                    _drive, tail = os.path.splitdrive(val)
                    if tail.startswith(os.sep):
                        tail = tail[1:]
                    self.install_lib = os.path.join(cmd_obj.root, tail)
                else:
                    self.install_lib = val
            data.append("%s = %r" % (attr, cnormpath(val)))
        self.distribution.create_conf_file(data, directory=self.install_lib)
        return self.get_conf_output()
39718
def setup_config(command, filename, section, vars):
    """"""
    confuri = "config:" + filename
    if ":" in section:
        confuri += "#" + section.rsplit(":", 1)[-1]
    conf = appconfig(confuri)

    load_environment(conf.global_conf, conf.local_conf)
386765
private function loadConfig() {
    drush_log(dt('Loading config paths.'), 'debug');
    $config_paths = [$this->getSiteDir()];

    // Find directories to scan for environment config files.
    // system, 'home.drush', 'drupal', 'custom'
    foreach ($this->contexts as $context) {
      if ($files = _drush_config_file($context, 'env')) {
        if (is_array($files)) {
          foreach ($files as $file) {
            $config_paths[] = dirname($file);
          }
        }
        else {
          $config_paths[] = dirname($files);
        }
      }
    }

    // Remove any empty values.
    $config_paths = array_filter($config_paths);

    // Flip the config list for proper hierarchy.
    $this->configPaths = array_reverse($config_paths);
    drush_log(dt('Loaded config paths.'), 'debug');
  }
1200318
def create_default_file(cls, data=None, mode=None):
        """"""
        filepath = cls.get_default_filepath()
        if not filepath:
            return False

        filename = os.path.basename(filepath)
        config = read_file(get_data_path(), filename)

        # Find and replace data in default config
        data = data or {}
        for k, v in six.iteritems(data):
            v = v or ""
            config = re.sub(
                r"^(%(key)s) =[ ]*$" % {"key": k},
                "%(key)s = %(value)s" % {"key": k, "value": v},
                config,
                flags=re.MULTILINE,
            )

        dirpath = os.path.dirname(filepath)
        if not os.path.exists(dirpath):
            os.makedirs(dirpath)
        with click.open_file(filepath, "w+") as f:
            f.write(config)

        if mode is not None:
            os.chmod(filepath, mode)

        return True
205517
def create_config_files(ctx, opts, api_key):
    """"""
    # pylint: disable=unused-argument
    config_reader = opts.get_config_reader()
    creds_reader = opts.get_creds_reader()
    has_config = config_reader.has_default_file()
    has_creds = creds_reader.has_default_file()

    if has_config and has_creds:
        create = False
    else:
        click.echo()
        create = click.confirm(
            "No default config file(s) found, do you want to create them?"
        )

    click.echo()
    if not create:
        click.secho(
            "For reference here are your default config file locations:", fg="yellow"
        )
    else:
        click.secho(
            "Great! Let me just create your default configs for you now ...", fg="green"
        )

    configs = (
        ConfigValues(reader=config_reader, present=has_config, mode=None, data={}),
        ConfigValues(
            reader=creds_reader,
            present=has_creds,
            mode=stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP,
            data={"api_key": api_key},
        ),
    )

    has_errors = False
    for config in configs:
        click.echo(
            "%(name)s config file: %(filepath)s ... "
            % {
                "name": click.style(config.reader.config_name.capitalize(), bold=True),
                "filepath": click.style(
                    config.reader.get_default_filepath(), fg="magenta"
                ),
            },
            nl=False,
        )

        if not config.present and create:
            try:
                ok = config.reader.create_default_file(
                    data=config.data, mode=config.mode
                )
            except (OSError, IOError) as exc:
                ok = False
                error_message = exc.strerror
                has_errors = True

            if ok:
                click.secho("CREATED", fg="green")
            else:
                click.secho("ERROR", fg="red")
                click.secho(
                    "The following error occurred while trying to "
                    "create the file: %(message)s"
                    % {"message": click.style(error_message, fg="red")}
                )
            continue

        click.secho("EXISTS" if config.present else "NOT CREATED", fg="yellow")

    return create, has_errors
623834
def load_config(force_default=False):
    '''
    '''
    def _load(cdir, recurse=False):
      confl = os.path.join(cdir, CONFIG_FNAME)
      try:
        with open(confl, 'r') as fp:
          conf = yaml.safe_load(fp)
          if type(conf) is not dict:
            raise InvalidConfiguration('Configuration at %s is not a dictionary.' % confl)
          return conf
      except EnvironmentError:
        parent = os.path.dirname(cdir)
        if recurse and parent != cdir:
          return _load(parent, recurse=True)
        else:
          return dict()
      except yaml.YAMLError:
        raise InvalidConfiguration('Configuration at %s is an invalid YAML file.' % confl)

    def _update(prev, next):
      for k, v in next.items():
        if isinstance(v, dict):
          prev[k] = _update(prev.get(k, {}), v)
        else:
          prev[k] = v
      return prev

    conf = _load(os.path.dirname(__file__))

    if not force_default:
      home_conf = _load(os.path.expanduser('~'))
      local_conf = _load(os.path.abspath(os.curdir), recurse=True)

      _update(conf, home_conf)
      _update(conf, local_conf)
    return conf
847386
def _download_initial_config(self):
        """"""
        _initial_config = self._download_running_config()  # this is a bit slow!
        self._last_working_config = _initial_config
        self._config_history.append(_initial_config)
        self._config_history.append(_initial_config)
863214
def initialize_configs
      config_dir = root.join(DEFAULT_CONFIG_DIR_NAME)

      CONFIGS.each do |name, klass|
        instance_variable_set(:"@#{name}", klass.new(config_dir))
      end
    end
66338
def init_config(self):
        """"""

        input_fpath = os.path.join(self.work_path, 'input.nml')

        input_nml = f90nml.read(input_fpath)

        if self.expt.counter == 0 or self.expt.repeat_run:
            input_type = 'n'
        else:
            input_type = 'r'
        input_nml['MOM_input_nml']['input_filename'] = input_type

        f90nml.write(input_nml, input_fpath, force=True)
529338
function init(config) {
  var hydroConfig = config.hydro || {};
  var hydroJs = hydroConfig.path || dirname(dirname(require.resolve('hydro'))) + '/dist/hydro.js';
  var before = hydroConfig.before || [];

  config.files.unshift(createPattern(__dirname + '/adapter.js'));
  config.files.unshift(createPattern(hydroJs));

  before.reverse().forEach(function(file) {
    config.files.unshift(createPattern(path.resolve(file)));
  });
}
1065104
def init():
    ''''''
    # Load values from config file
    config_file = os.path.realpath(os.path.join(os.getcwd(), 'swaggery.ini'))
    config = configparser.RawConfigParser(allow_no_value=True)
    config.read(config_file)
    log_level = config.get('application', 'logging_level').upper()
    api_dirs = list(config['apis'])
    do_checks = config.get('application',
                           'disable_boot_checks').lower() == 'false'
    # Set logging level
    log.setLevel(getattr(logging, log_level))
    log.debug('Log level set to {}'.format(log_level))
    # Bootstrap application
    log.debug('Exploring directories: {}'.format(api_dirs))
    application = Swaggery(api_dirs=api_dirs, do_checks=do_checks)
    return application
1073217
def generate_configurations(*, guided=False, fresh_start=False, save=False):
    

    if fresh_start:
        purge_configs()

    loaded_status, loaded_data = get_config()
    if loaded_status != CONFIG_VALID:
        if save:
            make_config_file(guided=guided)
            status, config_data = get_config()
        else:
            config_data = make_config_data(guided=guided)
    else:
        config_data = loaded_data

    return config_data
168428
def _create_main_config(cls, overrides=None):
        """"""
        filepaths = []
        filepaths.append(get_module_root_config())
        filepath = os.getenv("REZ_CONFIG_FILE")
        if filepath:
            filepaths.extend(filepath.split(os.pathsep))

        filepath = os.path.expanduser("~/.rezconfig")
        filepaths.append(filepath)

        return Config(filepaths, overrides)
1099866
def create(file_path):
    """"""
    if os.path.exists(file_path):
        raise IOError("There is already a configuration file at %s" %
                      file_path)
    with open(file_path, 'w') as f:
        config = configparser.ConfigParser()
        config.add_section('misc')
        config.set('misc', 'config-version', '1.0')
        default_nb_name = os.path.split(os.path.dirname(file_path))[1]
        config.set('misc', 'nb-name', default_nb_name)
        config.add_section('root')
        config.set('root', 'path', '.')
        config.add_section('models')
        config.set('models', 'module', 'models')
        config.add_section('tests')
        config.set('tests', 'module', 'tests')
        config.add_section('suites')
        config.set('suites', 'module', 'suites')
        config.write(f)
748686
def init():
    """"""
    default_config_path = path.join(
        (os.environ.get('TLDR_CONFIG_DIR') or path.expanduser('~')),
        '.tldrrc')
    if path.exists(default_config_path):
        click.echo("There is already a config file exists, "
                   "skip initializing it.")
    else:
        repo_path = click.prompt("Input the tldr repo path(absolute path)")
        if not path.exists(repo_path):
            sys.exit("Repo path not exist, clone it first.")

        platform = click.prompt("Input your platform(linux, osx or sunos)")
        if platform not in ['linux', 'osx', 'sunos']:
            sys.exit("Platform should be in linux, osx or sunos.")

        colors = {
            "description": "blue",
            "usage": "green",
            "command": "cyan"
        }

        config = {
            "repo_directory": repo_path,
            "colors": colors,
            "platform": platform
        }
        with open(default_config_path, 'w') as f:
            f.write(yaml.safe_dump(config, default_flow_style=False))

        click.echo("Initializing the config file at {0}".format(
            default_config_path))