reformatting, pep8 stuff

This commit is contained in:
Eric Blade 2011-03-06 06:08:08 -05:00
parent d0acf8e943
commit 10f098dc18
2 changed files with 175 additions and 155 deletions

View File

@ -62,9 +62,11 @@ class Table(Table_Window):
if re.search(self.search_string, titles[hwnd], re.I): if re.search(self.search_string, titles[hwnd], re.I):
if self.check_bad_words(titles[hwnd]): if self.check_bad_words(titles[hwnd]):
continue continue
if not win32gui.IsWindowVisible(hwnd): # if window not visible, probably not a table # if window not visible, probably not a table
if not win32gui.IsWindowVisible(hwnd):
continue continue
if win32gui.GetParent(hwnd) != 0: # if window is a child of another window, probably not a table # if window is a child of another window, probably not a table
if win32gui.GetParent(hwnd) != 0:
continue continue
HasNoOwner = win32gui.GetWindow(hwnd, win32con.GW_OWNER) == 0 HasNoOwner = win32gui.GetWindow(hwnd, win32con.GW_OWNER) == 0
WindowStyle = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) WindowStyle = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)

View File

@ -38,9 +38,9 @@ if os.name == 'nt' and sys.version[0:3] not in ('2.5', '2.6', '2.7') and '-r' no
print "Python " + sys.version[0:3] + _(' - press return to continue\n') print "Python " + sys.version[0:3] + _(' - press return to continue\n')
sys.stdin.readline() sys.stdin.readline()
if os.name == 'nt': if os.name == 'nt':
os.execvpe('pythonw.exe', ('pythonw.exe', 'fpdb.pyw', '-r'), os.environ) # first arg is ignored (name of program being run) os.execvpe('pythonw.exe', ('pythonw.exe', 'fpdb.pyw', '-r'), os.environ)
else: else:
os.execvpe('python', ('python', 'fpdb.pyw', '-r'), os.environ) # first arg is ignored (name of program being run) os.execvpe('python', ('python', 'fpdb.pyw', '-r'), os.environ)
else: else:
print _("\npython 2.5-2.7 not found, please install python 2.5, 2.6 or 2.7 for fpdb\n") print _("\npython 2.5-2.7 not found, please install python 2.5, 2.6 or 2.7 for fpdb\n")
raw_input(_("Press ENTER to continue.")) raw_input(_("Press ENTER to continue."))
@ -67,7 +67,8 @@ import string
cl_options = string.join(sys.argv[1:]) cl_options = string.join(sys.argv[1:])
(options, argv) = Options.fpdb_options() (options, argv) = Options.fpdb_options()
import logging, logging.config import logging
import logging.config
log = logging.getLogger("fpdb") log = logging.getLogger("fpdb")
try: try:
@ -205,9 +206,9 @@ class fpdb:
image = gtk.Image() image = gtk.Image()
image.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_SMALL_TOOLBAR) image.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_SMALL_TOOLBAR)
gtk.Button.set_relief(button, gtk.RELIEF_NONE) gtk.Button.set_relief(button, gtk.RELIEF_NONE)
settings = gtk.Widget.get_settings(button); settings = gtk.Widget.get_settings(button)
(w,h) = gtk.icon_size_lookup_for_settings(settings, gtk.ICON_SIZE_SMALL_TOOLBAR); (w, h) = gtk.icon_size_lookup_for_settings(settings, gtk.ICON_SIZE_SMALL_TOOLBAR)
gtk.Widget.set_size_request(button, w + 4, h + 4); gtk.Widget.set_size_request(button, w + 4, h + 4)
image.show() image.show()
iconBox.pack_start(image, True, False, 0) iconBox.pack_start(image, True, False, 0)
button.add(iconBox) button.add(iconBox)
@ -253,15 +254,15 @@ class fpdb:
db_version = "" db_version = ""
#if self.db is not None: #if self.db is not None:
# db_version = self.db.get_version() # db_version = self.db.get_version()
nums = [ (_('Operating System'), os.name) nums = [(_('Operating System'), os.name),
, ('Python', sys.version[0:3]) ('Python', sys.version[0:3]),
, ('GTK+', '.'.join([str(x) for x in gtk.gtk_version])) ('GTK+', '.'.join([str(x) for x in gtk.gtk_version])),
, ('PyGTK', '.'.join([str(x) for x in gtk.pygtk_version])) ('PyGTK', '.'.join([str(x) for x in gtk.pygtk_version])),
, ('matplotlib', matplotlib_version) ('matplotlib', matplotlib_version),
, ('numpy', numpy_version) ('numpy', numpy_version),
, ('sqlite', sqlite_version) ('sqlite', sqlite_version),
, ('fpdb version', VERSION) ('fpdb version', VERSION),
, ('database used', self.settings['db-server']) ('database used', self.settings['db-server'])
] ]
versions = gtk.TextBuffer() versions = gtk.TextBuffer()
w = 20 # width used for module names and version numbers w = 20 # width used for module names and version numbers
@ -394,7 +395,10 @@ class fpdb:
response = diaSelections.run() response = diaSelections.run()
diaSelections.destroy() diaSelections.destroy()
if response == gtk.RESPONSE_ACCEPT and self.hudConfiguratorRows!=None and self.hudConfiguratorColumns!=None and self.hudConfiguratorGame!=None: if (response == gtk.RESPONSE_ACCEPT and
self.hudConfiguratorRows != None and
self.hudConfiguratorColumns != None and
self.hudConfiguratorGame != None):
#print "clicked ok and selected:", self.hudConfiguratorGame,"with", str(self.hudConfiguratorRows), "rows and", str(self.hudConfiguratorColumns), "columns" #print "clicked ok and selected:", self.hudConfiguratorGame,"with", str(self.hudConfiguratorRows), "rows and", str(self.hudConfiguratorColumns), "columns"
self.diaHudConfiguratorTable() self.diaHudConfiguratorTable()
#end def diaHudConfigurator #end def diaHudConfigurator
@ -442,10 +446,12 @@ class fpdb:
statDir = dir(Stats) statDir = dir(Stats)
statDict = {} statDict = {}
for attr in statDir: for attr in statDir:
if attr.startswith('__'): continue if attr.startswith('__'):
continue
if attr in ("Charset", "Configuration", "Database", "GInitiallyUnowned", "gtk", "pygtk", if attr in ("Charset", "Configuration", "Database", "GInitiallyUnowned", "gtk", "pygtk",
"player", "c", "db_connection", "do_stat", "do_tip", "stat_dict", "player", "c", "db_connection", "do_stat", "do_tip", "stat_dict",
"h", "re", "re_Percent", "re_Places", ): continue "h", "re", "re_Percent", "re_Places", ):
continue
statDict[attr] = eval("Stats.%s.__doc__" % (attr)) statDict[attr] = eval("Stats.%s.__doc__" % (attr))
for rowNumber in range(self.hudConfiguratorRows + 1): for rowNumber in range(self.hudConfiguratorRows + 1):
@ -456,11 +462,17 @@ class fpdb:
pass pass
else: else:
label = gtk.Label("column " + str(columnNumber)) label = gtk.Label("column " + str(columnNumber))
table.attach(child=label, left_attach=columnNumber, right_attach=columnNumber+1, top_attach=rowNumber, bottom_attach=rowNumber+1) table.attach(child=label, left_attach=columnNumber,
right_attach=columnNumber + 1,
top_attach=rowNumber,
bottom_attach=rowNumber + 1)
label.show() label.show()
elif columnNumber == 0: elif columnNumber == 0:
label = gtk.Label("row " + str(rowNumber)) label = gtk.Label("row " + str(rowNumber))
table.attach(child=label, left_attach=columnNumber, right_attach=columnNumber+1, top_attach=rowNumber, bottom_attach=rowNumber+1) table.attach(child=label, left_attach=columnNumber,
right_attach=columnNumber + 1,
top_attach=rowNumber,
bottom_attach=rowNumber + 1)
label.show() label.show()
else: else:
comboBox = gtk.combo_box_new_text() comboBox = gtk.combo_box_new_text()
@ -470,7 +482,10 @@ class fpdb:
comboBox.set_active(0) comboBox.set_active(0)
newRow.append(comboBox) newRow.append(comboBox)
table.attach(child=comboBox, left_attach=columnNumber, right_attach=columnNumber+1, top_attach=rowNumber, bottom_attach=rowNumber+1) table.attach(child=comboBox, left_attach=columnNumber,
right_attach=columnNumber + 1,
top_attach=rowNumber,
bottom_attach=rowNumber + 1)
comboBox.show() comboBox.show()
if rowNumber != 0: if rowNumber != 0:
@ -625,11 +640,11 @@ class fpdb:
def dia_rebuild_indexes(self, widget, data=None): def dia_rebuild_indexes(self, widget, data=None):
if self.obtain_global_lock("dia_rebuild_indexes"): if self.obtain_global_lock("dia_rebuild_indexes"):
self.dia_confirm = gtk.MessageDialog(parent=self.window self.dia_confirm = gtk.MessageDialog(parent=self.window,
,flags=gtk.DIALOG_DESTROY_WITH_PARENT flags=gtk.DIALOG_DESTROY_WITH_PARENT,
,type=gtk.MESSAGE_WARNING type=gtk.MESSAGE_WARNING,
,buttons=(gtk.BUTTONS_YES_NO) buttons=(gtk.BUTTONS_YES_NO),
,message_format=_("Confirm rebuilding database indexes")) message_format=_("Confirm rebuilding database indexes"))
diastring = _("Please confirm that you want to rebuild the database indexes.") diastring = _("Please confirm that you want to rebuild the database indexes.")
self.dia_confirm.format_secondary_text(diastring) self.dia_confirm.format_secondary_text(diastring)
# disable windowclose, do not want the the underlying processing interrupted mid-process # disable windowclose, do not want the the underlying processing interrupted mid-process
@ -693,7 +708,6 @@ class fpdb:
self.logbuffer.insert(end_iter, text) self.logbuffer.insert(end_iter, text)
self.logview.scroll_to_mark(self.logbuffer.get_insert(), 0) self.logview.scroll_to_mark(self.logbuffer.get_insert(), 0)
def process_close_messages(self): def process_close_messages(self):
# check for close messages # check for close messages
try: try:
@ -848,21 +862,20 @@ class fpdb:
return menubar return menubar
#end def get_menu #end def get_menu
def load_profile(self, create_db=False): def load_profile(self, create_db=False):
"""Loads profile from the provided path name.""" """Loads profile from the provided path name."""
self.config = Configuration.Config(file=options.config, dbname=options.dbname) self.config = Configuration.Config(file=options.config, dbname=options.dbname)
if self.config.file_error: if self.config.file_error:
self.warning_box(_("There is an error in your config file\n") + self.config.file self.warning_box(_("There is an error in your config file\n") + self.config.file
+ _("\n\nError is: ") + str(self.config.file_error) + _("\n\nError is: ") + str(self.config.file_error),
, diatitle=_("CONFIG FILE ERROR")) diatitle=_("CONFIG FILE ERROR"))
sys.exit() sys.exit()
log = Configuration.get_logger("logging.conf", "fpdb", log_dir=self.config.dir_log) log = Configuration.get_logger("logging.conf", "fpdb", log_dir=self.config.dir_log)
print (_("Logfile is %s\n") % os.path.join(self.config.dir_log, self.config.log_file)) print (_("Logfile is %s\n") % os.path.join(self.config.dir_log, self.config.log_file))
if self.config.example_copy: if self.config.example_copy:
self.info_box(_("Config file") self.info_box(_("Config file"),
, _("has been created at:\n%s.\n") % self.config.file _("has been created at:\n%s.\n") % self.config.file
+ _("Edit your screen_name and hand history path in the supported_sites section of the Preferences window (Main menu) before trying to import hands.")) + _("Edit your screen_name and hand history path in the supported_sites section of the Preferences window (Main menu) before trying to import hands."))
self.settings = {} self.settings = {}
self.settings['global_lock'] = self.lock self.settings['global_lock'] = self.lock
@ -919,7 +932,8 @@ class fpdb:
# sys.stderr.write("Failed to connect to %s database with username %s." % (self.settings['db-server'], self.settings['db-user'])) # sys.stderr.write("Failed to connect to %s database with username %s." % (self.settings['db-server'], self.settings['db-user']))
if self.db is not None and self.db.wrongDbVersion: if self.db is not None and self.db.wrongDbVersion:
diaDbVersionWarning = gtk.Dialog(title=_("Strong Warning - Invalid database version"), parent=None, flags=0, buttons=(gtk.STOCK_OK,gtk.RESPONSE_OK)) diaDbVersionWarning = gtk.Dialog(title=_("Strong Warning - Invalid database version"),
parent=None, flags=0, buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK))
label = gtk.Label(_("An invalid DB version or missing tables have been detected.")) label = gtk.Label(_("An invalid DB version or missing tables have been detected."))
diaDbVersionWarning.vbox.add(label) diaDbVersionWarning.vbox.add(label)
@ -1129,8 +1143,10 @@ You can find the full license texts in agpl-3.0.txt, gpl-2.0.txt, gpl-3.0.txt an
self.window.set_border_width(1) self.window.set_border_width(1)
defx, defy = 900, 720 defx, defy = 900, 720
sx, sy = gtk.gdk.screen_width(), gtk.gdk.screen_height() sx, sy = gtk.gdk.screen_width(), gtk.gdk.screen_height()
if sx < defx: defx = sx if sx < defx:
if sy < defy: defy = sy defx = sx
if sy < defy:
defy = sy
self.window.set_default_size(defx, defy) self.window.set_default_size(defx, defy)
self.window.set_resizable(True) self.window.set_resizable(True)
@ -1275,15 +1291,17 @@ You can find the full license texts in agpl-3.0.txt, gpl-2.0.txt, gpl-3.0.txt an
self.window.present() self.window.present()
def info_box(self, str1, str2): def info_box(self, str1, str2):
diapath = gtk.MessageDialog( parent=self.window, flags=gtk.DIALOG_DESTROY_WITH_PARENT, type=gtk.MESSAGE_INFO diapath = gtk.MessageDialog(parent=self.window, flags=gtk.DIALOG_DESTROY_WITH_PARENT, type=gtk.MESSAGE_INFO,
, buttons=(gtk.BUTTONS_OK), message_format=str1 ) buttons=(gtk.BUTTONS_OK), message_format=str1)
diapath.format_secondary_text(str2) diapath.format_secondary_text(str2)
response = diapath.run() response = diapath.run()
diapath.destroy() diapath.destroy()
return response return response
def warning_box(self, str, diatitle=_("FPDB WARNING")): def warning_box(self, str, diatitle=_("FPDB WARNING")):
diaWarning = gtk.Dialog(title=diatitle, parent=self.window, flags=gtk.DIALOG_DESTROY_WITH_PARENT, buttons=(gtk.STOCK_OK,gtk.RESPONSE_OK)) diaWarning = gtk.Dialog(title=diatitle, parent=self.window,
flags=gtk.DIALOG_DESTROY_WITH_PARENT,
buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK))
label = gtk.Label(str) label = gtk.Label(str)
diaWarning.vbox.add(label) diaWarning.vbox.add(label)
@ -1329,10 +1347,10 @@ You can find the full license texts in agpl-3.0.txt, gpl-2.0.txt, gpl-3.0.txt an
self.add_site(site) self.add_site(site)
def add_site(self, site): def add_site(self, site):
dia = gtk.Dialog( title="Add Site", parent=self.window dia = gtk.Dialog(title="Add Site", parent=self.window,
, flags=gtk.DIALOG_DESTROY_WITH_PARENT flags=gtk.DIALOG_DESTROY_WITH_PARENT,
, buttons=(gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT buttons=(gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT,
,gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT) gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT)
) )
h = gtk.HBox() h = gtk.HBox()