Called by ``self.write_config``, this returns the text content
        for the config file, given the provided variables.
176152
def config_content(self, command, vars):
        
        settable_vars = [
                var('db_url', 'Database url for sqlite, postgres or mysql', 
                    default='sqlite:///%(here)s/studio.db'),
                var('ms_url','Url to the mapserv CGI',
                    default='http://localhost/cgi-bin/mapserv'),
                var('admin_password','Password for default admin user',
                    default=secret.secret_string(length=8))
        ]

        for svar in settable_vars:
            if command.interactive:
                prompt = 'Enter %s' % svar.full_description()
                response = command.challenge(prompt, svar.default, svar.should_echo)
                vars[svar.name] = response
            else:
                if not vars.has_key(svar.name):
                    vars[svar.name] = svar.default

        vars['cookie_secret'] = secret.secret_string()

        # call default pylons install
        return super(StudioInstaller, self).config_content(command, vars)
1048927
def get_variables(self):
        
        variables = [variable.find('NAME').text for variable in self.network.findall('VARIABLE')]
        return variables
1032388
def get_variables(self) -> Set[str]:
        
        variables = set()
        for cmd in self._cmd:
            for var in self.__formatter.parse(cmd):
                logger.debug("Checking variable: %s", var)
                # creates and requires are special class values
                if var[1] is not None and var[1] not in ["creates", "requires"]:
                    variables.add(var[1])
        return variables
1157532
def write(self, config_dir=None, config_name=None, codec=None):
        
        # get name of config directory
        if not config_dir:
            config_dir = self._meta_config_dir
            if not config_dir:
                raise IOError("config_dir not set")

        # get name of config file
        if not config_name:
            config_name = self._defaults.get('config_name', None)
        if not config_name:
            raise KeyError('config_name not set')

        if codec:
            codec = munge.get_codec(codec)()
        else:
            codec = munge.get_codec(self._defaults['codec'])()

        config_dir = os.path.expanduser(config_dir)
        if not os.path.exists(config_dir):
            os.mkdir(config_dir)

        codec.dumpu(self.data, os.path.join(config_dir, 'config.' + codec.extension))
331350
def writeConfig(self):
        
        with self.writeSharedFileStream('config.pickle', isProtected=False) as fileHandle:
            pickle.dump(self.__config, fileHandle, pickle.HIGHEST_PROTOCOL)
1326266
def write_config(filename, config, mode="w"):
    '''
    '''
    with open(filename, mode) as filey:
        config.write(filey)
    return filename
1327970
def set_config_variables(repo, variables):
    
    with repo.config_writer() as writer:
        for k, value in variables.items():
            section, option = k.split('.')
            writer.set_value(section, option, value)
        writer.release()
560437
def parse_input_file(text, variables=None):
    
    text = find_includes(text)
    lines = text.splitlines()
    tasks, linenumbers = find_tasks(lines)
    preamble = [line for line in lines[:linenumbers[0]]]
    logging.debug("Preamble:\n{}".format("\n".join(preamble)))
    if variables is not None:
        preamble += "\n" + "\n".join(variables)
    environment = create_environment(preamble)
    code_sections = []
    for n in range(len(linenumbers) - 1):
        code_sections.append((linenumbers[n], linenumbers[n+1]))
    for n, task in zip(code_sections, tasks):
        task["code"] = lines[n[0]: n[1]]
        task["environment"] = environment
    clean_tasks = []
    for task in tasks:
        clean_tasks.append(Task(**task))
    return clean_tasks
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))
666903
def write_config_file(self, f, comments):
        
        if comments:
            f.write("#####################################\n")
            f.write("# Section : ")
            f.write("#".join(self.get_representation()) + "\n")
            f.write("#####################################\n")
        f.write("[" + self._name + "]\n")
        if self._desc and comments:
            f.write("# Description : ")
            for i in self._desc.split('\n'):
                f.write("# ")
                f.write(i)
                f.write("\n")
            f.write("\n")
236817
def _WritesString(self, content):
    
    content_bytes = codecs.encode(content, 'utf-8')
    self._sample_file.write(content_bytes)
