[pitivi] Set the project name from the project filename.



commit 205f7420e62d7859ad03e199ba75cfa0e27c9f8a
Author: Alessandro Decina <alessandro d gmail com>
Date:   Tue Aug 18 13:11:50 2009 +0200

    Set the project name from the project filename.

 pitivi/formatters/base.py |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/pitivi/formatters/base.py b/pitivi/formatters/base.py
index a17131b..7c7b087 100644
--- a/pitivi/formatters/base.py
+++ b/pitivi/formatters/base.py
@@ -24,6 +24,7 @@ Base Formatter classes
 """
 
 import os
+from urlparse import urlparse
 from pitivi.project import Project
 from pitivi.utils import uri_is_reachable, uri_is_valid
 from pitivi.signalinterface import Signallable
@@ -119,6 +120,7 @@ class Formatter(Signallable, Loggable):
         project = self.newProject()
         self.emit("new-project-created", project)
 
+        project.name = self._projectNameFromURI(location)
         project.uri = location
 
         self.log("location:%s, project:%r", location, project)
@@ -128,6 +130,11 @@ class Formatter(Signallable, Loggable):
         # FIXME : maybe have a convenience method for opening a location
         self._loadProject(location, project)
 
+    def _projectNameFromURI(self, uri):
+        path = urlparse(uri).path
+        basename = os.path.basename(path)
+        return os.path.splitext(basename)[0]
+
     def _finishLoadingProject(self, project):
         self.debug("About to get used sources")
         # ask for all sources being used
@@ -187,7 +194,10 @@ class Formatter(Signallable, Loggable):
             raise FormatterURIError()
         if overwrite == False and uri_is_reachable(location):
             raise FormatterOverwriteError()
+        old_uri = project.uri
         if self._saveProject(project, location):
+            if old_uri is None:
+                project.name = self._projectNameFromURI(location)
             self.emit("project-saved", project, location)
             return True
 



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