[pitivi] project: Change load method to return the project



commit 02a933d45c9bb6a366979bf286bd75298fac94e0
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Sun Jan 27 23:18:51 2019 +0100

    project: Change load method to return the project

 pitivi/application.py           |  2 +-
 pitivi/greeterperspective.py    |  6 +++---
 pitivi/project.py               |  8 ++++----
 tests/test_editorperspective.py |  2 +-
 tests/test_media_library.py     |  2 +-
 tests/test_project.py           | 19 ++++++++-----------
 6 files changed, 18 insertions(+), 21 deletions(-)
---
diff --git a/pitivi/application.py b/pitivi/application.py
index 25317659..f7b2a85d 100644
--- a/pitivi/application.py
+++ b/pitivi/application.py
@@ -219,7 +219,7 @@ class Pitivi(Gtk.Application, Loggable):
             self.warning(
                 "Can open only one project file at a time. Ignoring the rest!")
         project_file = giofiles[0]
-        self.project_manager.loadProject(quote_uri(project_file.get_uri()))
+        self.project_manager.load_project(quote_uri(project_file.get_uri()))
         return True
 
     def shutdown(self):
diff --git a/pitivi/greeterperspective.py b/pitivi/greeterperspective.py
index 56d3bfa5..44231b2d 100644
--- a/pitivi/greeterperspective.py
+++ b/pitivi/greeterperspective.py
@@ -312,7 +312,7 @@ class GreeterPerspective(Perspective):
         uri = uris[0]
         extension = os.path.splitext(uri)[1][1:]
         if extension in self.__project_filter:
-            self.app.project_manager.loadProject(uri)
+            self.app.project_manager.load_project(uri)
 
     def __new_project_cb(self, unused_action, unused_param):
         self.app.project_manager.new_blank_project()
@@ -323,7 +323,7 @@ class GreeterPerspective(Perspective):
         uri = dialog.get_uri()
         dialog.destroy()
         if response == Gtk.ResponseType.OK:
-            self.app.project_manager.loadProject(uri)
+            self.app.project_manager.load_project(uri)
 
     def __app_version_info_received_cb(self, app, unused_version_information):
         """Handles new version info."""
@@ -360,7 +360,7 @@ class GreeterPerspective(Perspective):
         if row.select_button.get_visible():
             row.select_button.set_active(not row.select_button.get_active())
         else:
-            self.app.project_manager.loadProject(row.uri)
+            self.app.project_manager.load_project(row.uri)
 
     def __projects_button_press_cb(self, listbox, event):
         if event.button == 3:
diff --git a/pitivi/project.py b/pitivi/project.py
index add96b65..7469d72f 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -232,7 +232,7 @@ class ProjectManager(GObject.Object, Loggable):
 
         self.app.shutdown()
 
-    def loadProject(self, uri):
+    def load_project(self, uri):
         """Loads the specified URI as a project.
 
         If a backup file exists, asks if it should be loaded instead, and if so,
@@ -261,7 +261,7 @@ class ProjectManager(GObject.Object, Loggable):
                       _('This might be due to a bug or an unsupported project file format. '
                         'If you were trying to add a media file to your project, '
                         'use the "Import" button instead.'))
-            return False
+            return None
 
         self.current_project = project
         self.emit("new-project-created", project)
@@ -271,7 +271,7 @@ class ProjectManager(GObject.Object, Loggable):
         if is_validate_scenario:
             self.current_project.setupValidateScenario()
 
-        return True
+        return project
 
     def _restoreFromBackupDialog(self, time_diff):
         """Asks if we need to load the autosaved project backup.
@@ -551,7 +551,7 @@ class ProjectManager(GObject.Object, Loggable):
         uri = self.current_project.uri
         self.current_project.setModificationState(False)
         self.closeRunningProject()
-        self.loadProject(uri)
+        self.load_project(uri)
 
     def _projectChangedCb(self, project):
         # _backup_lock is a timer, when a change in the project is done it is
