Exemple #1
0
 def addTemplate(self, task):
     handle, filename = tempfile.mkstemp('.tsktmpl', dir=self._path)
     os.close(handle)
     templateFile = file(filename, 'w')
     writer = TemplateXMLWriter(templateFile)
     writer.write(task.copy())
     templateFile.close()
     theTask = TemplateXMLReader(file(filename, 'rU')).read()
     self._templates.append((theTask, os.path.split(filename)[-1]))
     return theTask
 def addTemplate(self, task):
     handle, filename = tempfile.mkstemp('.tsktmpl', dir=self._path)
     os.close(handle)
     templateFile = file(filename, 'w')
     writer = TemplateXMLWriter(templateFile)
     writer.write(task.copy())
     templateFile.close()
     theTask = TemplateXMLReader(file(filename, 'rU')).read()
     self._templates.append((theTask, os.path.split(filename)[-1]))
     return theTask
    def save(self):
        pickle.dump([name for task, name in self._templates], file(os.path.join(self._path, 'list.pickle'), 'wb'))

        for task, name in self._templates:
            templateFile = file(os.path.join(self._path, name), 'w')
            writer = TemplateXMLWriter(templateFile)
            writer.write(task)
            templateFile.close()

        for task, name in self._toDelete:
            os.remove(os.path.join(self._path, name))
        self._toDelete = []
        pub.sendMessage('templates.saved')
Exemple #4
0
    def save(self):
        pickle.dump([name for task, name in self._templates],
                    file(os.path.join(self._path, 'list.pickle'), 'wb'))

        for task, name in self._templates:
            templateFile = file(os.path.join(self._path, name), 'w')
            writer = TemplateXMLWriter(templateFile)
            writer.write(task)
            templateFile.close()

        for task, name in self._toDelete:
            os.remove(os.path.join(self._path, name))
        self._toDelete = []
        pub.sendMessage('templates.saved')