changeset 218:699d8f1cebd4

unify imports, especially Qt imports. Use consistent super syntax
author Dirk Olmes <dirk@xanthippe.ping.de>
date Sun, 27 Apr 2014 06:04:57 +0200
parents bb3c851b18b1
children 38d1898e7d82
files AddFeed.py DisplayModel.py FeedEntryItemDelegate.py FeedSettings.py MainWindow.py OpmlImport.py PreferencesDialog.py backend/AbstractBackend.py backend/AbstractFeedUpdater.py backend/couchdb/CouchDbBackend.py backend/sqlalchemy/Feed.py backend/sqlalchemy/FeedEntry.py backend/sqlalchemy/Preference.py backend/sqlalchemy/SqlAlchemyBackend.py
diffstat 14 files changed, 40 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/AddFeed.py	Sun Apr 27 05:33:34 2014 +0200
+++ b/AddFeed.py	Sun Apr 27 06:04:57 2014 +0200
@@ -1,11 +1,11 @@
 # -*- coding: utf-8 -*-
-from PyQt4 import QtGui
+from PyQt4.QtGui import QDialog
 from Ui_AddFeed import Ui_AddFeed
 import logging
 
-class AddFeed(QtGui.QDialog):
+class AddFeed(QDialog):
     def __init__(self, backend=None):
-        QtGui.QWidget.__init__(self, None)
+        super(AddFeed, self).__init__(None)
         self.backend = backend
         self.exception = None
         self.ui = Ui_AddFeed()
@@ -18,8 +18,8 @@
             self.backend.createFeed(url)
         except AttributeError as ae:
             logging.getLogger("AddFeed").info(ae)
-            self.exception = ae       
-        QtGui.QDialog.accept(self)
+            self.exception = ae
+        super(AddFeed, self).accept()
 
     def getUrl(self):
         text = self.ui.url.text()
--- a/DisplayModel.py	Sun Apr 27 05:33:34 2014 +0200
+++ b/DisplayModel.py	Sun Apr 27 06:04:57 2014 +0200
@@ -3,7 +3,7 @@
 
 class DisplayModel(QAbstractListModel):
     def __init__(self, parent=None, list=None, displayAttribute=None, **args):
-        QAbstractListModel.__init__(self, parent, *args)
+        super(DisplayModel, self).__init__(parent, *args)
         self.list = list
         self.displayAttribute = displayAttribute
 
--- a/FeedEntryItemDelegate.py	Sun Apr 27 05:33:34 2014 +0200
+++ b/FeedEntryItemDelegate.py	Sun Apr 27 06:04:57 2014 +0200
@@ -1,10 +1,9 @@
 # -*- coding: utf-8 -*-
-from PyQt4 import QtGui
-from PyQt4.QtGui import QFont
+from PyQt4.QtGui import QFont, QStyledItemDelegate
 
-class FeedEntryItemDelegate(QtGui.QStyledItemDelegate):
+class FeedEntryItemDelegate(QStyledItemDelegate):
     def __init__(self):
-        QtGui.QStyledItemDelegate.__init__(self, None)
+        super(FeedEntryItemDelegate, self).__init__(None)
 
     def paint(self, painter, style, index):
         feedEntryTableModel = index.model()
@@ -16,4 +15,4 @@
             style.font.setWeight(QFont.Normal)
         else:
             style.font.setWeight(QFont.Bold)
-        QtGui.QStyledItemDelegate.paint(self, painter, style, index)
+        super(FeedEntryItemDelegate, self).paint(painter, style, index)
--- a/FeedSettings.py	Sun Apr 27 05:33:34 2014 +0200
+++ b/FeedSettings.py	Sun Apr 27 06:04:57 2014 +0200
@@ -1,14 +1,14 @@
 # -*- coding: utf-8 -*-
-from PyQt4 import QtGui
+from PyQt4.QtGui import QDialog
 from Ui_FeedSettings import Ui_FeedSettings
 
-class FeedSettings(QtGui.QDialog):
+class FeedSettings(QDialog):
     """
     Copy all feed properties into the GUI on initialization. Collect all changes
     in a separate dict that's passed into the backend along with the feed to modify.
     """
     def __init__(self, backend):
-        QtGui.QWidget.__init__(self, None)
+        super(FeedSettings, self).__init__(None)
         self.backend = backend
         self.feed = backend.selectedFeed
         self.changes = {}
@@ -45,4 +45,4 @@
 
     def accept(self):
         self.backend.updateFeed(self.feed, self.changes)
-        QtGui.QDialog.accept(self)
+        super(FeedSettings, self).accept()
--- a/MainWindow.py	Sun Apr 27 05:33:34 2014 +0200
+++ b/MainWindow.py	Sun Apr 27 06:04:57 2014 +0200
@@ -1,4 +1,5 @@
 # -*- coding: utf-8 -*-
+import subprocess
 from AddFeed import AddFeed
 from DisplayModel import DisplayModel
 from FeedEntryItemDelegate import FeedEntryItemDelegate
@@ -6,11 +7,8 @@
 from FeedSettings import FeedSettings
 from PreferencesDialog import PreferencesDialog
 from PyQt4.QtCore import QUrl
-from PyQt4.QtGui import QApplication
-from PyQt4.QtGui import QMainWindow
-from PyQt4.QtGui import QWidget
+from PyQt4.QtGui import QApplication, QMainWindow, QWidget
 from Ui_MainWindow import Ui_MainWindow
-import subprocess
 
 STATUS_MESSAGE_DISPLAY_MILLIS = 20000
 
--- a/OpmlImport.py	Sun Apr 27 05:33:34 2014 +0200
+++ b/OpmlImport.py	Sun Apr 27 06:04:57 2014 +0200
@@ -8,7 +8,7 @@
     for outline in outlines:
         url = outline.getAttribute("xmlUrl")
         title = outline.getAttribute("title")