diff --git a/tests/test_editorperspective.py b/tests/test_editorperspective.py
index 76d5e132..c630c1b2 100644
--- a/tests/test_editorperspective.py
+++ b/tests/test_editorperspective.py
@@ -99,7 +99,7 @@ class TestEditorPerspective(common.TestCase):
         with common.cloned_sample():
             asset_uri = common.get_sample_uri("missing.png")
             with common.created_project_file(asset_uri) as uri:
-                app.project_manager.loadProject(uri)
+                app.project_manager.load_project(uri)
 
         mainloop.run()
 
diff --git a/tests/test_media_library.py b/tests/test_media_library.py
index a7f9e0e7..74bcb541 100644
--- a/tests/test_media_library.py
+++ b/tests/test_media_library.py
@@ -63,7 +63,7 @@ class BaseTestMediaLibrary(common.TestCase):
         self.medialibrary = medialibrary.MediaLibraryWidget(self.app)
 
         if project_uri:
-            self.app.project_manager.loadProject(project_uri)
+            self.app.project_manager.load_project(project_uri)
         else:
             self.app.project_manager.new_blank_project()
 
diff --git a/tests/test_project.py b/tests/test_project.py
index 00bbf234..8f9a267a 100644
--- a/tests/test_project.py
+++ b/tests/test_project.py
@@ -72,12 +72,9 @@ class TestProjectManager(common.TestCase):
         self.signals = self.listener.signals
 
     def testLoadProjectFailedUnknownFormat(self):
-        """
-        Check that new-project-failed is emitted when we don't have a suitable
-        formatter.
-        """
+        """Checks new-project-failed is emitted for unsuitable formatters."""
         uri = "file:///Untitled.meh"
-        self.manager.loadProject(uri)
+        self.manager.load_project(uri)
 
         # loading
         name, args = self.signals[0]
@@ -115,7 +112,7 @@ class TestProjectManager(common.TestCase):
         with common.cloned_sample():
             asset_uri = common.get_sample_uri("missing.png")
             with common.created_project_file(asset_uri) as uri:
-                self.assertTrue(self.manager.loadProject(uri))
+                self.assertIsNotNone(self.manager.load_project(uri))
                 mainloop.run()
         self.assertTrue(result[0], "missing-uri has not been emitted")
 
@@ -130,10 +127,10 @@ class TestProjectManager(common.TestCase):
         with common.cloned_sample("flat_colour1_640x480.png"):
             asset_uri = common.get_sample_uri("flat_colour1_640x480.png")
             with common.created_project_file(asset_uri=asset_uri) as uri:
-                self.assertTrue(self.manager.loadProject(uri))
+                project = self.manager.load_project(uri)
+                self.assertIsNotNone(project)
                 mainloop.run()
 
-        project = self.manager.current_project
         self.assertFalse(project.at_least_one_asset_missing)
         self.assertTrue(project.loaded)
         self.assertFalse(project.hasUnsavedModifications())
@@ -380,7 +377,7 @@ class TestProjectLoading(common.TestCase):
         project_manager.connect("closing-project", closing_project_cb)
         proxy_manager.connect_after("proxy-ready", proxy_ready_cb)
 
-        app.project_manager.loadProject(proj_uri)
+        app.project_manager.load_project(proj_uri)
         return mainloop, app, medialib, proxy_uri
 
     def test_load_project_with_missing_proxy(self):
@@ -480,7 +477,7 @@ class TestProjectLoading(common.TestCase):
         project_manager.connect("missing-uri", missing_uri_cb)
         project_manager.connect("new-project-loaded", new_project_loaded_cb)
 
-        project_manager.loadProject(proj_uri)
+        project_manager.load_project(proj_uri)
         with common.cloned_sample("1sec_simpsons_trailer.mp4"):
             mainloop.run()
         self.assertEqual(medialib._progressbar.get_fraction(), 1.0)
@@ -523,7 +520,7 @@ class TestProjectLoading(common.TestCase):
             project_manager.connect("missing-uri", missing_uri_cb)
             project_manager.connect("new-project-loaded", new_project_loaded_cb)
 
-            project_manager.loadProject(proj_uri)
+            project_manager.load_project(proj_uri)
             mainloop.run()
             self.assertEqual(len(missing_uris), 1,
                 "missing_uri_cb should be called only once, got %s." % missing_uris)


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