writes the templates read from the rules document
546180
def process_rules(self, path: Path, system: System):
        """"""
        self.context.update({
            'system': system,
        })
        document = FileSystem.load_yaml(path, required=True)
        for module, rules in document.items():
            click.secho('process: {0}'.format(module), fg='green')
            self._process_rules(rules, system)
793446
def template(colors, input_file, output_file=None):
    """"""
    template_data = util.read_file_raw(input_file)

    try:
        template_data = "".join(template_data).format(**colors)
    except ValueError:
        logging.error("Syntax error in template file '%s'.", input_file)
        return

    util.save_file(template_data, output_file)
1138550
def write_template_file(source, target, content):
    """"""

    # print(formatTemplateFile(source, content))
    print(target)
    data = format_template_file(source, content)
    with open(target, 'w') as f:
        for line in data:
            if type(line) != str:
                line = line.encode('utf-8')
            f.write(line)
757619
def write_report(self, force=False):
        '''
        
        '''
        path = self.title + '.html'
        value = self._template.format(
            title=self.title, body=self.body, sidebar=self.sidebar)
        write_file(path, value, force=force)
        plt.ion()
659277
function writeFileSync(templateName, templateOption, filename) {
  var templateString = fs.readFileSync(path.join(__dirname, '/templates/' + templateName), 'utf8');
  fs.writeFileSync(path.join(projectDirectory, filename), Mustache.render(templateString, templateOption));
}
1124661
private List<OutputFile> processTemplates(List<TemplateFile> inputs) throws IOException {
    List<OutputFile> outputs = new ArrayList<>();
    for (TemplateFile f : inputs) {
      String fileName = f.getFileName();
      if (!fileName.contains("VType") && fileName.contains("KType")) {
        for (Type ktype : Type.values()) {
          TemplateOptions options = new TemplateOptions(ktype);
          options.templateFile = f.path;
          generate(f, outputs, options);
        }
      }
      if (fileName.contains("KTypeVType")) {
        for (Type ktype : Type.values()) {
          for (Type vtype : Type.values()) {
            TemplateOptions options = new TemplateOptions(ktype, vtype);
            options.templateFile = f.path;
            generate(f, outputs, options);
          }
        }
      }
    }
    return outputs;
  }
372922
def write(models, out=None, base=None, propertybase=None, shorteners=None, logger=logging):
    '''
    
    '''
    assert out is not None #Output stream required
    if not isinstance(models, list): models = [models]
    shorteners = shorteners or {}

    all_propertybase = [propertybase] if propertybase else []
    all_propertybase.append(VERSA_BASEIRI)

    if any((base, propertybase, shorteners)):
        out.write('# @docheader\n\n* @iri:\n')
    if base:
        out.write('    * @base: {0}'.format(base))
    #for k, v in shorteners:
    #    out.write('    * @base: {0}'.format(base))

    out.write('\n\n')

    origin_space = set()
    #base_out = models[0].base
    for m in models:
        origin_space.update(all_origins(m))

    for o in origin_space:
        out.write('# {0}\n\n'.format(o))
        for o_, r, t, a in m.match(o):
            abbr_r = abbreviate(r, all_propertybase)
            value_format(t)
            out.write('* {0}: {1}\n'.format(abbr_r, value_format(t)))
            for k, v in a.items():
                abbr_k = abbreviate(k, all_propertybase)
                out.write('    * {0}: {1}\n'.format(k, value_format(v)))

        out.write('\n')
    return
1131018
public void writeTo(Writer writer) throws IOException {
        JsonSerializer.write(Json.jObject("template", asJson()), writer);
        writer.flush();
    }
349192
protected function writeMainExceptionTemplate()
	{
		$data = $this->mainExceptionData;

		$filePath = $this->outputPath . DIRECTORY_SEPARATOR . 'Exceptions' . DIRECTORY_SEPARATOR . 'ApiException.php';

		if (!is_null($this->outputInterface)) {
			$this->outputInterface->writeln('<info>Writing ' . $filePath . '</info>');
		}

		file_put_contents($filePath, $this->mainExceptionTemplate->render($data));
	}
1166401
def _par_write(self, dirname):
        
        filename = dirname + '/' + 'template_parameters.csv'
        with open(filename, 'w') as parfile:
            for template in self.templates:
                for key in template.__dict__.keys():
                    if key not in ['st', 'event']:
                        parfile.write(key + ': ' +
                                      str(template.__dict__[key]) + ', ')
                parfile.write('\n')
        return self
937478
def write(models, csvout, rulelist, write_header, base=None, logger=logging):
    '''
    
    '''
    properties = [ k for (k, v) in rulelist ]
    numprops = len(properties)
    headers = [ v for (k, v) in rulelist ]
    if write_header:
        csvout.writerow(['id', 'type'] + headers)

    rules = { k: v for (k, v) in rulelist }

    if not isinstance(models, list): models = [models]
    for m in models:
        mapped = omap(m)
        for o, props in mapped.items():
            rtypes = list(map(operator.itemgetter(0), props.get(RDF_TYPE_REL, [])))
            if not rtypes: continue
            #print('RES TYPES:', rtypes)
            row = [o, fromlist(rtypes)] + [None] * numprops
            for ix, p in enumerate(properties):
                v = list(map(operator.itemgetter(0), props.get(p, [])))
                if v:
                    row[ix + 2] = fromlist(v)
                    csvout.writerow(row)

    return
