[pitivi: 36/65] Change pitivi.sourcelist.SourceList.addUri to not raise an exception when the URI is already added.
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi: 36/65] Change pitivi.sourcelist.SourceList.addUri to not raise an exception when the URI is already added.
- Date: Mon, 4 Jul 2011 01:22:15 +0000 (UTC)
commit 25752644473c6730f5c50ddb6ef02d0bfc623b7f
Author: Alex BÄluÈ <alexandru balut gmail com>
Date: Fri Jun 10 00:46:44 2011 +0200
Change pitivi.sourcelist.SourceList.addUri to not raise an exception when the URI is already added.
The problem fixed by this patch is that currently, when running "bin/pitivi -i video.mkv video.mkv" the application breaks and shows a stacktrace.
pitivi/sourcelist.py | 3 ++-
pitivi/ui/sourcelist.py | 17 +++--------------
tests/test_sourcelist.py | 12 ++++--------
3 files changed, 9 insertions(+), 23 deletions(-)
---
diff --git a/pitivi/sourcelist.py b/pitivi/sourcelist.py
index 5bd46b9..0e07fa8 100644
--- a/pitivi/sourcelist.py
+++ b/pitivi/sourcelist.py
@@ -92,7 +92,8 @@ class SourceList(Signallable, Loggable):
The uri will be analyzed before being added.
"""
if uri in self._sources:
- raise SourceListError("URI already present in the source list", uri)
+ # uri is already added. Nothing to do.
+ return
self._sources[uri] = None
# Tell the discoverer to investigate the URI and report back when
# it has the info or failed.
diff --git a/pitivi/ui/sourcelist.py b/pitivi/ui/sourcelist.py
index ab71b63..9f03aef 100644
--- a/pitivi/ui/sourcelist.py
+++ b/pitivi/ui/sourcelist.py
@@ -530,14 +530,6 @@ class SourceList(gtk.VBox, Loggable):
self._importDialog.connect('close', self._dialogBoxCloseCb)
self._importDialog.show()
- def addUris(self, files):
- """ Add files to the list """
- try:
- self.app.current.sources.addUris(files)
- except SourceListError as error:
- disclaimer, uri = error.args
- self.error("'%s' is already present in the source list." + uri)
-
def addFolders(self, folders):
""" walks the trees of the folders in the list and adds the files it finds """
self.app.threads.addThread(PathWalker, folders, self.app.current.sources.addUris)
@@ -680,7 +672,7 @@ class SourceList(gtk.VBox, Loggable):
if select_folders:
self.addFolders(filenames)
else:
- self.addUris(filenames)
+ self.app.current.sources.addUris(filenames)
if self.app.settings.closeImportDialog:
dialogbox.destroy()
self._importDialog = None
@@ -1025,11 +1017,8 @@ class SourceList(gtk.VBox, Loggable):
#TODO waiting for remote files downloader support to be implemented
pass
- try:
- self.addUris([quote_uri(uri) for uri in filenames])
- except SourceListError:
- # filenames already present in the sourcelist
- pass
+ uris = [quote_uri(uri) for uri in filenames]
+ self.app.current.sources.addUris(uris)
#used with TreeView and IconView
def _dndDragBeginCb(self, view, context):
diff --git a/tests/test_sourcelist.py b/tests/test_sourcelist.py
index 00286c2..4d6c89f 100644
--- a/tests/test_sourcelist.py
+++ b/tests/test_sourcelist.py
@@ -46,14 +46,13 @@ class TestSourceList(TestCase):
factory = FileSourceFactory(uri)
self.sourcelist.addUri(uri)
self.failUnlessEqual(len(self.sourcelist.getSources()), 0)
- self.failUnlessRaises(SourceListError, self.sourcelist.addUri, uri)
+ self.failUnlessRaises(SourceListError, self.sourcelist.getUri, uri)
# mock discovery-done
self.sourcelist.discoverer.emit("discovery-done", uri, factory)
self.failUnlessEqual(len(self.sourcelist.getSources()), 1)
- # can't add again
- self.failUnlessRaises(SourceListError, self.sourcelist.addUri, uri)
+ self.failUnlessEqual(self.sourcelist.getUri(uri), factory)
def testAddUriDiscoveryOkSourceGone(self):
"""
@@ -77,7 +76,6 @@ class TestSourceList(TestCase):
Same as the test above, but testing the discovery-error handler.
"""
uri = "file:///ciao"
- factory = FileSourceFactory(uri)
self.sourcelist.addUri(uri)
self.sourcelist.removeUri(uri)
@@ -91,15 +89,13 @@ class TestSourceList(TestCase):
def testAddUriDiscoveryError(self):
uri = "file:///ciao"
- factory = FileSourceFactory(uri)
self.sourcelist.addUri(uri)
self.failUnlessEqual(len(self.sourcelist.getSources()), 0)
- self.failUnlessRaises(SourceListError, self.sourcelist.addUri, uri)
# mock discovery-done
self.sourcelist.discoverer.emit("discovery-error", uri,
"error", "verbose debug")
self.failUnlessEqual(len(self.sourcelist.getSources()), 0)
- # there was an error, the factory wasn't added so this shouldn't raise
- self.sourcelist.addUri(uri)
+ # there was an error, the factory wasn't added so this should raise
+ self.failUnlessRaises(SourceListError, self.sourcelist.getUri, uri)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]