From a0a6207810d3f51364f1db57a61ab3bccb4fb484 Mon Sep 17 00:00:00 2001 From: Mika Bostrom Date: Wed, 2 Dec 2009 12:29:48 +0200 Subject: [PATCH 1/4] Fix profit graph query At least postgresql requires to have grouping by hp.sawShowdown as well --- pyfpdb/SQL.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index 85b5fd80..eb9296ef 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -2572,7 +2572,7 @@ class Sql: AND h.handStart < '' AND hp.tourneysPlayersId IS NULL - GROUP BY h.handStart, hp.handId, hp.totalProfit + GROUP BY h.handStart, hp.handId, hp.sawShowdown, hp.totalProfit ORDER BY h.handStart""" #################################### From 76163733ee8b4d2af5360aee09a32b0bf36d4677 Mon Sep 17 00:00:00 2001 From: Worros Date: Thu, 3 Dec 2009 16:46:10 +0800 Subject: [PATCH 2/4] Repair recent damage to Options --- pyfpdb/Options.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyfpdb/Options.py b/pyfpdb/Options.py index 9859e7d2..ab226124 100644 --- a/pyfpdb/Options.py +++ b/pyfpdb/Options.py @@ -36,8 +36,11 @@ def fpdb_options(): action="store_true", help="Indicates program was restarted with a different path (only allowed once).") parser.add_option("-i", "--infile", - dest="config", default=None, + dest="infile", default="Slartibartfast", help="Input file") + parser.add_option("-k", "--konverter", + dest="hhc", default="PokerStarsToFpdb", + help="Module name for Hand History Converter") (options, argv) = parser.parse_args() return (options, argv) From 247af28f7ebb2b85b14752cd3c3038a7083dabbd Mon Sep 17 00:00:00 2001 From: Worros Date: Thu, 3 Dec 2009 17:26:40 +0800 Subject: [PATCH 3/4] Add a HH anonymiser Usage: python Anonymise.py -i regression-test-files/tour/Stars/Flop/NLHE-USD-MTT-5r-200710.txt At least works for Stars at the moment --- pyfpdb/Anonymise.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 pyfpdb/Anonymise.py diff --git a/pyfpdb/Anonymise.py b/pyfpdb/Anonymise.py new file mode 100644 index 00000000..32036b1e --- /dev/null +++ b/pyfpdb/Anonymise.py @@ -0,0 +1,37 @@ +import os +import re +import codecs +import Options +import HandHistoryConverter + +(options, argv) = Options.fpdb_options() + +filter = options.hhc + +filter_name = filter.replace("ToFpdb", "") + +mod = __import__(filter) +obj = getattr(mod, filter_name, None) + +hhc = obj(autostart=False) + +if os.path.exists(options.infile): + in_fh = codecs.open(options.infile, 'r', "utf8") + filecontents = in_fh.read() + in_fh.close() +else: + print "Could not find file %s" % options.infile + exit(1) + +m = hhc.re_PlayerInfo.finditer(filecontents) + +players = [] +for a in m: + players = players + [a.group('PNAME')] + +uniq = set(players) + +for i, name in enumerate(uniq, 1): + filecontents = filecontents.replace(name, 'Player%d' %i) + +print filecontents From b7d9a843bdf00bc236bcad22affa335ab13c5538 Mon Sep 17 00:00:00 2001 From: Worros Date: Thu, 3 Dec 2009 17:45:04 +0800 Subject: [PATCH 4/4] Add PLO test file for Betfair, update test to import it --- ...0.05-0.10-200909.All.in.river.splitpot.txt | 55 +++++++++++++++++++ pyfpdb/test_Betfair.py | 41 +++++++++----- 2 files changed, 82 insertions(+), 14 deletions(-) create mode 100644 pyfpdb/regression-test-files/cash/Betfair/Flop/PLO-6max-USD-0.05-0.10-200909.All.in.river.splitpot.txt diff --git a/pyfpdb/regression-test-files/cash/Betfair/Flop/PLO-6max-USD-0.05-0.10-200909.All.in.river.splitpot.txt b/pyfpdb/regression-test-files/cash/Betfair/Flop/PLO-6max-USD-0.05-0.10-200909.All.in.river.splitpot.txt new file mode 100644 index 00000000..f1fc48c0 --- /dev/null +++ b/pyfpdb/regression-test-files/cash/Betfair/Flop/PLO-6max-USD-0.05-0.10-200909.All.in.river.splitpot.txt @@ -0,0 +1,55 @@ +***** Betfair Poker Hand History for Game 100000000 ***** +PL $0.05/$0.10 Omaha - Sunday, October 18, 20:00:00 GMT 2009 +Table Death 1 6-max (Real Money) +Seat 2 is the button +Total number of active players : 6 +Seat 1: Player6 ( $1 ) +Seat 2: Player3 ( $9.38 ) +Seat 3: Player2 ( $2.82 ) +Seat 4: Player4 ( $4.13 ) +Seat 5: Player5 ( $28.77 ) +Seat 6: Player1 ( $6.46 ) +Player2 posts small blind [$0.05] +Player4 posts big blind [$0.10] +Player6 posts big blind [$0.10] +** Dealing down cards ** +Dealt to Player6 [ 7c, 6c, 5h, Jh ] +Player5 folds +Player1 calls [$0.10] +Player6 checks +Player3 calls [$0.10] +Player2 raises to [$0.30] +Player4 calls [$0.20] +Player1 calls [$0.20] +Player6 goes all-in +Player6 raises to [$1] +Player3 calls [$0.90] +Player2 calls [$0.70] +Player4 calls [$0.70] +Player1 calls [$0.70] +** Dealing Flop ** [ 4d, 5d, 6d ] +Player2 checks +Player4 checks +Player1 checks +Player3 checks +** Dealing Turn ** [ 3s ] +Player2 checks +Player4 bets [$0.10] +Player1 calls [$0.10] +Player3 folds +Player2 folds +** Dealing River ** [ 4c ] +Player4 goes all-in +Player4 bets [$3.03] +Player1 calls [$3.03] +** Showdown ** +Player6 shows [ 7c, 6c, 5h, Jh ] a straight, Seven to Three +Player4 shows [ 7d, 8c, 3d, 6h ] a straight flush, Seven to Three +Player1 shows [ 3h, 4h, Td, 4s ] four of a kind, Fours +** Hand Conclusion ** +Player4 wins $6.26 from side pot #1 with a straight flush, Seven to Three +Player4 wins $4.44 from main pot with a straight flush, Seven to Three +************ Game 100000000 ends ************ + + + diff --git a/pyfpdb/test_Betfair.py b/pyfpdb/test_Betfair.py index 50949e93..7c979882 100644 --- a/pyfpdb/test_Betfair.py +++ b/pyfpdb/test_Betfair.py @@ -1,21 +1,34 @@ # -*- coding: utf-8 -*- import BetfairToFpdb +from Hand import * import py +import Configuration +import Database +import SQL +import fpdb_import -def checkGameInfo(hhc, header, info): - assert hhc.determineGameType(header) == info +config = Configuration.Config(file = "HUD_config.test.xml") +db = Database.Database(config) +sql = SQL.Sql(db_server = 'sqlite') -def testGameInfo(): - hhc = BetfairToFpdb.Betfair(autostart=False) - pairs = ( - (u"""***** Betfair Poker Hand History for Game 472386869 ***** -NL $0.02/$0.04 Texas Hold'em - Sunday, January 25, 10:10:42 GMT 2009 -Table Rookie 191 6-max (Real Money) -Seat 1 is the button -Total number of active players : 6""", - {'type':'ring', 'base':"hold", 'category':'holdem', 'limitType':'nl', 'sb':'0.02', 'bb':'0.04', 'currency':'USD'}), - ) +settings = {} +settings.update(config.get_db_parameters()) +settings.update(config.get_tv_parameters()) +settings.update(config.get_import_parameters()) +settings.update(config.get_default_paths()) - for (header, info) in pairs: - yield checkGameInfo, hhc, header, info +def testFlopImport(): + db.recreate_tables() + importer = fpdb_import.Importer(False, settings, config) + importer.setDropIndexes("don't drop") + importer.setFailOnError(True) + importer.setThreads(-1) + importer.addBulkImportImportFileOrDir( + """regression-test-files/cash/Betfair/Flop/PLO-6max-USD-0.05-0.10-200909.All.in.river.splitpot.txt""", site="Betfair") + importer.setCallHud(False) + (stored, dups, partial, errs, ttime) = importer.runImport() + importer.clearFileList() + + # Should actually do some testing here + assert 1 == 1