Update template file by path.
426619
public function update(TemplateRequest $request, $template)
    {
        try {
            $template = $request->template;
            $path = theme_path('views').$template;
            $content = $request->content;

            // Notify if file was not changed.
            if (\File::exists($path) and \File::get($path) == $content) {
                return response()->json([
                    'status' => false,
                    'message' => sprintf(__('msg.not_updated'), $template),
                ], 200);
            }

            \File::put($path, $content, true);

            return response()->json([
                'status' => true,
                'message' => sprintf(__('msg.updated'), $template),
                'file' => [
                    'size' => formatBytes(\File::size($path)),
                    'modified' => strftime('%Y-%m-%d %H:%M', \File::lastModified($path))
                ]
            ], 200);

        } catch (ValidationException $e) {
            $message = $e->validator->errors()->first();
            return response()->json(['status' => false, 'message' => $message], 200);
        } catch (\Exception $e) {
            $message = $e->getMessage();
            return response()->json(['status' => false, 'message' => $message], 404 );
        }
    }
689050
def in_path(self, new_path, old_path=None):
        """"""
        self.path = new_path
        try:
            yield
        finally:
            self.path = old_path
650454
def copy_template(template_name, copy_to, **options):
    """"""
    import django_extensions

    style = color_style()
    ERROR = getattr(style, 'ERROR', lambda x: x)
    SUCCESS = getattr(style, 'SUCCESS', lambda x: x)

    template_dir = os.path.join(django_extensions.__path__[0], 'conf', template_name)
    verbosity = options["verbosity"]

    # walks the template structure and copies it
    for d, subdirs, files in os.walk(template_dir):
        relative_dir = d[len(template_dir) + 1:]
        if relative_dir and not os.path.exists(os.path.join(copy_to, relative_dir)):
            os.mkdir(os.path.join(copy_to, relative_dir))
        for i, subdir in enumerate(subdirs):
            if subdir.startswith('.'):
                del subdirs[i]
        for f in files:
            if f.endswith('.pyc') or f.startswith('.DS_Store'):
                continue
            path_old = os.path.join(d, f)
            path_new = os.path.join(copy_to, relative_dir, f).rstrip(".tmpl")
            if os.path.exists(path_new):
                if verbosity > 1:
                    print(ERROR("%s already exists" % path_new))
                continue
            if verbosity > 1:
                print(SUCCESS("%s" % path_new))

            with open(path_old, 'r') as fp_orig:
                with open(path_new, 'w') as fp_new:
                    fp_new.write(fp_orig.read())

            try:
                shutil.copymode(path_old, path_new)
                _make_writeable(path_new)
            except OSError:
                sys.stderr.write("Notice: Couldn't set permission bits on %s. You're probably using an uncommon filesystem setup. No problem.\n" % path_new)
1191114
def add(self, path):
        '''
        
        '''
        with salt.utils.files.fopen(path, 'rb') as ifile:
            for chunk in iter(lambda: ifile.read(self.__buff), b''):
                self.__digest.update(chunk)
1188591
def _write_template(upgrade_file, name, depends_on, repository, auto=False):
    """"""
    if auto:
        # Ensure all models are loaded
        from invenio_db import models
        list(models)
        template_args = produce_upgrade_operations()
        operations_str = template_args['upgrades']
        import_str = template_args['imports']
    else:
        operations_str = "    pass"
        import_str = ""

    with open(upgrade_file, 'w') as f:
        f.write(UPGRADE_TEMPLATE % {
            'depends_on': depends_on,
            'repository': repository,
            'year': date.today().year,
            'operations': operations_str,
            'imports': import_str,
            'cls': ''.join(w.capitalize() or '_' for w in name.split('_'))
        })
650950
def refresh_plugin(self, new_path=None, force_current=True):
        """"""
        self.fileexplorer.treewidget.update_history(new_path)
        self.fileexplorer.treewidget.refresh(new_path,
                                             force_current=force_current)
