Merge branch 'master' of git://git.assembla.com/fpdboz.git

Conflicts:
	pyfpdb/fpdb_import.py
This commit is contained in:
eblade 2009-03-13 16:10:44 -04:00
commit d35184cc79
5 changed files with 24 additions and 68 deletions

View File

@ -43,6 +43,7 @@ out_path (default '-' = sys.stdout)
follow : whether to tail -f the input
autostart: whether to run the thread (or you can call start() yourself)
debugging: if False, pass on partially supported game types. If true, have a go and error..."""
print "DEBUG: XXXXXXXXXXXXXXX"
HandHistoryConverter.__init__(self, in_path, out_path, sitename="Everleaf", follow=follow)
logging.info("Initialising Everleaf converter class")
self.filetype = "text"

View File

@ -22,9 +22,9 @@ import sys
import logging
from HandHistoryConverter import *
# FullTilt HH Format converter
# Fulltilt HH Format converter
class FullTilt(HandHistoryConverter):
class Fulltilt(HandHistoryConverter):
# Static regexes
re_GameInfo = re.compile('- (?P<CURRENCY>\$|)?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (Ante \$(?P<ANTE>[.0-9]+) )?- (?P<LIMIT>(No Limit|Pot Limit|Limit))? (?P<GAME>(Hold\'em|Omaha Hi|Razz))')
@ -39,8 +39,8 @@ class FullTilt(HandHistoryConverter):
in_path (default '-' = sys.stdin)
out_path (default '-' = sys.stdout)
follow : whether to tail -f the input"""
HandHistoryConverter.__init__(self, in_path, out_path, sitename="FullTilt", follow=follow)
logging.info("Initialising FullTilt converter class")
HandHistoryConverter.__init__(self, in_path, out_path, sitename="Fulltilt", follow=follow)
logging.info("Initialising Fulltilt converter class")
self.filetype = "text"
self.codepage = "cp1252"
if autostart:
@ -314,4 +314,4 @@ if __name__ == "__main__":
LOG_FILENAME = './logging.out'
logging.basicConfig(filename=LOG_FILENAME,level=options.verbosity)
e = FullTilt(in_path = options.ipath, out_path = options.opath, follow = options.follow)
e = Fulltilt(in_path = options.ipath, out_path = options.opath, follow = options.follow)

View File

@ -29,6 +29,7 @@ from Exceptions import *
class Hand:
UPS = {'a':'A', 't':'T', 'j':'J', 'q':'Q', 'k':'K', 'S':'s', 'C':'c', 'H':'h', 'D':'d'}
LCS = {'H':'h', 'D':'d', 'C':'c', 'S':'s'}
def __init__(self, sitename, gametype, handText):
self.sitename = sitename
self.gametype = gametype
@ -316,32 +317,6 @@ Map the tuple self.gametype onto the pokerstars string describing it
return retstring
def lookupLimitBetSize(self):
#Lookup table for limit games
betlist = {
"Everleaf" : { "0.10" : ("0.02", "0.05"),
"0.20" : ("0.05", "0.10"),
"0.50" : ("0.10", "0.25"),
"1" : ("0.25", "0.50"),
"2" : ("0.50", "1.00"),
"4" : ("1.00", "2.00"),
"6" : ("1.00", "3.00")
},
"FullTilt" : { "0.10" : ("0.02", "0.05"),
"0.20" : ("0.05", "0.10"),
"1" : ("0.25", "0.50"),
"2" : ("0.50", "1"),
"4" : ("1", "2")
}
}
try:
ret = betlist[self.sitename][self.bb]
except:
logging.warning("Don't know the small blind/big blind size for %s, big bet size %s." % (self.sitename, self.bb))
ret = (Decimal(self.sb)/2,Decimal(self.bb)/2)
return ret
def writeHand(self, fh=sys.__stdout__):
print >>fh, "Override me"
@ -451,23 +426,6 @@ Card ranks will be uppercased
#Only print stacks of players who do something preflop
print >>fh, _("Seat %s: %s ($%s in chips) " %(player[0], player[1], player[2]))
#May be more than 1 bb posting
if self.gametype['limitType'] == "fl":
(smallbet, bigbet) = self.lookupLimitBetSize()
else:
smallbet = self.sb
bigbet = self.bb
# for a in self.posted:
# if(a[1] == "small blind"):
# print >>fh, _("%s: posts small blind $%s" %(a[0], smallbet))
# if(a[1] == "big blind"):
# print >>fh, _("%s: posts big blind $%s" %(a[0], bigbet))
# if(a[1] == "both"):
# print >>fh, _("%s: posts small & big blinds $%.2f" %(a[0], (Decimal(smallbet) + Decimal(bigbet))))
# I think these can just be actions in 'blindsantes' round
if self.actions['BLINDSANTES']:
for act in self.actions['BLINDSANTES']:
self.printActionLine(act, fh)

View File

@ -43,11 +43,13 @@ import Configuration
import Stats
import Mucked
import Database
import HUD_main
import HUD_main
import Utils
def importName(module_name, name):
def importName(module_name, name, params):
"""Import a named object 'name' from module 'module_name'."""
# Recipe 16.3 in the Python Cookbook, 2nd ed. Thanks!!!!
# Modded by Carl G to support additional params
try:
module = __import__(module_name, globals(), locals(), [name])
except:

View File

@ -33,8 +33,6 @@ import fpdb_simple
import fpdb_db
import fpdb_parse_logic
import Configuration
import EverleafToFpdb
import FulltiltToFpdb
# database interface modules
try:
@ -240,24 +238,21 @@ class Importer:
except:
out_path = os.path.join(hhdir, "x"+strftime("%d-%m-%y")+os.path.basename(file))
# someone can just create their own python module for it
if filter in ("EverleafToFpdb","Everleaf"):
conv = EverleafToFpdb.Everleaf(in_path = file, out_path = out_path)
elif filter == "FulltiltToFpdb":
conv = FulltiltToFpdb.FullTilt(in_path = file, out_path = out_path)
else:
print "Unknown filter ", filter
return
filter_name = filter.replace("ToFpdb", "")
supp = conv.readSupportedGames() # Should this be done by HHC on init?
#gt = conv.determineGameType()
# TODO: Check that gt is in supp - error appropriately if not
if(conv.getStatus()):
(stored, duplicates, partial, errors, ttime) = self.import_fpdb_file(out_path, site)
mod = __import__(filter)
obj = getattr(mod, filter_name, None)
if callable(obj):
conv = obj(in_path = file, out_path = out_path)
if(conv.getStatus()):
(stored, duplicates, partial, errors, ttime) = self.import_fpdb_file(out_path, site)
else:
# conversion didn't work
# TODO: appropriate response?
return (0, 0, 0, 1, 0)
else:
# conversion didn't work
# TODO: appropriate response?
return (0, 0, 0, 1, 0)
print "Unknown filter filter_name:'%s' in filter:'%s'" %(filter_name, filter)
return
#This will barf if conv.getStatus != True
return (stored, duplicates, partial, errors, ttime)