1177886
def write_data(self, variable_id, value, task):
        
        if variable_id not in self.variables:
            return False

        if not self.variables[variable_id].writeable:
            return False

        if self.variables[variable_id].modbusvariable.function_code_read == 3:
            # write register
            if 0 <= self.variables[variable_id].modbusvariable.address <= 65535:

                if self._connect():
                    if self.variables[variable_id].get_bits_by_class() / 16 == 1:
                        # just write the value to one register
                        self.slave.write_register(self.variables[variable_id].modbusvariable.address, int(value),
                                                  unit=self._unit_id)
                    else:
                        # encode it first
                        self.slave.write_registers(self.variables[variable_id].modbusvariable.address,
                                                   list(self.variables[variable_id].encode_value(value)),
                                                   unit=self._unit_id)
                    self._disconnect()
                    return True
                else:
                    logger.info("device with id: %d is now accessible" % self.device.pk)
                    return False
            else:
                logger.error('Modbus Address %d out of range' % self.variables[variable_id].modbusvariable.address)
                return False
        elif self.variables[variable_id].modbusvariable.function_code_read == 1:
            # write coil
            if 0 <= self.variables[variable_id].modbusvariable.address <= 65535:
                if self._connect():
                    self.slave.write_coil(self.variables[variable_id].modbusvariable.address, bool(value),
                                          unit=self._unit_id)
                    self._disconnect()
                    return True
                else:
                    logger.info("device with id: %d is now accessible" % self.device.pk)
                    return False
            else:
                logger.error('Modbus Address %d out of range' % self.variables[variable_id].modbusvariable.address)
        else:
            logger.error('wrong type of function code %d' %
                         self.variables[variable_id].modbusvariable.function_code_read)
            return False
955983
def write_config(configfile, content):
    
    with open(configfile, 'w+') as ymlfile:
        yaml.dump(
            content,
            ymlfile,
            default_flow_style=False,
        )
685371
def _write_config_file(items, global_vars, template, project_name, out_dir,
                       remotes):
    
    config_dir = utils.safe_makedir(os.path.join(out_dir, "config"))
    out_config_file = os.path.join(config_dir, "%s.yaml" % project_name)
    out = {"fc_name": project_name,
           "upload": {"dir": "../final"},
           "details": items}
    if remotes.get("base"):
        r_base = objectstore.parse_remote(remotes.get("base"))
        out["upload"]["method"] = r_base.store
        out["upload"]["bucket"] = r_base.bucket
        out["upload"]["folder"] = os.path.join(r_base.key, "final") if r_base.key else "final"
        if r_base.region:
            out["upload"]["region"] = r_base.region
    if global_vars:
        out["globals"] = global_vars
    for k, v in template.items():
        if k not in ["details"]:
            out[k] = v
    if os.path.exists(out_config_file):
        shutil.move(out_config_file,
                    out_config_file + ".bak%s" % datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S"))
    with open(out_config_file, "w") as out_handle:
        yaml.safe_dump(out, out_handle, default_flow_style=False, allow_unicode=False)
    return out_config_file
290676
def _load_from_configs(self, filename):
    
    config_filename = os.path.join(self._config_path, filename)
    if os.path.exists(config_filename):
      try:
        f = open(config_filename, 'r')
        content = ''.join(f.readlines())
        f.close()
        return content
      except Exception as err:
        raise err
    else:
      raise IOError("File not found: {}".format(config_filename))
296626
def get_variable_str(self):
        
        if self.var_name is None:
            prefix = ''
        else:
            prefix = self.var_name

        suffix = str(self.var_value)
        if len(suffix) == 0:
            suffix = "''"
        elif len(suffix) > self.__max_str_length_displayed__:
            suffix = ''

        if len(prefix) > 0 and len(suffix) > 0:
            return prefix + '=' + suffix
        else:
            return prefix + suffix
1061322
def _write_config(config, newlines=2):
    '''
    
    '''
    text = config
    if isinstance(config, dict) and len(list(list(config.keys()))) == 1:
        key = next(six.iterkeys(config))
        text = config[key]

    try:
        with salt.utils.files.fopen(__SYSLOG_NG_CONFIG_FILE, 'a') as fha:
            fha.write(salt.utils.stringutils.to_str(text))

            for _ in range(0, newlines):
                fha.write(salt.utils.stringutils.to_str(os.linesep))
        return True
    except Exception as err:
        log.error(six.text_type(err))
        return False