640499
public static void write(final String templateFilename, final Map<String, Object> data,
            final Writer writer) {
        Template tmpl = null;
        try {
            /*-
             * note that we don't need to cache templates by ourselves since getTemplate() does that internally already
             */
            tmpl = conf.getTemplate(templateFilename);
        } catch (FileNotFoundException e1) {
            String errMsg = "FileNotFoundException: template file '" + templateFilename
                    + "' not found";
            log.error("{}: {}", errMsg, e1.getMessage());
            throw new AwsMockException(errMsg, e1);
        } catch (IOException e) {
            String errMsg = "IOException: failed to getTemplate (filename is " + templateFilename
                    + ")";
            log.error("{}: {}", errMsg, e.getMessage());
            throw new AwsMockException(errMsg, e);
        }

        try {
            tmpl.process(data, writer);
        } catch (TemplateException e) {
            StringBuilder dataDescription = new StringBuilder();

            if (null != data) {
                for (Map.Entry<String, Object> entry : data.entrySet()) {
                    dataDescription.append(entry.getKey() + " - " + entry.getValue()).append('\n');
                }
            }
            String errMsg = "TemplateException: failed to process template '" + templateFilename
                    + "', with data: "
                    + dataDescription.toString()
                    + " The probable cause could be un-matching of key-values for that template. ";
            log.error("{}: {}", errMsg, e.getMessage());
            throw new AwsMockException(errMsg, e);
        } catch (IOException e) {
            String errMsg = "IOException: failed to process template and write to writer. ";
            log.error("{}: {}", errMsg, e.getMessage());
            throw new AwsMockException(errMsg, e);
        }

    }
373493
def _process_rules(self, rules: dict, system: System):
        
        self._source = None # reset the template source
        if not self._shall_proceed(rules):
            return
        self.context.update(rules.get('context', {}))
        self.path = rules.get('path', '')
        self.source = rules.get('source', None)
        self._process_rule(rules.get('system', None), {'system': system})
        for module in system.modules:
            self._process_rule(rules.get('module', None), {'module': module})
            for interface in module.interfaces:
                self._process_rule(rules.get('interface', None), {'interface': interface})
            for struct in module.structs:
                self._process_rule(rules.get('struct', None), {'struct': struct})
            for enum in module.enums:
                self._process_rule(rules.get('enum', None), {'enum': enum})
243546
def write_template_to_file(conf, template_body):
    
    template_file_name = _get_stack_name(conf) + '-generated-cf-template.json'
    with open(template_file_name, 'w') as opened_file:
        opened_file.write(template_body)
    print('wrote cf-template for %s to disk: %s' % (
        get_env(), template_file_name))
    return template_file_name
33790
def _write_method(schema):
    
    def method(
        self,
        filename=None,
        schema=schema,
        id_col='uid',
        sequence_col='sequence',
        extra_data=None,
        alphabet=None,
        **kwargs):
        # Use generic write class to write data.
        return _write(
            self._data,
            filename=filename,
            schema=schema,
            id_col=id_col,
            sequence_col=sequence_col,
            extra_data=extra_data,
            alphabet=alphabet,
            **kwargs
        )
    # Update docs
    method.__doc__ = _write_doc_template(schema)
    return method
1317259
def write(self, module):
        

        modname = module.__name__

        # Based on code in generate_autosummary_docs in https://git.io/fxpJS
        ns = {}
        ns['members'] = dir(module)
        ns['functions'] = list(map(lambda x: x.__name__,
                                   get_module_functions(module)))
        ns['classes'] = list(map(lambda x: x.__name__,
                                 get_module_classes(module)))
        ns['exceptions'] = list(map(lambda x: x.__name__,
                                    get_module_exceptions(module)))
        ns['fullname'] = modname
        ns['module'] = modname
        ns['objname'] = modname
        ns['name'] = modname.split('.')[-1]
        ns['objtype'] = 'module'
        ns['underline'] = len(modname) * '='
        rndr = self.template.render(**ns)

        rstfile = os.path.join(self.outpath, modname + '.rst')
        with open(rstfile, 'w') as f:
            f.write(rndr)
56267
def run(self):
        """"""
        for rel_path in sorted(self.paths):
            file_path = join(self.data_dir, rel_path)
            self.minify(file_path)

        after = self.size_of(self.after_total)
        before = self.size_of(self.before_total)
        saved = self.size_of(self.before_total - self.after_total)

        template = '\nTotal: ' \
                   '\033[92m{}\033[0m -> \033[92m{}\033[0m. ' \
                   'Compressed: \033[92m{}\033[0m\n'

        print(template.format(before, after, saved))