def insert_new_template(self, package, template, path): newfile = readfile(path) filename = self.template_filename(package, template) makepaths(dirname(filename)) writefile(filename, newfile) try: self.traittemplate.insert_template( dict(package=package, template=template), file(path)) except OperationalError: dialogs.Message('template already exists') self.set_template(package, template) self.reset_rows()
def insert_new_template(self, package, template, path): newfile = readfile(path) filename = self.template_filename(package, template) makepaths(dirname(filename)) writefile(filename, newfile) try: self.traittemplate.insert_template(dict(package=package, template=template), file(path)) except OperationalError: dialogs.Message('template already exists') self.set_template(package, template) self.reset_rows()
def set_template(self, package, template): self.package = package self.template = template path = self.template_filename(package, template) print self.trait, 'self.trait' clause = Eq('trait', self.trait) & Eq('package', package) & Eq('template', template) print 'clause', clause template_text = self.traittemplate.templatedata(package, template) self.workspace.set_text(template_text) self.template_view.set_text(template_text) if self.extracted: path = join(self.trait_temp_path(), package, template) try: self.original_view.set_text(readfile(path)) except NoExistError: pass except IOError: pass
def set_template(self, package, template): self.package = package self.template = template path = self.template_filename(package, template) print self.trait, 'self.trait' clause = Eq('trait', self.trait) & Eq('package', package) & Eq( 'template', template) print 'clause', clause template_text = self.traittemplate.templatedata(package, template) self.workspace.set_text(template_text) self.template_view.set_text(template_text) if self.extracted: path = join(self.trait_temp_path(), package, template) try: self.original_view.set_text(readfile(path)) except NoExistError: pass except IOError: pass
def set_template(self, package, template): self.package = package self.template = template path = self.template_filename(package, template) clause = Eq('trait', self.trait) & Eq('package', package) & Eq('template', template) row = self.cmd.cmd.select(fields=['templatefile'], clause=clause)[0] filename = row.templatefile.name tfile = self.cmd.cmd.openfile(self.conn, filename) template_text = tfile.read() tfile.close() self.workspace.set_text(template_text) self.template_view.set_text(template_text) if self.extracted: path = join(self.trait_temp_path(), package, template) try: self.original_view.set_text(readfile(path)) except NoExistError: pass except IOError: pass
def parse(self): filename = join(self.source.distpath, 'Release') self.fields = email.message_from_string(readfile(filename)) self.sums = self._parse_md5sums(self.fields['md5sum'])
def parse_release(suite, path): filename = pjoin(path, DISTS, suite, 'Release') release = email.message_from_string(readfile(filename)) return release, parse_release_md5sums(release['md5sum'])
def _fill_from_path(self, path): self.__original_text__ = readfile(path) self.editor.set_text(copy(self.__original_text__))