Ejemplo n.º 1
0
 def save_to_xml(self, outfile):
     """Create a XML file that can be used by load_from_xml.
     outfile can be a file object or a filename."""
     root = ET.Element("exclude_list")
     # reversed in order to keep order of entries when reloading from xml later
     for item in reversed(self._excluded):
         exclude_node = ET.SubElement(root, "exclude")
         exclude_node.set("regex", str(item[0]))
         exclude_node.set("marked", ("y" if self.is_marked(item[0]) else "n"))
     tree = ET.ElementTree(root)
     with FileOrPath(outfile, "wb") as fp:
         tree.write(fp, encoding="utf-8")
Ejemplo n.º 2
0
    def save_to_xml(self, outfile):
        """Create a XML file that can be used by load_from_xml.

        outfile can be a file object or a filename.
        """
        root = ET.Element("ignore_list")
        for filename, subfiles in self._ignored.items():
            file_node = ET.SubElement(root, "file")
            file_node.set("path", filename)
            for subfilename in subfiles:
                subfile_node = ET.SubElement(file_node, "file")
                subfile_node.set("path", subfilename)
        tree = ET.ElementTree(root)
        with FileOrPath(outfile, "wb") as fp:
            tree.write(fp, encoding="utf-8")
Ejemplo n.º 3
0
    def save_to_file(self, outfile):
        """Save folder selection as XML to ``outfile``.

        :param file outfile: path or file pointer to XML file to save to.
        """
        with FileOrPath(outfile, "wb") as fp:
            root = ET.Element("directories")
            for root_path in self:
                root_path_node = ET.SubElement(root, "root_directory")
                root_path_node.set("path", str(root_path))
            for path, state in self.states.items():
                state_node = ET.SubElement(root, "state")
                state_node.set("path", str(path))
                state_node.set("value", str(state))
            tree = ET.ElementTree(root)
            tree.write(fp, encoding="utf-8")
Ejemplo n.º 4
0
    def save_to_file(self, outfile):
        """Save folder selection as XML to ``outfile``.

        :param file outfile: path or file pointer to XML file to save to.
        """
        with FileOrPath(outfile, 'wb') as fp:
            root = ET.Element('directories')
            for root_path in self:
                root_path_node = ET.SubElement(root, 'root_directory')
                root_path_node.set('path', str(root_path))
            for path, state in self.states.items():
                state_node = ET.SubElement(root, 'state')
                state_node.set('path', str(path))
                state_node.set('value', str(state))
            tree = ET.ElementTree(root)
            tree.write(fp, encoding='utf-8')
Ejemplo n.º 5
0
 def do_write(outfile):
     with FileOrPath(outfile, 'wb') as fp:
         tree.write(fp, encoding='utf-8')
Ejemplo n.º 6
0
 def do_write(outfile):
     with FileOrPath(outfile, "wb") as fp:
         tree.write(fp, encoding="utf-8")