def write_file(self, file_path):
        tar = Tarball(file_path, 'w')

        self._main_area.update_save()
        manifest = self.serialize_to_xml(self._main_area.save,
                self._main_area.element)
        tar.write('MANIFEST', manifest)
        self._main_area.save_thyself(tar)

        tar.close()
    def read_file(self, file_path):
        tar = Tarball(file_path)

        doc = dom.parseString(tar.read(tar.getnames()[0]))
        top_element = doc.documentElement

        self.set_title(top_element.getAttribute("title"))
        self._mode = int(top_element.getAttribute("mode"))

        self._main_area.set_mode(self._mode)
        self._main_area.load_thyself(top_element, doc, tar)

        if top_element.hasAttribute("scale_factor"):
            fac = float(top_element.getAttribute("scale_factor"))
            self._main_area.scale_fac = fac

        if top_element.hasAttribute("translation"):
            tmp = top_element.getAttribute("translation")
            x, y = utils.parse_coords(tmp)
            self._main_area.translation = [x, y]

        tar.close()
    def write_file(self, file_path):
        tar = Tarball(file_path, 'w')

        self._main_area.update_save()
        manifest = self.serialize_to_xml(self._main_area.save,
                self._main_area.element)
        tar.write('MANIFEST', manifest)
        self._main_area.save_thyself(tar)

        tar.close()
示例#4
0
    def read_file(self, file_path):
        tar = Tarball(file_path)

        doc = dom.parseString(tar.read(tar.getnames()[0]))
        top_element = doc.documentElement

        self.set_title(top_element.getAttribute("title"))
        self._mode = int(top_element.getAttribute("mode"))

        self._main_area.set_mode(self._mode)
        self._main_area.load_thyself(top_element, doc, tar)

        if top_element.hasAttribute("scale_factor"):
            fac = float(top_element.getAttribute("scale_factor"))
            self._main_area.scale_fac = fac

        if top_element.hasAttribute("translation"):
            tmp = top_element.getAttribute("translation")
            x, y = utils.parse_coords(tmp)
            self._main_area.translation = [x, y]

        tar.close()