Commits

Anonymous committed fbcc3ed Draft

handle pyflakes found issues, move import to top

  • Participants
  • Parent commits 092e9e3

Comments (0)

Files changed (1)

     from  ConfigParser import RawConfigParser as rcp
     import urwid as u
     from dumbo.utk import *
+    try:
+        import psycopg2
+    except ImportError:
+        class dummy(str): pass
+        psycopg2 = dummy()  # :/
+        psycopg2.ProgrammingError, psycopg2.InternalError = None, None
 
     appname     = 'dumbo'
     __version__ = '0.61a'
         self.conns = {}
         try:
             self.module = __import__(module)
-        except ImportError, e:
+        except ImportError:
             raise RuntimeError, 'Database API module not found.'
 
     def close(self, conn=None):
 
     def query(self, dbname, querystr, fetchresults=True):
         'Query database.'
-        try:
-            import psycopg2
-        except ImportError:
-            class dummy(str): pass
-            psycopg2 = dummy()  # :/
-            psycopg2.ProgrammingError, psycopg2.InternalError = None, None
         retval = True # success
 
         cur = self.conns[dbname].cursor()
                     if results:
                         legend.pkeys = results
                 self.legendcache[key] = legend
-            except Exception, e:
+            except Exception:
                 import traceback
                 log.error('Legend not found: %s' % traceback.format_exc())
         return legend
             log.debug('pkeys:' + repr(pkeys))
             # figure which col is which field, could be more efficient
             nmfromi = dict(( (i,leg[1]) for i,leg in enumerate(legend) ))
-            ifromnm = dict(( (leg[1], i) for i,leg in enumerate(legend) ))
+            #~ ifromnm = dict(( (leg[1], i) for i,leg in enumerate(legend) ))
 
             for row in data:
                 try:
 
     def unhandled_input(self, input):
         '''Handle input that wasn't already.'''
-        if self.db: dbconns = self.db.conns
-        else:       dbconns = ()
         i = self.body.get_focus_column()
         log.debug('focus in column:%s' % i)