From a26151717570747a4843f6f3cebadbbf7c554156 Mon Sep 17 00:00:00 2001 From: Worros Date: Mon, 1 Jun 2009 17:14:31 +0800 Subject: [PATCH] Add additional siteids to db, move player select function --- pyfpdb/BetfairToFpdb.py | 1 + pyfpdb/CarbonToFpdb.py | 1 + pyfpdb/EverleafToFpdb.py | 1 + pyfpdb/FulltiltToFpdb.py | 1 + pyfpdb/Hand.py | 23 +++++++++++++++++++++++ pyfpdb/OnGameToFpdb.py | 1 + pyfpdb/PokerStarsToFpdb.py | 1 + pyfpdb/UltimateBetToFpdb.py | 1 + pyfpdb/fpdb_db.py | 4 ++++ pyfpdb/fpdb_simple.py | 21 --------------------- 10 files changed, 34 insertions(+), 21 deletions(-) diff --git a/pyfpdb/BetfairToFpdb.py b/pyfpdb/BetfairToFpdb.py index bc1d17c9..672e858a 100755 --- a/pyfpdb/BetfairToFpdb.py +++ b/pyfpdb/BetfairToFpdb.py @@ -43,6 +43,7 @@ follow : whether to tail -f the input""" logging.info("Initialising Betfair converter class") self.filetype = "text" self.codepage = "cp1252" + self.siteId = 7 # Needs to match id entry in Sites database if autostart: self.start() diff --git a/pyfpdb/CarbonToFpdb.py b/pyfpdb/CarbonToFpdb.py index cf9fc8d3..fa1ad6fd 100644 --- a/pyfpdb/CarbonToFpdb.py +++ b/pyfpdb/CarbonToFpdb.py @@ -54,6 +54,7 @@ class CarbonPoker(HandHistoryConverter): print "Initialising Carbon Poker converter class" HandHistoryConverter.__init__(self, config, filename, "Carbon") # Call super class init self.setFileType("xml") + self.siteId = 4 # Needs to match id entry in Sites database def readSupportedGames(self): pass diff --git a/pyfpdb/EverleafToFpdb.py b/pyfpdb/EverleafToFpdb.py index f353bc61..6ed2b6ba 100755 --- a/pyfpdb/EverleafToFpdb.py +++ b/pyfpdb/EverleafToFpdb.py @@ -49,6 +49,7 @@ debugging: if False, pass on partially supported game types. If true, have a go logging.info("Initialising Everleaf converter class") self.filetype = "text" self.codepage = "cp1252" + self.siteId = 3 # Needs to match id entry in Sites database self.debugging = debugging if autostart: self.start() diff --git a/pyfpdb/FulltiltToFpdb.py b/pyfpdb/FulltiltToFpdb.py index dd0927b9..a84f683c 100755 --- a/pyfpdb/FulltiltToFpdb.py +++ b/pyfpdb/FulltiltToFpdb.py @@ -45,6 +45,7 @@ follow : whether to tail -f the input""" logging.info("Initialising Fulltilt converter class") self.filetype = "text" self.codepage = "cp1252" + self.siteId = 1 # Needs to match id entry in Sites database if autostart: self.start() diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index 17eefe12..d45bae97 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -100,6 +100,29 @@ db: a connected fpdb_db object""" """ Function to create Hand object from database """ pass +# Get SQL player IDs from database +# this version could also be improved upon using list comprehensions, etc + +#def recognisePlayerIDs(cursor, names, site_id): +# result = [] +# notfound = [] +# cursor.execute("SELECT name,id FROM Players WHERE name='%s'" % "' OR name='".join(names)) +# tmp = dict(cursor.fetchall()) +# for n in names: +# if n not in tmp: +# notfound.append(n) +# else: +# result.append(tmp[n]) +# if notfound: +# cursor.executemany("INSERT INTO Players (name, siteId) VALUES (%s, "+str(site_id)+")", (notfound)) +# cursor.execute("SELECT id FROM Players WHERE name='%s'" % "' OR name='".join(notfound)) +# tmp = cursor.fetchall() +# for n in tmp: +# result.append(n[0]) +# +# return result + + def addPlayer(self, seat, name, chips): """\ diff --git a/pyfpdb/OnGameToFpdb.py b/pyfpdb/OnGameToFpdb.py index ee16eb41..8a68b105 100755 --- a/pyfpdb/OnGameToFpdb.py +++ b/pyfpdb/OnGameToFpdb.py @@ -72,6 +72,7 @@ class OnGame(HandHistoryConverter): HandHistoryConverter.__init__(self, config, file, sitename="OnGame") # Call super class init. self.sitename = "OnGame" self.setFileType("text", "cp1252") + self.siteId = 5 # Needs to match id entry in Sites database #self.rexx.setGameInfoRegex('.*Blinds \$?(?P[.0-9]+)/\$?(?P[.0-9]+)') self.rexx.setSplitHandRegex('\n\n\n+') diff --git a/pyfpdb/PokerStarsToFpdb.py b/pyfpdb/PokerStarsToFpdb.py index 300c6071..2b4ec6a1 100755 --- a/pyfpdb/PokerStarsToFpdb.py +++ b/pyfpdb/PokerStarsToFpdb.py @@ -44,6 +44,7 @@ follow : whether to tail -f the input""" logging.info("Initialising PokerStars converter class") self.filetype = "text" self.codepage = "cp1252" + self.siteId = 2 # Needs to match id entry in Sites database if autostart: self.start() diff --git a/pyfpdb/UltimateBetToFpdb.py b/pyfpdb/UltimateBetToFpdb.py index 6b11d8e6..b57e789e 100755 --- a/pyfpdb/UltimateBetToFpdb.py +++ b/pyfpdb/UltimateBetToFpdb.py @@ -42,6 +42,7 @@ follow : whether to tail -f the input""" logging.info("Initialising UltimateBetconverter class") self.filetype = "text" self.codepage = "cp1252" + self.siteId = 6 # Needs to match id entry in Sites database if autostart: self.start() diff --git a/pyfpdb/fpdb_db.py b/pyfpdb/fpdb_db.py index 8814f104..b45d6cbf 100644 --- a/pyfpdb/fpdb_db.py +++ b/pyfpdb/fpdb_db.py @@ -205,6 +205,10 @@ class fpdb_db: self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, 'Full Tilt Poker', 'USD');") self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, 'PokerStars', 'USD');") self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, 'Everleaf', 'USD');") + self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, 'Carbon', 'USD');") + self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, 'OnGame', 'USD');") + self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, 'UltimateBet', 'USD');") + self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, 'Betfair', 'USD');") self.cursor.execute("INSERT INTO TourneyTypes VALUES (DEFAULT, 1, 0, 0, 0, False);") #end def fillDefaultData diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index c6f79d9d..2241feab 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -1390,27 +1390,6 @@ def recognisePlayerIDs(cursor, names, site_id): #end def recognisePlayerIDs -# Here's a version that would work if it wasn't for the fact that it needs to have the output in the same order as input -# this version could also be improved upon using list comprehensions, etc - -#def recognisePlayerIDs(cursor, names, site_id): -# result = [] -# notfound = [] -# cursor.execute("SELECT name,id FROM Players WHERE name='%s'" % "' OR name='".join(names)) -# tmp = dict(cursor.fetchall()) -# for n in names: -# if n not in tmp: -# notfound.append(n) -# else: -# result.append(tmp[n]) -# if notfound: -# cursor.executemany("INSERT INTO Players (name, siteId) VALUES (%s, "+str(site_id)+")", (notfound)) -# cursor.execute("SELECT id FROM Players WHERE name='%s'" % "' OR name='".join(notfound)) -# tmp = cursor.fetchall() -# for n in tmp: -# result.append(n[0]) -# -# return result #recognises the name in the given line and returns its array position in the given array def recognisePlayerNo(line, names, atype):