[pitivi] etree: Split the serialization into a separate method.
- From: Edward Hervey <edwardrv src gnome org>
- To: svn-commits-list gnome org
- Subject: [pitivi] etree: Split the serialization into a separate method.
- Date: Fri, 17 Apr 2009 09:36:25 -0400 (EDT)
commit 04fd5edb9812b822ed8d66157dd0b443a92228c6
Author: Edward Hervey <bilboed bilboed com>
Date: Tue Apr 7 22:07:07 2009 +0200
etree: Split the serialization into a separate method.
This still allows the unit test to check the validity of the output.
---
pitivi/formatters/etree.py | 10 ++++++++--
tests/test_formatter.py | 9 ++++-----
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/pitivi/formatters/etree.py b/pitivi/formatters/etree.py
index 5e043bd..eab7c58 100644
--- a/pitivi/formatters/etree.py
+++ b/pitivi/formatters/etree.py
@@ -380,7 +380,14 @@ class ElementTreeFormatter(Formatter):
return element
- def _saveProject(self, project):
+ def _saveProject(self, project, location):
+ root = self._serializeProject(project)
+ f = file(location.split('file://')[1], "w")
+ indent(root)
+ f.write(tostring(root))
+ f.close()
+
+ def _serializeProject(self, project):
root = self._saveMainTag()
factories = project.sources.sources.values()
@@ -389,7 +396,6 @@ class ElementTreeFormatter(Formatter):
timeline_element = self._saveTimeline(project.timeline)
root.append(timeline_element)
-
return root
def _loadProject(self, element):
diff --git a/tests/test_formatter.py b/tests/test_formatter.py
index 2ca4ce6..1654567 100644
--- a/tests/test_formatter.py
+++ b/tests/test_formatter.py
@@ -22,12 +22,11 @@
from unittest import TestCase
from StringIO import StringIO
import gst
-from xml.etree.ElementTree import Element, SubElement, tostring
+from xml.etree.ElementTree import Element, SubElement
from pitivi.reflect import qual, namedAny
from pitivi.formatters.etree import ElementTreeFormatter, version, \
- ElementTreeFormatterSaveContext, ElementTreeFormatterLoadContext, \
- indent, tostring
+ ElementTreeFormatterContext, indent, tostring
from pitivi.stream import VideoStream, AudioStream
from pitivi.factories.file import FileSourceFactory
from pitivi.factories.test import VideoTestSourceFactory
@@ -297,7 +296,7 @@ class TestFormatterSave(TestCase):
project.timeline = timeline
project.sources.addFactory("meh", source1)
- element = self.formatter._saveProject(project)
+ element = self.formatter._serializeProject(project)
self.failUnlessEqual(element.tag, "pitivi")
self.failIfEqual(element.find("factories"), None)
@@ -498,7 +497,7 @@ class TestFormatterLoad(TestCase):
project.timeline = timeline
project.sources.addFactory("meh", source1)
- element = self.formatter._saveProject(project)
+ element = self.formatter._serializeProject(project)
self.failUnlessEqual(element.tag, "pitivi")
self.failIfEqual(element.find("factories"), None)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]