Fix pyflakes warnings
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 17 Feb 2008 10:38:22 +0000 (11:38 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 17 Feb 2008 10:38:22 +0000 (11:38 +0100)
build-windows-py2exe-installer.py
check.py
setup.py
src/packages/kofoto/gkofoto/environment.py
src/packages/kofoto/gkofoto/generatehtmldialog.py
src/packages/kofoto/gkofoto/mainwindow.py
src/packages/kofoto/shelf.py
src/test/test_dag.py
src/test/test_searching.py
src/test/test_shelf.py

index 93894c9..e475d07 100755 (executable)
@@ -7,8 +7,7 @@ import setup
 import shutil
 import sys
 import _winreg
-import msvcrt
-from os.path import join, isdir, basename
+from os.path import join, isdir
 
 def zap(glob_pattern):
     for entry in glob.glob(glob_pattern):
index 7032198..94e4e03 100755 (executable)
--- a/check.py
+++ b/check.py
@@ -3,7 +3,6 @@
 import os
 import sys
 from optparse import OptionParser
-import warnings
 from pylint import lint
 
 def disable_message(arguments, message_id):
index 647d4ba..0b0bc55 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -4,7 +4,6 @@ from distutils.core import setup
 import glob
 import os
 import shutil
-import sys
 
 package_dirs = {
     "kofoto": "src/packages/kofoto",
index bfec284..5924cd2 100644 (file)
@@ -10,9 +10,7 @@ try:
 except AssertionError:
     # pygtk.require("2.0") fails in the py2exe installer. Don't know why.
     pass
-import gtk
-import gtk.gdk
-import gtk.glade
+from gtk import glade, gdk
 from kofoto.gkofoto import crashdialog
 sys.excepthook = crashdialog.show
 
@@ -21,7 +19,7 @@ from kofoto.gkofoto.cachingpixbufloader import CachingPixbufLoader
 
 class WidgetsWrapper:
     def __init__(self):
-        self.widgets = gtk.glade.XML(env.gladeFile, "mainWindow")
+        self.widgets = glade.XML(env.gladeFile, "mainWindow")
 
     def __getitem__(self, key):
         return self.widgets.get_widget(key)
@@ -86,10 +84,10 @@ class Environment(ClientEnvironment):
         self.iconDir = os.path.join(dataDir, "icons")
         self.gladeFile = os.path.join(dataDir, "glade", "gkofoto.glade")
         self.albumIconFileName = os.path.join(self.iconDir, "album.png")
-        self.albumIconPixbuf = gtk.gdk.pixbuf_new_from_file(self.albumIconFileName)
+        self.albumIconPixbuf = gdk.pixbuf_new_from_file(self.albumIconFileName)
         self.loadingPixbuf = self.albumIconPixbuf # TODO: create another icon with a hour-glass or something
         self.unknownImageIconFileName = os.path.join(self.iconDir, "unknownimage.png")
-        self.unknownImageIconPixbuf = gtk.gdk.pixbuf_new_from_file(self.unknownImageIconFileName)
+        self.unknownImageIconPixbuf = gdk.pixbuf_new_from_file(self.unknownImageIconFileName)
         from kofoto.gkofoto.clipboard import Clipboard
         self.clipboard = Clipboard()
 
index 817e1bd..4b72b66 100644 (file)
@@ -2,8 +2,8 @@ import gtk
 import os
 import re
 from kofoto.gkofoto.environment import env
-import kofoto.generate
-import kofoto.shelfexceptions
+from kofoto import generate
+from kofoto import shelfexceptions
 
 class GenerateHTMLDialog:
     def __init__(self, album):
@@ -87,12 +87,12 @@ class GenerateHTMLDialog:
         env.imagesizelimits = imgsizes
 
         try:
-            generator = kofoto.generate.Generator(u"woolly", env)
+            generator = generate.Generator(u"woolly", env)
             generator.generate(self.album, None, directoryName, "utf-8")
             progressBar.set_fraction(1)
             while gtk.events_pending():
                 gtk.main_iteration()
-        except (IOError, kofoto.shelfexceptions.KofotoError), e:
+        except (IOError, shelfexceptions.KofotoError), e:
             dialog = gtk.MessageDialog(
                 type=gtk.MESSAGE_ERROR,
                 buttons=gtk.BUTTONS_OK,
index 87323f5..3247b69 100644 (file)
@@ -1,5 +1,5 @@
 import gtk
-import gtk.gdk
+from gtk import gdk
 import os
 
 from kofoto.gkofoto.categories import Categories
@@ -66,15 +66,15 @@ class MainWindow(gtk.Window):
             "activate", self.handleModifiedOrRenamedImages, None)
 
         env.widgets["menubarRotateLeft"].get_children()[1].set_from_pixbuf(
-            gtk.gdk.pixbuf_new_from_file(os.path.join(env.iconDir, "rotateleft.png")))
+            gdk.pixbuf_new_from_file(os.path.join(env.iconDir, "rotateleft.png")))
         env.widgets["menubarRotateRight"].get_children()[1].set_from_pixbuf(
-            gtk.gdk.pixbuf_new_from_file(os.path.join(env.iconDir, "rotateright.png")))
+            gdk.pixbuf_new_from_file(os.path.join(env.iconDir, "rotateright.png")))
         env.widgets["menubarRotateImageVersionLeft"].get_children()[1].set_from_pixbuf(
-            gtk.gdk.pixbuf_new_from_file(os.path.join(env.iconDir, "rotateleft.png")))
+            gdk.pixbuf_new_from_file(os.path.join(env.iconDir, "rotateleft.png")))
         env.widgets["menubarRotateImageVersionRight"].get_children()[1].set_from_pixbuf(
-            gtk.gdk.pixbuf_new_from_file(os.path.join(env.iconDir, "rotateright.png")))
+            gdk.pixbuf_new_from_file(os.path.join(env.iconDir, "rotateright.png")))
         env.widgets["menubarAbout"].get_children()[1].set_from_pixbuf(
-            gtk.gdk.pixbuf_new_from_file(os.path.join(env.iconDir, "about-icon.png")))
+            gdk.pixbuf_new_from_file(os.path.join(env.iconDir, "about-icon.png")))
 
         env.widgets["menubarAbout"].connect("activate", self.showAboutBox)
 
