merge from eric @6df03cb...
This commit is contained in:
commit
8d77b961d7
|
@ -94,29 +94,32 @@ def cardFromValueSuit(value, suit):
|
||||||
elif suit == 's': return(value+38)
|
elif suit == 's': return(value+38)
|
||||||
else: return(0)
|
else: return(0)
|
||||||
|
|
||||||
def valueSuitFromCard(card):
|
suitFromCardList = ['', '2h', '3h', '4h', '5h', '6h', '7h', '8h', '9h', 'Th', 'Jh', 'Qh', 'Kh', 'Ah'
|
||||||
""" Function to convert a card stored in the database (int 0-52) into value
|
|
||||||
and suit like 9s, 4c etc """
|
|
||||||
if card < 0 or card > 52 or not card:
|
|
||||||
return('')
|
|
||||||
else:
|
|
||||||
return( ['', '2h', '3h', '4h', '5h', '6h', '7h', '8h', '9h', 'Th', 'Jh', 'Qh', 'Kh', 'Ah'
|
|
||||||
, '2d', '3d', '4d', '5d', '6d', '7d', '8d', '9d', 'Td', 'Jd', 'Qd', 'Kd', 'Ad'
|
, '2d', '3d', '4d', '5d', '6d', '7d', '8d', '9d', 'Td', 'Jd', 'Qd', 'Kd', 'Ad'
|
||||||
, '2c', '3c', '4c', '5c', '6c', '7c', '8c', '9c', 'Tc', 'Jc', 'Qc', 'Kc', 'Ac'
|
, '2c', '3c', '4c', '5c', '6c', '7c', '8c', '9c', 'Tc', 'Jc', 'Qc', 'Kc', 'Ac'
|
||||||
, '2s', '3s', '4s', '5s', '6s', '7s', '8s', '9s', 'Ts', 'Js', 'Qs', 'Ks', 'As'
|
, '2s', '3s', '4s', '5s', '6s', '7s', '8s', '9s', 'Ts', 'Js', 'Qs', 'Ks', 'As'
|
||||||
][card] )
|
]
|
||||||
|
def valueSuitFromCard(card):
|
||||||
|
""" Function to convert a card stored in the database (int 0-52) into value
|
||||||
|
and suit like 9s, 4c etc """
|
||||||
|
global suitFromCardList
|
||||||
|
if card < 0 or card > 52 or not card:
|
||||||
|
return('')
|
||||||
|
else:
|
||||||
|
return suitFromCardList[card]
|
||||||
|
|
||||||
def encodeCard(cardString):
|
encodeCardList = {'2h': 1, '3h': 2, '4h': 3, '5h': 4, '6h': 5, '7h': 6, '8h': 7, '9h': 8, 'Th': 9, 'Jh': 10, 'Qh': 11, 'Kh': 12, 'Ah': 13,
|
||||||
"""Take a card string (Ah) and convert it to the db card code (1)."""
|
|
||||||
try:
|
|
||||||
return {'2h': 1, '3h': 2, '4h': 3, '5h': 4, '6h': 5, '7h': 6, '8h': 7, '9h': 8, 'Th': 9, 'Jh': 10, 'Qh': 11, 'Kh': 12, 'Ah': 13,
|
|
||||||
'2d': 14, '3d': 15, '4d': 16, '5d': 17, '6d': 18, '7d': 19, '8d': 20, '9d': 21, 'Td': 22, 'Jd': 23, 'Qd': 24, 'Kd': 25, 'Ad': 26,
|
'2d': 14, '3d': 15, '4d': 16, '5d': 17, '6d': 18, '7d': 19, '8d': 20, '9d': 21, 'Td': 22, 'Jd': 23, 'Qd': 24, 'Kd': 25, 'Ad': 26,
|
||||||
'2c': 27, '3c': 28, '4c': 29, '5c': 30, '6c': 31, '7c': 32, '8c': 33, '9c': 34, 'Tc': 35, 'Jc': 36, 'Qc': 27, 'Kc': 38, 'Ac': 39,
|
'2c': 27, '3c': 28, '4c': 29, '5c': 30, '6c': 31, '7c': 32, '8c': 33, '9c': 34, 'Tc': 35, 'Jc': 36, 'Qc': 27, 'Kc': 38, 'Ac': 39,
|
||||||
'2s': 40, '3s': 41, '4s': 42, '5s': 43, '6s': 44, '7s': 45, '8s': 46, '9s': 47, 'Ts': 48, 'Js': 49, 'Qs': 50, 'Ks': 51, 'As': 52,
|
'2s': 40, '3s': 41, '4s': 42, '5s': 43, '6s': 44, '7s': 45, '8s': 46, '9s': 47, 'Ts': 48, 'Js': 49, 'Qs': 50, 'Ks': 51, 'As': 52,
|
||||||
' ': 0
|
' ': 0
|
||||||
}[cardString]
|
}
|
||||||
except:
|
|
||||||
return 0 # everthing that isn't known is a unknown!
|
def encodeCard(cardString):
|
||||||
|
"""Take a card string (Ah) and convert it to the db card code (1)."""
|
||||||
|
global encodeCardList
|
||||||
|
if cardString not in encodeCardList: return 0
|
||||||
|
return encodeCardList[cardString]
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print "fpdb card encoding(same as pokersource)"
|
print "fpdb card encoding(same as pokersource)"
|
||||||
|
|
|
@ -163,7 +163,8 @@ class HUD_main(object):
|
||||||
cards['common'] = comm_cards['common']
|
cards['common'] = comm_cards['common']
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
print "db error: skipping ", new_hand_id, err
|
print "db error: skipping ", new_hand_id, err
|
||||||
sys.stderr.write("Database error %s in hand %d. Skipping.\n" % (err, int(new_hand_id)))
|
if new_hand_id: # new_hand_id is none if we had an error prior to the store
|
||||||
|
sys.stderr.write("Database error %s in hand %d. Skipping.\n" % (err, int(new_hand_id)))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if type == "tour": # hand is from a tournament
|
if type == "tour": # hand is from a tournament
|
||||||
|
|
|
@ -204,10 +204,10 @@ class fpdb:
|
||||||
# print 'User cancelled loading profile'
|
# print 'User cancelled loading profile'
|
||||||
#except:
|
#except:
|
||||||
# pass
|
# pass
|
||||||
try:
|
#try:
|
||||||
self.load_profile()
|
self.load_profile()
|
||||||
except:
|
#except:
|
||||||
pass
|
# pass
|
||||||
self.release_global_lock()
|
self.release_global_lock()
|
||||||
#end def dia_load_profile
|
#end def dia_load_profile
|
||||||
|
|
||||||
|
@ -246,19 +246,16 @@ class fpdb:
|
||||||
|
|
||||||
def dia_recreate_hudcache(self, widget, data=None):
|
def dia_recreate_hudcache(self, widget, data=None):
|
||||||
if self.obtain_global_lock():
|
if self.obtain_global_lock():
|
||||||
try:
|
dia_confirm = gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_WARNING, buttons=(gtk.BUTTONS_YES_NO), message_format="Confirm recreating HUD cache")
|
||||||
dia_confirm = gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_WARNING, buttons=(gtk.BUTTONS_YES_NO), message_format="Confirm recreating HUD cache")
|
diastring = "Please confirm that you want to re-create the HUD cache."
|
||||||
diastring = "Please confirm that you want to re-create the HUD cache."
|
dia_confirm.format_secondary_text(diastring)
|
||||||
dia_confirm.format_secondary_text(diastring)
|
|
||||||
|
|
||||||
response = dia_confirm.run()
|
response = dia_confirm.run()
|
||||||
dia_confirm.destroy()
|
dia_confirm.destroy()
|
||||||
if response == gtk.RESPONSE_YES:
|
if response == gtk.RESPONSE_YES:
|
||||||
self.db.rebuild_hudcache()
|
self.db.rebuild_hudcache()
|
||||||
elif response == gtk.REPSONSE_NO:
|
elif response == gtk.REPSONSE_NO:
|
||||||
print 'User cancelled rebuilding hud cache'
|
print 'User cancelled rebuilding hud cache'
|
||||||
except:
|
|
||||||
pass
|
|
||||||
self.release_global_lock()
|
self.release_global_lock()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,8 @@ class Importer:
|
||||||
self.addToDirList = {}
|
self.addToDirList = {}
|
||||||
self.removeFromFileList = {} # to remove deleted files
|
self.removeFromFileList = {} # to remove deleted files
|
||||||
self.monitor = False
|
self.monitor = False
|
||||||
self.updated = {} #Time last import was run {file:mtime}
|
self.updatedsize = {}
|
||||||
|
self.updatedtime = {}
|
||||||
self.lines = None
|
self.lines = None
|
||||||
self.faobs = None # File as one big string
|
self.faobs = None # File as one big string
|
||||||
self.pos_in_file = {} # dict to remember how far we have read in the file
|
self.pos_in_file = {} # dict to remember how far we have read in the file
|
||||||
|
@ -336,15 +337,18 @@ class Importer:
|
||||||
if os.path.exists(file):
|
if os.path.exists(file):
|
||||||
stat_info = os.stat(file)
|
stat_info = os.stat(file)
|
||||||
#rulog.writelines("path exists ")
|
#rulog.writelines("path exists ")
|
||||||
if file in self.updated:
|
if file in self.updatedsize: # we should be able to assume that if we're in size, we're in time as well
|
||||||
if stat_info.st_size > self.updated[file]:
|
if stat_info.st_size > self.updatedsize[file] or stat_info.st_mtime > self.updatedtime[file]:
|
||||||
self.import_file_dict(self.database, file, self.filelist[file][0], self.filelist[file][1])
|
self.import_file_dict(file, self.filelist[file][0], self.filelist[file][1])
|
||||||
self.updated[file] = stat_info.st_size
|
self.updatedsize[file] = stat_info.st_size
|
||||||
|
self.updatedtime[file] = time()
|
||||||
else:
|
else:
|
||||||
if os.path.isdir(file) or (time() - stat_info.st_mtime) < 60:
|
if os.path.isdir(file) or (time() - stat_info.st_mtime) < 60:
|
||||||
self.updated[file] = 0
|
self.updatedsize[file] = 0
|
||||||
|
self.updatedtime[file] = 0
|
||||||
else:
|
else:
|
||||||
self.updated[file] = stat_info.st_size
|
self.updatedsize[file] = stat_info.st_size
|
||||||
|
self.updatedtime[file] = time()
|
||||||
else:
|
else:
|
||||||
self.removeFromFileList[file] = True
|
self.removeFromFileList[file] = True
|
||||||
self.addToDirList = filter(lambda x: self.addImportDirectory(x, True, self.addToDirList[x][0], self.addToDirList[x][1]), self.addToDirList)
|
self.addToDirList = filter(lambda x: self.addImportDirectory(x, True, self.addToDirList[x][0], self.addToDirList[x][1]), self.addToDirList)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user