def write(self, path=None): if not path: fobj = strfile() else: fobj = file(path, 'w') PrettyPrint(self.doc, fobj) if not path: fobj.seek(0) return fobj.read()
def new_script(self, name): if self.script.get(name) is not None: dialogs.Message('script exists') raise Error, 'script exists' tmp = strfile() self.script.insert_script(name, tmp) self.append_script(name) tmp.close() self.edit_script(None, name, None)
def parse_configdb(path): cf = file(path).read() return map(rfc822.Message, [strfile(x + '\n') for x in cf.split('\n\n')[:-1]])
def scriptfile(self, name): return strfile(self.scriptdata(name))
def templatefile(self, package, template): return strfile(self.templatedata(package, template))
def get_strfile(self, id): return strfile(self.get_data(id))
def insert_data(self, data): md5 = md5sum(strfile(data)) md5size = '_'.join([md5, str(len(data))]) return self._insert_data(md5size, data)
def save_template(self): template_path = 'in database' package, template = self.package, self.template data = strfile(self.workspace.get_text()) self.traittemplate.save_template(package, template, data) dialogs.Message('saved %s in\n%s' % (template, template_path))