585705
function loadTemplatesFiles (dir, files, options, templates) {
    // require files
    if (!Array.isArray(files)) {
        return Promise.resolve()
    }
    // load template for each file
    return Promise.each(files, file => {
        // get absolute file from dir
        var absFile = dir+'/'+file
        // get express template name by stripping off extension
        file = file.replace(GLOBAL.extRegExp, '')
        // if template has already been defined then do not replace so that
        // first incidence of file in multiple paths is used
        if (templates[file]) {
            return
        }
        // load template
        var promise = templates[file] = loadTemplate(absFile, options)
        // once template is loaded replace promise with template
        .then(template => {
            templates[file] = template
        })
        // wait for template to load
        return promise
    })
}
796148
public void updatedTemplate(Bundle bundle, File templateFile) {
        ThymeLeafTemplateImplementation template = getTemplateByFile(templateFile);
        if (template != null) {
            LOGGER.debug("Thymeleaf template updated for {} ({})", templateFile.getAbsoluteFile(), template.fullName());
            updatedTemplate();
        } else {
            try {
                addTemplate(bundle, templateFile.toURI().toURL());
            } catch (MalformedURLException e) { //NOSONAR
                // Ignored.
            }
        }
    }
120352
def update_readme(self, template_readme: Template):
        """"""
        readme = os.path.join(self.cached_repo, "README.md")
        if os.path.exists(readme):
            os.remove(readme)
        links = {model_type: {} for model_type in self.models.keys()}
        for model_type, model_uuids in self.models.items():
            for model_uuid in model_uuids:
                links[model_type][model_uuid] = os.path.join("/", model_type, "%s.md" % model_uuid)
        with open(readme, "w") as fout:
            fout.write(template_readme.render(models=self.models, meta=self.meta, links=links))
        git.add(self.cached_repo, [readme])
        self._log.info("Updated %s", readme)
1294854
public function update()
    {
        if (!file_exists(static::FILENAME)) {
            return;
        }

        $contents = Yaml::parse(file_get_contents(static::FILENAME)) ?: [];

        if (!isset($contents['paths'])) {
            return;
        }

        $originalPaths = $contents['paths'];
        $contents['paths'] = $newPaths = $this->updatePaths(new MutableBag($originalPaths))->toArray();

        if ($originalPaths === $newPaths) {
            return;
        }

        $this->save($contents);
    }
1350280
def update_payload(self, fields=None):
        """"""
        payload = super(ProvisioningTemplate, self).update_payload(fields)
        if 'template_combinations' in payload:
            payload['template_combinations_attributes'] = payload.pop(
                'template_combinations')
        return {u'provisioning_template': payload}
697622
def _update_aws_include_relative_path(template_dict, original_root, new_root):
    

    for key, val in template_dict.items():
        if key == "Fn::Transform":
            if isinstance(val, dict) and val.get("Name") == "AWS::Include":
                path = val.get("Parameters", {}).get("Location", {})
                updated_path = _resolve_relative_to(path, original_root, new_root)
                if not updated_path:
                    # This path does not need to get updated
                    continue

                val["Parameters"]["Location"] = updated_path

        # Recurse through all dictionary values
        elif isinstance(val, dict):
            _update_aws_include_relative_path(val, original_root, new_root)
        elif isinstance(val, list):
            for item in val:
                if isinstance(item, dict):
                    _update_aws_include_relative_path(item, original_root, new_root)

    return template_dict
238594
public function setTemplatePath(string $path = null, string $context = null) : self
    {
        if (empty($path)) {
            $this->templatePath = $this->getPath($context)['dirname'] . '/' . $this->getPath($context)['filename'];
        } elseif (substr($path, 0, 1) == '/') {
            $this->templatePath = $path;
        } else {
            $this->templatePath = $this->getPath($context)['dirname'] . '/' . $path;
        }

        return $this;
    }
1211074
def load_template(self, path):
        
        if not path.startswith('/'):
            for folder in self.options['template_folders']:
                fullpath = op.join(folder, path)
                if op.exists(fullpath):
                    path = fullpath
                    break
            else:
                raise JadeException('Template doesnt exist: %s' % path)

        with open(path, 'rb') as f:
            source = f.read().decode(self.options['encoding'])

        return ExtendCompiler(
            pyjade.parser.Parser(source).parse(), pretty=self.options['pretty'],
            env=self, compileDebug=True
        )
990619
def render_template(self):
        """"""
        self._parse_paths()
        context = dict(napp=self._napp.__dict__, paths=self._paths)
        self._save(context)
1354083
public function updateTemplateFiles($template_id, Template $request)
    {
      $params = $request->toUpdateParams();
      $response = $this->rest->post(
        static::TEMPLATE_UPDATE_FILES_PATH . '/' . $template_id,
        $params
      );

      return new Template($response);
    }
116127
def load_file_template(path):
    
    template = StringIO()
    if not os.path.exists(path):
        raise ValueError("path does not exist: %s" % path)
    with open(clean_path(path), "rb") as infile:  # opened as binary
        for line in infile:
            template.write(line.decode("utf-8"))  # ensure utf-8
    return template