[KILLFTP 5/x] Remove references to the named site "PokerStars" or
"Full Tilt Poker"
This commit is contained in:
parent
161485e44e
commit
264b188633
|
@ -293,7 +293,7 @@ class Importer:
|
|||
# print "import_fpdb_file", file, site, self.lines, "\n"
|
||||
return (0,0,0,1,0)
|
||||
|
||||
site=fpdb_simple.recogniseSite(firstline)
|
||||
# site=fpdb_simple.recogniseSite(firstline)
|
||||
category=fpdb_simple.recogniseCategory(firstline)
|
||||
|
||||
startpos=0
|
||||
|
@ -318,13 +318,13 @@ class Importer:
|
|||
else:
|
||||
isTourney=fpdb_simple.isTourney(hand[0])
|
||||
if not isTourney:
|
||||
fpdb_simple.filterAnteBlindFold(site,hand)
|
||||
hand=fpdb_simple.filterCrap(site, hand, isTourney)
|
||||
fpdb_simple.filterAnteBlindFold(hand)
|
||||
hand=fpdb_simple.filterCrap(hand, isTourney)
|
||||
self.hand=hand
|
||||
|
||||
try:
|
||||
handsId=fpdb_parse_logic.mainParser(self.settings['db-backend'], self.fdb.db
|
||||
,self.fdb.cursor, site, category, hand)
|
||||
,self.fdb.cursor, category, hand)
|
||||
self.fdb.db.commit()
|
||||
|
||||
stored+=1
|
||||
|
|
|
@ -21,7 +21,7 @@ import fpdb_simple
|
|||
import fpdb_save_to_db
|
||||
|
||||
#parses a holdem hand
|
||||
def mainParser(backend, db, cursor, site, category, hand):
|
||||
def mainParser(backend, db, cursor, category, hand):
|
||||
category=fpdb_simple.recogniseCategory(hand[0])
|
||||
if (category=="holdem" or category=="omahahi" or category=="omahahilo"):
|
||||
base="hold"
|
||||
|
@ -35,8 +35,8 @@ def mainParser(backend, db, cursor, site, category, hand):
|
|||
|
||||
#part 1: read hand no and check for duplicate
|
||||
siteHandNo=fpdb_simple.parseSiteHandNo(hand[0])
|
||||
handStartTime=fpdb_simple.parseHandStartTime(hand[0], site)
|
||||
siteID=fpdb_simple.recogniseSiteID(cursor, site)
|
||||
handStartTime=fpdb_simple.parseHandStartTime(hand[0])
|
||||
siteID=fpdb_simple.recogniseSiteID()
|
||||
#print "parse logic, siteID:",siteID,"site:",site
|
||||
|
||||
isTourney=fpdb_simple.isTourney(hand[0])
|
||||
|
@ -51,8 +51,6 @@ def mainParser(backend, db, cursor, site, category, hand):
|
|||
#print "small blind line:",smallBlindLine
|
||||
gametypeID=fpdb_simple.recogniseGametypeID(backend, db, cursor, hand[0], hand[smallBlindLine], siteID, category, isTourney)
|
||||
if isTourney:
|
||||
if site!="ps":
|
||||
raise fpdb_simple.FpdbError("tourneys are only supported on PS right now")
|
||||
siteTourneyNo=fpdb_simple.parseTourneyNo(hand[0])
|
||||
buyin=fpdb_simple.parseBuyin(hand[0])
|
||||
fee=fpdb_simple.parseFee(hand[0])
|
||||
|
@ -75,7 +73,7 @@ def mainParser(backend, db, cursor, site, category, hand):
|
|||
seatLines.append(hand[i])
|
||||
names=fpdb_simple.parseNames(seatLines)
|
||||
playerIDs = fpdb_simple.recognisePlayerIDs(cursor, names, siteID)
|
||||
tmp=fpdb_simple.parseCashesAndSeatNos(seatLines, site)
|
||||
tmp=fpdb_simple.parseCashesAndSeatNos(seatLines)
|
||||
startCashes=tmp['startCashes']
|
||||
seatNos=tmp['seatNos']
|
||||
|
||||
|
@ -88,15 +86,15 @@ def mainParser(backend, db, cursor, site, category, hand):
|
|||
#part 4: take appropriate action for each line based on linetype
|
||||
for i in range(len(hand)):
|
||||
if (lineTypes[i]=="cards"):
|
||||
fpdb_simple.parseCardLine (site, category, lineStreets[i], hand[i], names, cardValues, cardSuits, boardValues, boardSuits)
|
||||
fpdb_simple.parseCardLine (category, lineStreets[i], hand[i], names, cardValues, cardSuits, boardValues, boardSuits)
|
||||
#if category=="studhilo":
|
||||
# print "hand[i]:", hand[i]
|
||||
# print "cardValues:", cardValues
|
||||
# print "cardSuits:", cardSuits
|
||||
elif (lineTypes[i]=="action"):
|
||||
fpdb_simple.parseActionLine (site, base, isTourney, hand[i], lineStreets[i], playerIDs, names, actionTypes, allIns, actionAmounts, actionNos, actionTypeByNo)
|
||||
fpdb_simple.parseActionLine (base, isTourney, hand[i], lineStreets[i], playerIDs, names, actionTypes, allIns, actionAmounts, actionNos, actionTypeByNo)
|
||||
elif (lineTypes[i]=="win"):
|
||||
fpdb_simple.parseWinLine (hand[i], site, names, winnings, isTourney)
|
||||
fpdb_simple.parseWinLine (hand[i], names, winnings, isTourney)
|
||||
elif (lineTypes[i]=="rake"):
|
||||
if isTourney:
|
||||
totalRake=0
|
||||
|
@ -106,9 +104,9 @@ def mainParser(backend, db, cursor, site, category, hand):
|
|||
elif (lineTypes[i]=="header" or lineTypes[i]=="rake" or lineTypes[i]=="name" or lineTypes[i]=="ignore"):
|
||||
pass
|
||||
elif (lineTypes[i]=="ante"):
|
||||
fpdb_simple.parseAnteLine(hand[i], site, isTourney, names, antes)
|
||||
fpdb_simple.parseAnteLine(hand[i], isTourney, names, antes)
|
||||
elif (lineTypes[i]=="table"):
|
||||
tableResult=fpdb_simple.parseTableLine(site, base, hand[i])
|
||||
tableResult=fpdb_simple.parseTableLine(base, hand[i])
|
||||
else:
|
||||
raise fpdb_simple.FpdbError("unrecognised lineType:"+lineTypes[i])
|
||||
maxSeats=tableResult['maxSeats']
|
||||
|
@ -125,7 +123,7 @@ def mainParser(backend, db, cursor, site, category, hand):
|
|||
|
||||
cursor.execute("SELECT limitType FROM Gametypes WHERE id=%s",(gametypeID, ))
|
||||
limit_type=cursor.fetchone()[0]
|
||||
fpdb_simple.convert3B4B(site, category, limit_type, actionTypes, actionAmounts)
|
||||
fpdb_simple.convert3B4B(category, limit_type, actionTypes, actionAmounts)
|
||||
|
||||
totalWinnings=0
|
||||
for i in range(len(winnings)):
|
||||
|
|
|
@ -458,7 +458,7 @@ def classifyLines(hand, category, lineTypes, lineStreets):
|
|||
lineStreets.append(currentStreet)
|
||||
#end def classifyLines
|
||||
|
||||
def convert3B4B(site, category, limit_type, actionTypes, actionAmounts):
|
||||
def convert3B4B(category, limit_type, actionTypes, actionAmounts):
|
||||
"""calculates the actual bet amounts in the given amount array and changes it accordingly."""
|
||||
for i in range (len(actionTypes)):
|
||||
for j in range (len(actionTypes[i])):
|
||||
|
@ -474,7 +474,7 @@ def convert3B4B(site, category, limit_type, actionTypes, actionAmounts):
|
|||
elif (len(bets)>2):
|
||||
fail=True
|
||||
#todo: run correction for below
|
||||
if (site=="ps" and category=="holdem" and limit_type=="nl" and len(bets)==3):
|
||||
if (limit_type=="nl" or limit_type == "pl"):
|
||||
fail=False
|
||||
|
||||
if fail:
|
||||
|
@ -611,7 +611,7 @@ def fillCardArrays(player_count, base, category, card_values, card_suits):
|
|||
|
||||
#filters out a player that folded before paying ante or blinds. This should be called
|
||||
#before calling the actual hand parser. manipulates hand, no return.
|
||||
def filterAnteBlindFold(site,hand):
|
||||
def filterAnteBlindFold(hand):
|
||||
#todo: this'll only get rid of one ante folder, not multiple ones
|
||||
#todo: in tourneys this should not be removed but
|
||||
#print "start of filterAnteBlindFold"
|
||||
|
@ -649,7 +649,7 @@ def filterAnteBlindFold(site,hand):
|
|||
#end def filterAnteFold
|
||||
|
||||
#removes useless lines as well as trailing spaces
|
||||
def filterCrap(site, hand, isTourney):
|
||||
def filterCrap(hand, isTourney):
|
||||
#remove two trailing spaces at end of line
|
||||
for i in range (len(hand)):
|
||||
if (hand[i][-1]==' '):
|
||||
|
@ -714,12 +714,8 @@ def filterCrap(site, hand, isTourney):
|
|||
toRemove.append(hand[i])
|
||||
elif (hand[i].find("joins the table at seat ")!=-1):
|
||||
toRemove.append(hand[i])
|
||||
elif (hand[i].endswith(" sits down")):
|
||||
toRemove.append(hand[i])
|
||||
elif (hand[i].endswith("leaves the table")):
|
||||
toRemove.append(hand[i])
|
||||
elif (hand[i].endswith(" stands up")):
|
||||
toRemove.append(hand[i])
|
||||
elif (hand[i].find("is high with ")!=-1):
|
||||
toRemove.append(hand[i])
|
||||
elif (hand[i].endswith("doesn't show hand")):
|
||||
|
@ -862,7 +858,7 @@ def isWinLine(line):
|
|||
#end def isWinLine
|
||||
|
||||
#returns the amount of cash/chips put into the put in the given action line
|
||||
def parseActionAmount(line, atype, site, isTourney):
|
||||
def parseActionAmount(line, atype, isTourney):
|
||||
#if (line.endswith(" and is all-in")):
|
||||
# line=line[:-14]
|
||||
#elif (line.endswith(", and is all in")):
|
||||
|
@ -878,14 +874,14 @@ def parseActionAmount(line, atype, site, isTourney):
|
|||
amount=0
|
||||
elif (atype=="check"):
|
||||
amount=0
|
||||
elif (atype=="unbet" and site=="ps"):
|
||||
elif (atype=="unbet"):
|
||||
#print "ps unbet, line:",line
|
||||
pos1=line.find("$")+1
|
||||
if pos1==0:
|
||||
pos1=line.find("(")+1
|
||||
pos2=line.find(")")
|
||||
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 line.find(": raises $")!=-1 and line.find("to $")!=-1):
|
||||
pos=line.find("to $")+4
|
||||
amount=float2int(line[pos:])
|
||||
else:
|
||||
|
@ -908,7 +904,7 @@ def parseActionAmount(line, atype, site, isTourney):
|
|||
#doesnt return anything, simply changes the passed arrays action_types and
|
||||
# action_amounts. For stud this expects numeric streets (3-7), for
|
||||
# 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(base, isTourney, line, street, playerIDs, names, action_types, allIns, action_amounts, actionNos, actionTypeByNo):
|
||||
if (street=="predeal" or street=="preflop"):
|
||||
street=0
|
||||
elif (street=="flop"):
|
||||
|
@ -927,7 +923,7 @@ def parseActionLine(site, base, isTourney, line, street, playerIDs, names, actio
|
|||
line, allIn=goesAllInOnThisLine(line)
|
||||
atype=parseActionType(line)
|
||||
playerno=recognisePlayerNo(line, names, atype)
|
||||
amount=parseActionAmount(line, atype, site, isTourney)
|
||||
amount=parseActionAmount(line, atype, isTourney)
|
||||
|
||||
action_types[street][playerno].append(atype)
|
||||
allIns[street][playerno].append(allIn)
|
||||
|
@ -988,7 +984,7 @@ def parseActionType(line):
|
|||
#end def parseActionType
|
||||
|
||||
#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, isTourney, names, antes):
|
||||
for i in range(len(names)):
|
||||
if (line.startswith(names[i].encode("latin-1"))): #found the ante'er
|
||||
pos=line.rfind("$")+1
|
||||
|
@ -1014,7 +1010,7 @@ def parseBuyin(topline):
|
|||
|
||||
#parses a card line and changes the passed arrays accordingly
|
||||
#todo: reorganise this messy method
|
||||
def parseCardLine(site, category, street, line, names, cardValues, cardSuits, boardValues, boardSuits):
|
||||
def parseCardLine(category, street, line, names, cardValues, cardSuits, boardValues, boardSuits):
|
||||
if (line.startswith("Dealt to ") or line.find(" shows [")!=-1 or line.find("mucked [")!=-1):
|
||||
playerNo=recognisePlayerNo(line, names, "card") #anything but unbet will be ok for that string
|
||||
|
||||
|
@ -1088,7 +1084,7 @@ def parseCardLine(site, category, street, line, names, cardValues, cardSuits, bo
|
|||
raise FpdbError ("unrecognised line:"+line)
|
||||
#end def parseCardLine
|
||||
|
||||
def parseCashesAndSeatNos(lines, site):
|
||||
def parseCashesAndSeatNos(lines):
|
||||
"""parses the startCashes and seatNos of each player out of the given lines and returns them as a dictionary of two arrays"""
|
||||
cashes = []
|
||||
seatNos = []
|
||||
|
@ -1099,7 +1095,6 @@ def parseCashesAndSeatNos(lines, site):
|
|||
pos1=lines[i].rfind("($")+2
|
||||
if pos1==1: #for tourneys - it's 1 instead of -1 due to adding 2 above
|
||||
pos1=lines[i].rfind("(")+1
|
||||
elif (site=="ps"):
|
||||
pos2=lines[i].find(" in chips")
|
||||
cashes.append(float2int(lines[i][pos1:pos2]))
|
||||
return {'startCashes':cashes, 'seatNos':seatNos}
|
||||
|
@ -1114,7 +1109,7 @@ def parseFee(topline):
|
|||
#end def parsefee
|
||||
|
||||
#returns a datetime object with the starttime indicated in the given topline
|
||||
def parseHandStartTime(topline, site):
|
||||
def parseHandStartTime(topline):
|
||||
#convert x:13:35 to 0x:13:35
|
||||
counter=0
|
||||
while (True):
|
||||
|
@ -1258,7 +1253,7 @@ def parseSiteHandNo(topline):
|
|||
return topline[pos1:pos2]
|
||||
#end def parseSiteHandNo
|
||||
|
||||
def parseTableLine(site, base, line):
|
||||
def parseTableLine(base, line):
|
||||
"""returns a dictionary with maxSeats and tableName"""
|
||||
pos1=line.find('\'')+1
|
||||
pos2=line.find('\'', pos1)
|
||||
|
@ -1278,7 +1273,7 @@ def parseTourneyNo(topline):
|
|||
#end def parseTourneyNo
|
||||
|
||||
#parses a win/collect line. manipulates the passed array winnings, no explicit return
|
||||
def parseWinLine(line, site, names, winnings, isTourney):
|
||||
def parseWinLine(line, names, winnings, isTourney):
|
||||
#print "parseWinLine: line:",line
|
||||
for i in range(len(names)):
|
||||
if (line.startswith(names[i].encode("latin-1"))): #found a winner
|
||||
|
@ -1473,28 +1468,8 @@ def recognisePlayerNo(line, names, atype):
|
|||
raise FpdbError ("failed to recognise player in: "+line+" atype:"+atype)
|
||||
#end def recognisePlayerNo
|
||||
|
||||
#returns the site abbreviation for the given site
|
||||
def recogniseSite(line):
|
||||
# TODO: Make site agnostic
|
||||
if (line.startswith("Full Tilt Poker")):
|
||||
return "ftp"
|
||||
elif (line.startswith("PokerStars")):
|
||||
return "ps"
|
||||
else:
|
||||
raise FpdbError("failed to recognise site, line:"+line)
|
||||
#end def recogniseSite
|
||||
|
||||
#returns the ID of the given site
|
||||
def recogniseSiteID(cursor, site):
|
||||
if (site=="ftp"):
|
||||
return 1
|
||||
#cursor.execute("SELECT id FROM Sites WHERE name = ('Full Tilt Poker')")
|
||||
elif (site=="ps"):
|
||||
def recogniseSiteID():
|
||||
return 2
|
||||
#cursor.execute("SELECT id FROM Sites WHERE name = ('PokerStars')")
|
||||
else:
|
||||
raise FpdbError("invalid site in recogniseSiteID: "+site)
|
||||
return cursor.fetchall()[0][0]
|
||||
#end def recogniseSiteID
|
||||
|
||||
#removes trailing \n from the given array
|
||||
|
|
Loading…
Reference in New Issue
Block a user