-        
+
         feed = Feed(title, url)
         session.add(feed)
     session.commit()
--- a/PreferencesDialog.py	Sun Apr 27 05:33:34 2014 +0200
+++ b/PreferencesDialog.py	Sun Apr 27 06:04:57 2014 +0200
@@ -1,10 +1,10 @@
 # -*- coding: utf-8 -*-
-from PyQt4 import QtGui
+from PyQt4.QtGui import QDialog
 from Ui_Preferences import Ui_Preferences
 
-class PreferencesDialog(QtGui.QDialog):
+class PreferencesDialog(QDialog):
     def __init__(self, backend=None):
-        QtGui.QWidget.__init__(self, None)
+        super(PreferencesDialog, self).__init__(None)
         self.backend = backend
         self.preferences = backend.preferences()
         self.ui = Ui_Preferences()
@@ -83,9 +83,8 @@
     def accept(self):
         self.storeProxySettings()
         self.preferences.commit();
-        QtGui.QDialog.accept(self)
+        super(PreferencesDialog, self).accept()
 
     def reject(self):
         self.preferences.rollback()
-        QtGui.QDialog.reject(self)
-
+        super(PreferencesDialog, self).reject()
--- a/backend/AbstractBackend.py	Sun Apr 27 05:33:34 2014 +0200
+++ b/backend/AbstractBackend.py	Sun Apr 27 06:04:57 2014 +0200
@@ -2,10 +2,10 @@
 from datetime import datetime, timedelta
 
 def calculateExpireDate(preferences):
-        now = datetime.now()
-        daysToKeepFeedEntries = preferences.daysToKeepFeedEntries()
-        delta = timedelta(days=daysToKeepFeedEntries)
-        return now - delta
+    now = datetime.now()
+    daysToKeepFeedEntries = preferences.daysToKeepFeedEntries()
+    delta = timedelta(days=daysToKeepFeedEntries)
+    return now - delta
 
 class AbstractBackend(object):
     def __init__(self):
--- a/backend/AbstractFeedUpdater.py	Sun Apr 27 05:33:34 2014 +0200
+++ b/backend/AbstractFeedUpdater.py	Sun Apr 27 06:04:57 2014 +0200
@@ -1,9 +1,9 @@
 # -*- coding: utf-8 -*-
-from datetime import datetime
-from urllib2 import ProxyHandler
 import AbstractBackend
 import feedparser
 import logging
+from datetime import datetime
+from urllib2 import ProxyHandler
 
 STATUS_ERROR = 400
 log = logging.getLogger("FeedUpdater")
--- a/backend/couchdb/CouchDbBackend.py	Sun Apr 27 05:33:34 2014 +0200
+++ b/backend/couchdb/CouchDbBackend.py	Sun Apr 27 06:04:57 2014 +0200
@@ -1,12 +1,12 @@
 # -*- coding: utf-8 -*-
+import couchdb
+import logging
 from FeedUpdater import FeedUpdater
 from Preferences import Preferences
 from backend.AbstractBackend import AbstractBackend
 from backend.couchdb import CouchDb
 from backend.couchdb.Feed import Feed
 from backend.couchdb.FeedEntry import FeedEntry
-import couchdb
-import logging
 
 class CouchDbBackend(AbstractBackend):
     '''
@@ -14,6 +14,7 @@
     '''
 
     def __init__(self):
+        super(CouchDbBackend, self).__init__()
         CouchDb.init()
         server = self._initServer()
         self.database = server[CouchDb.database]
--- a/backend/sqlalchemy/Feed.py	Sun Apr 27 05:33:34 2014 +0200
+++ b/backend/sqlalchemy/Feed.py	Sun Apr 27 06:04:57 2014 +0200
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
+import FeedEntry
 from datetime import datetime, timedelta
-import FeedEntry
 
 class Feed(object):
     @staticmethod
--- a/backend/sqlalchemy/FeedEntry.py	Sun Apr 27 05:33:34 2014 +0200
+++ b/backend/sqlalchemy/FeedEntry.py	Sun Apr 27 06:04:57 2014 +0200
@@ -29,13 +29,13 @@
 
     def userPresentableString(self):
         return self.title
-    
+
     def toggleRead(self):
         if self.read:
             self.markUnread()
         else:
             self.markRead()
-            
+
     def markRead(self):
         self.read = 1
 
--- a/backend/sqlalchemy/Preference.py	Sun Apr 27 05:33:34 2014 +0200
+++ b/backend/sqlalchemy/Preference.py	Sun Apr 27 06:04:57 2014 +0200
@@ -3,10 +3,10 @@
     @staticmethod
     def forKey(key, session):
         return session.query(Preference).filter(Preference.key == key).first()
-    
+
     def __init__(self, key, value):
         self.key = key
         self.value = value
-    
+
     def __repr__(self):
         return "<Preference %s = %s>" % (self.key, self.value)
--- a/backend/sqlalchemy/SqlAlchemyBackend.py	Sun Apr 27 05:33:34 2014 +0200
+++ b/backend/sqlalchemy/SqlAlchemyBackend.py	Sun Apr 27 06:04:57 2014 +0200
@@ -1,4 +1,8 @@
 # -*- coding: utf-8 -*-
+import Database
+import Mapping
+import logging
+import util
 from Feed import Feed
 from FeedEntry import FeedEntry
 from FeedUpdater import FeedUpdater
@@ -6,10 +10,6 @@
 from backend.AbstractBackend import AbstractBackend
 from sqlalchemy.orm import joinedload
 from sqlalchemy.sql import and_
-import Database
-import Mapping
-import logging
-import util
 
 class SqlAlchemyBackend(AbstractBackend):
     '''