Merge branch 'master' of git://git.assembla.com/fpdboz
This commit is contained in:
commit
a7bace7ddc
|
@ -32,12 +32,12 @@ import shutil
|
||||||
import xml.dom.minidom
|
import xml.dom.minidom
|
||||||
from xml.dom.minidom import Node
|
from xml.dom.minidom import Node
|
||||||
|
|
||||||
def fix_tf(x):
|
def fix_tf(x, default = True):
|
||||||
if x == "1" or x == 1 or string.lower(x) == "true" or string.lower(x) == "t":
|
if x == "1" or x == 1 or string.lower(x) == "true" or string.lower(x) == "t":
|
||||||
return True
|
return True
|
||||||
if x == "0" or x == 0 or string.lower(x) == "false" or string.lower(x) == "f":
|
if x == "0" or x == 0 or string.lower(x) == "false" or string.lower(x) == "f":
|
||||||
return False
|
return False
|
||||||
return False
|
return default
|
||||||
|
|
||||||
class Layout:
|
class Layout:
|
||||||
def __init__(self, node):
|
def __init__(self, node):
|
||||||
|
@ -212,18 +212,12 @@ class Import:
|
||||||
self.interval = node.getAttribute("interval")
|
self.interval = node.getAttribute("interval")
|
||||||
self.callFpdbHud = node.getAttribute("callFpdbHud")
|
self.callFpdbHud = node.getAttribute("callFpdbHud")
|
||||||
self.hhArchiveBase = node.getAttribute("hhArchiveBase")
|
self.hhArchiveBase = node.getAttribute("hhArchiveBase")
|
||||||
if node.hasAttribute("saveActions"):
|
self.saveActions = fix_tf(node.getAttribute("saveActions"), True)
|
||||||
self.saveActions = fix_tf(node.getAttribute("saveActions"))
|
self.fastStoreHudCache = fix_tf(node.getAttribute("fastStoreHudCache"), True)
|
||||||
else:
|
|
||||||
self.saveActions = True
|
|
||||||
if node.hasAttribute("fastStoreHudCache"):
|
|
||||||
self.fastStoreHudCache = fix_tf(node.getAttribute("fastStoreHudCache"))
|
|
||||||
else:
|
|
||||||
self.fastStoreHudCache = False
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return " interval = %s\n callFpdbHud = %s\n hhArchiveBase = %s\n saveActions = %s\n fastStoreHudCache = %s\n" \
|
return " interval = %s\n callFpdbHud = %s\n hhArchiveBase = %s\n saveActions = %s\n fastStoreHudCache = %s\n" \
|
||||||
% (self.interval, self.callFpdbHud, self.hhArchiveBase, self.saveActions, self.saveActions)
|
% (self.interval, self.callFpdbHud, self.hhArchiveBase, self.saveActions, self.fastStoreHudCache)
|
||||||
|
|
||||||
class Tv:
|
class Tv:
|
||||||
def __init__(self, node):
|
def __init__(self, node):
|
||||||
|
|
|
@ -122,21 +122,10 @@ follow : whether to tail -f the input"""
|
||||||
hand.handid = m.group('HID')
|
hand.handid = m.group('HID')
|
||||||
hand.tablename = m.group('TABLE')
|
hand.tablename = m.group('TABLE')
|
||||||
hand.starttime = time.strptime(m.group('DATETIME'), "%H:%M:%S ET - %Y/%m/%d")
|
hand.starttime = time.strptime(m.group('DATETIME'), "%H:%M:%S ET - %Y/%m/%d")
|
||||||
|
|
||||||
# attributes
|
|
||||||
# (deep 6)
|
|
||||||
# (6 max)
|
|
||||||
#
|
|
||||||
# be goodd idea to log those what we don't know idea
|
|
||||||
hand.maxseats = 8 # assume 8-max until we see otherwise
|
hand.maxseats = 8 # assume 8-max until we see otherwise
|
||||||
# stud tables are usually 8-max?
|
if m.group('TABLEATTRIBUTES'):
|
||||||
#
|
m2 = re.search("(\d+) max", m.group('TABLEATTRIBUTES'))
|
||||||
atts = m.group('ATTRIBUTES')
|
hand.maxseats = int(m2.group(1))
|
||||||
if atts:
|
|
||||||
# TODO: parse these
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
# These work, but the info is already in the Hand class - should be used for tourneys though.
|
# These work, but the info is already in the Hand class - should be used for tourneys though.
|
||||||
# m.group('SB')
|
# m.group('SB')
|
||||||
# m.group('BB')
|
# m.group('BB')
|
||||||
|
|
|
@ -176,7 +176,10 @@ class GuiBulkImport():
|
||||||
# ComboBox - filter
|
# ComboBox - filter
|
||||||
self.cbfilter = gtk.combo_box_new_text()
|
self.cbfilter = gtk.combo_box_new_text()
|
||||||
self.cbfilter.append_text("passthrough")
|
self.cbfilter.append_text("passthrough")
|
||||||
self.cbfilter.append_text("Everleaf")
|
self.cbfilter.append_text("BetfairToFpdb")
|
||||||
|
self.cbfilter.append_text("EverleafToFpdb")
|
||||||
|
self.cbfilter.append_text("FulltiltToFpdb")
|
||||||
|
self.cbfilter.append_text("PokerStarsToFpdb")
|
||||||
self.cbfilter.set_active(0)
|
self.cbfilter.set_active(0)
|
||||||
self.table.attach(self.cbfilter, 3, 4, 2, 3, xpadding = 10, ypadding = 0, yoptions=gtk.SHRINK)
|
self.table.attach(self.cbfilter, 3, 4, 2, 3, xpadding = 10, ypadding = 0, yoptions=gtk.SHRINK)
|
||||||
self.cbfilter.show()
|
self.cbfilter.show()
|
||||||
|
|
|
@ -123,7 +123,7 @@ class HUD_main(object):
|
||||||
gtk.gdk.threads_enter()
|
gtk.gdk.threads_enter()
|
||||||
try:
|
try:
|
||||||
self.hud_dict[table_name].update(new_hand_id, config)
|
self.hud_dict[table_name].update(new_hand_id, config)
|
||||||
map(lambda aw: aw.update_gui(new_hand_id), self.hud_dict[table_name].aux_windows)
|
[aw.update_gui(new_hand_id) for aw in self.hud_dict[table_name].aux_windows]
|
||||||
return False
|
return False
|
||||||
finally:
|
finally:
|
||||||
gtk.gdk.threads_leave()
|
gtk.gdk.threads_leave()
|
||||||
|
@ -152,6 +152,8 @@ class HUD_main(object):
|
||||||
(table_name, max, poker_game) = self.db_connection.get_table_name(new_hand_id)
|
(table_name, max, poker_game) = self.db_connection.get_table_name(new_hand_id)
|
||||||
stat_dict = self.db_connection.get_stats_from_hand(new_hand_id)
|
stat_dict = self.db_connection.get_stats_from_hand(new_hand_id)
|
||||||
cards = self.db_connection.get_cards(new_hand_id)
|
cards = self.db_connection.get_cards(new_hand_id)
|
||||||
|
comm_cards = self.db_connection.get_common_cards(new_hand_id)
|
||||||
|
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)))
|
sys.stderr.write("Database error %s in hand %d. Skipping.\n" % (err, int(new_hand_id)))
|
||||||
|
@ -172,8 +174,7 @@ class HUD_main(object):
|
||||||
if temp_key in self.hud_dict:
|
if temp_key in self.hud_dict:
|
||||||
self.hud_dict[temp_key].stat_dict = stat_dict
|
self.hud_dict[temp_key].stat_dict = stat_dict
|
||||||
self.hud_dict[temp_key].cards = cards
|
self.hud_dict[temp_key].cards = cards
|
||||||
for aw in self.hud_dict[temp_key].aux_windows:
|
[aw.update_data(new_hand_id, self.db_connection) for aw in self.hud_dict[temp_key].aux_windows]
|
||||||
aw.update_data(new_hand_id, self.db_connection)
|
|
||||||
self.update_HUD(new_hand_id, temp_key, self.config)
|
self.update_HUD(new_hand_id, temp_key, self.config)
|
||||||
|
|
||||||
# Or create a new HUD
|
# Or create a new HUD
|
||||||
|
|
|
@ -99,3 +99,15 @@ class Hello_plus(Aux_Window):
|
||||||
# hands played that was updated in the "update_data()" function.
|
# hands played that was updated in the "update_data()" function.
|
||||||
self.label.set_text("Hello %s\nYou have played %d hands\n on %s." % (self.hero, self.hands_played, self.site))
|
self.label.set_text("Hello %s\nYou have played %d hands\n on %s." % (self.hero, self.hands_played, self.site))
|
||||||
|
|
||||||
|
class Hello_Menu(Aux_Window):
|
||||||
|
"""A 'Hello World' Aux_Window demo."""
|
||||||
|
def create(self):
|
||||||
|
# This demo puts a menu item on the HUD mainwindow.
|
||||||
|
self.item = gtk.MenuItem('Print cards')
|
||||||
|
self.hud.menu.append(self.item)
|
||||||
|
self.item.connect("activate", self.print_cards)
|
||||||
|
self.item.show()
|
||||||
|
|
||||||
|
def print_cards(self, *args):
|
||||||
|
# callback for the menu item
|
||||||
|
print "cards =", self.hud.cards
|
||||||
|
|
|
@ -196,7 +196,7 @@ class Hud:
|
||||||
s.window.destroy()
|
s.window.destroy()
|
||||||
self.stat_windows = {}
|
self.stat_windows = {}
|
||||||
# also kill any aux windows
|
# also kill any aux windows
|
||||||
map(lambda m: m.destroy(), self.aux_windows)
|
[aux.destroy() for aux in self.aux_windows]
|
||||||
self.aux_windows = []
|
self.aux_windows = []
|
||||||
|
|
||||||
def reposition_windows(self, *args):
|
def reposition_windows(self, *args):
|
||||||
|
@ -217,8 +217,7 @@ class Hud:
|
||||||
new_layout[self.stat_windows[sw].adj - 1] = new_loc
|
new_layout[self.stat_windows[sw].adj - 1] = new_loc
|
||||||
self.config.edit_layout(self.table.site, self.max, locations = new_layout)
|
self.config.edit_layout(self.table.site, self.max, locations = new_layout)
|
||||||
# ask each aux to save its layout back to the config object
|
# ask each aux to save its layout back to the config object
|
||||||
for aux in self.aux_windows:
|
[aux.save_layout() for aux in self.aux_windows]
|
||||||
aux.save_layout()
|
|
||||||
# save the config object back to the file
|
# save the config object back to the file
|
||||||
print "saving new xml file"
|
print "saving new xml file"
|
||||||
self.config.save()
|
self.config.save()
|
||||||
|
@ -351,6 +350,8 @@ class Hud:
|
||||||
style = win32gui.GetWindowLong(self.table.number, win32con.GWL_EXSTYLE)
|
style = win32gui.GetWindowLong(self.table.number, win32con.GWL_EXSTYLE)
|
||||||
style |= win32con.WS_CLIPCHILDREN
|
style |= win32con.WS_CLIPCHILDREN
|
||||||
win32gui.SetWindowLong(self.table.number, win32con.GWL_EXSTYLE, style)
|
win32gui.SetWindowLong(self.table.number, win32con.GWL_EXSTYLE, style)
|
||||||
|
break
|
||||||
|
|
||||||
window.set_title(real_name)
|
window.set_title(real_name)
|
||||||
|
|
||||||
class Stat_Window:
|
class Stat_Window:
|
||||||
|
@ -575,6 +576,7 @@ class Popup_window:
|
||||||
style = win32gui.GetWindowLong(self.table.number, win32con.GWL_EXSTYLE)
|
style = win32gui.GetWindowLong(self.table.number, win32con.GWL_EXSTYLE)
|
||||||
style |= win32con.WS_CLIPCHILDREN
|
style |= win32con.WS_CLIPCHILDREN
|
||||||
win32gui.SetWindowLong(self.table.number, win32con.GWL_EXSTYLE, style)
|
win32gui.SetWindowLong(self.table.number, win32con.GWL_EXSTYLE, style)
|
||||||
|
break
|
||||||
|
|
||||||
window.set_title(real_name)
|
window.set_title(real_name)
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ Mucked cards display for FreePokerTools HUD.
|
||||||
|
|
||||||
# Standard Library modules
|
# Standard Library modules
|
||||||
import sys
|
import sys
|
||||||
|
import pprint
|
||||||
|
|
||||||
# pyGTK modules
|
# pyGTK modules
|
||||||
import pygtk
|
import pygtk
|
||||||
|
@ -37,7 +38,7 @@ import Database
|
||||||
|
|
||||||
class Aux_Window:
|
class Aux_Window:
|
||||||
def __init__(self, hud, params, config):
|
def __init__(self, hud, params, config):
|
||||||
self.config = hud
|
self.hud = hud
|
||||||
self.config = config
|
self.config = config
|
||||||
|
|
||||||
def update_data(self, *parms):
|
def update_data(self, *parms):
|
||||||
|
@ -318,6 +319,7 @@ class Flop_Mucked(Aux_Window):
|
||||||
self.params = params # dict aux params from config
|
self.params = params # dict aux params from config
|
||||||
self.positions = {} # dict of window positions
|
self.positions = {} # dict of window positions
|
||||||
self.displayed_cards = False
|
self.displayed_cards = False
|
||||||
|
self.timer_on = False # bool = Ture if the timeout for removing the cards is on
|
||||||
self.card_images = self.get_card_images()
|
self.card_images = self.get_card_images()
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
|
@ -349,10 +351,6 @@ class Flop_Mucked(Aux_Window):
|
||||||
self.m_windows[i].show_all()
|
self.m_windows[i].show_all()
|
||||||
self.m_windows[i].hide()
|
self.m_windows[i].hide()
|
||||||
|
|
||||||
def update_data(self, new_hand_id, db_connection):
|
|
||||||
cards = db_connection.get_common_cards(new_hand_id)
|
|
||||||
self.hud.cards['common'] = cards['common']
|
|
||||||
|
|
||||||
def update_gui(self, new_hand_id):
|
def update_gui(self, new_hand_id):
|
||||||
"""Prepare and show the mucked cards."""
|
"""Prepare and show the mucked cards."""
|
||||||
if self.displayed_cards:
|
if self.displayed_cards:
|
||||||
|
@ -378,35 +376,64 @@ class Flop_Mucked(Aux_Window):
|
||||||
self.m_windows[i].move(self.positions[i][0], self.positions[i][1]) # here is where I move back
|
self.m_windows[i].move(self.positions[i][0], self.positions[i][1]) # here is where I move back
|
||||||
self.displayed_cards = True
|
self.displayed_cards = True
|
||||||
|
|
||||||
|
for stats in self.hud.stat_dict.itervalues():
|
||||||
|
self.eb[stats['seat']].set_tooltip_text(stats['screen_name'])
|
||||||
|
|
||||||
if self.displayed_cards and float(self.params['timeout']) > 0:
|
if self.displayed_cards and float(self.params['timeout']) > 0:
|
||||||
gobject.timeout_add(int(1000*float(self.params['timeout'])), self.hide_mucked_cards)
|
self.timer_on = True
|
||||||
|
gobject.timeout_add(int(1000*float(self.params['timeout'])), self.timed_out)
|
||||||
|
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
"""Destroy all of the mucked windows."""
|
"""Destroy all of the mucked windows."""
|
||||||
for w in self.m_windows.values():
|
for w in self.m_windows.values():
|
||||||
w.destroy()
|
w.destroy()
|
||||||
|
|
||||||
|
def timed_out(self):
|
||||||
|
# this is the callback from the timeout
|
||||||
|
|
||||||
|
# if timer_on is False the user has cancelled the timer with a click
|
||||||
|
# so just return False to cancel the timer
|
||||||
|
if not self.timer_on:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
self.hide_mucked_cards()
|
||||||
|
return False
|
||||||
|
|
||||||
def hide_mucked_cards(self):
|
def hide_mucked_cards(self):
|
||||||
"""Hide the mucked card windows."""
|
"""Hide the mucked card windows."""
|
||||||
# this is the callback from the timeout
|
|
||||||
for (i, w) in self.m_windows.iteritems():
|
for (i, w) in self.m_windows.iteritems():
|
||||||
self.positions[i] = w.get_position()
|
self.positions[i] = w.get_position()
|
||||||
w.hide()
|
w.hide()
|
||||||
self.displayed_cards = False
|
self.displayed_cards = False
|
||||||
return False # this tells the system to NOT run this timeout again
|
|
||||||
|
|
||||||
def button_press_cb(self, widget, event, *args):
|
def button_press_cb(self, widget, event, *args):
|
||||||
"""Handle button clicks in the event boxes."""
|
"""Handle button clicks in the event boxes."""
|
||||||
|
|
||||||
|
# shift-any button exposes all the windows and turns off the timer
|
||||||
|
if event.state & gtk.gdk.SHIFT_MASK:
|
||||||
|
self.timer_on = False
|
||||||
|
self.expose_all()
|
||||||
|
|
||||||
if event.button == 3: # right button event
|
if event.button == 3: # right button event
|
||||||
pass
|
pass
|
||||||
|
|
||||||
elif event.button == 2: # middle button event
|
elif event.button == 2: # middle button event
|
||||||
|
if self.timer_on == True:
|
||||||
|
self.timer_on = False
|
||||||
|
else:
|
||||||
|
self.timer_on = False
|
||||||
self.hide_mucked_cards()
|
self.hide_mucked_cards()
|
||||||
|
|
||||||
elif event.button == 1: # left button event
|
elif event.button == 1: # left button event
|
||||||
window = widget.get_parent()
|
window = widget.get_parent()
|
||||||
window.begin_move_drag(event.button, int(event.x_root), int(event.y_root), event.time)
|
window.begin_move_drag(event.button, int(event.x_root), int(event.y_root), event.time)
|
||||||
|
|
||||||
|
def expose_all(self):
|
||||||
|
for (i, cards) in self.hud.cards.iteritems():
|
||||||
|
self.m_windows[i].present()
|
||||||
|
self.m_windows[i].move(self.positions[i][0], self.positions[i][1]) # here is where I move back
|
||||||
|
self.displayed_cards = True
|
||||||
|
|
||||||
def save_layout(self, *args):
|
def save_layout(self, *args):
|
||||||
"""Save new layout back to the aux element in the config file."""
|
"""Save new layout back to the aux element in the config file."""
|
||||||
new_locs = {}
|
new_locs = {}
|
||||||
|
|
|
@ -82,20 +82,10 @@ class fpdb:
|
||||||
"""displays the indicated tab"""
|
"""displays the indicated tab"""
|
||||||
#print "start of display_tab, len(self.tab_names):",len(self.tab_names)
|
#print "start of display_tab, len(self.tab_names):",len(self.tab_names)
|
||||||
tab_no = -1
|
tab_no = -1
|
||||||
#if len(self.tab_names)>1:
|
for i, name in enumerate(self.tab_names):
|
||||||
for i in range(len(self.tab_names)):
|
if name == new_tab_name:
|
||||||
#print "display_tab, new_tab_name:",new_tab_name," self.tab_names[i]:", self.tab_names[i]
|
|
||||||
if (new_tab_name==self.tab_names[i]):
|
|
||||||
tab_no = i
|
tab_no = i
|
||||||
#self.tab_buttons[i].set_active(False)
|
break
|
||||||
#else:
|
|
||||||
# tab_no=0
|
|
||||||
|
|
||||||
#current_tab_no=-1
|
|
||||||
for i in range(len(self.tab_names)):
|
|
||||||
if self.current_tab==self.tabs[i]:
|
|
||||||
#self.tab_buttons[i].set_active(False)
|
|
||||||
pass
|
|
||||||
|
|
||||||
if tab_no == -1:
|
if tab_no == -1:
|
||||||
raise fpdb_simple.FpdbError("invalid tab_no")
|
raise fpdb_simple.FpdbError("invalid tab_no")
|
||||||
|
@ -199,9 +189,10 @@ class fpdb:
|
||||||
def dia_recreate_tables(self, widget, data):
|
def dia_recreate_tables(self, widget, data):
|
||||||
"""Dialogue that asks user to confirm that he wants to delete and recreate the tables"""
|
"""Dialogue that asks user to confirm that he wants to delete and recreate the tables"""
|
||||||
self.obtain_global_lock()
|
self.obtain_global_lock()
|
||||||
|
|
||||||
dia_confirm = gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_WARNING,
|
dia_confirm = gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_WARNING,
|
||||||
buttons=(gtk.BUTTONS_YES_NO), message_format="Confirm deleting and recreating tables")
|
buttons=(gtk.BUTTONS_YES_NO), message_format="Confirm deleting and recreating tables")
|
||||||
diastring=("Please confirm that you want to (re-)create the tables. If there already are tables in the database "+self.db.database+" on "+self.db.host+" they will be deleted.")
|
diastring = "Please confirm that you want to (re-)create the tables. If there already are tables in the database "+self.db.database+" on "+self.db.host+" they will be deleted."
|
||||||
dia_confirm.format_secondary_text(diastring)#todo: make above string with bold for db, host and deleted
|
dia_confirm.format_secondary_text(diastring)#todo: make above string with bold for db, host and deleted
|
||||||
|
|
||||||
response = dia_confirm.run()
|
response = dia_confirm.run()
|
||||||
|
|
|
@ -37,10 +37,7 @@ class fpdb_db:
|
||||||
raise FpdbError('Configuration not defined')
|
raise FpdbError('Configuration not defined')
|
||||||
|
|
||||||
self.settings = {}
|
self.settings = {}
|
||||||
if (os.sep=="/"):
|
self.settings['os'] = "linuxmac" if os.name != "nt" else "windows"
|
||||||
self.settings['os']="linuxmac"
|
|
||||||
else:
|
|
||||||
self.settings['os']="windows"
|
|
||||||
|
|
||||||
self.settings.update(config.get_db_parameters())
|
self.settings.update(config.get_db_parameters())
|
||||||
self.connect(self.settings['db-backend'],
|
self.connect(self.settings['db-backend'],
|
||||||
|
|
|
@ -196,6 +196,7 @@ class Importer:
|
||||||
self.addImportDirectory(self.dirlist[site][0], False, site, self.dirlist[site][1])
|
self.addImportDirectory(self.dirlist[site][0], False, site, self.dirlist[site][1])
|
||||||
|
|
||||||
for file in self.filelist:
|
for file in self.filelist:
|
||||||
|
if os.path.exists(file):
|
||||||
stat_info = os.stat(file)
|
stat_info = os.stat(file)
|
||||||
try:
|
try:
|
||||||
lastupdate = self.updated[file]
|
lastupdate = self.updated[file]
|
||||||
|
@ -213,7 +214,8 @@ class Importer:
|
||||||
# TODO we also test if directory, why?
|
# TODO we also test if directory, why?
|
||||||
#if os.path.isdir(file):
|
#if os.path.isdir(file):
|
||||||
#self.import_file_dict(file, self.filelist[file][0], self.filelist[file][1])
|
#self.import_file_dict(file, self.filelist[file][0], self.filelist[file][1])
|
||||||
|
else:
|
||||||
|
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)
|
||||||
|
|
||||||
for file in self.removeFromFileList:
|
for file in self.removeFromFileList:
|
||||||
|
@ -259,7 +261,6 @@ class Importer:
|
||||||
print "Unknown filter filter_name:'%s' in filter:'%s'" %(filter_name, filter)
|
print "Unknown filter filter_name:'%s' in filter:'%s'" %(filter_name, filter)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
#This will barf if conv.getStatus != True
|
#This will barf if conv.getStatus != True
|
||||||
return (stored, duplicates, partial, errors, ttime)
|
return (stored, duplicates, partial, errors, ttime)
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,9 @@ import fpdb_save_to_db
|
||||||
#parses a holdem hand
|
#parses a holdem hand
|
||||||
def mainParser(backend, db, cursor, site, category, hand, config):
|
def mainParser(backend, db, cursor, site, category, hand, config):
|
||||||
category = fpdb_simple.recogniseCategory(hand[0])
|
category = fpdb_simple.recogniseCategory(hand[0])
|
||||||
if (category=="holdem" or category=="omahahi" or category=="omahahilo"):
|
|
||||||
base="hold"
|
base = "hold" if category == "holdem" or category == "omahahi" or category == "omahahilo" else "stud"
|
||||||
else:
|
|
||||||
base="stud"
|
|
||||||
#part 0: create the empty arrays
|
#part 0: create the empty arrays
|
||||||
lineTypes = [] #char, valid values: header, name, cards, action, win, rake, ignore
|
lineTypes = [] #char, valid values: header, name, cards, action, win, rake, ignore
|
||||||
lineStreets = [] #char, valid values: (predeal, preflop, flop, turn, river)
|
lineStreets = [] #char, valid values: (predeal, preflop, flop, turn, river)
|
||||||
|
@ -41,14 +40,13 @@ def mainParser(backend, db, cursor, site, category, hand, config):
|
||||||
|
|
||||||
isTourney = fpdb_simple.isTourney(hand[0])
|
isTourney = fpdb_simple.isTourney(hand[0])
|
||||||
smallBlindLine = 0
|
smallBlindLine = 0
|
||||||
for i in range(len(hand)):
|
for i, line in enumerate(hand):
|
||||||
if 'posts small blind' in hand[i] or 'posts the small blind' in hand[i]:
|
if 'posts small blind' in line or 'posts the small blind' in line:
|
||||||
if hand[i][-2:] == "$0":
|
if line[-2:] == "$0": continue
|
||||||
continue
|
|
||||||
smallBlindLine = i
|
smallBlindLine = i
|
||||||
#print "found small blind line:",smallBlindLine
|
|
||||||
break
|
break
|
||||||
#print "small blind line:",smallBlindLine
|
#print "small blind line:",smallBlindLine
|
||||||
|
|
||||||
gametypeID = fpdb_simple.recogniseGametypeID(backend, db, cursor, hand[0], hand[smallBlindLine], siteID, category, isTourney)
|
gametypeID = fpdb_simple.recogniseGametypeID(backend, db, cursor, hand[0], hand[smallBlindLine], siteID, category, isTourney)
|
||||||
if isTourney:
|
if isTourney:
|
||||||
if site != "ps":
|
if site != "ps":
|
||||||
|
@ -63,6 +61,7 @@ def mainParser(backend, db, cursor, site, category, hand, config):
|
||||||
rebuyOrAddon = fpdb_simple.isRebuyOrAddon(hand[0])
|
rebuyOrAddon = fpdb_simple.isRebuyOrAddon(hand[0])
|
||||||
|
|
||||||
tourneyTypeId = fpdb_simple.recogniseTourneyTypeId(cursor, siteID, buyin, fee, knockout, rebuyOrAddon)
|
tourneyTypeId = fpdb_simple.recogniseTourneyTypeId(cursor, siteID, buyin, fee, knockout, rebuyOrAddon)
|
||||||
|
|
||||||
fpdb_simple.isAlreadyInDB(cursor, gametypeID, siteHandNo)
|
fpdb_simple.isAlreadyInDB(cursor, gametypeID, siteHandNo)
|
||||||
|
|
||||||
hand=fpdb_simple.filterCrap(site, hand, isTourney)
|
hand=fpdb_simple.filterCrap(site, hand, isTourney)
|
||||||
|
@ -72,9 +71,10 @@ def mainParser(backend, db, cursor, site, category, hand, config):
|
||||||
|
|
||||||
#part 3: read basic player info
|
#part 3: read basic player info
|
||||||
#3a read player names, startcashes
|
#3a read player names, startcashes
|
||||||
for i in range (len(hand)): #todo: use maxseats+1 here.
|
for i, line in enumerate(hand):
|
||||||
if (lineTypes[i]=="name"):
|
if lineTypes[i] == "name":
|
||||||
seatLines.append(hand[i])
|
seatLines.append(line)
|
||||||
|
|
||||||
names = fpdb_simple.parseNames(seatLines)
|
names = fpdb_simple.parseNames(seatLines)
|
||||||
playerIDs = fpdb_simple.recognisePlayerIDs(cursor, names, siteID)
|
playerIDs = fpdb_simple.recognisePlayerIDs(cursor, names, siteID)
|
||||||
tmp = fpdb_simple.parseCashesAndSeatNos(seatLines, site)
|
tmp = fpdb_simple.parseCashesAndSeatNos(seatLines, site)
|
||||||
|
@ -88,33 +88,32 @@ def mainParser(backend, db, cursor, site, category, hand, config):
|
||||||
positions = fpdb_simple.parsePositions(hand, names)
|
positions = fpdb_simple.parsePositions(hand, names)
|
||||||
|
|
||||||
#part 4: take appropriate action for each line based on linetype
|
#part 4: take appropriate action for each line based on linetype
|
||||||
for i in range(len(hand)):
|
for i, line in enumerate(hand):
|
||||||
if (lineTypes[i]=="cards"):
|
if lineTypes[i] == "cards":
|
||||||
fpdb_simple.parseCardLine (site, category, lineStreets[i], hand[i], names, cardValues, cardSuits, boardValues, boardSuits)
|
fpdb_simple.parseCardLine(site, category, lineStreets[i], line, names, cardValues, cardSuits, boardValues, boardSuits)
|
||||||
#if category=="studhilo":
|
#if category=="studhilo":
|
||||||
# print "hand[i]:", hand[i]
|
# print "hand[i]:", hand[i]
|
||||||
# print "cardValues:", cardValues
|
# print "cardValues:", cardValues
|
||||||
# print "cardSuits:", cardSuits
|
# print "cardSuits:", cardSuits
|
||||||
elif (lineTypes[i]=="action"):
|
elif lineTypes[i] == "action":
|
||||||
fpdb_simple.parseActionLine (site, base, isTourney, hand[i], lineStreets[i], playerIDs, names, actionTypes, allIns, actionAmounts, actionNos, actionTypeByNo)
|
fpdb_simple.parseActionLine(site, base, isTourney, line, lineStreets[i], playerIDs, names, actionTypes, allIns, actionAmounts, actionNos, actionTypeByNo)
|
||||||
elif (lineTypes[i]=="win"):
|
elif lineTypes[i] == "win":
|
||||||
fpdb_simple.parseWinLine (hand[i], site, names, winnings, isTourney)
|
fpdb_simple.parseWinLine(line, site, names, winnings, isTourney)
|
||||||
elif (lineTypes[i]=="rake"):
|
elif lineTypes[i] == "rake":
|
||||||
if isTourney:
|
totalRake = 0 if isTourney else fpdb_simple.parseRake(line)
|
||||||
totalRake=0
|
|
||||||
else:
|
|
||||||
totalRake=fpdb_simple.parseRake(hand[i])
|
|
||||||
fpdb_simple.splitRake(winnings, rakes, totalRake)
|
fpdb_simple.splitRake(winnings, rakes, totalRake)
|
||||||
elif (lineTypes[i]=="header" or lineTypes[i]=="rake" or lineTypes[i]=="name" or lineTypes[i]=="ignore"):
|
elif lineTypes[i]=="header" or lineTypes[i]=="rake" or lineTypes[i]=="name" or lineTypes[i]=="ignore":
|
||||||
pass
|
pass
|
||||||
elif (lineTypes[i]=="ante"):
|
elif lineTypes[i]=="ante":
|
||||||
fpdb_simple.parseAnteLine(hand[i], site, isTourney, names, antes)
|
fpdb_simple.parseAnteLine(line, site, isTourney, names, antes)
|
||||||
elif (lineTypes[i]=="table"):
|
elif lineTypes[i]=="table":
|
||||||
tableResult=fpdb_simple.parseTableLine(site, base, hand[i])
|
tableResult=fpdb_simple.parseTableLine(site, base, line)
|
||||||
else:
|
else:
|
||||||
raise fpdb_simple.FpdbError("unrecognised lineType:"+lineTypes[i])
|
raise fpdb_simple.FpdbError("unrecognised lineType:"+lineTypes[i])
|
||||||
|
|
||||||
if site == "ftp":
|
if site == "ftp":
|
||||||
tableResult = fpdb_simple.parseTableLine(site, base, hand[0])
|
tableResult = fpdb_simple.parseTableLine(site, base, hand[0])
|
||||||
|
|
||||||
maxSeats = tableResult['maxSeats']
|
maxSeats = tableResult['maxSeats']
|
||||||
tableName = tableResult['tableName']
|
tableName = tableResult['tableName']
|
||||||
#print "before part5, antes:", antes
|
#print "before part5, antes:", antes
|
||||||
|
@ -131,10 +130,9 @@ def mainParser(backend, db, cursor, site, category, hand, config):
|
||||||
limit_type = cursor.fetchone()[0]
|
limit_type = cursor.fetchone()[0]
|
||||||
fpdb_simple.convert3B4B(site, category, limit_type, actionTypes, actionAmounts)
|
fpdb_simple.convert3B4B(site, category, limit_type, actionTypes, actionAmounts)
|
||||||
|
|
||||||
totalWinnings=0
|
totalWinnings = sum(winnings)
|
||||||
for i in range(len(winnings)):
|
|
||||||
totalWinnings+=winnings[i]
|
|
||||||
|
|
||||||
|
# if hold'em, use positions and not antes, if stud do not use positions, use antes
|
||||||
if base == "hold":
|
if base == "hold":
|
||||||
hudImportData = fpdb_simple.generateHudCacheData(playerIDs, base, category, actionTypes
|
hudImportData = fpdb_simple.generateHudCacheData(playerIDs, base, category, actionTypes
|
||||||
, allIns, actionTypeByNo, winnings, totalWinnings, positions
|
, allIns, actionTypeByNo, winnings, totalWinnings, positions
|
||||||
|
@ -145,9 +143,7 @@ def mainParser(backend, db, cursor, site, category, hand, config):
|
||||||
, actionTypes, actionAmounts, antes)
|
, actionTypes, actionAmounts, antes)
|
||||||
|
|
||||||
if isTourney:
|
if isTourney:
|
||||||
ranks=[]
|
ranks = map(lambda x: 0, names) # create an array of 0's equal to the length of names
|
||||||
for i in range (len(names)):
|
|
||||||
ranks.append(0)
|
|
||||||
payin_amounts = fpdb_simple.calcPayin(len(names), buyin, fee)
|
payin_amounts = fpdb_simple.calcPayin(len(names), buyin, fee)
|
||||||
|
|
||||||
if base == "hold":
|
if base == "hold":
|
||||||
|
@ -169,7 +165,7 @@ def mainParser(backend, db, cursor, site, category, hand, config):
|
||||||
, allIns, actionAmounts, actionNos, hudImportData, maxSeats
|
, allIns, actionAmounts, actionNos, hudImportData, maxSeats
|
||||||
, tableName, seatNos)
|
, tableName, seatNos)
|
||||||
else:
|
else:
|
||||||
raise fpdb_simple.FpdbError ("unrecognised category")
|
raise fpdb_simple.FpdbError("unrecognised category") # it's impossible to get here, but w/e
|
||||||
else:
|
else:
|
||||||
if base == "hold":
|
if base == "hold":
|
||||||
result = fpdb_save_to_db.ring_holdem_omaha(
|
result = fpdb_save_to_db.ring_holdem_omaha(
|
||||||
|
@ -187,7 +183,7 @@ def mainParser(backend, db, cursor, site, category, hand, config):
|
||||||
, actionAmounts, actionNos, hudImportData, maxSeats, tableName
|
, actionAmounts, actionNos, hudImportData, maxSeats, tableName
|
||||||
, seatNos)
|
, seatNos)
|
||||||
else:
|
else:
|
||||||
raise fpdb_simple.FpdbError ("unrecognised category")
|
raise fpdb_simple.FpdbError ("unrecognised category") # also impossible to get here
|
||||||
db.commit()
|
db.commit()
|
||||||
return result
|
return result
|
||||||
#end def mainParser
|
#end def mainParser
|
||||||
|
|
|
@ -41,8 +41,9 @@ def ring_stud(config, backend, db, cursor, base, category, site_hand_no, gametyp
|
||||||
,seatNos):
|
,seatNos):
|
||||||
|
|
||||||
import_options = config.get_import_parameters()
|
import_options = config.get_import_parameters()
|
||||||
saveActions = import_options['saveActions']
|
|
||||||
fastStoreHudCache = import_options['fastStoreHudCache']
|
saveActions = True if import_options['saveActions'] == 'True' else False
|
||||||
|
fastStoreHudCache = True if import_options['fastStoreHudCache'] == 'True' else False
|
||||||
|
|
||||||
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
||||||
|
|
||||||
|
@ -69,8 +70,8 @@ def ring_holdem_omaha(config, backend, db, cursor, base, category, site_hand_no,
|
||||||
"""stores a holdem/omaha hand into the database"""
|
"""stores a holdem/omaha hand into the database"""
|
||||||
|
|
||||||
import_options = config.get_import_parameters()
|
import_options = config.get_import_parameters()
|
||||||
saveActions = import_options['saveActions']
|
saveActions = True if import_options['saveActions'] == 'True' else False
|
||||||
fastStoreHudCache = import_options['fastStoreHudCache']
|
fastStoreHudCache = True if import_options['fastStoreHudCache'] == 'True' else False
|
||||||
|
|
||||||
t0 = time()
|
t0 = time()
|
||||||
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
||||||
|
@ -110,8 +111,8 @@ def tourney_holdem_omaha(config, backend, db, cursor, base, category, siteTourne
|
||||||
"""stores a tourney holdem/omaha hand into the database"""
|
"""stores a tourney holdem/omaha hand into the database"""
|
||||||
|
|
||||||
import_options = config.get_import_parameters()
|
import_options = config.get_import_parameters()
|
||||||
saveActions = import_options['saveActions']
|
saveActions = True if import_options['saveActions'] == 'True' else False
|
||||||
fastStoreHudCache = import_options['fastStoreHudCache']
|
fastStoreHudCache = True if import_options['fastStoreHudCache'] == 'True' else False
|
||||||
|
|
||||||
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
||||||
fpdb_simple.fill_board_cards(board_values, board_suits)
|
fpdb_simple.fill_board_cards(board_values, board_suits)
|
||||||
|
@ -147,8 +148,8 @@ def tourney_stud(config, backend, db, cursor, base, category, siteTourneyNo, buy
|
||||||
#stores a tourney stud/razz hand into the database
|
#stores a tourney stud/razz hand into the database
|
||||||
|
|
||||||
import_options = config.get_import_parameters()
|
import_options = config.get_import_parameters()
|
||||||
saveActions = import_options['saveActions']
|
saveActions = True if import_options['saveActions'] == 'True' else False
|
||||||
fastStoreHudCache = import_options['fastStoreHudCache']
|
fastStoreHudCache = True if import_options['fastStoreHudCache'] == 'True' else False
|
||||||
|
|
||||||
fpdb_simple.fillCardArrays(len(names), base, category, cardValues, cardSuits)
|
fpdb_simple.fillCardArrays(len(names), base, category, cardValues, cardSuits)
|
||||||
|
|
||||||
|
|
|
@ -18,14 +18,17 @@
|
||||||
#This file contains simple functions for fpdb
|
#This file contains simple functions for fpdb
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
import time
|
||||||
import re
|
import re
|
||||||
|
|
||||||
PS = 1
|
PS = 1
|
||||||
FTP = 2
|
FTP = 2
|
||||||
|
|
||||||
|
# TODO: these constants are also used in fpdb_save_to_db and others, is there a way to do like C #define, and #include ?
|
||||||
MYSQL_INNODB = 2
|
MYSQL_INNODB = 2
|
||||||
PGSQL = 3
|
PGSQL = 3
|
||||||
SQLITE = 4
|
SQLITE = 4
|
||||||
|
|
||||||
# Data Structures for index and foreign key creation
|
# Data Structures for index and foreign key creation
|
||||||
# drop_code is an int with possible values: 0 - don't drop for bulk import
|
# drop_code is an int with possible values: 0 - don't drop for bulk import
|
||||||
# 1 - drop during bulk import
|
# 1 - drop during bulk import
|
||||||
|
@ -387,20 +390,13 @@ def calcPayin(count, buyin, fee):
|
||||||
#end def calcPayin
|
#end def calcPayin
|
||||||
|
|
||||||
def checkPositions(positions):
|
def checkPositions(positions):
|
||||||
"""verifies that these positions are valid"""
|
""" verify positions are valid """
|
||||||
for i in xrange(len(positions)):
|
for p in positions:
|
||||||
pos=positions[i]
|
if not (p == "B" or p == "S" or (p >= 0 and p <= 9)):
|
||||||
try:#todo: use type recognition instead of error
|
raise FpdbError("invalid position '" + p + "' found in checkPositions")
|
||||||
if (len(pos)!=1):
|
|
||||||
raise FpdbError("invalid position found in checkPositions. i: "+str(i)+" position: "+pos) #dont need to str() here
|
|
||||||
except TypeError:#->not string->is int->fine
|
|
||||||
pass
|
|
||||||
|
|
||||||
### RHH modified to allow for "position 9" here (pos==9 is when you're a dead hand before the BB
|
### RHH modified to allow for "position 9" here (pos==9 is when you're a dead hand before the BB
|
||||||
### eric - position 8 could be valid - if only one blind is posted, but there's still 10 people, ie a sitout is present, and the small is dead...
|
### eric - position 8 could be valid - if only one blind is posted, but there's still 10 people, ie a sitout is present, and the small is dead...
|
||||||
if not (pos == "B" or pos == "S" or (pos >= 0 and pos <= 9)):
|
|
||||||
raise FpdbError("invalid position found in checkPositions. i: "+str(i)+" position: "+str(pos))
|
|
||||||
#end def fpdb_simple.checkPositions
|
|
||||||
|
|
||||||
#classifies each line for further processing in later code. Manipulates the passed arrays.
|
#classifies each line for further processing in later code. Manipulates the passed arrays.
|
||||||
def classifyLines(hand, category, lineTypes, lineStreets):
|
def classifyLines(hand, category, lineTypes, lineStreets):
|
||||||
|
@ -416,20 +412,14 @@ def classifyLines(hand, category, lineTypes, lineStreets):
|
||||||
lineTypes.append("cards")
|
lineTypes.append("cards")
|
||||||
elif i == 0:
|
elif i == 0:
|
||||||
lineTypes.append("header")
|
lineTypes.append("header")
|
||||||
|
elif line.startswith("Table '"):
|
||||||
|
lineTypes.append("table")
|
||||||
elif line.startswith("Seat ") and ( ("in chips" in line) or "($" in line):
|
elif line.startswith("Seat ") and ( ("in chips" in line) or "($" in line):
|
||||||
lineTypes.append("name")
|
lineTypes.append("name")
|
||||||
elif isActionLine(line):
|
elif isActionLine(line):
|
||||||
lineTypes.append("action")
|
lineTypes.append("action")
|
||||||
if " posts " in line or " posts the " in line:
|
if " posts " in line or " posts the " in line:
|
||||||
currentStreet="preflop"
|
currentStreet="preflop"
|
||||||
elif isWinLine(line):
|
|
||||||
lineTypes.append("win")
|
|
||||||
elif line.startswith("Total pot ") and "Rake" in line:
|
|
||||||
lineTypes.append("rake")
|
|
||||||
done=True
|
|
||||||
elif "*** SHOW DOWN ***" in line or "*** SUMMARY ***" in line:
|
|
||||||
lineTypes.append("ignore")
|
|
||||||
#print "in classifyLine, showdown or summary"
|
|
||||||
elif " antes " in line or " posts the ante " in line:
|
elif " antes " in line or " posts the ante " in line:
|
||||||
lineTypes.append("ante")
|
lineTypes.append("ante")
|
||||||
elif line.startswith("*** FLOP *** ["):
|
elif line.startswith("*** FLOP *** ["):
|
||||||
|
@ -456,10 +446,16 @@ def classifyLines(hand, category, lineTypes, lineStreets):
|
||||||
elif line.startswith("*** 7") or line == "*** RIVER ***":
|
elif line.startswith("*** 7") or line == "*** RIVER ***":
|
||||||
lineTypes.append("ignore")
|
lineTypes.append("ignore")
|
||||||
currentStreet=4
|
currentStreet=4
|
||||||
|
elif isWinLine(line):
|
||||||
|
lineTypes.append("win")
|
||||||
|
elif line.startswith("Total pot ") and "Rake" in line:
|
||||||
|
lineTypes.append("rake")
|
||||||
|
done=True
|
||||||
|
elif "*** SHOW DOWN ***" in line or "*** SUMMARY ***" in line:
|
||||||
|
lineTypes.append("ignore")
|
||||||
|
#print "in classifyLine, showdown or summary"
|
||||||
elif " shows [" in line:
|
elif " shows [" in line:
|
||||||
lineTypes.append("cards")
|
lineTypes.append("cards")
|
||||||
elif line.startswith("Table '"):
|
|
||||||
lineTypes.append("table")
|
|
||||||
else:
|
else:
|
||||||
raise FpdbError("unrecognised linetype in:"+hand[i])
|
raise FpdbError("unrecognised linetype in:"+hand[i])
|
||||||
lineStreets.append(currentStreet)
|
lineStreets.append(currentStreet)
|
||||||
|
@ -517,68 +513,45 @@ def convertCardValues(arr):
|
||||||
map(convertCardValuesBoard, arr)
|
map(convertCardValuesBoard, arr)
|
||||||
#end def convertCardValues
|
#end def convertCardValues
|
||||||
|
|
||||||
|
card_map = { "2": 2, "3" : 3, "4" : 4, "5" : 5, "6" : 6, "7" : 7, "8" : 8, "9" : 9, "T" : 10, "J" : 11, "Q" : 12, "K" : 13, "A" : 14}
|
||||||
|
|
||||||
#converts the strings in the given array to ints (changes the passed array, no returning). see table design for conversion details
|
#converts the strings in the given array to ints (changes the passed array, no returning). see table design for conversion details
|
||||||
def convertCardValuesBoard(arr):
|
def convertCardValuesBoard(arr):
|
||||||
for i in xrange(len(arr)):
|
for i in xrange(len(arr)):
|
||||||
if (arr[i]=="A"):
|
arr[i] = card_map[arr[i]]
|
||||||
arr[i]=14
|
|
||||||
elif (arr[i]=="K"):
|
|
||||||
arr[i]=13
|
|
||||||
elif (arr[i]=="Q"):
|
|
||||||
arr[i]=12
|
|
||||||
elif (arr[i]=="J"):
|
|
||||||
arr[i]=11
|
|
||||||
elif (arr[i]=="T"):
|
|
||||||
arr[i]=10
|
|
||||||
else:
|
|
||||||
arr[i]=int(arr[i])
|
|
||||||
#end def convertCardValuesBoard
|
#end def convertCardValuesBoard
|
||||||
|
|
||||||
#this creates the 2D/3D arrays. manipulates the passed arrays instead of returning.
|
#this creates the 2D/3D arrays. manipulates the passed arrays instead of returning.
|
||||||
def createArrays(category, seats, card_values, card_suits, antes, winnings, rakes, action_types, allIns, action_amounts, actionNos, actionTypeByNo):
|
def createArrays(category, seats, card_values, card_suits, antes, winnings, rakes, action_types, allIns, action_amounts, actionNos, actionTypeByNo):
|
||||||
for i in xrange(seats):#create second dimension arrays
|
for i in xrange(seats):#create second dimension arrays
|
||||||
tmp=[]
|
card_values.append( [] )
|
||||||
card_values.append(tmp)
|
card_suits.append( [] )
|
||||||
tmp=[]
|
|
||||||
card_suits.append(tmp)
|
|
||||||
antes.append(0)
|
antes.append(0)
|
||||||
winnings.append(0)
|
winnings.append(0)
|
||||||
rakes.append(0)
|
rakes.append(0)
|
||||||
|
|
||||||
if (category=="holdem" or category=="omahahi" or category=="omahahilo"):
|
streetCount = 4 if category == "holdem" or category == "omahahi" or category == "omahahilo" else 5
|
||||||
streetCount=4
|
|
||||||
else:
|
|
||||||
streetCount=5
|
|
||||||
|
|
||||||
for i in xrange(streetCount): #build the first dimension array, for streets
|
for i in xrange(streetCount): #build the first dimension array, for streets
|
||||||
tmp=[]
|
action_types.append([])
|
||||||
action_types.append(tmp)
|
allIns.append([])
|
||||||
tmp=[]
|
action_amounts.append([])
|
||||||
allIns.append(tmp)
|
actionNos.append([])
|
||||||
tmp=[]
|
actionTypeByNo.append([])
|
||||||
action_amounts.append(tmp)
|
|
||||||
tmp=[]
|
|
||||||
actionNos.append(tmp)
|
|
||||||
tmp=[]
|
|
||||||
actionTypeByNo.append(tmp)
|
|
||||||
for j in xrange (seats): #second dimension arrays: players
|
for j in xrange (seats): #second dimension arrays: players
|
||||||
tmp=[]
|
action_types[i].append([])
|
||||||
action_types[i].append(tmp)
|
allIns[i].append([])
|
||||||
tmp=[]
|
action_amounts[i].append([])
|
||||||
allIns[i].append(tmp)
|
actionNos[i].append([])
|
||||||
tmp=[]
|
# if (category=="holdem" or category=="omahahi" or category=="omahahilo"):
|
||||||
action_amounts[i].append(tmp)
|
# pass
|
||||||
tmp=[]
|
if category=="razz" or category=="studhi" or category=="studhilo":#need to fill card arrays.
|
||||||
actionNos[i].append(tmp)
|
|
||||||
if (category=="holdem" or category=="omahahi" or category=="omahahilo"):
|
|
||||||
pass
|
|
||||||
elif (category=="razz" or category=="studhi" or category=="studhilo"):#need to fill card arrays.
|
|
||||||
for i in xrange(seats):
|
for i in xrange(seats):
|
||||||
for j in xrange(7):
|
for j in xrange(7):
|
||||||
card_values[i].append(0)
|
card_values[i].append(0)
|
||||||
card_suits[i].append("x")
|
card_suits[i].append("x")
|
||||||
else:
|
# else:
|
||||||
raise FpdbError("invalid category")
|
# raise FpdbError("invalid category")
|
||||||
#end def createArrays
|
#end def createArrays
|
||||||
|
|
||||||
def fill_board_cards(board_values, board_suits):
|
def fill_board_cards(board_values, board_suits):
|
||||||
|
@ -612,150 +585,146 @@ def filterAnteBlindFold(site,hand):
|
||||||
#todo: in tourneys this should not be removed but
|
#todo: in tourneys this should not be removed but
|
||||||
#print "start of filterAnteBlindFold"
|
#print "start of filterAnteBlindFold"
|
||||||
pre3rd=[]
|
pre3rd=[]
|
||||||
for i in xrange (len(hand)):
|
for i, line in enumerate(hand):
|
||||||
if (hand[i].startswith("*** 3") or hand[i].startswith("*** HOLE")):
|
if line.startswith("*** 3") or line.startswith("*** HOLE"):
|
||||||
pre3rd = hand[0:i]
|
pre3rd = hand[0:i]
|
||||||
|
|
||||||
foldeeName=None
|
foldeeName=None
|
||||||
for i in xrange (len(pre3rd)):
|
for line in pre3rd:
|
||||||
if (pre3rd[i].endswith("folds") or pre3rd[i].endswith("is sitting out") or pre3rd[i].endswith(" stands up")): #found ante fold or timeout
|
if line.endswith("folds") or line.endswith("is sitting out") or line.endswith(" stands up"): #found ante fold or timeout
|
||||||
pos=pre3rd[i].find (" folds")
|
pos = line.find(" folds")
|
||||||
foldeeName=pre3rd[i][0:pos]
|
foldeeName = line[0:pos]
|
||||||
if pos == -1 and " in chips)" not in pre3rd[i]:
|
if pos == -1 and " in chips)" not in line:
|
||||||
pos=pre3rd[i].find (" is sitting out")
|
pos = line.find(" is sitting out")
|
||||||
foldeeName=pre3rd[i][0:pos]
|
foldeeName = line[0:pos]
|
||||||
if pos == -1:
|
if pos == -1:
|
||||||
pos=pre3rd[i].find (" stands up")
|
pos = line.find(" stands up")
|
||||||
foldeeName=pre3rd[i][0:pos]
|
foldeeName = line[0:pos]
|
||||||
if pos==-1:#this one is for PS tourney
|
if pos == -1:
|
||||||
pos1=pre3rd[i].find (": ")+2
|
pos1 = line.find(": ") + 2
|
||||||
pos2=pre3rd[i].find (" (")
|
pos2 = line.find(" (")
|
||||||
foldeeName=pre3rd[i][pos1:pos2]
|
foldeeName = line[pos1:pos2]
|
||||||
|
|
||||||
if foldeeName!=None:
|
if foldeeName!=None:
|
||||||
#print "filterAnteBlindFold, foldeeName:",foldeeName
|
#print "filterAnteBlindFold, foldeeName:",foldeeName
|
||||||
toRemove=[]
|
for i, line in enumerate(hand):
|
||||||
for i in xrange(len(hand)): #using hand again to filter from all streets, just in case.
|
if foldeeName in line:
|
||||||
#todo: this will break it if sittin out BB wins a hand
|
hand[i] = None
|
||||||
if (hand[i].find(foldeeName)!=-1):
|
|
||||||
toRemove.append(hand[i])
|
|
||||||
|
|
||||||
for i in xrange(len(toRemove)):
|
hand = [line for line in hand if line]
|
||||||
hand.remove(toRemove[i])
|
|
||||||
#end def filterAnteFold
|
#end def filterAnteFold
|
||||||
|
|
||||||
|
def stripEOLspaces(str):
|
||||||
|
if str[-1] == ' ':
|
||||||
|
str = str[:-1]
|
||||||
|
if str[-1] == ' ':
|
||||||
|
str = str[:-1]
|
||||||
|
return str
|
||||||
|
|
||||||
#removes useless lines as well as trailing spaces
|
#removes useless lines as well as trailing spaces
|
||||||
def filterCrap(site, hand, isTourney):
|
def filterCrap(site, hand, isTourney):
|
||||||
#remove two trailing spaces at end of line
|
#remove two trailing spaces at end of line
|
||||||
for i in xrange (len(hand)):
|
hand = [stripEOLspaces(line) for line in hand]
|
||||||
if (hand[i][-1]==' '):
|
|
||||||
hand[i]=hand[i][:-1]
|
|
||||||
if (hand[i][-1]==' '):
|
|
||||||
hand[i]=hand[i][:-1]
|
|
||||||
|
|
||||||
#print "hand after trailing space removal in filterCrap:",hand
|
#print "hand after trailing space removal in filterCrap:",hand
|
||||||
#general variable position word filter/string filter
|
#general variable position word filter/string filter
|
||||||
toRemove=[]
|
|
||||||
for i in xrange (len(hand)):
|
for i in xrange (len(hand)):
|
||||||
if (hand[i].startswith("Board [")):
|
if (hand[i].startswith("Board [")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].find(" out of hand ")!=-1):
|
elif (hand[i].find(" out of hand ")!=-1):
|
||||||
hand[i]=hand[i][:-56]
|
hand[i]=hand[i][:-56]
|
||||||
elif (hand[i].find("($0 in chips)") != -1):
|
elif (hand[i].find("($0 in chips)") != -1):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i]=="*** HOLE CARDS ***"):
|
elif (hand[i]=="*** HOLE CARDS ***"):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith("has been disconnected")):
|
elif (hand[i].endswith("has been disconnected")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith("has requested TIME")):
|
elif (hand[i].endswith("has requested TIME")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith("has returned")):
|
elif (hand[i].endswith("has returned")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith("will be allowed to play after the button")):
|
elif (hand[i].endswith("will be allowed to play after the button")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith("has timed out")):
|
elif (hand[i].endswith("has timed out")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith("has timed out while disconnected")):
|
elif (hand[i].endswith("has timed out while disconnected")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith("has timed out while being disconnected")):
|
elif (hand[i].endswith("has timed out while being disconnected")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith("is connected")):
|
elif (hand[i].endswith("is connected")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith("is disconnected")):
|
elif (hand[i].endswith("is disconnected")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith(" is feeling angry")):
|
elif (hand[i].endswith(" is feeling angry")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith(" is feeling confused")):
|
elif (hand[i].endswith(" is feeling confused")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith(" is feeling happy")):
|
elif (hand[i].endswith(" is feeling happy")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith(" is feeling normal")):
|
elif (hand[i].endswith(" is feeling normal")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].find(" is low with [")!=-1):
|
elif (hand[i].find(" is low with [")!=-1):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
#elif (hand[i].find("-max Seat #")!=-1 and hand[i].find(" is the button")!=-1):
|
#elif (hand[i].find("-max Seat #")!=-1 and hand[i].find(" is the button")!=-1):
|
||||||
# toRemove.append(hand[i])
|
# toRemove.append(hand[i])
|
||||||
elif (hand[i].endswith(" mucks")):
|
elif (hand[i].endswith(" mucks")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith(": mucks hand")):
|
elif (hand[i].endswith(": mucks hand")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i]=="No low hand qualified"):
|
elif (hand[i]=="No low hand qualified"):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i]=="Pair on board - a double bet is allowed"):
|
elif (hand[i]=="Pair on board - a double bet is allowed"):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].find(" shows ")!=-1 and hand[i].find("[")==-1):
|
elif (hand[i].find(" shows ")!=-1 and hand[i].find("[")==-1):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
#elif (hand[i].startswith("Table '") and hand[i].endswith("-max")):
|
#elif (hand[i].startswith("Table '") and hand[i].endswith("-max")):
|
||||||
# toRemove.append(hand[i])
|
# toRemove.append(hand[i])
|
||||||
elif (hand[i].startswith("The button is in seat #")):
|
elif (hand[i].startswith("The button is in seat #")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
#above is alphabetic, reorder below if bored
|
#above is alphabetic, reorder below if bored
|
||||||
elif (hand[i].startswith("Time has expired")):
|
elif (hand[i].startswith("Time has expired")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith("has reconnected")):
|
elif (hand[i].endswith("has reconnected")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith("seconds left to act")):
|
elif (hand[i].endswith("seconds left to act")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith("seconds to reconnect")):
|
elif (hand[i].endswith("seconds to reconnect")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith("was removed from the table for failing to post")):
|
elif (hand[i].endswith("was removed from the table for failing to post")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].find("joins the table at seat ")!=-1):
|
elif (hand[i].find("joins the table at seat ")!=-1):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith(" sits down")):
|
elif (hand[i].endswith(" sits down")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith("leaves the table")):
|
elif (hand[i].endswith("leaves the table")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith(" stands up")):
|
elif (hand[i].endswith(" stands up")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].find("is high with ")!=-1):
|
elif (hand[i].find("is high with ")!=-1):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith("doesn't show hand")):
|
elif (hand[i].endswith("doesn't show hand")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith("is being treated as all-in")):
|
elif (hand[i].endswith("is being treated as all-in")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].find(" adds $")!=-1):
|
elif (hand[i].find(" adds $")!=-1):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i]=="Betting is capped"):
|
elif (hand[i]=="Betting is capped"):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
#site specific variable position filter
|
#site specific variable position filter
|
||||||
elif (hand[i].find(" said, \"")!=-1):
|
elif (hand[i].find(" said, \"")!=-1):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].find(": ")!=-1 and site=="ftp" and hand[i].find("Seat ")==-1 and hand[i].find(": Table")==-1): #filter ftp chat
|
elif (hand[i].find(": ")!=-1 and site=="ftp" and hand[i].find("Seat ")==-1 and hand[i].find(": Table")==-1): #filter ftp chat
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
if isTourney:
|
if isTourney and not hand[i] == False:
|
||||||
if (hand[i].endswith(" is sitting out") and (not hand[i].startswith("Seat "))):
|
if (hand[i].endswith(" is sitting out") and (not hand[i].startswith("Seat "))):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
else:
|
elif hand[i]:
|
||||||
if (hand[i].endswith(": sits out")):
|
if (hand[i].endswith(": sits out")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
elif (hand[i].endswith(" is sitting out")):
|
elif (hand[i].endswith(" is sitting out")):
|
||||||
toRemove.append(hand[i])
|
hand[i] = False
|
||||||
|
|
||||||
|
hand = [line for line in hand if line] # python docs say this is identical to filter(None, list)
|
||||||
for i in xrange (len(toRemove)):
|
|
||||||
#print "removing in filterCr:",toRemove[i]
|
|
||||||
hand.remove(toRemove[i])
|
|
||||||
|
|
||||||
#print "done with filterCrap, hand:", hand
|
#print "done with filterCrap, hand:", hand
|
||||||
return hand
|
return hand
|
||||||
|
@ -765,11 +734,11 @@ def filterCrap(site, hand, isTourney):
|
||||||
def float2int (string):
|
def float2int (string):
|
||||||
pos=string.find(",")
|
pos=string.find(",")
|
||||||
if (pos!=-1): #remove , the thousand seperator
|
if (pos!=-1): #remove , the thousand seperator
|
||||||
string=string[0:pos]+string[pos+1:]
|
string = "%s%s" % (string[0:pos], string[pos+1:])
|
||||||
|
|
||||||
pos=string.find(".")
|
pos=string.find(".")
|
||||||
if (pos!=-1): #remove decimal point
|
if (pos!=-1): #remove decimal point
|
||||||
string=string[0:pos]+string[pos+1:]
|
string = "%s%s" % (string[0:pos], string[pos+1:])
|
||||||
|
|
||||||
result = int(string)
|
result = int(string)
|
||||||
if pos == -1: #no decimal point - was in full dollars - need to multiply with 100
|
if pos == -1: #no decimal point - was in full dollars - need to multiply with 100
|
||||||
|
@ -777,40 +746,24 @@ def float2int (string):
|
||||||
return result
|
return result
|
||||||
#end def float2int
|
#end def float2int
|
||||||
|
|
||||||
|
ActionLines = ( "calls $", ": calls ", "brings in for", "completes it to", "posts small blind",
|
||||||
|
"posts the small blind", "posts big blind", "posts the big blind",
|
||||||
|
"posts small & big blinds", "posts $", "posts a dead", "bets $",
|
||||||
|
": bets ", "raises")
|
||||||
|
|
||||||
#returns boolean whether the passed line is an action line
|
#returns boolean whether the passed line is an action line
|
||||||
def isActionLine(line):
|
def isActionLine(line):
|
||||||
if (line.endswith("folds")):
|
if (line.endswith("folds")):
|
||||||
return True
|
return True
|
||||||
elif (line.endswith("checks")):
|
elif (line.endswith("checks")):
|
||||||
return True
|
return True
|
||||||
elif (line.find("calls $")!=-1 or line.find(": calls ")!=-1):
|
|
||||||
return True
|
|
||||||
elif (line.find("brings in for")!=-1):
|
|
||||||
return True
|
|
||||||
elif (line.find("completes it to")!=-1):
|
|
||||||
return True
|
|
||||||
elif (line.find("posts small blind")!=-1):
|
|
||||||
return True
|
|
||||||
elif (line.find("posts the small blind")!=-1):
|
|
||||||
return True
|
|
||||||
elif (line.find("posts big blind")!=-1):
|
|
||||||
return True
|
|
||||||
elif (line.find("posts the big blind")!=-1):
|
|
||||||
return True
|
|
||||||
elif (line.find("posts small & big blinds")!=-1):
|
|
||||||
return True
|
|
||||||
elif (line.find(" posts $")!=-1): #this reads voluntary blind pay in FTP Holdem
|
|
||||||
return True
|
|
||||||
elif (line.find(" posts a dead ")!=-1): #this reads voluntary blind pay in FTP Holdem
|
|
||||||
return True
|
|
||||||
elif (line.find("bets $")!=-1 or line.find(": bets ")!=-1):
|
|
||||||
return True
|
|
||||||
elif (line.find("raises")!=-1):
|
|
||||||
return True
|
|
||||||
elif (line.startswith("Uncalled bet")):
|
elif (line.startswith("Uncalled bet")):
|
||||||
return True
|
return True
|
||||||
else:
|
|
||||||
return False
|
return len( [ x for x in ActionLines if x in line]) > 0
|
||||||
|
# ret = any(True for searchstr in ActionLines if searchstr in line)
|
||||||
|
# ret = len( [ x for x in ActionLines if line.find(x) > -1] ) > 0
|
||||||
|
# ret = any(searchstr in line for searchstr in ActionLines)
|
||||||
#end def isActionLine
|
#end def isActionLine
|
||||||
|
|
||||||
#returns whether this is a duplicate
|
#returns whether this is a duplicate
|
||||||
|
@ -829,56 +782,14 @@ def isRebuyOrAddon(topline):
|
||||||
|
|
||||||
#returns whether the passed topline indicates a tournament or not
|
#returns whether the passed topline indicates a tournament or not
|
||||||
def isTourney(topline):
|
def isTourney(topline):
|
||||||
if (topline.find("Tournament")!=-1):
|
return "Tournament" in topline
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
#end def isTourney
|
#end def isTourney
|
||||||
|
|
||||||
|
WinLines = ( "wins the pot", "ties for the ", "wins side pot", "wins the low main pot", "wins the high main pot",
|
||||||
|
"wins the high pot", "wins the high side pot", "wins the main pot", "wins the side pot", "collected" )
|
||||||
#returns boolean whether the passed line is a win line
|
#returns boolean whether the passed line is a win line
|
||||||
def isWinLine(line):
|
def isWinLine(line):
|
||||||
if (line.find("wins the pot")!=-1):
|
return len( [ x for x in WinLines if x in line ] ) > 0
|
||||||
return True
|
|
||||||
elif (line.find("ties for the high pot")!=-1):
|
|
||||||
return True
|
|
||||||
elif (line.find("ties for the high main pot")!=-1):
|
|
||||||
return True
|
|
||||||
elif (line.find("ties for the high side pot")!=-1):
|
|
||||||
return True
|
|
||||||
elif (line.find("ties for the low pot")!=-1):
|
|
||||||
return True
|
|
||||||
elif (line.find("ties for the low main pot")!=-1):
|
|
||||||
return True
|
|
||||||
elif (line.find("ties for the low side pot")!=-1):
|
|
||||||
return True
|
|
||||||
elif (line.find("ties for the main pot")!=-1): #for ftp tied main pot of split pot
|
|
||||||
return True
|
|
||||||
elif (line.find("ties for the pot")!=-1): #for ftp tie
|
|
||||||
return True
|
|
||||||
elif (line.find("ties for the side pot")!=-1): #for ftp tied split pots
|
|
||||||
return True
|
|
||||||
elif (line.find("wins side pot #")!=-1): #for ftp multi split pots
|
|
||||||
return True
|
|
||||||
elif (line.find("wins the low main pot")!=-1):
|
|
||||||
return True
|
|
||||||
elif (line.find("wins the low pot")!=-1):
|
|
||||||
return True
|
|
||||||
elif (line.find("wins the low side pot")!=-1):
|
|
||||||
return True
|
|
||||||
elif (line.find("wins the high main pot")!=-1):
|
|
||||||
return True
|
|
||||||
elif (line.find("wins the high pot")!=-1):
|
|
||||||
return True
|
|
||||||
elif (line.find("wins the high side pot")!=-1):
|
|
||||||
return True
|
|
||||||
elif (line.find("wins the main pot")!=-1):
|
|
||||||
return True
|
|
||||||
elif (line.find("wins the side pot")!=-1): #for ftp split pots
|
|
||||||
return True
|
|
||||||
elif (line.find("collected")!=-1):
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False #not raising error here, any unknown line wouldve been detected in isActionLine already
|
|
||||||
#end def isWinLine
|
#end def isWinLine
|
||||||
|
|
||||||
#returns the amount of cash/chips put into the put in the given action line
|
#returns the amount of cash/chips put into the put in the given action line
|
||||||
|
@ -893,23 +804,20 @@ def parseActionAmount(line, atype, site, isTourney):
|
||||||
if line.endswith(" and is capped"):
|
if line.endswith(" and is capped"):
|
||||||
line=line[:-14]
|
line=line[:-14]
|
||||||
|
|
||||||
|
if atype == "fold" or atype == "check":
|
||||||
if (atype=="fold"):
|
|
||||||
amount = 0
|
amount = 0
|
||||||
elif (atype=="check"):
|
elif atype == "unbet":
|
||||||
amount=0
|
if site == "ftp":
|
||||||
elif (atype=="unbet" and site=="ftp"):
|
|
||||||
pos1 = line.find("$") + 1
|
pos1 = line.find("$") + 1
|
||||||
pos2 = line.find(" returned to")
|
pos2 = line.find(" returned to")
|
||||||
amount = float2int(line[pos1:pos2])
|
amount = float2int(line[pos1:pos2])
|
||||||
elif (atype=="unbet" and site=="ps"):
|
elif site == "ps":
|
||||||
#print "ps unbet, line:",line
|
|
||||||
pos1 = line.find("$") + 1
|
pos1 = line.find("$") + 1
|
||||||
if pos1 == 0:
|
if pos1 == 0:
|
||||||
pos1 = line.find("(") + 1
|
pos1 = line.find("(") + 1
|
||||||
pos2 = line.find(")")
|
pos2 = line.find(")")
|
||||||
amount = float2int(line[pos1:pos2])
|
amount = float2int(line[pos1:pos2])
|
||||||
elif (atype=="bet" and site=="ps" and line.find(": raises $")!=-1 and line.find("to $")!=-1):
|
elif atype == "bet" and site == "ps" and line.find(": raises $")!=-1 and line.find("to $")!=-1:
|
||||||
pos = line.find("to $")+4
|
pos = line.find("to $")+4
|
||||||
amount = float2int(line[pos:])
|
amount = float2int(line[pos:])
|
||||||
else:
|
else:
|
||||||
|
@ -933,13 +841,13 @@ def parseActionAmount(line, atype, site, isTourney):
|
||||||
# action_amounts. For stud this expects numeric streets (3-7), for
|
# action_amounts. For stud this expects numeric streets (3-7), for
|
||||||
# holdem/omaha it expects predeal, preflop, flop, turn or river
|
# holdem/omaha it expects predeal, preflop, flop, turn or river
|
||||||
def parseActionLine(site, base, isTourney, line, street, playerIDs, names, action_types, allIns, action_amounts, actionNos, actionTypeByNo):
|
def parseActionLine(site, base, isTourney, line, street, playerIDs, names, action_types, allIns, action_amounts, actionNos, actionTypeByNo):
|
||||||
if (street=="predeal" or street=="preflop"):
|
if street == "predeal" or street == "preflop":
|
||||||
street = 0
|
street = 0
|
||||||
elif (street=="flop"):
|
elif street == "flop":
|
||||||
street = 1
|
street = 1
|
||||||
elif (street=="turn"):
|
elif street == "turn":
|
||||||
street = 2
|
street = 2
|
||||||
elif (street=="river"):
|
elif street == "river":
|
||||||
street = 3
|
street = 3
|
||||||
|
|
||||||
nextActionNo = 0
|
nextActionNo = 0
|
||||||
|
@ -948,7 +856,7 @@ def parseActionLine(site, base, isTourney, line, street, playerIDs, names, actio
|
||||||
if actionNos[street][player][count]>=nextActionNo:
|
if actionNos[street][player][count]>=nextActionNo:
|
||||||
nextActionNo=actionNos[street][player][count]+1
|
nextActionNo=actionNos[street][player][count]+1
|
||||||
|
|
||||||
line, allIn=goesAllInOnThisLine(line)
|
(line, allIn) = goesAllInOnThisLine(line)
|
||||||
atype = parseActionType(line)
|
atype = parseActionType(line)
|
||||||
playerno = recognisePlayerNo(line, names, atype)
|
playerno = recognisePlayerNo(line, names, atype)
|
||||||
amount = parseActionAmount(line, atype, site, isTourney)
|
amount = parseActionAmount(line, atype, site, isTourney)
|
||||||
|
@ -1013,13 +921,13 @@ def parseActionType(line):
|
||||||
|
|
||||||
#parses the ante out of the given line and checks which player paid it, updates antes accordingly.
|
#parses the ante out of the given line and checks which player paid it, updates antes accordingly.
|
||||||
def parseAnteLine(line, site, isTourney, names, antes):
|
def parseAnteLine(line, site, isTourney, names, antes):
|
||||||
for i in xrange(len(names)):
|
for i, name in enumerate(names):
|
||||||
if (line.startswith(names[i].encode("latin-1"))): #found the ante'er
|
if line.startswith(name.encode("latin-1")):
|
||||||
pos = line.rfind("$") + 1
|
pos = line.rfind("$") + 1
|
||||||
if not isTourney:
|
if not isTourney:
|
||||||
antes[i] += float2int(line[pos:])
|
antes[i] += float2int(line[pos:])
|
||||||
else:
|
else:
|
||||||
if line.find("all-in")==-1:
|
if "all-in" not in line:
|
||||||
pos = line.rfind(" ") + 1
|
pos = line.rfind(" ") + 1
|
||||||
antes[i] += int(line[pos:])
|
antes[i] += int(line[pos:])
|
||||||
else:
|
else:
|
||||||
|
@ -1039,22 +947,22 @@ def parseBuyin(topline):
|
||||||
#parses a card line and changes the passed arrays accordingly
|
#parses a card line and changes the passed arrays accordingly
|
||||||
#todo: reorganise this messy method
|
#todo: reorganise this messy method
|
||||||
def parseCardLine(site, category, street, line, names, cardValues, cardSuits, boardValues, boardSuits):
|
def parseCardLine(site, category, street, line, names, cardValues, cardSuits, boardValues, boardSuits):
|
||||||
if (line.startswith("Dealt to ") or line.find(" shows [")!=-1 or line.find("mucked [")!=-1):
|
if line.startswith("Dealt to") or " shows [" in line or "mucked [" in line:
|
||||||
playerNo = recognisePlayerNo(line, names, "card") #anything but unbet will be ok for that string
|
playerNo = recognisePlayerNo(line, names, "card") #anything but unbet will be ok for that string
|
||||||
|
|
||||||
pos = line.rfind("[")+1
|
pos = line.rfind("[")+1
|
||||||
if (category=="holdem"):
|
if category == "holdem":
|
||||||
for i in (pos, pos+3):
|
for i in (pos, pos+3):
|
||||||
cardValues[playerNo].append(line[i:i+1])
|
cardValues[playerNo].append(line[i:i+1])
|
||||||
cardSuits[playerNo].append(line[i+1:i+2])
|
cardSuits[playerNo].append(line[i+1:i+2])
|
||||||
if (len(cardValues[playerNo])!=2):
|
if len(cardValues[playerNo]) !=2:
|
||||||
if cardValues[playerNo][0]==cardValues[playerNo][2] and cardSuits[playerNo][1]==cardSuits[playerNo][3]: #two tests will do
|
if cardValues[playerNo][0]==cardValues[playerNo][2] and cardSuits[playerNo][1]==cardSuits[playerNo][3]: #two tests will do
|
||||||
cardValues[playerNo]=cardValues[playerNo][0:2]
|
cardValues[playerNo]=cardValues[playerNo][0:2]
|
||||||
cardSuits[playerNo]=cardSuits[playerNo][0:2]
|
cardSuits[playerNo]=cardSuits[playerNo][0:2]
|
||||||
else:
|
else:
|
||||||
print "line:",line,"cardValues[playerNo]:",cardValues[playerNo]
|
print "line:",line,"cardValues[playerNo]:",cardValues[playerNo]
|
||||||
raise FpdbError("read too many/too few holecards in parseCardLine")
|
raise FpdbError("read too many/too few holecards in parseCardLine")
|
||||||
elif (category=="omahahi" or category=="omahahilo"):
|
elif category == "omahahi" or category == "omahahilo":
|
||||||
for i in (pos, pos+3, pos+6, pos+9):
|
for i in (pos, pos+3, pos+6, pos+9):
|
||||||
cardValues[playerNo].append(line[i:i+1])
|
cardValues[playerNo].append(line[i:i+1])
|
||||||
cardSuits[playerNo].append(line[i+1:i+2])
|
cardSuits[playerNo].append(line[i+1:i+2])
|
||||||
|
@ -1065,8 +973,8 @@ def parseCardLine(site, category, street, line, names, cardValues, cardSuits, bo
|
||||||
else:
|
else:
|
||||||
print "line:",line,"cardValues[playerNo]:",cardValues[playerNo]
|
print "line:",line,"cardValues[playerNo]:",cardValues[playerNo]
|
||||||
raise FpdbError("read too many/too few holecards in parseCardLine")
|
raise FpdbError("read too many/too few holecards in parseCardLine")
|
||||||
elif (category=="razz" or category=="studhi" or category=="studhilo"):
|
elif category=="razz" or category=="studhi" or category=="studhilo":
|
||||||
if (line.find("shows")==-1 and line.find("mucked")==-1):
|
if "shows" not in line and "mucked" not in line:
|
||||||
#print "parseCardLine(in stud if), street:", street
|
#print "parseCardLine(in stud if), street:", street
|
||||||
if line[pos+2]=="]": #-> not (hero and 3rd street)
|
if line[pos+2]=="]": #-> not (hero and 3rd street)
|
||||||
cardValues[playerNo][street+2]=line[pos:pos+1]
|
cardValues[playerNo][street+2]=line[pos:pos+1]
|
||||||
|
@ -1205,12 +1113,8 @@ def parseNames(lines):
|
||||||
return result
|
return result
|
||||||
#end def parseNames
|
#end def parseNames
|
||||||
|
|
||||||
#returns an array with the positions of the respective players
|
|
||||||
def parsePositions(hand, names):
|
def parsePositions(hand, names):
|
||||||
#prep array
|
positions = map(lambda x: -1, names)
|
||||||
positions=[]
|
|
||||||
for i in xrange(len(names)):
|
|
||||||
positions.append(-1)
|
|
||||||
|
|
||||||
#find blinds
|
#find blinds
|
||||||
sb,bb=-1,-1
|
sb,bb=-1,-1
|
||||||
|
@ -1369,17 +1273,19 @@ def parseWinLine(line, site, names, winnings, isTourney):
|
||||||
|
|
||||||
#returns the category (as per database) string for the given line
|
#returns the category (as per database) string for the given line
|
||||||
def recogniseCategory(line):
|
def recogniseCategory(line):
|
||||||
if (line.find("Razz")!=-1):
|
if "Razz" in line:
|
||||||
return "razz"
|
return "razz"
|
||||||
elif (line.find("Hold'em")!=-1):
|
elif "Hold'em" in line:
|
||||||
return "holdem"
|
return "holdem"
|
||||||
elif (line.find("Omaha")!=-1 and line.find("Hi/Lo")==-1 and line.find("H/L")==-1):
|
elif "Omaha" in line:
|
||||||
|
if "Hi/Lo" not in line and "H/L" not in line:
|
||||||
return "omahahi"
|
return "omahahi"
|
||||||
elif (line.find("Omaha")!=-1 and (line.find("Hi/Lo")!=-1 or line.find("H/L")!=-1)):
|
else:
|
||||||
return "omahahilo"
|
return "omahahilo"
|
||||||
elif (line.find("Stud")!=-1 and line.find("Hi/Lo")==-1 and line.find("H/L")==-1):
|
elif "Stud" in line:
|
||||||
|
if "Hi/Lo" not in line and "H/L" not in line:
|
||||||
return "studhi"
|
return "studhi"
|
||||||
elif (line.find("Stud")!=-1 and (line.find("Hi/Lo")!=-1 or line.find("H/L")!=-1)):
|
else:
|
||||||
return "studhilo"
|
return "studhilo"
|
||||||
else:
|
else:
|
||||||
raise FpdbError("failed to recognise category, line:"+line)
|
raise FpdbError("failed to recognise category, line:"+line)
|
||||||
|
@ -1793,19 +1699,20 @@ sure to also change the following storage method and table_viewer.prepare_data i
|
||||||
firstPfRaiserNo=-1
|
firstPfRaiserNo=-1
|
||||||
firstPfCallByNo=-1
|
firstPfCallByNo=-1
|
||||||
firstPfCallerId=-1
|
firstPfCallerId=-1
|
||||||
for i in xrange(len(actionTypeByNo[0])):
|
|
||||||
if actionTypeByNo[0][i][1]=="bet":
|
for i, action in enumerate(actionTypeByNo[0]):
|
||||||
|
if action[1] == "bet":
|
||||||
firstPfRaiseByNo = i
|
firstPfRaiseByNo = i
|
||||||
firstPfRaiserId=actionTypeByNo[0][i][0]
|
firstPfRaiserId = action[0]
|
||||||
for j in xrange(len(player_ids)):
|
for j, pid in enumerate(player_ids):
|
||||||
if player_ids[j]==firstPfRaiserId:
|
if pid == firstPfRaiserId:
|
||||||
firstPfRaiserNo = j
|
firstPfRaiserNo = j
|
||||||
break
|
break
|
||||||
break
|
break
|
||||||
for i in xrange(len(actionTypeByNo[0])):
|
for i, action in enumerate(actionTypeByNo[0]):
|
||||||
if actionTypeByNo[0][i][1]=="call":
|
if action[1] == "call":
|
||||||
firstPfCallByNo = i
|
firstPfCallByNo = i
|
||||||
firstPfCallerId=actionTypeByNo[0][i][0]
|
firstPfCallerId = action[0]
|
||||||
break
|
break
|
||||||
|
|
||||||
cutoffId=-1
|
cutoffId=-1
|
||||||
|
@ -1813,14 +1720,14 @@ sure to also change the following storage method and table_viewer.prepare_data i
|
||||||
sbId=-1
|
sbId=-1
|
||||||
bbId=-1
|
bbId=-1
|
||||||
if base=="hold":
|
if base=="hold":
|
||||||
for player in xrange(len(positions)):
|
for player, pos in enumerate(positions):
|
||||||
if positions==1:
|
if pos == 1:
|
||||||
cutoffId = player_ids[player]
|
cutoffId = player_ids[player]
|
||||||
if positions==0:
|
if pos == 0:
|
||||||
buttonId = player_ids[player]
|
buttonId = player_ids[player]
|
||||||
if positions=='S':
|
if pos == 'S':
|
||||||
sbId = player_ids[player]
|
sbId = player_ids[player]
|
||||||
if positions=='B':
|
if pos == 'B':
|
||||||
bbId = player_ids[player]
|
bbId = player_ids[player]
|
||||||
|
|
||||||
someoneStole=False
|
someoneStole=False
|
||||||
|
@ -1857,22 +1764,21 @@ sure to also change the following storage method and table_viewer.prepare_data i
|
||||||
#calculate VPIP and PFR
|
#calculate VPIP and PFR
|
||||||
street=0
|
street=0
|
||||||
heroPfRaiseCount=0
|
heroPfRaiseCount=0
|
||||||
for count in xrange(len(action_types[street][player])):#finally individual actions
|
for currentAction in action_types[street][player]: # finally individual actions
|
||||||
currentAction=action_types[street][player][count]
|
|
||||||
if currentAction == "bet":
|
if currentAction == "bet":
|
||||||
myStreet0Aggr = True
|
myStreet0Aggr = True
|
||||||
if (currentAction=="bet" or currentAction=="call"):
|
if currentAction == "bet" or currentAction == "call":
|
||||||
myStreet0VPI = True
|
myStreet0VPI = True
|
||||||
|
|
||||||
#PF3B4BChance and PF3B4B
|
#PF3B4BChance and PF3B4B
|
||||||
pfFold=-1
|
pfFold=-1
|
||||||
pfRaise=-1
|
pfRaise=-1
|
||||||
if firstPfRaiseByNo != -1:
|
if firstPfRaiseByNo != -1:
|
||||||
for i in xrange(len(actionTypeByNo[0])):
|
for i, actionType in enumerate(actionTypeByNo[0]):
|
||||||
if actionTypeByNo[0][i][0]==player_ids[player]:
|
if actionType[0] == player_ids[player]:
|
||||||
if actionTypeByNo[0][i][1]=="bet" and pfRaise==-1 and i>firstPfRaiseByNo:
|
if actionType[1] == "bet" and pfRaise == -1 and i > firstPfRaiseByNo:
|
||||||
pfRaise = i
|
pfRaise = i
|
||||||
if actionTypeByNo[0][i][1]=="fold" and pfFold==-1:
|
if actionType[1] == "fold" and pfFold == -1:
|
||||||
pfFold = i
|
pfFold = i
|
||||||
if pfFold == -1 or pfFold > firstPfRaiseByNo:
|
if pfFold == -1 or pfFold > firstPfRaiseByNo:
|
||||||
myStreet0_3B4BChance = True
|
myStreet0_3B4BChance = True
|
||||||
|
@ -1909,20 +1815,17 @@ sure to also change the following storage method and table_viewer.prepare_data i
|
||||||
|
|
||||||
#calculate saw* values
|
#calculate saw* values
|
||||||
isAllIn = False
|
isAllIn = False
|
||||||
for i in xrange(len(allIns[0][player])):
|
if any(i for i in allIns[0][player]):
|
||||||
if allIns[0][player][i]:
|
|
||||||
isAllIn = True
|
isAllIn = True
|
||||||
if (len(action_types[1][player])>0 or isAllIn):
|
if (len(action_types[1][player])>0 or isAllIn):
|
||||||
myStreet1Seen = True
|
myStreet1Seen = True
|
||||||
|
|
||||||
for i in xrange(len(allIns[1][player])):
|
if any(i for i in allIns[1][player]):
|
||||||
if allIns[1][player][i]:
|
|
||||||
isAllIn = True
|
isAllIn = True
|
||||||
if (len(action_types[2][player])>0 or isAllIn):
|
if (len(action_types[2][player])>0 or isAllIn):
|
||||||
myStreet2Seen = True
|
myStreet2Seen = True
|
||||||
|
|
||||||
for i in xrange(len(allIns[2][player])):
|
if any(i for i in allIns[2][player]):
|
||||||
if allIns[2][player][i]:
|
|
||||||
isAllIn = True
|
isAllIn = True
|
||||||
if (len(action_types[3][player])>0 or isAllIn):
|
if (len(action_types[3][player])>0 or isAllIn):
|
||||||
myStreet3Seen = True
|
myStreet3Seen = True
|
||||||
|
@ -1930,29 +1833,25 @@ sure to also change the following storage method and table_viewer.prepare_data i
|
||||||
#print "base:", base
|
#print "base:", base
|
||||||
if base=="hold":
|
if base=="hold":
|
||||||
mySawShowdown = True
|
mySawShowdown = True
|
||||||
for count in xrange(len(action_types[3][player])):
|
if any(actiontype == "fold" for actiontype in action_types[3][player]):
|
||||||
if action_types[3][player][count]=="fold":
|
|
||||||
mySawShowdown = False
|
mySawShowdown = False
|
||||||
else:
|
else:
|
||||||
#print "in else"
|
#print "in else"
|
||||||
for i in xrange(len(allIns[3][player])):
|
if any(i for i in allIns[3][player]):
|
||||||
if allIns[3][player][i]:
|
|
||||||
isAllIn = True
|
isAllIn = True
|
||||||
if (len(action_types[4][player])>0 or isAllIn):
|
if (len(action_types[4][player])>0 or isAllIn):
|
||||||
#print "in if"
|
#print "in if"
|
||||||
myStreet4Seen = True
|
myStreet4Seen = True
|
||||||
|
|
||||||
mySawShowdown = True
|
mySawShowdown = True
|
||||||
for count in xrange(len(action_types[4][player])):
|
if any(actiontype == "fold" for actiontype in action_types[4][player]):
|
||||||
if action_types[4][player][count]=="fold":
|
|
||||||
mySawShowdown = False
|
mySawShowdown = False
|
||||||
|
|
||||||
|
|
||||||
#flop stuff
|
#flop stuff
|
||||||
street=1
|
street=1
|
||||||
if myStreet1Seen:
|
if myStreet1Seen:
|
||||||
for count in xrange(len(action_types[street][player])):
|
if any(actiontype == "bet" for actiontype in action_types[street][player]):
|
||||||
if action_types[street][player][count]=="bet":
|
|
||||||
myStreet1Aggr = True
|
myStreet1Aggr = True
|
||||||
|
|
||||||
for otherPlayer in xrange(len(player_ids)):
|
for otherPlayer in xrange(len(player_ids)):
|
||||||
|
@ -1969,8 +1868,7 @@ sure to also change the following storage method and table_viewer.prepare_data i
|
||||||
#turn stuff - copy of flop with different vars
|
#turn stuff - copy of flop with different vars
|
||||||
street=2
|
street=2
|
||||||
if myStreet2Seen:
|
if myStreet2Seen:
|
||||||
for count in xrange(len(action_types[street][player])):
|
if any(actiontype == "bet" for actiontype in action_types[street][player]):
|
||||||
if action_types[street][player][count]=="bet":
|
|
||||||
myStreet2Aggr = True
|
myStreet2Aggr = True
|
||||||
|
|
||||||
for otherPlayer in xrange(len(player_ids)):
|
for otherPlayer in xrange(len(player_ids)):
|
||||||
|
@ -1987,8 +1885,7 @@ sure to also change the following storage method and table_viewer.prepare_data i
|
||||||
#river stuff - copy of flop with different vars
|
#river stuff - copy of flop with different vars
|
||||||
street=3
|
street=3
|
||||||
if myStreet3Seen:
|
if myStreet3Seen:
|
||||||
for count in xrange(len(action_types[street][player])):
|
if any(actiontype == "bet" for actiontype in action_types[street][player]):
|
||||||
if action_types[street][player][count]=="bet":
|
|
||||||
myStreet3Aggr = True
|
myStreet3Aggr = True
|
||||||
|
|
||||||
for otherPlayer in xrange(len(player_ids)):
|
for otherPlayer in xrange(len(player_ids)):
|
||||||
|
@ -2005,8 +1902,7 @@ sure to also change the following storage method and table_viewer.prepare_data i
|
||||||
#stud river stuff - copy of flop with different vars
|
#stud river stuff - copy of flop with different vars
|
||||||
street=4
|
street=4
|
||||||
if myStreet4Seen:
|
if myStreet4Seen:
|
||||||
for count in xrange(len(action_types[street][player])):
|
if any(actiontype == "bet" for actiontype in action_types[street][player]):
|
||||||
if action_types[street][player][count]=="bet":
|
|
||||||
myStreet4Aggr=True
|
myStreet4Aggr=True
|
||||||
|
|
||||||
for otherPlayer in xrange(len(player_ids)):
|
for otherPlayer in xrange(len(player_ids)):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user