@@ -150,7 +150,7 @@ class MainWindow(gtk.Window):
         dialog.run()
 
     def getIconImage(self, name):
-        pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.join(env.iconDir, name))
+        pixbuf = gdk.pixbuf_new_from_file(os.path.join(env.iconDir, name))
         image = gtk.Image()
         image.set_from_pixbuf(pixbuf)
         image.show()
index 2fd0852..ad66f52 100644 (file)
@@ -24,8 +24,8 @@ from kofoto.cachedobject import CachedObject
 from kofoto.albumtype import AlbumType
 from kofoto.imageversiontype import ImageVersionType
 import kofoto.exifthumbsupport
-import kofoto.shelfupgrade
-import kofoto.shelfschema
+from kofoto import shelfupgrade
+from kofoto import shelfschema
 from kofoto.shelfexceptions import \
     AlbumDoesNotExistError, \
     AlbumExistsError, \
@@ -180,7 +180,7 @@ class Shelf:
         If this method returns True, run Shelf.tryUpgrade.
         """
         assert not self.inTransaction
-        return kofoto.shelfupgrade.isUpgradable(self.location)
+        return shelfupgrade.isUpgradable(self.location)
 
 
     def tryUpgrade(self):
@@ -191,8 +191,7 @@ class Shelf:
         Returns True if upgrade was successful, otherwise False.
         """
         assert not self.inTransaction
-        return kofoto.shelfupgrade.tryUpgrade(
-            self.location, _SHELF_FORMAT_VERSION)
+        return shelfupgrade.tryUpgrade(self.location, _SHELF_FORMAT_VERSION)
 
 
     def begin(self):
@@ -958,7 +957,7 @@ class Shelf:
     def _createShelf(self):
         """Helper method for Shelf.create."""
         cursor = self.connection.cursor()
-        cursor.execute(kofoto.shelfschema.schema)
+        cursor.execute(shelfschema.schema)
         cursor.execute(
             " insert into dbinfo (version)"
             " values (%s)",
index e92730e..3bbce11 100755 (executable)
@@ -10,7 +10,7 @@ if __name__ == "__main__":
         os.path.join(os.path.dirname(sys.argv[0]), "..", "packages")))
     os.chdir(libdir)
     sys.path.insert(0, libdir)
-from kofoto.dag import *
+from kofoto.dag import DAG, LoopError
 
 PICDIR = unicode(os.path.realpath(
     os.path.join("..", "reference_pictures", "working")))
index 0b3adff..89b5848 100755 (executable)
@@ -10,8 +10,7 @@ if __name__ == "__main__":
         os.path.join(os.path.dirname(sys.argv[0]), "..", "packages")))
     os.chdir(libdir)
     sys.path.insert(0, libdir)
-from kofoto.shelf import *
-from kofoto.search import *
+from kofoto.search import Parser, BadTokenError, UnterminatedStringError
 
 PICDIR = unicode(os.path.realpath(
     os.path.join("..", "reference_pictures", "working")))
index c835650..7429e51 100755 (executable)
@@ -38,7 +38,6 @@ from kofoto.shelfexceptions import \
     ShelfLockedError, \
     ShelfNotFoundError, \
     UndeletableAlbumError, \
-    UndeletableAlbumError, \
     UnsettableChildrenError, \
     UnsupportedShelfError