Generate default config file
518103
def generate_config(directory):
    
    default_config = os.path.join(os.path.dirname(os.path.realpath(__file__)), "config.yml")
    target_config_path = os.path.abspath(os.path.join(directory, 'config.yml'))
    shutil.copy(default_config, target_config_path)
    six.print_("Config file has been generated in", target_config_path)
809818
def write_default_config_file(self, output, comments=True):
        
        if self.use_config_file:
            # pylint: disable-msg=W0621
            log = logging.getLogger('argtoolbox')
            with open(output, 'w') as f:
                if comments:
                    f.write("#####################################\n")
                    f.write("# Description :\n")
                    f.write("# -------------\n# ")
                    for i in self._desc.split('\n'):
                        f.write("# ")
                        f.write(i)
                        f.write("\n")
                    f.write("\n\n")

                for s in self.sections.values():
                    log.debug("loading section : " + s.get_section_name())
                    s.write_config_file(f, comments)
            log.debug("config file generation completed : " + str(output))
118428
function writeConfigFile(config, yoRcPath = '.yo-rc.json') {
  let newYoRc = { ...config };
  if (FileUtils.doesFileExist(yoRcPath)) {
    const yoRc = JSON.parse(fs.readFileSync(yoRcPath, { encoding: 'utf-8' }));
    newYoRc = {
      ...yoRc,
      ...config,
      [GENERATOR_NAME]: {
        ...yoRc[GENERATOR_NAME],
        ...config[GENERATOR_NAME]
      }
    };
  }
  fs.writeFileSync(yoRcPath, JSON.stringify(newYoRc, null, 2));
}
23351
def get_default_config(self):
        
        config = super(ArchiveHandler, self).get_default_config()

        config.update({
            'log_file': '',
            'when': 'midnight',
            'days': 7,
            'rollover_interval': 1,
            'encoding': None,
            'propagate': False,
        })

        return config
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()
1266908
public function GenerateConfigs()
    {
        // Variables used by some template files.
        $authors = \Peg\Lib\Settings::GetAuthors();
        $contributors = \Peg\Lib\Settings::GetContributors();
        $extension = \Peg\Lib\Settings::GetExtensionName();
        $version = \Peg\Lib\Settings::GetVersion();

        // Variable to temporarily store a template file content.
        $content = "";

        // Generate sources list
        $source_files = array(
            "src/functions.cpp",
            "src/references.cpp"
        );

        foreach($this->symbols->headers as $header_name=>$header_object)
        {
            if($header_object->enabled)
            {
                $source_files[] = "src/".$this->GetSourceNamePHP($header_name);
            }
        }

        // Generate custom sources list
        $custom_sources = $this->GetCustomSources();

        if(count($custom_sources) > 0)
        {
            foreach($custom_sources as $custom_source)
            {
                if($custom_source != "." && $custom_source != "..")
                {
                    if(
                        (strpos($custom_source, ".c") !== false)
                        ||
                        (strpos($custom_source, ".cpp") !== false)
                    )
                    {
                        $source_files[] = "src/".$custom_source;
                    }
                }
            }
        }

        $source_files = implode(" \\\n        ", $source_files);

        // Generate config.m4
        ob_start();
            include($this->GetGenericTemplate("config.m4", "configs"));
            $content = ob_get_contents();
        ob_end_clean();

        $this->AddGenericFile("config.m4", $content);

        // Generate config.w32
        ob_start();
            include($this->GetGenericTemplate("config.w32", "configs"));
            $content = ob_get_contents();
        ob_end_clean();

        $this->AddGenericFile("config.w32", $content);
    }
1084154
public function generateConfig()
    {
        if ($this->isSymfony4()) {
            return;
        }

        $configFile = $this->rootDir.'/app/config/config.yml';
        $config = file_get_contents($configFile);

        $data = Yaml::parse($config);
        if (!array_key_exists('white_october_pagerfanta', $data)) {
            $ymlData = "\n\nwhite_october_pagerfanta:";
            $ymlData .= "\n    default_view: twitter_bootstrap\n";
            file_put_contents($configFile, $ymlData, FILE_APPEND);
        }
    }
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)
1156557
def default_bundle_config():
    """"""

    import os
    from ambry.util import AttrDict

    config = AttrDict()
    f = os.path.join(
        os.path.dirname(
            os.path.realpath(__file__)),
        'bundle.yaml')

    config.update_yaml(f)

    return config
863150
def write_default_config(self, filename):
        
        try:
            with open(filename, 'wt') as file:
                file.write(DEFAULT_CONFIG)
            return True
        except (IOError, OSError) as e:
            print('Error writing %s: %s' % (filename, e.strerror or e), file=sys.stderr)
            return False
