Example #1
0
 def save(self):
     'Write schedule to disk.'
     self.filename = check_filename(self.title, self.filename)
     root = etree.Element("schedule")
     root.attrib["created"] = "0"
     root.attrib["modified"] = "0"
     node = etree.Element("title")
     node.text = self.title
     root.append(node)
     
     itr = self.get_iter_first()
     while itr:
         item = self.get_value(itr, 0)
         
         node = etree.Element("presentation")
         node2 = etree.Element("file")
         node2.text = item.filename
         node.append(node2)
         node2 = etree.Element("comment")
         node2.text = item.comment
         node.append(node2)
         root.append(node)
         itr = self.iter_next(itr)
     dom = etree.ElementTree(root)
     dom.write(self.filename, encoding=u'UTF-8')
Example #2
0
 def _save_changes(self, *args):
     """
     Saves the theme to a new file if it didn't exist,
     updates the file according to the theme name if it existed before.
     """
     #Metadata
     for key, value in self._meta.iteritems():
         if value.get_text() != "":
             self.theme.meta[key] = value.get_text()
     name = self._title_entry.get_text()
     self.theme.meta['title'] = name
     if not self.theme.filename:
         self.theme.filename = find_freefile(os.path.join(
                 DATA_PATH, 'theme', title_to_filename(name)+'.xml'))
     else:
         self.theme.filename = check_filename(name, os.path.join(
                 DATA_PATH, 'theme', self.theme.filename))
     self.theme.save()
     self._set_changed(False)