[pitivi] mainwindow: [pylint] Remove generic try/except.



commit 88e203d5db08e69b2b225fdf5c0047eaaa3de561
Author: Mathieu Duponchelle <mduponchelle1 gmail com>
Date:   Thu Feb 6 12:38:06 2014 +0100

    mainwindow: [pylint] Remove generic try/except.
    
    Replaced with an else if because IndexError would be too generic
    to catch ^^

 pitivi/mainwindow.py |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/pitivi/mainwindow.py b/pitivi/mainwindow.py
index 7ce24ad..3fd6e13 100644
--- a/pitivi/mainwindow.py
+++ b/pitivi/mainwindow.py
@@ -1262,16 +1262,20 @@ class PitiviMainWindow(Gtk.Window, Loggable):
         preview_window.hide()  # Hack to allow setting the window position
         previewer.previewUri(uri)
         previewer.setMinimal()
+
         info = self.app.current_project.get_asset(uri, GES.UriClip).get_info()
-        try:
+        video_streams = info.get_video_streams()
+
+        if video_streams:
             # For videos and images, automatically resize the window
             # Try to keep it 1:1 if it can fit within 85% of the parent window
-            img_width = info.get_video_streams()[0].get_width()
-            img_height = info.get_video_streams()[0].get_height()
+            img_width = video_streams[0].get_width()
+            img_height = video_streams[0].get_height()
             controls_height = previewer.bbox.size_request().height
             mainwindow_width, mainwindow_height = self.get_size()
             max_width = 0.85 * mainwindow_width
             max_height = 0.85 * mainwindow_height
+
             if img_width < max_width and (img_height + controls_height) < max_height:
                 # The video is small enough, keep it 1:1
                 preview_window.resize(img_width, img_height + controls_height)
@@ -1281,10 +1285,11 @@ class PitiviMainWindow(Gtk.Window, Loggable):
                 new_height = max_width * img_height / img_width
                 preview_window.resize(int(max_width),
                     int(new_height + controls_height))
-        except:
+        else:
             # There is no video/image stream. This is an audio file.
             # Resize to the minimum and let the window manager deal with it
             preview_window.resize(1, 1)
+
         # Setting the position of the window only works if it's currently hidden
         # otherwise, after the resize the position will not be readjusted
         preview_window.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)


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