644165
def create_config_file(filename):
    
    import textwrap
    from six.moves.urllib import parse

    if not os.path.exists(filename):
        old_default_config_file = os.path.join(os.path.dirname(filename),
                                               '.tksrc')
        if os.path.exists(old_default_config_file):
            upgrade = click.confirm("\n".join(textwrap.wrap(
                "It looks like you recently updated Taxi. Some "
                "configuration changes are required. You can either let "
                "me upgrade your configuration file or do it "
                "manually.")) + "\n\nProceed with automatic configuration "
                "file upgrade?", default=True
            )

            if upgrade:
                settings = Settings(old_default_config_file)
                settings.convert_to_4()
                with open(filename, 'w') as config_file:
                    settings.config.write(config_file)
                os.remove(old_default_config_file)
                return
            else:
                print("Ok then.")
                sys.exit(0)

        welcome_msg = "Welcome to Taxi!"
        click.secho(welcome_msg, fg='green', bold=True)
        click.secho('=' * len(welcome_msg) + '\n', fg='green', bold=True)

        click.echo(click.wrap_text(
            "It looks like this is the first time you run Taxi. You will need "
            "a configuration file ({}) in order to proceed. Please answer a "
            "few questions to create your configuration file.".format(
                filename
            )
        ) + '\n')

        config = pkg_resources.resource_string('taxi', 'etc/taxirc.sample').decode('utf-8')
        context = {}
        available_backends = plugins_registry.get_available_backends()

        context['backend'] = click.prompt(
            "Backend you want to use (choices are %s)" %
            ', '.join(available_backends),
            type=click.Choice(available_backends)
        )
        context['username'] = click.prompt("Username or token")
        context['password'] = parse.quote(
            click.prompt("Password (leave empty if you're using"
                         " a token)", hide_input=True, default=''),
            safe=''
        )
        # Password can be empty in case of token auth so the ':' separator
        # is not included in the template config, so we add it if the user
        # has set a password
        if context['password']:
            context['password'] = ':' + context['password']

        context['hostname'] = click.prompt(
            "Hostname of the backend (eg. timesheets.example.com)",
            type=Hostname()
        )

        editor = Editor().get_editor()
        context['editor'] = click.prompt(
            "Editor command to edit your timesheets", default=editor
        )

        templated_config = config.format(**context)

        directory = os.path.dirname(filename)
        if not os.path.exists(directory):
            os.makedirs(directory)

        with open(filename, 'w') as f:
            f.write(templated_config)
    else:
        settings = Settings(filename)
        conversions = settings.needed_conversions

        if conversions:
            for conversion in conversions:
                conversion()

            settings.write_config()
188258
def make_config_file(guided=False):
    
    config_path = _make_config_location(guided=guided)

    config_data = make_config_data(guided=guided)

    write_config_file(config_path, config_data)
611894
def gen_code_api(self):
        """"""

        # edit config file

        conf_editor = Editor(self.conf_fpath)

        # insert code path for searching
        conf_editor.editline_with_regex(r'^# import os', 'import os')
        conf_editor.editline_with_regex(r'^# import sys', 'import sys')
        conf_editor.editline_with_regex(
            r'^# sys\.path\.insert',
            'sys.path.insert(0, "{}")'.format(self.code_fdpath))
        conf_editor.editline_with_regex(
            r"""html_theme = 'alabaster'""",
            'html_theme = \'default\''.format(self.code_fdpath))

        conf_editor.finish_writing()

        # sphinx-apidoc to generate rst from source code

        # force regenerate
        subprocess.call(self._sphinx_apidoc_cmd)

        pass
654418
def detect_config(self):
        """"""
        default_files = ("config.json", "config.yml")
        for file_ in default_files:
            if os.path.exists(file_):
                return file_
95685
def _setDefaults(self):
        

        for configName, configDict in self.configs.items():
            self._setConfig(configName, configDict['default'])
145898
def create_config_file(access_token, ssh_key_path, ssh_user, ssh_port, region, image, size, ssh_key, private_networking, backups_enabled, ip6, timeout)
      # Default SSH Key path
      ssh_key_path = File.join('~', DEFAULT_SSH_KEY_PATH) if ssh_key_path.empty?

      ssh_user = 'root' if ssh_user.empty?

      ssh_port = DEFAULT_SSH_PORT if ssh_port.empty?

      region = DEFAULT_REGION if region.empty?

      image = DEFAULT_IMAGE if image.empty?

      size = DEFAULT_SIZE if size.empty?

      default_ssh_key = DEFAULT_SSH_KEY if ssh_key.empty?

      if private_networking.empty?
        private_networking = DEFAULT_PRIVATE_NETWORKING
      end

      backups_enabled = DEFAULT_BACKUPS_ENABLED if backups_enabled.empty?

      ip6 = DEFAULT_IP6 if ip6.empty?

      timeout = DEFAULT_TIMEOUT if timeout.empty?

      require 'yaml'
      File.open(@path, File::RDWR | File::TRUNC | File::CREAT, 0o600) do |file|
        data = {
          'authentication' => {
            'access_token' => access_token
          },
          'connection' => {
            'timeout' => timeout
          },
          'ssh' => {
            'ssh_user' => ssh_user,
            'ssh_key_path' => ssh_key_path,
            'ssh_port' => ssh_port
          },
          'defaults' => {
            'region' => region,
            'image' => image,
            'size' => size,
            'ssh_key' => ssh_key,
            'private_networking' => private_networking,
            'backups_enabled' => backups_enabled,
            'ip6' => ip6
          }
        }
        file.write data.to_yaml
      end
    end
996000
def init_config_file_path_if_empty(self):
        

        if os.path.exists(self.cfg_directory_path):
            return

        user_choice = 'n'
        if self.no_confirm:
            user_choice = 'y'
        else:
            sys.stdout.write(
                "Config directory does not exist at '" + os.path.abspath(self.cfg_directory_path) + "'. "
                + "Should a default configuration be created at this path? [Y/n] ")
            if sys.version_info[0] < 3:
                user_choice = raw_input()
            else:
                user_choice = input()
            user_choice = user_choice.lower().replace("yes", "y").replace("no", "n")

        if not user_choice or user_choice == '':  # the default is yes
            user_choice = "y"
        if "y" not in user_choice and "n" not in user_choice:
            sys.stderr.write("Wrong input, aborting.")
            sys.exit(1)
        if "n" in user_choice:
            sys.stdout.write("Config file will not be created. Terminating.")
            sys.exit(1)

        # copy the default config file to the new path
        copy_tree(os.environ['CColon'] + os.path.sep + 'config', self.cfg_directory_path)
        return