[pitivi] Write filenames as utf-8 in the project file.



commit a864deab802295d53e45043eefe496ee2672d371
Author: Alessandro Decina <alessandro d gmail com>
Date:   Mon Apr 27 19:17:56 2009 +0200

    Write filenames as utf-8 in the project file.
    
    Fixes #579410.
---
 pitivi/formatters/etree.py |   10 +++++++++-
 pitivi/utils.py            |    4 ++++
 2 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/pitivi/formatters/etree.py b/pitivi/formatters/etree.py
index 142b6bb..189cef7 100644
--- a/pitivi/formatters/etree.py
+++ b/pitivi/formatters/etree.py
@@ -31,6 +31,7 @@ from pitivi.factories.file import FileSourceFactory
 from pitivi.timeline.track import Track, SourceTrackObject
 from pitivi.timeline.timeline import Timeline, TimelineObject
 from pitivi.formatters.base import Formatter
+from pitivi.utils import get_filesystem_encoding
 
 version = "0.1"
 
@@ -184,7 +185,14 @@ class ElementTreeFormatter(Formatter):
         return factory
 
     def _saveFileSourceFactory(self, element, source):
-        element.attrib["filename"] = source.filename
+        # FIXME: we should probably have a rule that we only deal with unicode
+        # strings in pitivi
+        if not isinstance(source.filename, unicode):
+            fs_encoding = get_filesystem_encoding()
+            filename = source.filename.decode(fs_encoding)
+        else:
+            filename = source.filename
+        element.attrib["filename"] = filename
 
         return element
 
diff --git a/pitivi/utils.py b/pitivi/utils.py
index 9338529..694daba 100644
--- a/pitivi/utils.py
+++ b/pitivi/utils.py
@@ -22,6 +22,7 @@
 
 # set of utility functions
 
+import sys
 import gobject
 import gst, bisect
 import os
@@ -265,3 +266,6 @@ class Seeker(object, Signallable):
         position, self.position = self.position, None
         format, self.format = self.format, None
         self.emit('seek', position, format)
+
+def get_filesystem_encoding():
+    return sys.getfilesystemencoding() or "utf-8"



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]