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

This commit is contained in:
Eric Blade 2010-09-26 02:20:34 -04:00
commit 765782c958
58 changed files with 3495 additions and 2466 deletions

View File

@ -18,23 +18,14 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
######################################################################## ########################################################################
import L10n
_ = L10n.get_translation()
# TODO: I have no idea if AP has multi-currency options, i just copied the regex out of Everleaf converter for the currency symbols.. weeeeee - Eric # TODO: I have no idea if AP has multi-currency options, i just copied the regex out of Everleaf converter for the currency symbols.. weeeeee - Eric
import sys import sys
import logging import logging
from HandHistoryConverter import * from HandHistoryConverter import *
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
# Class for converting Absolute HH format. # Class for converting Absolute HH format.
class Absolute(HandHistoryConverter): class Absolute(HandHistoryConverter):

View File

@ -15,6 +15,9 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt. #In the "official" distribution you can find the license in agpl-3.0.txt.
import L10n
_ = L10n.get_translation()
import os import os
import re import re
import codecs import codecs
@ -23,17 +26,6 @@ import HandHistoryConverter
import Configuration import Configuration
import sys import sys
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
(options, argv) = Options.fpdb_options() (options, argv) = Options.fpdb_options()
config = Configuration.Config() config = Configuration.Config()

View File

@ -18,22 +18,13 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
######################################################################## ########################################################################
import L10n
_ = L10n.get_translation()
import sys import sys
import logging import logging
from HandHistoryConverter import * from HandHistoryConverter import *
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
# Betfair HH format # Betfair HH format
class Betfair(HandHistoryConverter): class Betfair(HandHistoryConverter):

View File

@ -19,6 +19,9 @@
######################################################################## ########################################################################
import L10n
_ = L10n.get_translation()
# This code is based heavily on EverleafToFpdb.py, by Carl Gherardi # This code is based heavily on EverleafToFpdb.py, by Carl Gherardi
# #
# TODO: # TODO:
@ -52,18 +55,6 @@ import logging
from HandHistoryConverter import * from HandHistoryConverter import *
from decimal import Decimal from decimal import Decimal
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
class Carbon(HandHistoryConverter): class Carbon(HandHistoryConverter):

View File

@ -15,34 +15,37 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt. #In the "official" distribution you can find the license in agpl-3.0.txt.
import locale import L10n
lang=locale.getdefaultlocale()[0][0:2] _ = L10n.get_translation()
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
# From fpdb_simple
card_map = { "0": 0, "2": 2, "3" : 3, "4" : 4, "5" : 5, "6" : 6, "7" : 7, "8" : 8, card_map = { "0": 0, "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} "9" : 9, "T" : 10, "J" : 11, "Q" : 12, "K" : 13, "A" : 14}
card_map_low = { "0": 0, "A":1, "2": 2, "3" : 3, "4" : 4, "5" : 5, "6" : 6, "7" : 7, "8" : 8,
"9" : 9, "T" : 10, "J" : 11, "Q" : 12, "K" : 13}
def decodeStartHandValue(game, value):
if game == "holdem":
return twoStartCardString(value)
elif game == "razz":
return decodeRazzStartHand(value)
else:
return "xx"
# FIXME: the following is a workaround until switching to newimport. # FIXME: the following is a workaround until switching to newimport.
# This should be moved into DerivedStats # This should be moved into DerivedStats
# I'd also like to change HandsPlayers.startCards to a different datatype # I'd also like to change HandsPlayers.startCards to a different datatype
# so we can 'trivially' add different start card classifications # so we can 'trivially' add different start card classifications
def calcStartCards(hand, player): def calcStartCards(hand, player):
hcs = hand.join_holecards(player, asList=True)
if hand.gametype['category'] == 'holdem': if hand.gametype['category'] == 'holdem':
hcs = hand.join_holecards(player, asList=True)
#print "DEBUG: hcs: %s" % hcs
value1 = card_map[hcs[0][0]] value1 = card_map[hcs[0][0]]
value2 = card_map[hcs[1][0]] value2 = card_map[hcs[1][0]]
return twoStartCards(value1, hcs[0][1], value2, hcs[1][1]) return twoStartCards(value1, hcs[0][1], value2, hcs[1][1])
elif hand.gametype['category'] == 'razz':
return encodeRazzStartHand(hcs)
else: else:
# FIXME: Only do startCards value for holdem at the moment # FIXME: Only do startCards value for holdem at the moment
return 0 return 0
@ -95,7 +98,7 @@ def twoStartCardString(card):
if x == y: ret = s[x] + s[y] if x == y: ret = s[x] + s[y]
elif x > y: ret = s[x] + s[y] + 's' elif x > y: ret = s[x] + s[y] + 's'
else: ret = s[y] + s[x] + 'o' else: ret = s[y] + s[x] + 'o'
# print "twoStartCardString(", card ,") = " + ret print "twoStartCardString(", card ,") = " + ret
return ret return ret
def fourStartCards(value1, suit1, value2, suit2, value3, suit3, value4, suit4): def fourStartCards(value1, suit1, value2, suit2, value3, suit3, value4, suit4):
@ -163,6 +166,266 @@ def encodeCard(cardString):
if cardString not in encodeCardList: return 0 if cardString not in encodeCardList: return 0
return encodeCardList[cardString] return encodeCardList[cardString]
def decodeRazzStartHand(idx):
decodeRazzList = {
-13:'(00)A',-12:'(00)2',-11:'(00)3',-10:'(00)4',-9:'(00)5',-8:'(00)6',-7:'(00)7',-6:'(00)8',-5:'(00)9',-4:'(00)T',
-3:'(00)J',-2:'(00)Q',-1:'(00)K',0:'xxx',
1:'(32)A',2:'(3A)2',3:'(2A)3',4:'(42)A',5:'(4A)2',6:'(2A)4',7:'(43)A',8:'(4A)3',9:'(3A)4',
10:'(43)2',11:'(42)3',12:'(32)4',13:'(52)A',14:'(5A)2',15:'(2A)5',16:'(53)A',17:'(5A)3',18:'(3A)5',19:'(53)2',
20:'(52)3',21:'(32)5',22:'(54)A',23:'(5A)4',24:'(4A)5',25:'(54)2',26:'(52)4',27:'(42)5',28:'(54)3',29:'(53)4',
30:'(43)5',31:'(62)A',32:'(6A)2',33:'(2A)6',34:'(63)A',35:'(6A)3',36:'(3A)6',37:'(63)2',38:'(62)3',39:'(32)6',
40:'(64)A',41:'(6A)4',42:'(4A)6',43:'(64)2',44:'(62)4',45:'(42)6',46:'(64)3',47:'(63)4',48:'(43)6',49:'(65)A',
50:'(6A)5',51:'(5A)6',52:'(65)2',53:'(62)5',54:'(52)6',55:'(65)3',56:'(63)5',57:'(53)6',58:'(65)4',59:'(64)5',
60:'(54)6',61:'(72)A',62:'(7A)2',63:'(2A)7',64:'(73)A',65:'(7A)3',66:'(3A)7',67:'(73)2',68:'(72)3',69:'(32)7',
70:'(74)A',71:'(7A)4',72:'(4A)7',73:'(74)2',74:'(72)4',75:'(42)7',76:'(74)3',77:'(73)4',78:'(43)7',79:'(75)A',
80:'(7A)5',81:'(5A)7',82:'(75)2',83:'(72)5',84:'(52)7',85:'(75)3',86:'(73)5',87:'(53)7',88:'(75)4',89:'(74)5',
90:'(54)7',91:'(76)A',92:'(7A)6',93:'(6A)7',94:'(76)2',95:'(72)6',96:'(62)7',97:'(76)3',98:'(73)6',99:'(63)7',
100:'(76)4',101:'(74)6',102:'(64)7',103:'(76)5',104:'(75)6',105:'(65)7',106:'(82)A',107:'(8A)2',108:'(2A)8',109:'(83)A',
110:'(8A)3',111:'(3A)8',112:'(83)2',113:'(82)3',114:'(32)8',115:'(84)A',116:'(8A)4',117:'(4A)8',118:'(84)2',119:'(82)4',
120:'(42)8',121:'(84)3',122:'(83)4',123:'(43)8',124:'(85)A',125:'(8A)5',126:'(5A)8',127:'(85)2',128:'(82)5',129:'(52)8',
130:'(85)3',131:'(83)5',132:'(53)8',133:'(85)4',134:'(84)5',135:'(54)8',136:'(86)A',137:'(8A)6',138:'(6A)8',139:'(86)2',
140:'(82)6',141:'(62)8',142:'(86)3',143:'(83)6',144:'(63)8',145:'(86)4',146:'(84)6',147:'(64)8',148:'(86)5',149:'(85)6',
150:'(65)8',151:'(87)A',152:'(8A)7',153:'(7A)8',154:'(87)2',155:'(82)7',156:'(72)8',157:'(87)3',158:'(83)7',159:'(73)8',
160:'(87)4',161:'(84)7',162:'(74)8',163:'(87)5',164:'(85)7',165:'(75)8',166:'(87)6',167:'(86)7',168:'(76)8',169:'(92)A',
170:'(9A)2',171:'(2A)9',172:'(93)A',173:'(9A)3',174:'(3A)9',175:'(93)2',176:'(92)3',177:'(32)9',178:'(94)A',179:'(9A)4',
180:'(4A)9',181:'(94)2',182:'(92)4',183:'(42)9',184:'(94)3',185:'(93)4',186:'(43)9',187:'(95)A',188:'(9A)5',189:'(5A)9',
190:'(95)2',191:'(92)5',192:'(52)9',193:'(95)3',194:'(93)5',195:'(53)9',196:'(95)4',197:'(94)5',198:'(54)9',199:'(96)A',
200:'(9A)6',201:'(6A)9',202:'(96)2',203:'(92)6',204:'(62)9',205:'(96)3',206:'(93)6',207:'(63)9',208:'(96)4',209:'(94)6',
210:'(64)9',211:'(96)5',212:'(95)6',213:'(65)9',214:'(97)A',215:'(9A)7',216:'(7A)9',217:'(97)2',218:'(92)7',219:'(72)9',
220:'(97)3',221:'(93)7',222:'(73)9',223:'(97)4',224:'(94)7',225:'(74)9',226:'(97)5',227:'(95)7',228:'(75)9',229:'(97)6',
230:'(96)7',231:'(76)9',232:'(98)A',233:'(9A)8',234:'(8A)9',235:'(98)2',236:'(92)8',237:'(82)9',238:'(98)3',239:'(93)8',
240:'(83)9',241:'(98)4',242:'(94)8',243:'(84)9',244:'(98)5',245:'(95)8',246:'(85)9',247:'(98)6',248:'(96)8',249:'(86)9',
250:'(98)7',251:'(97)8',252:'(87)9',253:'(T2)A',254:'(TA)2',255:'(2A)T',256:'(T3)A',257:'(TA)3',258:'(3A)T',259:'(T3)2',
260:'(T2)3',261:'(32)T',262:'(T4)A',263:'(TA)4',264:'(4A)T',265:'(T4)2',266:'(T2)4',267:'(42)T',268:'(T4)3',269:'(T3)4',
270:'(43)T',271:'(T5)A',272:'(TA)5',273:'(5A)T',274:'(T5)2',275:'(T2)5',276:'(52)T',277:'(T5)3',278:'(T3)5',279:'(53)T',
280:'(T5)4',281:'(T4)5',282:'(54)T',283:'(T6)A',284:'(TA)6',285:'(6A)T',286:'(T6)2',287:'(T2)6',288:'(62)T',289:'(T6)3',
290:'(T3)6',291:'(63)T',292:'(T6)4',293:'(T4)6',294:'(64)T',295:'(T6)5',296:'(T5)6',297:'(65)T',298:'(T7)A',299:'(TA)7',
300:'(7A)T',301:'(T7)2',302:'(T2)7',303:'(72)T',304:'(T7)3',305:'(T3)7',306:'(73)T',307:'(T7)4',308:'(T4)7',309:'(74)T',
310:'(T7)5',311:'(T5)7',312:'(75)T',313:'(T7)6',314:'(T6)7',315:'(76)T',316:'(T8)A',317:'(TA)8',318:'(8A)T',319:'(T8)2',
320:'(T2)8',321:'(82)T',322:'(T8)3',323:'(T3)8',324:'(83)T',325:'(T8)4',326:'(T4)8',327:'(84)T',328:'(T8)5',329:'(T5)8',
330:'(85)T',331:'(T8)6',332:'(T6)8',333:'(86)T',334:'(T8)7',335:'(T7)8',336:'(87)T',337:'(T9)A',338:'(TA)9',339:'(9A)T',
340:'(T9)2',341:'(T2)9',342:'(92)T',343:'(T9)3',344:'(T3)9',345:'(93)T',346:'(T9)4',347:'(T4)9',348:'(94)T',349:'(T9)5',
350:'(T5)9',351:'(95)T',352:'(T9)6',353:'(T6)9',354:'(96)T',355:'(T9)7',356:'(T7)9',357:'(97)T',358:'(T9)8',359:'(T8)9',
360:'(98)T',361:'(J2)A',362:'(JA)2',363:'(2A)J',364:'(J3)A',365:'(JA)3',366:'(3A)J',367:'(J3)2',368:'(J2)3',369:'(32)J',
370:'(J4)A',371:'(JA)4',372:'(4A)J',373:'(J4)2',374:'(J2)4',375:'(42)J',376:'(J4)3',377:'(J3)4',378:'(43)J',379:'(J5)A',
380:'(JA)5',381:'(5A)J',382:'(J5)2',383:'(J2)5',384:'(52)J',385:'(J5)3',386:'(J3)5',387:'(53)J',388:'(J5)4',389:'(J4)5',
390:'(54)J',391:'(J6)A',392:'(JA)6',393:'(6A)J',394:'(J6)2',395:'(J2)6',396:'(62)J',397:'(J6)3',398:'(J3)6',399:'(63)J',
400:'(J6)4',401:'(J4)6',402:'(64)J',403:'(J6)5',404:'(J5)6',405:'(65)J',406:'(J7)A',407:'(JA)7',408:'(7A)J',409:'(J7)2',
410:'(J2)7',411:'(72)J',412:'(J7)3',413:'(J3)7',414:'(73)J',415:'(J7)4',416:'(J4)7',417:'(74)J',418:'(J7)5',419:'(J5)7',
420:'(75)J',421:'(J7)6',422:'(J6)7',423:'(76)J',424:'(J8)A',425:'(JA)8',426:'(8A)J',427:'(J8)2',428:'(J2)8',429:'(82)J',
430:'(J8)3',431:'(J3)8',432:'(83)J',433:'(J8)4',434:'(J4)8',435:'(84)J',436:'(J8)5',437:'(J5)8',438:'(85)J',439:'(J8)6',
440:'(J6)8',441:'(86)J',442:'(J8)7',443:'(J7)8',444:'(87)J',445:'(J9)A',446:'(JA)9',447:'(9A)J',448:'(J9)2',449:'(J2)9',
450:'(92)J',451:'(J9)3',452:'(J3)9',453:'(93)J',454:'(J9)4',455:'(J4)9',456:'(94)J',457:'(J9)5',458:'(J5)9',459:'(95)J',
460:'(J9)6',461:'(J6)9',462:'(96)J',463:'(J9)7',464:'(J7)9',465:'(97)J',466:'(J9)8',467:'(J8)9',468:'(98)J',469:'(JT)A',
470:'(JA)T',471:'(TA)J',472:'(JT)2',473:'(J2)T',474:'(T2)J',475:'(JT)3',476:'(J3)T',477:'(T3)J',478:'(JT)4',479:'(J4)T',
480:'(T4)J',481:'(JT)5',482:'(J5)T',483:'(T5)J',484:'(JT)6',485:'(J6)T',486:'(T6)J',487:'(JT)7',488:'(J7)T',489:'(T7)J',
490:'(JT)8',491:'(J8)T',492:'(T8)J',493:'(JT)9',494:'(J9)T',495:'(T9)J',496:'(Q2)A',497:'(QA)2',498:'(2A)Q',499:'(Q3)A',
500:'(QA)3',501:'(3A)Q',502:'(Q3)2',503:'(Q2)3',504:'(32)Q',505:'(Q4)A',506:'(QA)4',507:'(4A)Q',508:'(Q4)2',509:'(Q2)4',
510:'(42)Q',511:'(Q4)3',512:'(Q3)4',513:'(43)Q',514:'(Q5)A',515:'(QA)5',516:'(5A)Q',517:'(Q5)2',518:'(Q2)5',519:'(52)Q',
520:'(Q5)3',521:'(Q3)5',522:'(53)Q',523:'(Q5)4',524:'(Q4)5',525:'(54)Q',526:'(Q6)A',527:'(QA)6',528:'(6A)Q',529:'(Q6)2',
530:'(Q2)6',531:'(62)Q',532:'(Q6)3',533:'(Q3)6',534:'(63)Q',535:'(Q6)4',536:'(Q4)6',537:'(64)Q',538:'(Q6)5',539:'(Q5)6',
540:'(65)Q',541:'(Q7)A',542:'(QA)7',543:'(7A)Q',544:'(Q7)2',545:'(Q2)7',546:'(72)Q',547:'(Q7)3',548:'(Q3)7',549:'(73)Q',
550:'(Q7)4',551:'(Q4)7',552:'(74)Q',553:'(Q7)5',554:'(Q5)7',555:'(75)Q',556:'(Q7)6',557:'(Q6)7',558:'(76)Q',559:'(Q8)A',
560:'(QA)8',561:'(8A)Q',562:'(Q8)2',563:'(Q2)8',564:'(82)Q',565:'(Q8)3',566:'(Q3)8',567:'(83)Q',568:'(Q8)4',569:'(Q4)8',
570:'(84)Q',571:'(Q8)5',572:'(Q5)8',573:'(85)Q',574:'(Q8)6',575:'(Q6)8',576:'(86)Q',577:'(Q8)7',578:'(Q7)8',579:'(87)Q',
580:'(Q9)A',581:'(QA)9',582:'(9A)Q',583:'(Q9)2',584:'(Q2)9',585:'(92)Q',586:'(Q9)3',587:'(Q3)9',588:'(93)Q',589:'(Q9)4',
590:'(Q4)9',591:'(94)Q',592:'(Q9)5',593:'(Q5)9',594:'(95)Q',595:'(Q9)6',596:'(Q6)9',597:'(96)Q',598:'(Q9)7',599:'(Q7)9',
600:'(97)Q',601:'(Q9)8',602:'(Q8)9',603:'(98)Q',604:'(QT)A',605:'(QA)T',606:'(TA)Q',607:'(QT)2',608:'(Q2)T',609:'(T2)Q',
610:'(QT)3',611:'(Q3)T',612:'(T3)Q',613:'(QT)4',614:'(Q4)T',615:'(T4)Q',616:'(QT)5',617:'(Q5)T',618:'(T5)Q',619:'(QT)6',
620:'(Q6)T',621:'(T6)Q',622:'(QT)7',623:'(Q7)T',624:'(T7)Q',625:'(QT)8',626:'(Q8)T',627:'(T8)Q',628:'(QT)9',629:'(Q9)T',
630:'(T9)Q',631:'(QJ)A',632:'(QA)J',633:'(JA)Q',634:'(QJ)2',635:'(Q2)J',636:'(J2)Q',637:'(QJ)3',638:'(Q3)J',639:'(J3)Q',
640:'(QJ)4',641:'(Q4)J',642:'(J4)Q',643:'(QJ)5',644:'(Q5)J',645:'(J5)Q',646:'(QJ)6',647:'(Q6)J',648:'(J6)Q',649:'(QJ)7',
650:'(Q7)J',651:'(J7)Q',652:'(QJ)8',653:'(Q8)J',654:'(J8)Q',655:'(QJ)9',656:'(Q9)J',657:'(J9)Q',658:'(QJ)T',659:'(QT)J',
660:'(JT)Q',661:'(K2)A',662:'(KA)2',663:'(2A)K',664:'(K3)A',665:'(KA)3',666:'(3A)K',667:'(K3)2',668:'(K2)3',669:'(32)K',
670:'(K4)A',671:'(KA)4',672:'(4A)K',673:'(K4)2',674:'(K2)4',675:'(42)K',676:'(K4)3',677:'(K3)4',678:'(43)K',679:'(K5)A',
680:'(KA)5',681:'(5A)K',682:'(K5)2',683:'(K2)5',684:'(52)K',685:'(K5)3',686:'(K3)5',687:'(53)K',688:'(K5)4',689:'(K4)5',
690:'(54)K',691:'(K6)A',692:'(KA)6',693:'(6A)K',694:'(K6)2',695:'(K2)6',696:'(62)K',697:'(K6)3',698:'(K3)6',699:'(63)K',
700:'(K6)4',701:'(K4)6',702:'(64)K',703:'(K6)5',704:'(K5)6',705:'(65)K',706:'(K7)A',707:'(KA)7',708:'(7A)K',709:'(K7)2',
710:'(K2)7',711:'(72)K',712:'(K7)3',713:'(K3)7',714:'(73)K',715:'(K7)4',716:'(K4)7',717:'(74)K',718:'(K7)5',719:'(K5)7',
720:'(75)K',721:'(K7)6',722:'(K6)7',723:'(76)K',724:'(K8)A',725:'(KA)8',726:'(8A)K',727:'(K8)2',728:'(K2)8',729:'(82)K',
730:'(K8)3',731:'(K3)8',732:'(83)K',733:'(K8)4',734:'(K4)8',735:'(84)K',736:'(K8)5',737:'(K5)8',738:'(85)K',739:'(K8)6',
740:'(K6)8',741:'(86)K',742:'(K8)7',743:'(K7)8',744:'(87)K',745:'(K9)A',746:'(KA)9',747:'(9A)K',748:'(K9)2',749:'(K2)9',
750:'(92)K',751:'(K9)3',752:'(K3)9',753:'(93)K',754:'(K9)4',755:'(K4)9',756:'(94)K',757:'(K9)5',758:'(K5)9',759:'(95)K',
760:'(K9)6',761:'(K6)9',762:'(96)K',763:'(K9)7',764:'(K7)9',765:'(97)K',766:'(K9)8',767:'(K8)9',768:'(98)K',769:'(KT)A',
770:'(KA)T',771:'(TA)K',772:'(KT)2',773:'(K2)T',774:'(T2)K',775:'(KT)3',776:'(K3)T',777:'(T3)K',778:'(KT)4',779:'(K4)T',
780:'(T4)K',781:'(KT)5',782:'(K5)T',783:'(T5)K',784:'(KT)6',785:'(K6)T',786:'(T6)K',787:'(KT)7',788:'(K7)T',789:'(T7)K',
790:'(KT)8',791:'(K8)T',792:'(T8)K',793:'(KT)9',794:'(K9)T',795:'(T9)K',796:'(KJ)A',797:'(KA)J',798:'(JA)K',799:'(KJ)2',
800:'(K2)J',801:'(J2)K',802:'(KJ)3',803:'(K3)J',804:'(J3)K',805:'(KJ)4',806:'(K4)J',807:'(J4)K',808:'(KJ)5',809:'(K5)J',
810:'(J5)K',811:'(KJ)6',812:'(K6)J',813:'(J6)K',814:'(KJ)7',815:'(K7)J',816:'(J7)K',817:'(KJ)8',818:'(K8)J',819:'(J8)K',
820:'(KJ)9',821:'(K9)J',822:'(J9)K',823:'(KJ)T',824:'(KT)J',825:'(JT)K',826:'(KQ)A',827:'(KA)Q',828:'(QA)K',829:'(KQ)2',
830:'(K2)Q',831:'(Q2)K',832:'(KQ)3',833:'(K3)Q',834:'(Q3)K',835:'(KQ)4',836:'(K4)Q',837:'(Q4)K',838:'(KQ)5',839:'(K5)Q',
840:'(Q5)K',841:'(KQ)6',842:'(K6)Q',843:'(Q6)K',844:'(KQ)7',845:'(K7)Q',846:'(Q7)K',847:'(KQ)8',848:'(K8)Q',849:'(Q8)K',
850:'(KQ)9',851:'(K9)Q',852:'(Q9)K',853:'(KQ)T',854:'(KT)Q',855:'(QT)K',856:'(KQ)J',857:'(KJ)Q',858:'(QJ)K',859:'(2A)A',
860:'(22)A',861:'(AA)2',862:'(2A)2',863:'(3A)A',864:'(33)A',865:'(AA)3',866:'(3A)3',867:'(32)2',868:'(33)2',869:'(22)3',
870:'(32)3',871:'(4A)A',872:'(44)A',873:'(AA)4',874:'(4A)4',875:'(42)2',876:'(44)2',877:'(22)4',878:'(42)4',879:'(43)3',
880:'(44)3',881:'(33)4',882:'(43)4',883:'(5A)A',884:'(55)A',885:'(AA)5',886:'(5A)5',887:'(52)2',888:'(55)2',889:'(22)5',
890:'(52)5',891:'(53)3',892:'(55)3',893:'(33)5',894:'(53)5',895:'(54)4',896:'(55)4',897:'(44)5',898:'(54)5',899:'(6A)A',
900:'(66)A',901:'(AA)6',902:'(6A)6',903:'(62)2',904:'(66)2',905:'(22)6',906:'(62)6',907:'(63)3',908:'(66)3',909:'(33)6',
910:'(63)6',911:'(64)4',912:'(66)4',913:'(44)6',914:'(64)6',915:'(65)5',916:'(66)5',917:'(55)6',918:'(65)6',919:'(7A)A',
920:'(77)A',921:'(AA)7',922:'(7A)7',923:'(72)2',924:'(77)2',925:'(22)7',926:'(72)7',927:'(73)3',928:'(77)3',929:'(33)7',
930:'(73)7',931:'(74)4',932:'(77)4',933:'(44)7',934:'(74)7',935:'(75)5',936:'(77)5',937:'(55)7',938:'(75)7',939:'(76)6',
940:'(77)6',941:'(66)7',942:'(76)7',943:'(8A)A',944:'(88)A',945:'(AA)8',946:'(8A)8',947:'(82)2',948:'(88)2',949:'(22)8',
950:'(82)8',951:'(83)3',952:'(88)3',953:'(33)8',954:'(83)8',955:'(84)4',956:'(88)4',957:'(44)8',958:'(84)8',959:'(85)5',
960:'(88)5',961:'(55)8',962:'(85)8',963:'(86)6',964:'(88)6',965:'(66)8',966:'(86)8',967:'(87)7',968:'(88)7',969:'(77)8',
970:'(87)8',971:'(9A)A',972:'(99)A',973:'(AA)9',974:'(9A)9',975:'(92)2',976:'(99)2',977:'(22)9',978:'(92)9',979:'(93)3',
980:'(99)3',981:'(33)9',982:'(93)9',983:'(94)4',984:'(99)4',985:'(44)9',986:'(94)9',987:'(95)5',988:'(99)5',989:'(55)9',
990:'(95)9',991:'(96)6',992:'(99)6',993:'(66)9',994:'(96)9',995:'(97)7',996:'(99)7',997:'(77)9',998:'(97)9',999:'(98)8',
1000:'(99)8',1001:'(88)9',1002:'(98)9',1003:'(TA)A',1004:'(TT)A',1005:'(AA)T',1006:'(TA)T',1007:'(T2)2',1008:'(TT)2',1009:'(22)T',
1010:'(T2)T',1011:'(T3)3',1012:'(TT)3',1013:'(33)T',1014:'(T3)T',1015:'(T4)4',1016:'(TT)4',1017:'(44)T',1018:'(T4)T',1019:'(T5)5',
1020:'(TT)5',1021:'(55)T',1022:'(T5)T',1023:'(T6)6',1024:'(TT)6',1025:'(66)T',1026:'(T6)T',1027:'(T7)7',1028:'(TT)7',1029:'(77)T',
1030:'(T7)T',1031:'(T8)8',1032:'(TT)8',1033:'(88)T',1034:'(T8)T',1035:'(T9)9',1036:'(TT)9',1037:'(99)T',1038:'(T9)T',1039:'(JA)A',
1040:'(JJ)A',1041:'(AA)J',1042:'(JA)J',1043:'(J2)2',1044:'(JJ)2',1045:'(22)J',1046:'(J2)J',1047:'(J3)3',1048:'(JJ)3',1049:'(33)J',
1050:'(J3)J',1051:'(J4)4',1052:'(JJ)4',1053:'(44)J',1054:'(J4)J',1055:'(J5)5',1056:'(JJ)5',1057:'(55)J',1058:'(J5)J',1059:'(J6)6',
1060:'(JJ)6',1061:'(66)J',1062:'(J6)J',1063:'(J7)7',1064:'(JJ)7',1065:'(77)J',1066:'(J7)J',1067:'(J8)8',1068:'(JJ)8',1069:'(88)J',
1070:'(J8)J',1071:'(J9)9',1072:'(JJ)9',1073:'(99)J',1074:'(J9)J',1075:'(JT)T',1076:'(JJ)T',1077:'(TT)J',1078:'(JT)J',1079:'(QA)A',
1080:'(QQ)A',1081:'(AA)Q',1082:'(QA)Q',1083:'(Q2)2',1084:'(QQ)2',1085:'(22)Q',1086:'(Q2)Q',1087:'(Q3)3',1088:'(QQ)3',1089:'(33)Q',
1090:'(Q3)Q',1091:'(Q4)4',1092:'(QQ)4',1093:'(44)Q',1094:'(Q4)Q',1095:'(Q5)5',1096:'(QQ)5',1097:'(55)Q',1098:'(Q5)Q',1099:'(Q6)6',
1100:'(QQ)6',1101:'(66)Q',1102:'(Q6)Q',1103:'(Q7)7',1104:'(QQ)7',1105:'(77)Q',1106:'(Q7)Q',1107:'(Q8)8',1108:'(QQ)8',1109:'(88)Q',
1110:'(Q8)Q',1111:'(Q9)9',1112:'(QQ)9',1113:'(99)Q',1114:'(Q9)Q',1115:'(QT)T',1116:'(QQ)T',1117:'(TT)Q',1118:'(QT)Q',1119:'(QJ)J',
1120:'(QQ)J',1121:'(JJ)Q',1122:'(QJ)Q',1123:'(KA)A',1124:'(KK)A',1125:'(AA)K',1126:'(KA)K',1127:'(K2)2',1128:'(KK)2',1129:'(22)K',
1130:'(K2)K',1131:'(K3)3',1132:'(KK)3',1133:'(33)K',1134:'(K3)K',1135:'(K4)4',1136:'(KK)4',1137:'(44)K',1138:'(K4)K',1139:'(K5)5',
1140:'(KK)5',1141:'(55)K',1142:'(K5)K',1143:'(K6)6',1144:'(KK)6',1145:'(66)K',1146:'(K6)K',1147:'(K7)7',1148:'(KK)7',1149:'(77)K',
1150:'(K7)K',1151:'(K8)8',1152:'(KK)8',1153:'(88)K',1154:'(K8)K',1155:'(K9)9',1156:'(KK)9',1157:'(99)K',1158:'(K9)K',1159:'(KT)T',
1160:'(KK)T',1161:'(TT)K',1162:'(KT)K',1163:'(KJ)J',1164:'(KK)J',1165:'(JJ)K',1166:'(KJ)K',1167:'(KQ)Q',1168:'(KK)Q',1169:'(QQ)K',
1170:'(KQ)K',1171:'(AA)A',1172:'(22)2',1173:'(33)3',1174:'(44)4',1175:'(55)5',1176:'(66)6',1177:'(77)7',1178:'(88)8',1179:'(99)9',
1180:'(TT)T',1181:'(JJ)J',1182:'(QQ)Q',1183:'(KK)K',
}
return decodeRazzList[idx]
def encodeRazzStartHand(cards):
"""Take Razz starting hand and return an integer index for storing in db"""
startHand = ""
if card_map_low[cards[0][0]] > card_map_low[cards[1][0]]:
startHand = "(%s%s)%s" %(cards[0][0], cards[1][0], cards[2][0])
else:
startHand = "(%s%s)%s" %(cards[1][0], cards[0][0], cards[2][0])
#print "DEBUG: startHand: %s" % startHand
encodeRazzList = {
'(00)A':-13,'(00)2':-12,'(00)3':-11,'(00)4':-10,'(00)5':-9,'(00)6':-8,'(00)7':-7,'(00)8':-6,'(00)9':-5,'(00)T':-4,
'(00)J':-3,'(00)Q':-2,'(00)K':-1,
'(32)A':1,'(3A)2':2,'(2A)3':3,'(42)A':4,'(4A)2':5,'(2A)4':6,'(43)A':7,'(4A)3':8,'(3A)4':9,
'(43)2':10,'(42)3':11,'(32)4':12,'(52)A':13,'(5A)2':14,'(2A)5':15,'(53)A':16,'(5A)3':17,'(3A)5':18,'(53)2':19,
'(52)3':20,'(32)5':21,'(54)A':22,'(5A)4':23,'(4A)5':24,'(54)2':25,'(52)4':26,'(42)5':27,'(54)3':28,'(53)4':29,
'(43)5':30,'(62)A':31,'(6A)2':32,'(2A)6':33,'(63)A':34,'(6A)3':35,'(3A)6':36,'(63)2':37,'(62)3':38,'(32)6':39,
'(64)A':40,'(6A)4':41,'(4A)6':42,'(64)2':43,'(62)4':44,'(42)6':45,'(64)3':46,'(63)4':47,'(43)6':48,'(65)A':49,
'(6A)5':50,'(5A)6':51,'(65)2':52,'(62)5':53,'(52)6':54,'(65)3':55,'(63)5':56,'(53)6':57,'(65)4':58,'(64)5':59,
'(54)6':60,'(72)A':61,'(7A)2':62,'(2A)7':63,'(73)A':64,'(7A)3':65,'(3A)7':66,'(73)2':67,'(72)3':68,'(32)7':69,
'(74)A':70,'(7A)4':71,'(4A)7':72,'(74)2':73,'(72)4':74,'(42)7':75,'(74)3':76,'(73)4':77,'(43)7':78,'(75)A':79,
'(7A)5':80,'(5A)7':81,'(75)2':82,'(72)5':83,'(52)7':84,'(75)3':85,'(73)5':86,'(53)7':87,'(75)4':88,'(74)5':89,
'(54)7':90,'(76)A':91,'(7A)6':92,'(6A)7':93,'(76)2':94,'(72)6':95,'(62)7':96,'(76)3':97,'(73)6':98,'(63)7':99,
'(76)4':100,'(74)6':101,'(64)7':102,'(76)5':103,'(75)6':104,'(65)7':105,'(82)A':106,'(8A)2':107,'(2A)8':108,'(83)A':109,
'(8A)3':110,'(3A)8':111,'(83)2':112,'(82)3':113,'(32)8':114,'(84)A':115,'(8A)4':116,'(4A)8':117,'(84)2':118,'(82)4':119,
'(42)8':120,'(84)3':121,'(83)4':122,'(43)8':123,'(85)A':124,'(8A)5':125,'(5A)8':126,'(85)2':127,'(82)5':128,'(52)8':129,
'(85)3':130,'(83)5':131,'(53)8':132,'(85)4':133,'(84)5':134,'(54)8':135,'(86)A':136,'(8A)6':137,'(6A)8':138,'(86)2':139,
'(82)6':140,'(62)8':141,'(86)3':142,'(83)6':143,'(63)8':144,'(86)4':145,'(84)6':146,'(64)8':147,'(86)5':148,'(85)6':149,
'(65)8':150,'(87)A':151,'(8A)7':152,'(7A)8':153,'(87)2':154,'(82)7':155,'(72)8':156,'(87)3':157,'(83)7':158,'(73)8':159,
'(87)4':160,'(84)7':161,'(74)8':162,'(87)5':163,'(85)7':164,'(75)8':165,'(87)6':166,'(86)7':167,'(76)8':168,'(92)A':169,
'(9A)2':170,'(2A)9':171,'(93)A':172,'(9A)3':173,'(3A)9':174,'(93)2':175,'(92)3':176,'(32)9':177,'(94)A':178,'(9A)4':179,
'(4A)9':180,'(94)2':181,'(92)4':182,'(42)9':183,'(94)3':184,'(93)4':185,'(43)9':186,'(95)A':187,'(9A)5':188,'(5A)9':189,
'(95)2':190,'(92)5':191,'(52)9':192,'(95)3':193,'(93)5':194,'(53)9':195,'(95)4':196,'(94)5':197,'(54)9':198,'(96)A':199,
'(9A)6':200,'(6A)9':201,'(96)2':202,'(92)6':203,'(62)9':204,'(96)3':205,'(93)6':206,'(63)9':207,'(96)4':208,'(94)6':209,
'(64)9':210,'(96)5':211,'(95)6':212,'(65)9':213,'(97)A':214,'(9A)7':215,'(7A)9':216,'(97)2':217,'(92)7':218,'(72)9':219,
'(97)3':220,'(93)7':221,'(73)9':222,'(97)4':223,'(94)7':224,'(74)9':225,'(97)5':226,'(95)7':227,'(75)9':228,'(97)6':229,
'(96)7':230,'(76)9':231,'(98)A':232,'(9A)8':233,'(8A)9':234,'(98)2':235,'(92)8':236,'(82)9':237,'(98)3':238,'(93)8':239,
'(83)9':240,'(98)4':241,'(94)8':242,'(84)9':243,'(98)5':244,'(95)8':245,'(85)9':246,'(98)6':247,'(96)8':248,'(86)9':249,
'(98)7':250,'(97)8':251,'(87)9':252,'(T2)A':253,'(TA)2':254,'(2A)T':255,'(T3)A':256,'(TA)3':257,'(3A)T':258,'(T3)2':259,
'(T2)3':260,'(32)T':261,'(T4)A':262,'(TA)4':263,'(4A)T':264,'(T4)2':265,'(T2)4':266,'(42)T':267,'(T4)3':268,'(T3)4':269,
'(43)T':270,'(T5)A':271,'(TA)5':272,'(5A)T':273,'(T5)2':274,'(T2)5':275,'(52)T':276,'(T5)3':277,'(T3)5':278,'(53)T':279,
'(T5)4':280,'(T4)5':281,'(54)T':282,'(T6)A':283,'(TA)6':284,'(6A)T':285,'(T6)2':286,'(T2)6':287,'(62)T':288,'(T6)3':289,
'(T3)6':290,'(63)T':291,'(T6)4':292,'(T4)6':293,'(64)T':294,'(T6)5':295,'(T5)6':296,'(65)T':297,'(T7)A':298,'(TA)7':299,
'(7A)T':300,'(T7)2':301,'(T2)7':302,'(72)T':303,'(T7)3':304,'(T3)7':305,'(73)T':306,'(T7)4':307,'(T4)7':308,'(74)T':309,
'(T7)5':310,'(T5)7':311,'(75)T':312,'(T7)6':313,'(T6)7':314,'(76)T':315,'(T8)A':316,'(TA)8':317,'(8A)T':318,'(T8)2':319,
'(T2)8':320,'(82)T':321,'(T8)3':322,'(T3)8':323,'(83)T':324,'(T8)4':325,'(T4)8':326,'(84)T':327,'(T8)5':328,'(T5)8':329,
'(85)T':330,'(T8)6':331,'(T6)8':332,'(86)T':333,'(T8)7':334,'(T7)8':335,'(87)T':336,'(T9)A':337,'(TA)9':338,'(9A)T':339,
'(T9)2':340,'(T2)9':341,'(92)T':342,'(T9)3':343,'(T3)9':344,'(93)T':345,'(T9)4':346,'(T4)9':347,'(94)T':348,'(T9)5':349,
'(T5)9':350,'(95)T':351,'(T9)6':352,'(T6)9':353,'(96)T':354,'(T9)7':355,'(T7)9':356,'(97)T':357,'(T9)8':358,'(T8)9':359,
'(98)T':360,'(J2)A':361,'(JA)2':362,'(2A)J':363,'(J3)A':364,'(JA)3':365,'(3A)J':366,'(J3)2':367,'(J2)3':368,'(32)J':369,
'(J4)A':370,'(JA)4':371,'(4A)J':372,'(J4)2':373,'(J2)4':374,'(42)J':375,'(J4)3':376,'(J3)4':377,'(43)J':378,'(J5)A':379,
'(JA)5':380,'(5A)J':381,'(J5)2':382,'(J2)5':383,'(52)J':384,'(J5)3':385,'(J3)5':386,'(53)J':387,'(J5)4':388,'(J4)5':389,
'(54)J':390,'(J6)A':391,'(JA)6':392,'(6A)J':393,'(J6)2':394,'(J2)6':395,'(62)J':396,'(J6)3':397,'(J3)6':398,'(63)J':399,
'(J6)4':400,'(J4)6':401,'(64)J':402,'(J6)5':403,'(J5)6':404,'(65)J':405,'(J7)A':406,'(JA)7':407,'(7A)J':408,'(J7)2':409,
'(J2)7':410,'(72)J':411,'(J7)3':412,'(J3)7':413,'(73)J':414,'(J7)4':415,'(J4)7':416,'(74)J':417,'(J7)5':418,'(J5)7':419,
'(75)J':420,'(J7)6':421,'(J6)7':422,'(76)J':423,'(J8)A':424,'(JA)8':425,'(8A)J':426,'(J8)2':427,'(J2)8':428,'(82)J':429,
'(J8)3':430,'(J3)8':431,'(83)J':432,'(J8)4':433,'(J4)8':434,'(84)J':435,'(J8)5':436,'(J5)8':437,'(85)J':438,'(J8)6':439,
'(J6)8':440,'(86)J':441,'(J8)7':442,'(J7)8':443,'(87)J':444,'(J9)A':445,'(JA)9':446,'(9A)J':447,'(J9)2':448,'(J2)9':449,
'(92)J':450,'(J9)3':451,'(J3)9':452,'(93)J':453,'(J9)4':454,'(J4)9':455,'(94)J':456,'(J9)5':457,'(J5)9':458,'(95)J':459,
'(J9)6':460,'(J6)9':461,'(96)J':462,'(J9)7':463,'(J7)9':464,'(97)J':465,'(J9)8':466,'(J8)9':467,'(98)J':468,'(JT)A':469,
'(JA)T':470,'(TA)J':471,'(JT)2':472,'(J2)T':473,'(T2)J':474,'(JT)3':475,'(J3)T':476,'(T3)J':477,'(JT)4':478,'(J4)T':479,
'(T4)J':480,'(JT)5':481,'(J5)T':482,'(T5)J':483,'(JT)6':484,'(J6)T':485,'(T6)J':486,'(JT)7':487,'(J7)T':488,'(T7)J':489,
'(JT)8':490,'(J8)T':491,'(T8)J':492,'(JT)9':493,'(J9)T':494,'(T9)J':495,'(Q2)A':496,'(QA)2':497,'(2A)Q':498,'(Q3)A':499,
'(QA)3':500,'(3A)Q':501,'(Q3)2':502,'(Q2)3':503,'(32)Q':504,'(Q4)A':505,'(QA)4':506,'(4A)Q':507,'(Q4)2':508,'(Q2)4':509,
'(42)Q':510,'(Q4)3':511,'(Q3)4':512,'(43)Q':513,'(Q5)A':514,'(QA)5':515,'(5A)Q':516,'(Q5)2':517,'(Q2)5':518,'(52)Q':519,
'(Q5)3':520,'(Q3)5':521,'(53)Q':522,'(Q5)4':523,'(Q4)5':524,'(54)Q':525,'(Q6)A':526,'(QA)6':527,'(6A)Q':528,'(Q6)2':529,
'(Q2)6':530,'(62)Q':531,'(Q6)3':532,'(Q3)6':533,'(63)Q':534,'(Q6)4':535,'(Q4)6':536,'(64)Q':537,'(Q6)5':538,'(Q5)6':539,
'(65)Q':540,'(Q7)A':541,'(QA)7':542,'(7A)Q':543,'(Q7)2':544,'(Q2)7':545,'(72)Q':546,'(Q7)3':547,'(Q3)7':548,'(73)Q':549,
'(Q7)4':550,'(Q4)7':551,'(74)Q':552,'(Q7)5':553,'(Q5)7':554,'(75)Q':555,'(Q7)6':556,'(Q6)7':557,'(76)Q':558,'(Q8)A':559,
'(QA)8':560,'(8A)Q':561,'(Q8)2':562,'(Q2)8':563,'(82)Q':564,'(Q8)3':565,'(Q3)8':566,'(83)Q':567,'(Q8)4':568,'(Q4)8':569,
'(84)Q':570,'(Q8)5':571,'(Q5)8':572,'(85)Q':573,'(Q8)6':574,'(Q6)8':575,'(86)Q':576,'(Q8)7':577,'(Q7)8':578,'(87)Q':579,
'(Q9)A':580,'(QA)9':581,'(9A)Q':582,'(Q9)2':583,'(Q2)9':584,'(92)Q':585,'(Q9)3':586,'(Q3)9':587,'(93)Q':588,'(Q9)4':589,
'(Q4)9':590,'(94)Q':591,'(Q9)5':592,'(Q5)9':593,'(95)Q':594,'(Q9)6':595,'(Q6)9':596,'(96)Q':597,'(Q9)7':598,'(Q7)9':599,
'(97)Q':600,'(Q9)8':601,'(Q8)9':602,'(98)Q':603,'(QT)A':604,'(QA)T':605,'(TA)Q':606,'(QT)2':607,'(Q2)T':608,'(T2)Q':609,
'(QT)3':610,'(Q3)T':611,'(T3)Q':612,'(QT)4':613,'(Q4)T':614,'(T4)Q':615,'(QT)5':616,'(Q5)T':617,'(T5)Q':618,'(QT)6':619,
'(Q6)T':620,'(T6)Q':621,'(QT)7':622,'(Q7)T':623,'(T7)Q':624,'(QT)8':625,'(Q8)T':626,'(T8)Q':627,'(QT)9':628,'(Q9)T':629,
'(T9)Q':630,'(QJ)A':631,'(QA)J':632,'(JA)Q':633,'(QJ)2':634,'(Q2)J':635,'(J2)Q':636,'(QJ)3':637,'(Q3)J':638,'(J3)Q':639,
'(QJ)4':640,'(Q4)J':641,'(J4)Q':642,'(QJ)5':643,'(Q5)J':644,'(J5)Q':645,'(QJ)6':646,'(Q6)J':647,'(J6)Q':648,'(QJ)7':649,
'(Q7)J':650,'(J7)Q':651,'(QJ)8':652,'(Q8)J':653,'(J8)Q':654,'(QJ)9':655,'(Q9)J':656,'(J9)Q':657,'(QJ)T':658,'(QT)J':659,
'(JT)Q':660,'(K2)A':661,'(KA)2':662,'(2A)K':663,'(K3)A':664,'(KA)3':665,'(3A)K':666,'(K3)2':667,'(K2)3':668,'(32)K':669,
'(K4)A':670,'(KA)4':671,'(4A)K':672,'(K4)2':673,'(K2)4':674,'(42)K':675,'(K4)3':676,'(K3)4':677,'(43)K':678,'(K5)A':679,
'(KA)5':680,'(5A)K':681,'(K5)2':682,'(K2)5':683,'(52)K':684,'(K5)3':685,'(K3)5':686,'(53)K':687,'(K5)4':688,'(K4)5':689,
'(54)K':690,'(K6)A':691,'(KA)6':692,'(6A)K':693,'(K6)2':694,'(K2)6':695,'(62)K':696,'(K6)3':697,'(K3)6':698,'(63)K':699,
'(K6)4':700,'(K4)6':701,'(64)K':702,'(K6)5':703,'(K5)6':704,'(65)K':705,'(K7)A':706,'(KA)7':707,'(7A)K':708,'(K7)2':709,
'(K2)7':710,'(72)K':711,'(K7)3':712,'(K3)7':713,'(73)K':714,'(K7)4':715,'(K4)7':716,'(74)K':717,'(K7)5':718,'(K5)7':719,
'(75)K':720,'(K7)6':721,'(K6)7':722,'(76)K':723,'(K8)A':724,'(KA)8':725,'(8A)K':726,'(K8)2':727,'(K2)8':728,'(82)K':729,
'(K8)3':730,'(K3)8':731,'(83)K':732,'(K8)4':733,'(K4)8':734,'(84)K':735,'(K8)5':736,'(K5)8':737,'(85)K':738,'(K8)6':739,
'(K6)8':740,'(86)K':741,'(K8)7':742,'(K7)8':743,'(87)K':744,'(K9)A':745,'(KA)9':746,'(9A)K':747,'(K9)2':748,'(K2)9':749,
'(92)K':750,'(K9)3':751,'(K3)9':752,'(93)K':753,'(K9)4':754,'(K4)9':755,'(94)K':756,'(K9)5':757,'(K5)9':758,'(95)K':759,
'(K9)6':760,'(K6)9':761,'(96)K':762,'(K9)7':763,'(K7)9':764,'(97)K':765,'(K9)8':766,'(K8)9':767,'(98)K':768,'(KT)A':769,
'(KA)T':770,'(TA)K':771,'(KT)2':772,'(K2)T':773,'(T2)K':774,'(KT)3':775,'(K3)T':776,'(T3)K':777,'(KT)4':778,'(K4)T':779,
'(T4)K':780,'(KT)5':781,'(K5)T':782,'(T5)K':783,'(KT)6':784,'(K6)T':785,'(T6)K':786,'(KT)7':787,'(K7)T':788,'(T7)K':789,
'(KT)8':790,'(K8)T':791,'(T8)K':792,'(KT)9':793,'(K9)T':794,'(T9)K':795,'(KJ)A':796,'(KA)J':797,'(JA)K':798,'(KJ)2':799,
'(K2)J':800,'(J2)K':801,'(KJ)3':802,'(K3)J':803,'(J3)K':804,'(KJ)4':805,'(K4)J':806,'(J4)K':807,'(KJ)5':808,'(K5)J':809,
'(J5)K':810,'(KJ)6':811,'(K6)J':812,'(J6)K':813,'(KJ)7':814,'(K7)J':815,'(J7)K':816,'(KJ)8':817,'(K8)J':818,'(J8)K':819,
'(KJ)9':820,'(K9)J':821,'(J9)K':822,'(KJ)T':823,'(KT)J':824,'(JT)K':825,'(KQ)A':826,'(KA)Q':827,'(QA)K':828,'(KQ)2':829,
'(K2)Q':830,'(Q2)K':831,'(KQ)3':832,'(K3)Q':833,'(Q3)K':834,'(KQ)4':835,'(K4)Q':836,'(Q4)K':837,'(KQ)5':838,'(K5)Q':839,
'(Q5)K':840,'(KQ)6':841,'(K6)Q':842,'(Q6)K':843,'(KQ)7':844,'(K7)Q':845,'(Q7)K':846,'(KQ)8':847,'(K8)Q':848,'(Q8)K':849,
'(KQ)9':850,'(K9)Q':851,'(Q9)K':852,'(KQ)T':853,'(KT)Q':854,'(QT)K':855,'(KQ)J':856,'(KJ)Q':857,'(QJ)K':858,'(2A)A':859,
'(22)A':860,'(AA)2':861,'(2A)2':862,'(3A)A':863,'(33)A':864,'(AA)3':865,'(3A)3':866,'(32)2':867,'(33)2':868,'(22)3':869,
'(32)3':870,'(4A)A':871,'(44)A':872,'(AA)4':873,'(4A)4':874,'(42)2':875,'(44)2':876,'(22)4':877,'(42)4':878,'(43)3':879,
'(44)3':880,'(33)4':881,'(43)4':882,'(5A)A':883,'(55)A':884,'(AA)5':885,'(5A)5':886,'(52)2':887,'(55)2':888,'(22)5':889,
'(52)5':890,'(53)3':891,'(55)3':892,'(33)5':893,'(53)5':894,'(54)4':895,'(55)4':896,'(44)5':897,'(54)5':898,'(6A)A':899,
'(66)A':900,'(AA)6':901,'(6A)6':902,'(62)2':903,'(66)2':904,'(22)6':905,'(62)6':906,'(63)3':907,'(66)3':908,'(33)6':909,
'(63)6':910,'(64)4':911,'(66)4':912,'(44)6':913,'(64)6':914,'(65)5':915,'(66)5':916,'(55)6':917,'(65)6':918,'(7A)A':919,
'(77)A':920,'(AA)7':921,'(7A)7':922,'(72)2':923,'(77)2':924,'(22)7':925,'(72)7':926,'(73)3':927,'(77)3':928,'(33)7':929,
'(73)7':930,'(74)4':931,'(77)4':932,'(44)7':933,'(74)7':934,'(75)5':935,'(77)5':936,'(55)7':937,'(75)7':938,'(76)6':939,
'(77)6':940,'(66)7':941,'(76)7':942,'(8A)A':943,'(88)A':944,'(AA)8':945,'(8A)8':946,'(82)2':947,'(88)2':948,'(22)8':949,
'(82)8':950,'(83)3':951,'(88)3':952,'(33)8':953,'(83)8':954,'(84)4':955,'(88)4':956,'(44)8':957,'(84)8':958,'(85)5':959,
'(88)5':960,'(55)8':961,'(85)8':962,'(86)6':963,'(88)6':964,'(66)8':965,'(86)8':966,'(87)7':967,'(88)7':968,'(77)8':969,
'(87)8':970,'(9A)A':971,'(99)A':972,'(AA)9':973,'(9A)9':974,'(92)2':975,'(99)2':976,'(22)9':977,'(92)9':978,'(93)3':979,
'(99)3':980,'(33)9':981,'(93)9':982,'(94)4':983,'(99)4':984,'(44)9':985,'(94)9':986,'(95)5':987,'(99)5':988,'(55)9':989,
'(95)9':990,'(96)6':991,'(99)6':992,'(66)9':993,'(96)9':994,'(97)7':995,'(99)7':996,'(77)9':997,'(97)9':998,'(98)8':999,
'(99)8':1000,'(88)9':1001,'(98)9':1002,'(TA)A':1003,'(TT)A':1004,'(AA)T':1005,'(TA)T':1006,'(T2)2':1007,'(TT)2':1008,'(22)T':1009,
'(T2)T':1010,'(T3)3':1011,'(TT)3':1012,'(33)T':1013,'(T3)T':1014,'(T4)4':1015,'(TT)4':1016,'(44)T':1017,'(T4)T':1018,'(T5)5':1019,
'(TT)5':1020,'(55)T':1021,'(T5)T':1022,'(T6)6':1023,'(TT)6':1024,'(66)T':1025,'(T6)T':1026,'(T7)7':1027,'(TT)7':1028,'(77)T':1029,
'(T7)T':1030,'(T8)8':1031,'(TT)8':1032,'(88)T':1033,'(T8)T':1034,'(T9)9':1035,'(TT)9':1036,'(99)T':1037,'(T9)T':1038,'(JA)A':1039,
'(JJ)A':1040,'(AA)J':1041,'(JA)J':1042,'(J2)2':1043,'(JJ)2':1044,'(22)J':1045,'(J2)J':1046,'(J3)3':1047,'(JJ)3':1048,'(33)J':1049,
'(J3)J':1050,'(J4)4':1051,'(JJ)4':1052,'(44)J':1053,'(J4)J':1054,'(J5)5':1055,'(JJ)5':1056,'(55)J':1057,'(J5)J':1058,'(J6)6':1059,
'(JJ)6':1060,'(66)J':1061,'(J6)J':1062,'(J7)7':1063,'(JJ)7':1064,'(77)J':1065,'(J7)J':1066,'(J8)8':1067,'(JJ)8':1068,'(88)J':1069,
'(J8)J':1070,'(J9)9':1071,'(JJ)9':1072,'(99)J':1073,'(J9)J':1074,'(JT)T':1075,'(JJ)T':1076,'(TT)J':1077,'(JT)J':1078,'(QA)A':1079,
'(QQ)A':1080,'(AA)Q':1081,'(QA)Q':1082,'(Q2)2':1083,'(QQ)2':1084,'(22)Q':1085,'(Q2)Q':1086,'(Q3)3':1087,'(QQ)3':1088,'(33)Q':1089,
'(Q3)Q':1090,'(Q4)4':1091,'(QQ)4':1092,'(44)Q':1093,'(Q4)Q':1094,'(Q5)5':1095,'(QQ)5':1096,'(55)Q':1097,'(Q5)Q':1098,'(Q6)6':1099,
'(QQ)6':1100,'(66)Q':1101,'(Q6)Q':1102,'(Q7)7':1103,'(QQ)7':1104,'(77)Q':1105,'(Q7)Q':1106,'(Q8)8':1107,'(QQ)8':1108,'(88)Q':1109,
'(Q8)Q':1110,'(Q9)9':1111,'(QQ)9':1112,'(99)Q':1113,'(Q9)Q':1114,'(QT)T':1115,'(QQ)T':1116,'(TT)Q':1117,'(QT)Q':1118,'(QJ)J':1119,
'(QQ)J':1120,'(JJ)Q':1121,'(QJ)Q':1122,'(KA)A':1123,'(KK)A':1124,'(AA)K':1125,'(KA)K':1126,'(K2)2':1127,'(KK)2':1128,'(22)K':1129,
'(K2)K':1130,'(K3)3':1131,'(KK)3':1132,'(33)K':1133,'(K3)K':1134,'(K4)4':1135,'(KK)4':1136,'(44)K':1137,'(K4)K':1138,'(K5)5':1139,
'(KK)5':1140,'(55)K':1141,'(K5)K':1142,'(K6)6':1143,'(KK)6':1144,'(66)K':1145,'(K6)K':1146,'(K7)7':1147,'(KK)7':1148,'(77)K':1149,
'(K7)K':1150,'(K8)8':1151,'(KK)8':1152,'(88)K':1153,'(K8)K':1154,'(K9)9':1155,'(KK)9':1156,'(99)K':1157,'(K9)K':1158,'(KT)T':1159,
'(KK)T':1160,'(TT)K':1161,'(KT)K':1162,'(KJ)J':1163,'(KK)J':1164,'(JJ)K':1165,'(KJ)K':1166,'(KQ)Q':1167,'(KK)Q':1168,'(QQ)K':1169,
'(KQ)K':1170,'(AA)A':1171,'(22)2':1172,'(33)3':1173,'(44)4':1174,'(55)5':1175,'(66)6':1176,'(77)7':1177,'(88)8':1178,'(99)9':1179,
'(TT)T':1180,'(JJ)J':1181,'(QQ)Q':1182,'(KK)K':1183,
}
#print "DEBUG: encodeRazzList['%s']: %s" % (startHand, encodeRazzList[startHand])
return encodeRazzList[startHand]
if __name__ == '__main__': if __name__ == '__main__':
print _("fpdb card encoding(same as pokersource)") print _("fpdb card encoding(same as pokersource)")
for i in xrange(1, 14): for i in xrange(1, 14):

21
pyfpdb/Configuration.py Executable file → Normal file
View File

@ -23,8 +23,13 @@ Handles HUD configuration files.
######################################################################## ########################################################################
# Standard Library modules # Standard Library modules
from __future__ import with_statement from __future__ import with_statement
import L10n
_ = L10n.get_translation()
import os import os
import sys import sys
import inspect import inspect
@ -36,18 +41,6 @@ import re
import xml.dom.minidom import xml.dom.minidom
from xml.dom.minidom import Node from xml.dom.minidom import Node
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
import logging, logging.config import logging, logging.config
import ConfigParser import ConfigParser
@ -484,7 +477,7 @@ class Import:
self.callFpdbHud = node.getAttribute("callFpdbHud") self.callFpdbHud = node.getAttribute("callFpdbHud")
self.hhArchiveBase = node.getAttribute("hhArchiveBase") self.hhArchiveBase = node.getAttribute("hhArchiveBase")
self.hhBulkPath = node.getAttribute("hhBulkPath") self.hhBulkPath = node.getAttribute("hhBulkPath")
self.saveActions = string_to_bool(node.getAttribute("saveActions"), default=True) self.saveActions = string_to_bool(node.getAttribute("saveActions"), default=False)
self.fastStoreHudCache = string_to_bool(node.getAttribute("fastStoreHudCache"), default=False) self.fastStoreHudCache = string_to_bool(node.getAttribute("fastStoreHudCache"), default=False)
self.saveStarsHH = string_to_bool(node.getAttribute("saveStarsHH"), default=False) self.saveStarsHH = string_to_bool(node.getAttribute("saveStarsHH"), default=False)
@ -1263,7 +1256,7 @@ class Config:
except: imp['hhBulkPath'] = "" except: imp['hhBulkPath'] = ""
try: imp['saveActions'] = self.imp.saveActions try: imp['saveActions'] = self.imp.saveActions
except: imp['saveActions'] = True except: imp['saveActions'] = False
try: imp['saveStarsHH'] = self.imp.saveStarsHH try: imp['saveStarsHH'] = self.imp.saveStarsHH
except: imp['saveStarsHH'] = False except: imp['saveStarsHH'] = False

View File

@ -20,6 +20,9 @@ Create and manage the database objects.
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import L10n
_ = L10n.get_translation()
######################################################################## ########################################################################
# TODO: - rebuild indexes / vacuum option # TODO: - rebuild indexes / vacuum option
@ -46,18 +49,6 @@ import logging
# logging has been set up in fpdb.py or HUD_main.py, use their settings: # logging has been set up in fpdb.py or HUD_main.py, use their settings:
log = logging.getLogger("db") log = logging.getLogger("db")
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
# FreePokerTools modules # FreePokerTools modules
import SQL import SQL
import Card import Card
@ -1444,6 +1435,7 @@ class Database:
c.execute("INSERT INTO Sites (name,code) VALUES ('Carbon', 'CA')") c.execute("INSERT INTO Sites (name,code) VALUES ('Carbon', 'CA')")
c.execute("INSERT INTO Sites (name,code) VALUES ('PKR', 'PK')") c.execute("INSERT INTO Sites (name,code) VALUES ('PKR', 'PK')")
c.execute("INSERT INTO Sites (name,code) VALUES ('iPoker', 'IP')") c.execute("INSERT INTO Sites (name,code) VALUES ('iPoker', 'IP')")
c.execute("INSERT INTO Sites (name,code) VALUES ('Winamax', 'WM')")
#end def fillDefaultData #end def fillDefaultData
def rebuild_indexes(self, start=None): def rebuild_indexes(self, start=None):
@ -1949,7 +1941,7 @@ class Database:
hilo = "h" hilo = "h"
if game['category'] in ['studhilo', 'omahahilo']: if game['category'] in ['studhilo', 'omahahilo']:
hilo = "s" hilo = "s"
elif game['category'] in ['razz','27_3draw','badugi']: elif game['category'] in ['razz','27_3draw','badugi', '27_1draw']:
hilo = "l" hilo = "l"
tmp = self.insertGameTypes( (siteid, game['currency'], game['type'], game['base'], game['category'], game['limitType'], hilo, tmp = self.insertGameTypes( (siteid, game['currency'], game['type'], game['base'], game['category'], game['limitType'], hilo,
int(Decimal(game['sb'])*100), int(Decimal(game['bb'])*100), int(Decimal(game['sb'])*100), int(Decimal(game['bb'])*100),

View File

@ -18,22 +18,13 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
######################################################################## ########################################################################
import L10n
_ = L10n.get_translation()
import sys import sys
import logging import logging
from HandHistoryConverter import * from HandHistoryConverter import *
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
# Class for converting Everleaf HH format. # Class for converting Everleaf HH format.
class Everleaf(HandHistoryConverter): class Everleaf(HandHistoryConverter):

View File

@ -15,6 +15,9 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt. #In the "official" distribution you can find the license in agpl-3.0.txt.
import L10n
_ = L10n.get_translation()
import threading import threading
import pygtk import pygtk
pygtk.require('2.0') pygtk.require('2.0')
@ -30,18 +33,6 @@ import logging
# logging has been set up in fpdb.py or HUD_main.py, use their settings: # logging has been set up in fpdb.py or HUD_main.py, use their settings:
log = logging.getLogger("filter") log = logging.getLogger("filter")
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
import Configuration import Configuration
import Database import Database
import SQL import SQL

View File

@ -17,6 +17,9 @@
"""pokerstars-specific summary parsing code""" """pokerstars-specific summary parsing code"""
import L10n
_ = L10n.get_translation()
from decimal import Decimal from decimal import Decimal
import datetime import datetime
@ -25,18 +28,6 @@ from HandHistoryConverter import *
import PokerStarsToFpdb import PokerStarsToFpdb
from TourneySummary import * from TourneySummary import *
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
class FullTiltPokerSummary(TourneySummary): class FullTiltPokerSummary(TourneySummary):
limits = { 'No Limit':'nl', 'Pot Limit':'pl', 'Limit':'fl', 'LIMIT':'fl' } limits = { 'No Limit':'nl', 'Pot Limit':'pl', 'Limit':'fl', 'LIMIT':'fl' }
games = { # base, category games = { # base, category

View File

@ -18,17 +18,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
######################################################################## ########################################################################
import locale import L10n
lang=locale.getdefaultlocale()[0][0:2] _ = L10n.get_translation()
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
import logging import logging
from HandHistoryConverter import * from HandHistoryConverter import *

View File

@ -15,6 +15,9 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt. #In the "official" distribution you can find the license in agpl-3.0.txt.
import L10n
_ = L10n.get_translation()
import threading import threading
import subprocess import subprocess
import traceback import traceback
@ -37,18 +40,6 @@ from optparse import OptionParser
import Configuration import Configuration
import string import string
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
class GuiAutoImport (threading.Thread): class GuiAutoImport (threading.Thread):
def __init__(self, settings, config, sql, parent): def __init__(self, settings, config, sql, parent):
self.importtimer = 0 self.importtimer = 0

View File

@ -15,6 +15,9 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt. #In the "official" distribution you can find the license in agpl-3.0.txt.
import L10n
_ = L10n.get_translation()
# Standard Library modules # Standard Library modules
import os import os
import sys import sys
@ -33,17 +36,6 @@ import fpdb_import
import Configuration import Configuration
import Exceptions import Exceptions
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
class GuiBulkImport(): class GuiBulkImport():

View File

@ -15,6 +15,9 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt. #In the "official" distribution you can find the license in agpl-3.0.txt.
import L10n
_ = L10n.get_translation()
import os import os
import sys import sys
import traceback import traceback
@ -31,24 +34,11 @@ import logging
# logging has been set up in fpdb.py or HUD_main.py, use their settings: # logging has been set up in fpdb.py or HUD_main.py, use their settings:
log = logging.getLogger("maintdbs") log = logging.getLogger("maintdbs")
import Exceptions import Exceptions
import Configuration import Configuration
import Database import Database
import SQL import SQL
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
class GuiDatabase: class GuiDatabase:
# columns in liststore: # columns in liststore:

View File

@ -15,6 +15,9 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt. #In the "official" distribution you can find the license in agpl-3.0.txt.
import L10n
_ = L10n.get_translation()
import threading import threading
import pygtk import pygtk
pygtk.require('2.0') pygtk.require('2.0')
@ -26,18 +29,6 @@ from time import *
from datetime import datetime from datetime import datetime
#import pokereval #import pokereval
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
import fpdb_import import fpdb_import
import Database import Database
import Filters import Filters

View File

@ -15,6 +15,9 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt. #In the "official" distribution you can find the license in agpl-3.0.txt.
import L10n
_ = L10n.get_translation()
import threading import threading
import pygtk import pygtk
pygtk.require('2.0') pygtk.require('2.0')
@ -22,18 +25,6 @@ import gtk
from imaplib import IMAP4 from imaplib import IMAP4
from socket import gaierror from socket import gaierror
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
import ImapFetcher import ImapFetcher
class GuiImapFetcher (threading.Thread): class GuiImapFetcher (threading.Thread):

View File

@ -15,6 +15,9 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt. #In the "official" distribution you can find the license in agpl-3.0.txt.
import L10n
_ = L10n.get_translation()
import os import os
import Queue import Queue
@ -30,18 +33,6 @@ import logging
# logging has been set up in fpdb.py or HUD_main.py, use their settings: # logging has been set up in fpdb.py or HUD_main.py, use their settings:
log = logging.getLogger("logview") log = logging.getLogger("logview")
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
MAX_LINES = 100000 # max lines to display in window MAX_LINES = 100000 # max lines to display in window
EST_CHARS_PER_LINE = 150 # used to guesstimate number of lines in log file EST_CHARS_PER_LINE = 150 # used to guesstimate number of lines in log file
LOGFILES = [ [ 'Fpdb Errors', 'fpdb-errors.txt', False ] # label, filename, start value LOGFILES = [ [ 'Fpdb Errors', 'fpdb-errors.txt', False ] # label, filename, start value

View File

@ -15,6 +15,9 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt. #In the "official" distribution you can find the license in agpl-3.0.txt.
import L10n
_ = L10n.get_translation()
import traceback import traceback
import threading import threading
import pygtk import pygtk
@ -24,18 +27,6 @@ import os
import sys import sys
from time import time, strftime from time import time, strftime
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
import Card import Card
import fpdb_import import fpdb_import
import Database import Database
@ -103,34 +94,6 @@ class GuiRingPlayerStats (GuiPlayerStats.GuiPlayerStats):
# columns to display, keys match column name returned by sql, values in tuple are: # columns to display, keys match column name returned by sql, values in tuple are:
# is column displayed(summary then position), column heading, xalignment, formatting, celltype # is column displayed(summary then position), column heading, xalignment, formatting, celltype
self.columns = self.conf.get_gui_cash_stat_params() self.columns = self.conf.get_gui_cash_stat_params()
# self.columns = [ ["game", True, True, "Game", 0.0, "%s", "str"]
# , ["hand", False, False, "Hand", 0.0, "%s", "str"] # initial setting ignored for this line (set in code)
# , ["plposition", False, False, "Posn", 1.0, "%s", "str"] # initial setting ignored for this line (set in code)
# , ["pname", False, False, "Name", 0.0, "%s", "str"] # initial setting ignored for this line (set in code)
# , ["n", True, True, "Hds", 1.0, "%1.0f", "str"]
# , ["avgseats", False, False, "Seats", 1.0, "%3.1f", "str"]
# , ["vpip", True, True, "VPIP", 1.0, "%3.1f", "str"]
# , ["pfr", True, True, "PFR", 1.0, "%3.1f", "str"]
# , ["pf3", True, True, "PF3", 1.0, "%3.1f", "str"]
# , ["aggfac", True, True, "AggFac", 1.0, "%2.2f", "str"]
# , ["aggfrq", True, True, "AggFreq", 1.0, "%3.1f", "str"]
# , ["conbet", True, True, "ContBet", 1.0, "%3.1f", "str"]
# , ["rfi", True, True, "RFI", 1.0, "%3.1f", "str"]
# , ["steals", True, True, "Steals", 1.0, "%3.1f", "str"]
# , ["saw_f", True, True, "Saw_F", 1.0, "%3.1f", "str"]
# , ["sawsd", True, True, "SawSD", 1.0, "%3.1f", "str"]
# , ["wtsdwsf", True, True, "WtSDwsF", 1.0, "%3.1f", "str"]
# , ["wmsd", True, True, "W$SD", 1.0, "%3.1f", "str"]
# , ["flafq", True, True, "FlAFq", 1.0, "%3.1f", "str"]
# , ["tuafq", True, True, "TuAFq", 1.0, "%3.1f", "str"]
# , ["rvafq", True, True, "RvAFq", 1.0, "%3.1f", "str"]
# , ["pofafq", False, False, "PoFAFq", 1.0, "%3.1f", "str"]
# , ["net", True, True, "Net($)", 1.0, "%6.2f", "cash"]
# , ["bbper100", True, True, "bb/100", 1.0, "%4.2f", "str"]
# , ["rake", True, True, "Rake($)", 1.0, "%6.2f", "cash"]
# , ["bb100xr", True, True, "bbxr/100", 1.0, "%4.2f", "str"]
# , ["variance", True, True, "Variance", 1.0, "%5.2f", "str"]
# ]
# Detail filters: This holds the data used in the popup window, extra values are # Detail filters: This holds the data used in the popup window, extra values are
# added at the end of these lists during processing # added at the end of these lists during processing
@ -401,6 +364,7 @@ class GuiRingPlayerStats (GuiPlayerStats.GuiPlayerStats):
tmp = self.sql.query[query] tmp = self.sql.query[query]
tmp = self.refineQuery(tmp, flags, playerids, sitenos, limits, type, seats, groups, dates, games) tmp = self.refineQuery(tmp, flags, playerids, sitenos, limits, type, seats, groups, dates, games)
#print "DEBUG: query: %s" % tmp
self.cursor.execute(tmp) self.cursor.execute(tmp)
result = self.cursor.fetchall() result = self.cursor.fetchall()
colnames = [desc[0].lower() for desc in self.cursor.description] colnames = [desc[0].lower() for desc in self.cursor.description]
@ -476,7 +440,7 @@ class GuiRingPlayerStats (GuiPlayerStats.GuiPlayerStats):
else: else:
if column[colalias] == 'game': if column[colalias] == 'game':
if holecards: if holecards:
value = Card.twoStartCardString( result[sqlrow][hgametypeid_idx] ) value = Card.decodeStartHandValue(result[sqlrow][colnames.index('category')], result[sqlrow][hgametypeid_idx] )
else: else:
minbb = result[sqlrow][colnames.index('minbigblind')] minbb = result[sqlrow][colnames.index('minbigblind')]
maxbb = result[sqlrow][colnames.index('maxbigblind')] maxbb = result[sqlrow][colnames.index('maxbigblind')]

View File

@ -15,6 +15,9 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt. #In the "official" distribution you can find the license in agpl-3.0.txt.
import L10n
_ = L10n.get_translation()
import sys import sys
import threading import threading
import pygtk import pygtk
@ -41,18 +44,6 @@ except ImportError, inst:
print _("""Failed to load numpy and/or matplotlib in Session Viewer""") print _("""Failed to load numpy and/or matplotlib in Session Viewer""")
print _("ImportError: %s") % inst.args print _("ImportError: %s") % inst.args
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
import Card import Card
import fpdb_import import fpdb_import
import Database import Database

View File

@ -15,6 +15,9 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt. #In the "official" distribution you can find the license in agpl-3.0.txt.
import L10n
_ = L10n.get_translation()
import threading import threading
import pygtk import pygtk
pygtk.require('2.0') pygtk.require('2.0')
@ -26,18 +29,6 @@ from time import *
from datetime import datetime from datetime import datetime
#import pokereval #import pokereval
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
import fpdb_import import fpdb_import
import Database import Database
import Filters import Filters

View File

@ -15,6 +15,9 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt. #In the "official" distribution you can find the license in agpl-3.0.txt.
import L10n
_ = L10n.get_translation()
#import traceback #import traceback
import threading import threading
import pygtk import pygtk
@ -24,18 +27,6 @@ import gtk
#import sys #import sys
from time import time, strftime from time import time, strftime
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
#import Card #import Card
#import fpdb_import #import fpdb_import
#import Database #import Database

View File

@ -15,23 +15,14 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt. #In the "official" distribution you can find the license in agpl-3.0.txt.
import L10n
_ = L10n.get_translation()
import threading import threading
import pygtk import pygtk
pygtk.require('2.0') pygtk.require('2.0')
import gtk import gtk
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
class GuiTourneyViewer (threading.Thread): class GuiTourneyViewer (threading.Thread):
def __init__(self, config, db, sql, mainwin, debug=True): def __init__(self, config, db, sql, mainwin, debug=True):
self.db = db self.db = db

View File

@ -2,7 +2,7 @@
<FreePokerToolsConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FreePokerToolsConfig.xsd"> <FreePokerToolsConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FreePokerToolsConfig.xsd">
<import callFpdbHud = "True" interval = "10" fastStoreHudCache="False" hhArchiveBase="~/.fpdb/HandHistories/" saveActions="True"></import> <import callFpdbHud = "True" interval = "10" fastStoreHudCache="False" hhArchiveBase="~/.fpdb/HandHistories/" saveActions="False"></import>
<!-- These values determine what stats are displayed in the HUD <!-- These values determine what stats are displayed in the HUD

View File

@ -12,7 +12,7 @@
config_difficulty="expert" config_difficulty="expert"
/> />
<import callFpdbHud = "True" interval = "10" fastStoreHudCache="False" hhArchiveBase="~/.fpdb/HandHistories/" saveActions="True"></import> <import callFpdbHud = "True" interval = "10" fastStoreHudCache="False" hhArchiveBase="~/.fpdb/HandHistories/" saveActions="False"></import>
<gui_cash_stats> <gui_cash_stats>
<col col_name="game" disp_all="True" disp_posn="True" col_title="Game" xalignment="0.0" field_format="%s" field_type="str" /> <col col_name="game" disp_all="True" disp_posn="True" col_title="Game" xalignment="0.0" field_format="%s" field_type="str" />
@ -550,6 +550,43 @@ Left-Drag to Move"
<location seat="9" x="70" y="53"> </location> <location seat="9" x="70" y="53"> </location>
</layout> </layout>
</site> </site>
<site HH_path="C:/Program Files/Winamax/HandHistory/YOUR SCREEN NAME HERE/" converter="WinamaxToFpdb" decoder="everleaf_decode_table" enabled="False" screen_name="YOUR SCREEN NAME HERE" site_name="Winamax" site_path="C:/Program Files/Winamax/" supported_games="holdem" table_finder="Winamax.exe">
<layout fav_seat="0" height="547" max="8" width="794">
<location seat="1" x="640" y="64"> </location>
<location seat="2" x="650" y="230"> </location>
<location seat="3" x="650" y="385"> </location>
<location seat="4" x="588" y="425"> </location>
<location seat="5" x="92" y="425"> </location>
<location seat="6" x="0" y="373"> </location>
<location seat="7" x="0" y="223"> </location>
<location seat="8" x="25" y="50"> </location>
</layout>
<layout fav_seat="0" height="547" max="6" width="794">
<location seat="1" x="640" y="58"> </location>
<location seat="2" x="654" y="288"> </location>
<location seat="3" x="615" y="424"> </location>
<location seat="4" x="70" y="421"> </location>
<location seat="5" x="0" y="280"> </location>
<location seat="6" x="70" y="58"> </location>
</layout>
<layout fav_seat="0" height="547" max="2" width="794">
<location seat="1" x="651" y="288"> </location>
<location seat="2" x="10" y="288"> </location>
</layout>
<layout fav_seat="0" height="547" max="9" width="794">
<location seat="1" x="634" y="38"> </location>
<location seat="2" x="667" y="184"> </location>
<location seat="3" x="667" y="321"> </location>
<location seat="4" x="667" y="445"> </location>
<location seat="5" x="337" y="459"> </location>
<location seat="6" x="0" y="400"> </location>
<location seat="7" x="0" y="322"> </location>
<location seat="8" x="0" y="181"> </location>
<location seat="9" x="70" y="53"> </location>
</layout>
</site>
</supported_sites> </supported_sites>
<supported_games> <supported_games>
@ -609,6 +646,43 @@ Left-Drag to Move"
<stat click="tog_decorate" col="0" popup="default" row="2" stat_name="saw_f" tip="tip1"> </stat> <stat click="tog_decorate" col="0" popup="default" row="2" stat_name="saw_f" tip="tip1"> </stat>
<stat click="tog_decorate" col="1" popup="default" row="2" stat_name="ffreq1" tip="tip1"> </stat> <stat click="tog_decorate" col="1" popup="default" row="2" stat_name="ffreq1" tip="tip1"> </stat>
</game> </game>
<game cols="3" db="fpdb" game_name="27_3draw" rows="2">
<stat click="tog_decorate" col="0" popup="default" row="0" stat_name="vpip" tip="tip1"> </stat>
<stat click="tog_decorate" col="1" popup="default" row="0" stat_name="pfr" tip="tip1"> </stat>
<stat click="tog_decorate" col="2" popup="default" row="0" stat_name="ffreq1" tip="tip1"> </stat>
<stat click="tog_decorate" col="0" popup="default" row="1" stat_name="n" tip="tip1"> </stat>
<stat click="tog_decorate" col="1" popup="default" row="1" stat_name="wtsd" tip="tip1"> </stat>
<stat click="tog_decorate" col="2" popup="default" row="1" stat_name="wmsd" tip="tip1"> </stat>
</game>
<game cols="3" db="fpdb" game_name="27_1draw" rows="2">
<stat click="tog_decorate" col="0" popup="default" row="0" stat_name="vpip" tip="tip1"> </stat>
<stat click="tog_decorate" col="1" popup="default" row="0" stat_name="pfr" tip="tip1"> </stat>
<stat click="tog_decorate" col="2" popup="default" row="0" stat_name="ffreq1" tip="tip1"> </stat>
<stat click="tog_decorate" col="0" popup="default" row="1" stat_name="n" tip="tip1"> </stat>
<stat click="tog_decorate" col="1" popup="default" row="1" stat_name="wtsd" tip="tip1"> </stat>
<stat click="tog_decorate" col="2" popup="default" row="1" stat_name="wmsd" tip="tip1"> </stat>
</game>
<game cols="3" db="fpdb" game_name="badugi" rows="2">
<stat click="tog_decorate" col="0" popup="default" row="0" stat_name="vpip" tip="tip1"> </stat>
<stat click="tog_decorate" col="1" popup="default" row="0" stat_name="pfr" tip="tip1"> </stat>
<stat click="tog_decorate" col="2" popup="default" row="0" stat_name="ffreq1" tip="tip1"> </stat>
<stat click="tog_decorate" col="0" popup="default" row="1" stat_name="n" tip="tip1"> </stat>
<stat click="tog_decorate" col="1" popup="default" row="1" stat_name="wtsd" tip="tip1"> </stat>
<stat click="tog_decorate" col="2" popup="default" row="1" stat_name="wmsd" tip="tip1"> </stat>
</game>
<game cols="3" db="fpdb" game_name="fivedraw" rows="2">
<stat click="tog_decorate" col="0" popup="default" row="0" stat_name="vpip" tip="tip1"> </stat>
<stat click="tog_decorate" col="1" popup="default" row="0" stat_name="pfr" tip="tip1"> </stat>
<stat click="tog_decorate" col="2" popup="default" row="0" stat_name="ffreq1" tip="tip1"> </stat>
<stat click="tog_decorate" col="0" popup="default" row="1" stat_name="n" tip="tip1"> </stat>
<stat click="tog_decorate" col="1" popup="default" row="1" stat_name="wtsd" tip="tip1"> </stat>
<stat click="tog_decorate" col="2" popup="default" row="1" stat_name="wmsd" tip="tip1"> </stat>
</game>
</supported_games> </supported_games>
<popup_windows> <popup_windows>
@ -703,6 +777,7 @@ Left-Drag to Move"
<hhc site="OnGame" converter="OnGameToFpdb"/> <hhc site="OnGame" converter="OnGameToFpdb"/>
<hhc site="PKR" converter="PkrToFpdb"/> <hhc site="PKR" converter="PkrToFpdb"/>
<hhc site="iPoker" converter="iPokerToFpdb"/> <hhc site="iPoker" converter="iPokerToFpdb"/>
<hhc site="Winamax" converter="WinamaxToFpdb"/>
</hhcs> </hhcs>
<raw_hands save="none" compression="none"/> <raw_hands save="none" compression="none"/>

View File

@ -109,6 +109,11 @@ class HUD_main(object):
# a main window # a main window
self.main_window = gtk.Window() self.main_window = gtk.Window()
self.main_window.connect("client_moved", self.client_moved)
self.main_window.connect("client_resized", self.client_resized)
self.main_window.connect("client_destroyed", self.client_destroyed)
self.main_window.connect("game_changed", self.game_changed)
self.main_window.connect("table_changed", self.table_changed)
self.main_window.connect("destroy", self.destroy) self.main_window.connect("destroy", self.destroy)
self.vb = gtk.VBox() self.vb = gtk.VBox()
self.label = gtk.Label(_('Closing this window will exit from the HUD.')) self.label = gtk.Label(_('Closing this window will exit from the HUD.'))
@ -116,11 +121,27 @@ class HUD_main(object):
self.main_window.add(self.vb) self.main_window.add(self.vb)
self.main_window.set_title(_("HUD Main Window")) self.main_window.set_title(_("HUD Main Window"))
self.main_window.show_all() self.main_window.show_all()
gobject.timeout_add(100, self.check_tables)
except: except:
log.error( "*** Exception in HUD_main.init() *** " ) log.error( "*** Exception in HUD_main.init() *** " )
for e in traceback.format_tb(sys.exc_info()[2]): for e in traceback.format_tb(sys.exc_info()[2]):
log.error(e) log.error(e)
def client_moved(self, widget, hud):
print hud, hud.table.name, "moved", hud.table.x, hud.table.y
def client_resized(self, widget, hud):
print "Client resized"
def client_destroyed(self, widget, hud): # call back for terminating the main eventloop
self.kill_hud(None, hud.table.name)
def game_changed(self, widget, hud):
print "Game Changed."
def table_changed(self, widget, hud):
print "Table Changed."
self.kill_hud(None, hud.table.name)
def destroy(self, *args): # call back for terminating the main eventloop def destroy(self, *args): # call back for terminating the main eventloop
log.info(_("Terminating normally.")) log.info(_("Terminating normally."))
@ -135,6 +156,11 @@ class HUD_main(object):
del(self.hud_dict[table]) del(self.hud_dict[table])
self.main_window.resize(1,1) self.main_window.resize(1,1)
def check_tables(self):
for hud in self.hud_dict.keys():
self.hud_dict[hud].table.check_table(self.hud_dict[hud])
return True
def create_HUD(self, new_hand_id, table, table_name, max, poker_game, type, stat_dict, cards): def create_HUD(self, new_hand_id, table, table_name, max, poker_game, type, stat_dict, cards):
"""type is "ring" or "tour" used to set hud_params""" """type is "ring" or "tour" used to set hud_params"""
@ -269,6 +295,7 @@ class HUD_main(object):
stat_dict = self.db_connection.get_stats_from_hand(new_hand_id, type, self.hud_dict[temp_key].hud_params stat_dict = self.db_connection.get_stats_from_hand(new_hand_id, type, self.hud_dict[temp_key].hud_params
,self.hero_ids[site_id], num_seats) ,self.hero_ids[site_id], num_seats)
t3 = time.time() t3 = time.time()
try: try:
self.hud_dict[temp_key].stat_dict = stat_dict self.hud_dict[temp_key].stat_dict = stat_dict
except KeyError: # HUD instance has been killed off, key is stale except KeyError: # HUD instance has been killed off, key is stale
@ -299,10 +326,7 @@ class HUD_main(object):
cards['common'] = comm_cards['common'] cards['common'] = comm_cards['common']
table_kwargs = dict(table_name = table_name, tournament = tour_number, table_number = tab_number) table_kwargs = dict(table_name = table_name, tournament = tour_number, table_number = tab_number)
search_string = getTableTitleRe(self.config, site_name, type, **table_kwargs) tablewindow = Tables.Table(self.config, site_name, **table_kwargs)
# print "getTableTitleRe ", self.config, site_name, type, "=", search_string
tablewindow = Tables.Table(search_string, **table_kwargs)
if tablewindow is None: if tablewindow is None:
# If no client window is found on the screen, complain and continue # If no client window is found on the screen, complain and continue
if type == "tour": if type == "tour":
@ -321,7 +345,8 @@ class HUD_main(object):
log.info(_("HUD_main.read_stdin: hand read in %4.3f seconds (%4.3f,%4.3f,%4.3f,%4.3f,%4.3f,%4.3f)") log.info(_("HUD_main.read_stdin: hand read in %4.3f seconds (%4.3f,%4.3f,%4.3f,%4.3f,%4.3f,%4.3f)")
% (t6-t0,t1-t0,t2-t0,t3-t0,t4-t0,t5-t0,t6-t0)) % (t6-t0,t1-t0,t2-t0,t3-t0,t4-t0,t5-t0,t6-t0))
self.db_connection.connection.rollback() self.db_connection.connection.rollback()
if type == "tour":
tablewindow.check_table_no()
if __name__== "__main__": if __name__== "__main__":
# start the HUD_main object # start the HUD_main object

View File

@ -15,6 +15,9 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt. #In the "official" distribution you can find the license in agpl-3.0.txt.
import L10n
_ = L10n.get_translation()
# TODO: get writehand() encoding correct # TODO: get writehand() encoding correct
import re import re
@ -28,18 +31,6 @@ import time,datetime
from copy import deepcopy from copy import deepcopy
import pprint import pprint
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
import logging import logging
# logging has been set up in fpdb.py or HUD_main.py, use their settings: # logging has been set up in fpdb.py or HUD_main.py, use their settings:
log = logging.getLogger("parser") log = logging.getLogger("parser")

View File

@ -15,6 +15,9 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt. #In the "official" distribution you can find the license in agpl-3.0.txt.
import L10n
_ = L10n.get_translation()
import re import re
import sys import sys
import traceback import traceback
@ -41,18 +44,6 @@ import Hand
from Exceptions import FpdbParseError from Exceptions import FpdbParseError
import Configuration import Configuration
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
import pygtk import pygtk
import gtk import gtk
@ -670,12 +661,23 @@ or None if we fail to get the info """
else: else:
return table_name return table_name
@staticmethod
def getTableNoRe(tournament):
"Returns string to search window title for tournament table no."
# Full Tilt: $30 + $3 Tournament (181398949), Table 1 - 600/1200 Ante 100 - Limit Razz
# PokerStars: WCOOP 2nd Chance 02: $1,050 NLHE - Tournament 307521826 Table 1 - Blinds $30/$60
return "%s.+Table (\d+)" % (tournament, )
def getTableTitleRe(config, sitename, *args, **kwargs): def getTableTitleRe(config, sitename, *args, **kwargs):
"Returns string to search in windows titles for current site" "Returns string to search in windows titles for current site"
return getSiteHhc(config, sitename).getTableTitleRe(*args, **kwargs) return getSiteHhc(config, sitename).getTableTitleRe(*args, **kwargs)
def getTableNoRe(config, sitename, *args, **kwargs):
"Returns string to search window titles for tournament table no."
return getSiteHhc(config, sitename).getTableNoRe(*args, **kwargs)
def getSiteHhc(config, sitename): def getSiteHhc(config, sitename):
"Returns HHC class for current site" "Returns HHC class for current site"
hhcName = config.supported_sites[sitename].converter hhcName = config.supported_sites[sitename].converter

View File

@ -22,6 +22,10 @@ Create and manage the hud overlays.
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
######################################################################## ########################################################################
import L10n
_ = L10n.get_translation()
# Standard Library modules # Standard Library modules
import os import os
import sys import sys
@ -42,18 +46,6 @@ if os.name == 'nt':
import win32con import win32con
import win32api import win32api
import locale
lang = locale.getdefaultlocale()[0][0:2]
if lang == "en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
# FreePokerTools modules # FreePokerTools modules
import Configuration import Configuration
import Stats import Stats

View File

@ -19,6 +19,9 @@
#see http://docs.python.org/library/imaplib.html for the python interface #see http://docs.python.org/library/imaplib.html for the python interface
#see http://tools.ietf.org/html/rfc2060#section-6.4.4 for IMAP4 search criteria #see http://tools.ietf.org/html/rfc2060#section-6.4.4 for IMAP4 search criteria
import L10n
_ = L10n.get_translation()
from imaplib import IMAP4, IMAP4_SSL from imaplib import IMAP4, IMAP4_SSL
import sys import sys
import codecs import codecs
@ -33,18 +36,6 @@ import PokerStarsSummary
import FullTiltPokerSummary import FullTiltPokerSummary
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
def splitPokerStarsSummaries(summaryText): #TODO: this needs to go to PSS.py def splitPokerStarsSummaries(summaryText): #TODO: this needs to go to PSS.py
re_SplitTourneys = PokerStarsSummary.PokerStarsSummary.re_SplitTourneys re_SplitTourneys = PokerStarsSummary.PokerStarsSummary.re_SplitTourneys
splitSummaries = re.split(re_SplitTourneys, summaryText) splitSummaries = re.split(re_SplitTourneys, summaryText)

37
pyfpdb/L10n.py Normal file
View File

@ -0,0 +1,37 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#Copyright 2010 Steffen Schaumburg
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU Affero General Public License as published by
#the Free Software Foundation, version 3 of the License.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU Affero General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt.
import locale
def pass_through(to_translate): return to_translate
(lang, charset) = locale.getdefaultlocale()
if lang==None or lang[:2]=="en":
translation=pass_through
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
translation=_
except IOError:
translation=pass_through
#def translate(to_translate):
# return _(to_translate)
def get_translation():
return translation

View File

@ -18,6 +18,9 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
######################################################################## ########################################################################
import L10n
_ = L10n.get_translation()
import sys import sys
import exceptions import exceptions
@ -30,18 +33,6 @@ import Configuration
from HandHistoryConverter import * from HandHistoryConverter import *
from decimal import Decimal from decimal import Decimal
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
# OnGame HH Format # OnGame HH Format
class OnGame(HandHistoryConverter): class OnGame(HandHistoryConverter):

View File

@ -15,22 +15,13 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt. #In the "official" distribution you can find the license in agpl-3.0.txt.
import L10n
_ = L10n.get_translation()
import sys import sys
from optparse import OptionParser from optparse import OptionParser
# http://docs.python.org/library/optparse.html # http://docs.python.org/library/optparse.html
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
def fpdb_options(): def fpdb_options():
"""Process command line options for fpdb and HUD_main.""" """Process command line options for fpdb and HUD_main."""

View File

@ -18,21 +18,12 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
######################################################################## ########################################################################
import L10n
_ = L10n.get_translation()
import sys import sys
from collections import defaultdict from collections import defaultdict
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
from Exceptions import FpdbParseError from Exceptions import FpdbParseError
from HandHistoryConverter import * from HandHistoryConverter import *

View File

@ -18,22 +18,12 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
######################################################################## ########################################################################
import L10n
_ = L10n.get_translation()
import sys import sys
from HandHistoryConverter import * from HandHistoryConverter import *
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
class Pkr(HandHistoryConverter): class Pkr(HandHistoryConverter):

View File

@ -17,6 +17,9 @@
"""pokerstars-specific summary parsing code""" """pokerstars-specific summary parsing code"""
import L10n
_ = L10n.get_translation()
from decimal import Decimal from decimal import Decimal
import datetime import datetime
@ -25,18 +28,6 @@ from HandHistoryConverter import *
import PokerStarsToFpdb import PokerStarsToFpdb
from TourneySummary import * from TourneySummary import *
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
class PokerStarsSummary(TourneySummary): class PokerStarsSummary(TourneySummary):
limits = { 'No Limit':'nl', 'Pot Limit':'pl', 'Limit':'fl', 'LIMIT':'fl' } limits = { 'No Limit':'nl', 'Pot Limit':'pl', 'Limit':'fl', 'LIMIT':'fl' }
games = { # base, category games = { # base, category

View File

@ -18,24 +18,15 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
######################################################################## ########################################################################
import L10n
_ = L10n.get_translation()
# TODO: straighten out discards for draw games # TODO: straighten out discards for draw games
import sys import sys
from HandHistoryConverter import * from HandHistoryConverter import *
from decimal import Decimal from decimal import Decimal
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
# PokerStars HH Format # PokerStars HH Format
class PokerStars(HandHistoryConverter): class PokerStars(HandHistoryConverter):

View File

@ -0,0 +1,158 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Generate Razz startCards encoding and decoding for Card.py"""
import re
re_space = re.compile("([\(\)AKQJT0-9]+)\s+", re.MULTILINE)
razzlist = """(32)A (3A)2 (2A)3 (42)A (4A)2 (2A)4 (43)A (4A)3 (3A)4 (43)2
(42)3 (32)4 (52)A (5A)2 (2A)5 (53)A (5A)3 (3A)5 (53)2 (52)3
(32)5 (54)A (5A)4 (4A)5 (54)2 (52)4 (42)5 (54)3 (53)4 (43)5
(62)A (6A)2 (2A)6 (63)A (6A)3 (3A)6 (63)2 (62)3 (32)6 (64)A
(6A)4 (4A)6 (64)2 (62)4 (42)6 (64)3 (63)4 (43)6 (65)A (6A)5
(5A)6 (65)2 (62)5 (52)6 (65)3 (63)5 (53)6 (65)4 (64)5 (54)6
(72)A (7A)2 (2A)7 (73)A (7A)3 (3A)7 (73)2 (72)3 (32)7 (74)A
(7A)4 (4A)7 (74)2 (72)4 (42)7 (74)3 (73)4 (43)7 (75)A (7A)5
(5A)7 (75)2 (72)5 (52)7 (75)3 (73)5 (53)7 (75)4 (74)5 (54)7
(76)A (7A)6 (6A)7 (76)2 (72)6 (62)7 (76)3 (73)6 (63)7 (76)4
(74)6 (64)7 (76)5 (75)6 (65)7 (82)A (8A)2 (2A)8 (83)A (8A)3
(3A)8 (83)2 (82)3 (32)8 (84)A (8A)4 (4A)8 (84)2 (82)4 (42)8
(84)3 (83)4 (43)8 (85)A (8A)5 (5A)8 (85)2 (82)5 (52)8 (85)3
(83)5 (53)8 (85)4 (84)5 (54)8 (86)A (8A)6 (6A)8 (86)2 (82)6
(62)8 (86)3 (83)6 (63)8 (86)4 (84)6 (64)8 (86)5 (85)6 (65)8
(87)A (8A)7 (7A)8 (87)2 (82)7 (72)8 (87)3 (83)7 (73)8 (87)4
(84)7 (74)8 (87)5 (85)7 (75)8 (87)6 (86)7 (76)8 (92)A (9A)2
(2A)9 (93)A (9A)3 (3A)9 (93)2 (92)3 (32)9 (94)A (9A)4 (4A)9
(94)2 (92)4 (42)9 (94)3 (93)4 (43)9 (95)A (9A)5 (5A)9 (95)2
(92)5 (52)9 (95)3 (93)5 (53)9 (95)4 (94)5 (54)9 (96)A (9A)6
(6A)9 (96)2 (92)6 (62)9 (96)3 (93)6 (63)9 (96)4 (94)6 (64)9
(96)5 (95)6 (65)9 (97)A (9A)7 (7A)9 (97)2 (92)7 (72)9 (97)3
(93)7 (73)9 (97)4 (94)7 (74)9 (97)5 (95)7 (75)9 (97)6 (96)7
(76)9 (98)A (9A)8 (8A)9 (98)2 (92)8 (82)9 (98)3 (93)8 (83)9
(98)4 (94)8 (84)9 (98)5 (95)8 (85)9 (98)6 (96)8 (86)9 (98)7
(97)8 (87)9 (T2)A (TA)2 (2A)T (T3)A (TA)3 (3A)T (T3)2 (T2)3
(32)T (T4)A (TA)4 (4A)T (T4)2 (T2)4 (42)T (T4)3 (T3)4 (43)T
(T5)A (TA)5 (5A)T (T5)2 (T2)5 (52)T (T5)3 (T3)5 (53)T (T5)4
(T4)5 (54)T (T6)A (TA)6 (6A)T (T6)2 (T2)6 (62)T (T6)3 (T3)6
(63)T (T6)4 (T4)6 (64)T (T6)5 (T5)6 (65)T (T7)A (TA)7 (7A)T
(T7)2 (T2)7 (72)T (T7)3 (T3)7 (73)T (T7)4 (T4)7 (74)T (T7)5
(T5)7 (75)T (T7)6 (T6)7 (76)T (T8)A (TA)8 (8A)T (T8)2 (T2)8
(82)T (T8)3 (T3)8 (83)T (T8)4 (T4)8 (84)T (T8)5 (T5)8 (85)T
(T8)6 (T6)8 (86)T (T8)7 (T7)8 (87)T (T9)A (TA)9 (9A)T (T9)2
(T2)9 (92)T (T9)3 (T3)9 (93)T (T9)4 (T4)9 (94)T (T9)5 (T5)9
(95)T (T9)6 (T6)9 (96)T (T9)7 (T7)9 (97)T (T9)8 (T8)9 (98)T
(J2)A (JA)2 (2A)J (J3)A (JA)3 (3A)J (J3)2 (J2)3 (32)J (J4)A
(JA)4 (4A)J (J4)2 (J2)4 (42)J (J4)3 (J3)4 (43)J (J5)A (JA)5
(5A)J (J5)2 (J2)5 (52)J (J5)3 (J3)5 (53)J (J5)4 (J4)5 (54)J
(J6)A (JA)6 (6A)J (J6)2 (J2)6 (62)J (J6)3 (J3)6 (63)J (J6)4
(J4)6 (64)J (J6)5 (J5)6 (65)J (J7)A (JA)7 (7A)J (J7)2 (J2)7
(72)J (J7)3 (J3)7 (73)J (J7)4 (J4)7 (74)J (J7)5 (J5)7 (75)J
(J7)6 (J6)7 (76)J (J8)A (JA)8 (8A)J (J8)2 (J2)8 (82)J (J8)3
(J3)8 (83)J (J8)4 (J4)8 (84)J (J8)5 (J5)8 (85)J (J8)6 (J6)8
(86)J (J8)7 (J7)8 (87)J (J9)A (JA)9 (9A)J (J9)2 (J2)9 (92)J
(J9)3 (J3)9 (93)J (J9)4 (J4)9 (94)J (J9)5 (J5)9 (95)J (J9)6
(J6)9 (96)J (J9)7 (J7)9 (97)J (J9)8 (J8)9 (98)J (JT)A (JA)T
(TA)J (JT)2 (J2)T (T2)J (JT)3 (J3)T (T3)J (JT)4 (J4)T (T4)J
(JT)5 (J5)T (T5)J (JT)6 (J6)T (T6)J (JT)7 (J7)T (T7)J (JT)8
(J8)T (T8)J (JT)9 (J9)T (T9)J (Q2)A (QA)2 (2A)Q (Q3)A (QA)3
(3A)Q (Q3)2 (Q2)3 (32)Q (Q4)A (QA)4 (4A)Q (Q4)2 (Q2)4 (42)Q
(Q4)3 (Q3)4 (43)Q (Q5)A (QA)5 (5A)Q (Q5)2 (Q2)5 (52)Q (Q5)3
(Q3)5 (53)Q (Q5)4 (Q4)5 (54)Q (Q6)A (QA)6 (6A)Q (Q6)2 (Q2)6
(62)Q (Q6)3 (Q3)6 (63)Q (Q6)4 (Q4)6 (64)Q (Q6)5 (Q5)6 (65)Q
(Q7)A (QA)7 (7A)Q (Q7)2 (Q2)7 (72)Q (Q7)3 (Q3)7 (73)Q (Q7)4
(Q4)7 (74)Q (Q7)5 (Q5)7 (75)Q (Q7)6 (Q6)7 (76)Q (Q8)A (QA)8
(8A)Q (Q8)2 (Q2)8 (82)Q (Q8)3 (Q3)8 (83)Q (Q8)4 (Q4)8 (84)Q
(Q8)5 (Q5)8 (85)Q (Q8)6 (Q6)8 (86)Q (Q8)7 (Q7)8 (87)Q (Q9)A
(QA)9 (9A)Q (Q9)2 (Q2)9 (92)Q (Q9)3 (Q3)9 (93)Q (Q9)4 (Q4)9
(94)Q (Q9)5 (Q5)9 (95)Q (Q9)6 (Q6)9 (96)Q (Q9)7 (Q7)9 (97)Q
(Q9)8 (Q8)9 (98)Q (QT)A (QA)T (TA)Q (QT)2 (Q2)T (T2)Q (QT)3
(Q3)T (T3)Q (QT)4 (Q4)T (T4)Q (QT)5 (Q5)T (T5)Q (QT)6 (Q6)T
(T6)Q (QT)7 (Q7)T (T7)Q (QT)8 (Q8)T (T8)Q (QT)9 (Q9)T (T9)Q
(QJ)A (QA)J (JA)Q (QJ)2 (Q2)J (J2)Q (QJ)3 (Q3)J (J3)Q (QJ)4
(Q4)J (J4)Q (QJ)5 (Q5)J (J5)Q (QJ)6 (Q6)J (J6)Q (QJ)7 (Q7)J
(J7)Q (QJ)8 (Q8)J (J8)Q (QJ)9 (Q9)J (J9)Q (QJ)T (QT)J (JT)Q
(K2)A (KA)2 (2A)K (K3)A (KA)3 (3A)K (K3)2 (K2)3 (32)K (K4)A
(KA)4 (4A)K (K4)2 (K2)4 (42)K (K4)3 (K3)4 (43)K (K5)A (KA)5
(5A)K (K5)2 (K2)5 (52)K (K5)3 (K3)5 (53)K (K5)4 (K4)5 (54)K
(K6)A (KA)6 (6A)K (K6)2 (K2)6 (62)K (K6)3 (K3)6 (63)K (K6)4
(K4)6 (64)K (K6)5 (K5)6 (65)K (K7)A (KA)7 (7A)K (K7)2 (K2)7
(72)K (K7)3 (K3)7 (73)K (K7)4 (K4)7 (74)K (K7)5 (K5)7 (75)K
(K7)6 (K6)7 (76)K (K8)A (KA)8 (8A)K (K8)2 (K2)8 (82)K (K8)3
(K3)8 (83)K (K8)4 (K4)8 (84)K (K8)5 (K5)8 (85)K (K8)6 (K6)8
(86)K (K8)7 (K7)8 (87)K (K9)A (KA)9 (9A)K (K9)2 (K2)9 (92)K
(K9)3 (K3)9 (93)K (K9)4 (K4)9 (94)K (K9)5 (K5)9 (95)K (K9)6
(K6)9 (96)K (K9)7 (K7)9 (97)K (K9)8 (K8)9 (98)K (KT)A (KA)T
(TA)K (KT)2 (K2)T (T2)K (KT)3 (K3)T (T3)K (KT)4 (K4)T (T4)K
(KT)5 (K5)T (T5)K (KT)6 (K6)T (T6)K (KT)7 (K7)T (T7)K (KT)8
(K8)T (T8)K (KT)9 (K9)T (T9)K (KJ)A (KA)J (JA)K (KJ)2 (K2)J
(J2)K (KJ)3 (K3)J (J3)K (KJ)4 (K4)J (J4)K (KJ)5 (K5)J (J5)K
(KJ)6 (K6)J (J6)K (KJ)7 (K7)J (J7)K (KJ)8 (K8)J (J8)K (KJ)9
(K9)J (J9)K (KJ)T (KT)J (JT)K (KQ)A (KA)Q (QA)K (KQ)2 (K2)Q
(Q2)K (KQ)3 (K3)Q (Q3)K (KQ)4 (K4)Q (Q4)K (KQ)5 (K5)Q (Q5)K
(KQ)6 (K6)Q (Q6)K (KQ)7 (K7)Q (Q7)K (KQ)8 (K8)Q (Q8)K (KQ)9
(K9)Q (Q9)K (KQ)T (KT)Q (QT)K (KQ)J (KJ)Q (QJ)K (2A)A (22)A
(AA)2 (2A)2 (3A)A (33)A (AA)3 (3A)3 (32)2 (33)2 (22)3 (32)3
(4A)A (44)A (AA)4 (4A)4 (42)2 (44)2 (22)4 (42)4 (43)3 (44)3
(33)4 (43)4 (5A)A (55)A (AA)5 (5A)5 (52)2 (55)2 (22)5 (52)5
(53)3 (55)3 (33)5 (53)5 (54)4 (55)4 (44)5 (54)5 (6A)A (66)A
(AA)6 (6A)6 (62)2 (66)2 (22)6 (62)6 (63)3 (66)3 (33)6 (63)6
(64)4 (66)4 (44)6 (64)6 (65)5 (66)5 (55)6 (65)6 (7A)A (77)A
(AA)7 (7A)7 (72)2 (77)2 (22)7 (72)7 (73)3 (77)3 (33)7 (73)7
(74)4 (77)4 (44)7 (74)7 (75)5 (77)5 (55)7 (75)7 (76)6 (77)6
(66)7 (76)7 (8A)A (88)A (AA)8 (8A)8 (82)2 (88)2 (22)8 (82)8
(83)3 (88)3 (33)8 (83)8 (84)4 (88)4 (44)8 (84)8 (85)5 (88)5
(55)8 (85)8 (86)6 (88)6 (66)8 (86)8 (87)7 (88)7 (77)8 (87)8
(9A)A (99)A (AA)9 (9A)9 (92)2 (99)2 (22)9 (92)9 (93)3 (99)3
(33)9 (93)9 (94)4 (99)4 (44)9 (94)9 (95)5 (99)5 (55)9 (95)9
(96)6 (99)6 (66)9 (96)9 (97)7 (99)7 (77)9 (97)9 (98)8 (99)8
(88)9 (98)9 (TA)A (TT)A (AA)T (TA)T (T2)2 (TT)2 (22)T (T2)T
(T3)3 (TT)3 (33)T (T3)T (T4)4 (TT)4 (44)T (T4)T (T5)5 (TT)5
(55)T (T5)T (T6)6 (TT)6 (66)T (T6)T (T7)7 (TT)7 (77)T (T7)T
(T8)8 (TT)8 (88)T (T8)T (T9)9 (TT)9 (99)T (T9)T (JA)A (JJ)A
(AA)J (JA)J (J2)2 (JJ)2 (22)J (J2)J (J3)3 (JJ)3 (33)J (J3)J
(J4)4 (JJ)4 (44)J (J4)J (J5)5 (JJ)5 (55)J (J5)J (J6)6 (JJ)6
(66)J (J6)J (J7)7 (JJ)7 (77)J (J7)J (J8)8 (JJ)8 (88)J (J8)J
(J9)9 (JJ)9 (99)J (J9)J (JT)T (JJ)T (TT)J (JT)J (QA)A (QQ)A
(AA)Q (QA)Q (Q2)2 (QQ)2 (22)Q (Q2)Q (Q3)3 (QQ)3 (33)Q (Q3)Q
(Q4)4 (QQ)4 (44)Q (Q4)Q (Q5)5 (QQ)5 (55)Q (Q5)Q (Q6)6 (QQ)6
(66)Q (Q6)Q (Q7)7 (QQ)7 (77)Q (Q7)Q (Q8)8 (QQ)8 (88)Q (Q8)Q
(Q9)9 (QQ)9 (99)Q (Q9)Q (QT)T (QQ)T (TT)Q (QT)Q (QJ)J (QQ)J
(JJ)Q (QJ)Q (KA)A (KK)A (AA)K (KA)K (K2)2 (KK)2 (22)K (K2)K
(K3)3 (KK)3 (33)K (K3)K (K4)4 (KK)4 (44)K (K4)K (K5)5 (KK)5
(55)K (K5)K (K6)6 (KK)6 (66)K (K6)K (K7)7 (KK)7 (77)K (K7)K
(K8)8 (KK)8 (88)K (K8)K (K9)9 (KK)9 (99)K (K9)K (KT)T (KK)T
(TT)K (KT)K (KJ)J (KK)J (JJ)K (KJ)K (KQ)Q (KK)Q (QQ)K (KQ)K
(AA)A (22)2 (33)3 (44)4 (55)5 (66)6 (77)7 (88)8 (99)9 (TT)T
(JJ)J (QQ)Q (KK)K
"""
count = 1
string = ""
for a in re_space.finditer(razzlist):
string = string + ("'%s':%s," %(a.group(1), count))
count+=1
if count%10 == 0:
string = string + "\n"
print "-------------------------"
print "Razz encode list"
print "------------------------ "
print string
string = ""
count = 1
for a in re_space.finditer(razzlist):
string = string + ("%s:'%s'," %(count, a.group(1)))
count+=1
if count%10 == 0:
string = string + "\n"
print "-------------------------"
print "Razz decode list"
print "------------------------ "
print string

View File

@ -47,6 +47,9 @@
# other stuff. # other stuff.
# 6 For each stat you make add a line to the __main__ function to test it. # 6 For each stat you make add a line to the __main__ function to test it.
import L10n
_ = L10n.get_translation()
# Standard Library modules # Standard Library modules
import sys import sys
@ -55,18 +58,6 @@ import pygtk
import gtk import gtk
import re import re
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
# FreePokerTools modules # FreePokerTools modules
import Configuration import Configuration
import Database import Database

View File

@ -1,12 +1,14 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
"""Discover_TableWindow.py """Base class for interacting with poker client windows.
Inspects the currently open windows and finds those of interest to us--that is There are currently subclasses for X and Windows.
poker table windows from supported sites. Returns a list
of Table_Window objects representing the windows found. The class queries the poker client window for data of interest, such as
size and location. It also controls the signals to alert the HUD when the
client has been resized, destroyed, etc.
""" """
# Copyright 2008-2010, Ray E. Barker # Copyright 2008 - 2010, Ray E. Barker
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -25,37 +27,38 @@ of Table_Window objects representing the windows found.
######################################################################## ########################################################################
# Standard Library modules # Standard Library modules
import os import re
import sys
# pyGTK modules # pyGTK modules
import pygtk
import gtk import gtk
import gobject import gobject
# FreePokerTools modules # FreePokerTools modules
import Configuration from HandHistoryConverter import getTableTitleRe
#if os.name == "posix": from HandHistoryConverter import getTableNoRe
# import XTables
#elif os.name == "nt":
# import WinTables
# Global used for figuring out the current game being played from the title # Global used for figuring out the current game being played from the title.
# The dict key is the fpdb name for the game # The dict key is a tuple of (limit type, category) for the game.
# The list is the names for those games used by the supported poker sites # The list is the names for those games used by the supported poker sites
# This is currently only used for HORSE, so it only needs to support those # This is currently only used for mixed games, so it only needs to support those
# games on PokerStars and Full Tilt. # games on PokerStars and Full Tilt.
game_names = { #fpdb name Stars Name FTP Name nlpl_game_names = { #fpdb name Stars Name FTP Name (if different)
"holdem" : ("Hold\'em" , ), ("nl", "holdem" ) : ("No Limit Hold\'em" , ),
"omahahilo" : ("Omaha H/L" , ), ("pl", "holdem" ) : ("Pot Limit Hold\'em" , ),
"studhilo" : ("Stud H/L" , ), ("pl", "omahahi" ) : ("Pot Limit Omaha" ,"Pot Limit Omaha Hi" ),
"razz" : ("Razz" , ), }
"studhi" : ("Stud" , "Stud Hi") limit_game_names = { #fpdb name Stars Name FTP Name
("fl", "holdem" ) : ("Limit Hold\'em" , ),
("fl", "omahahilo" ) : ("Limit Omaha H/L" , ),
("fl", "studhilo" ) : ("Limit Stud H/L" , ),
("fl", "razz" ) : ("Limit Razz" , ),
("fl", "studhi" ) : ("Limit Stud" , "Stud Hi"),
("fl", "27_3draw" ) : ("Limit Triple Draw 2-7 Lowball", )
} }
# A window title might have our table name + one of theses words/ # A window title might have our table name + one of these words/
# phrases. If it has this word in the title, it is not a table. # phrases. If it has this word in the title, it is not a table.
bad_words = ('History for table:', 'HUD:', 'Chat:') bad_words = ('History for table:', 'HUD:', 'Chat:', 'FPDBHUD')
# Here are the custom signals we define for allowing the 'client watcher' # Here are the custom signals we define for allowing the 'client watcher'
# thread to communicate with the gui thread. Any time a poker client is # thread to communicate with the gui thread. Any time a poker client is
@ -76,11 +79,19 @@ gobject.signal_new("client_destroyed", gtk.Window,
gobject.TYPE_NONE, gobject.TYPE_NONE,
(gobject.TYPE_PYOBJECT,)) (gobject.TYPE_PYOBJECT,))
gobject.signal_new("game_changed", gtk.Window,
gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE,
(gobject.TYPE_PYOBJECT,))
gobject.signal_new("table_changed", gtk.Window,
gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE,
(gobject.TYPE_PYOBJECT,))
# Each TableWindow object must have the following attributes correctly populated: # Each TableWindow object must have the following attributes correctly populated:
# tw.name = the table name from the title bar, which must to match the table name # tw.name = the table name from the title bar, which must to match the table name
# from the corresponding hand history. # from the corresponding hand record in the db.
# tw.site = the site name, e.g. PokerStars, FullTilt. This must match the site
# name specified in the config file.
# tw.number = This is the system id number for the client table window in the # tw.number = This is the system id number for the client table window in the
# format that the system presents it. This is Xid in Xwindows and # format that the system presents it. This is Xid in Xwindows and
# hwnd in Microsoft Windows. # hwnd in Microsoft Windows.
@ -92,61 +103,153 @@ gobject.signal_new("client_destroyed", gtk.Window,
# to the top left of the display screen. This also does not include the # to the top left of the display screen. This also does not include the
# title bar and window borders. To put it another way, this is the # title bar and window borders. To put it another way, this is the
# screen location of (0, 0) in the working window. # screen location of (0, 0) in the working window.
# tournament = Tournament number for a tournament or None for a cash game.
# table = Table number for a tournament.
# gdkhandle =
# window =
# parent =
# game =
# search_string =
class Table_Window(object): class Table_Window(object):
def __init__(self, search_string, table_name = None, tournament = None, table_number = None): def __init__(self, config, site, table_name = None, tournament = None, table_number = None):
self.config = config
self.site = site
if tournament is not None and table_number is not None: if tournament is not None and table_number is not None:
print "tournament %s, table %s" % (tournament, table_number)
self.tournament = int(tournament) self.tournament = int(tournament)
self.table = int(table_number) self.table = int(table_number)
self.name = "%s - %s" % (self.tournament, self.table) self.name = "%s - %s" % (self.tournament, self.table)
self.type = "tour"
table_kwargs = dict(tournament = self.tournament, table_number = self.table)
self.tableno_re = getTableNoRe(self.config, self.site, tournament = self.tournament)
elif table_name is not None: elif table_name is not None:
# search_string = table_name
self.name = table_name self.name = table_name
self.type = "cash"
self.tournament = None self.tournament = None
table_kwargs = dict(table_name = table_name)
else: else:
return None return None
self.find_table_parameters(search_string) self.search_string = getTableTitleRe(self.config, self.site, self.type, **table_kwargs)
self.find_table_parameters()
geo = self.get_geometry()
if geo is None: return None
self.width = geo['width']
self.height = geo['height']
self.x = geo['x']
self.y = geo['y']
self.game = self.get_game()
def __str__(self): def __str__(self):
# __str__ method for testing # __str__ method for testing
likely_attrs = ("site", "number", "title", "width", "height", "x", "y", likely_attrs = ("number", "title", "site", "width", "height", "x", "y",
"tournament", "table", "gdkhandle") "tournament", "table", "gdkhandle", "window", "parent",
"game", "search_string", "tableno_re")
temp = 'TableWindow object\n' temp = 'TableWindow object\n'
for a in likely_attrs: for a in likely_attrs:
if getattr(self, a, 0): if getattr(self, a, 0):
temp += " %s = %s\n" % (a, getattr(self, a)) temp += " %s = %s\n" % (a, getattr(self, a))
return temp return temp
####################################################################
# "get" methods. These query the table and return the info to get.
# They don't change the data in the table and are generally used
# by the "check" methods. Most of the get methods are in the
# subclass because they are specific to X, Windows, etc.
def get_game(self): def get_game(self):
title = self.get_window_title() # title = self.get_window_title()
print title # if title is None:
for game, names in game_names.iteritems(): # return False
title = self.title
# check for nl and pl games first, to avoid bad matches
for game, names in nlpl_game_names.iteritems():
for name in names: for name in names:
if name in title: if name in title:
return game return game
return None for game, names in limit_game_names.iteritems():
for name in names:
if name in title:
return game
return False
def check_geometry(self): def get_table_no(self):
new_title = self.get_window_title()
if new_title is None:
return False
mo = re.search(self.tableno_re, new_title)
if mo is not None:
return mo[1]
return False
####################################################################
# check_table() is meant to be called by the hud periodically to
# determine if the client has been moved or resized. check_table()
# also checks and signals if the client has been closed.
def check_table(self, hud):
result = self.check_size()
if result != False:
hud.parent.main_window.emit(result, hud)
if result == "client_destroyed":
return True
result = self.check_loc()
if result != False:
hud.parent.main_window.emit(result, hud)
if result == "client_destroyed":
return True
return True
####################################################################
# "check" methods. They use the corresponding get method, update the
# table object and return the name of the signal to be emitted or
# False if unchanged. These do not signal for destroyed
# clients to prevent a race condition.
# These might be called by a Window.timeout, so they must not
# return False, or the timeout will be cancelled.
def check_game(self, hud):
new_game = self.get_game()
if new_game is not None and self.game != new_game:
self.game = new_game
hud.main_window.emit("game_changed", hud)
return "game_changed"
return True
def check_size(self):
new_geo = self.get_geometry() new_geo = self.get_geometry()
if new_geo is None: # window destroyed if new_geo is None: # window destroyed
return "client_destroyed" return "client_destroyed"
elif self.x != new_geo['x'] or self.y != new_geo['y']: # window moved
self.x = new_geo['x']
self.y = new_geo['y']
return "client_moved"
elif self.width != new_geo['width'] or self.height != new_geo['height']: # window resized elif self.width != new_geo['width'] or self.height != new_geo['height']: # window resized
self.width = new_geo['width'] self.width = new_geo['width']
self.height = new_geo['height'] self.height = new_geo['height']
return "client_resized" return "client_resized"
return False # no change
else: return False # window not changed def check_loc(self):
new_geo = self.get_geometry()
if new_geo is None: # window destroyed
return "client_destroyed"
if self.x != new_geo['x'] or self.y != new_geo['y']: # window moved
self.x = new_geo['x']
self.y = new_geo['y']
return "client_moved"
return False # no change
def check_table_no(self, hud):
result = self.get_table_no()
if result != False and result != self.table:
self.table = result
hud.main_window.emit("table_changed", hud)
return True
def check_bad_words(self, title): def check_bad_words(self, title):
for word in bad_words: for word in bad_words:
if word in title: return True if word in title: return True

View File

@ -22,31 +22,19 @@ Main program module to test/demo the Tables subclasses.
######################################################################## ########################################################################
import L10n
_ = L10n.get_translation()
# Standard Library modules # Standard Library modules
import sys import sys
import os import os
import re
# pyGTK modules # pyGTK modules
import pygtk
import gtk import gtk
import gobject import gobject
# fpdb/free poker tools modules # fpdb/free poker tools modules
import Configuration import Configuration
from HandHistoryConverter import getTableTitleRe
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
# get the correct module for the current os # get the correct module for the current os
if os.name == 'posix': if os.name == 'posix':
@ -73,24 +61,31 @@ if __name__=="__main__":
self.main_window.move(table.x + dx, table.y + dy) self.main_window.move(table.x + dx, table.y + dy)
self.main_window.show_all() self.main_window.show_all()
table.topify(self) table.topify(self)
# These are the currently defined signals. Do this in the HUD.
self.main_window.connect("client_moved", self.client_moved) self.main_window.connect("client_moved", self.client_moved)
self.main_window.connect("client_resized", self.client_resized) self.main_window.connect("client_resized", self.client_resized)
self.main_window.connect("client_destroyed", self.client_destroyed) self.main_window.connect("client_destroyed", self.client_destroyed)
self.main_window.connect("game_changed", self.game_changed)
self.main_window.connect("table_changed", self.table_changed)
# And these of the handlers that go with those signals.
# These would live inside the HUD code.
def client_moved(self, widget, hud): def client_moved(self, widget, hud):
self.main_window.move(self.table.x + self.dx, self.table.y + self.dy) self.main_window.move(self.table.x + self.dx, self.table.y + self.dy)
def client_resized(self, *args): def client_resized(self, *args):
print "client resized" print "Client resized"
def client_destroyed(self, *args): # call back for terminating the main eventloop def client_destroyed(self, *args): # call back for terminating the main eventloop
print "Client destroyed."
gtk.main_quit() gtk.main_quit()
def check_on_table(table, hud): def game_changed(self, *args):
result = table.check_geometry() print "Game Changed."
if result != False:
hud.main_window.emit(result, hud) def table_changed(self, *args):
return True print "Table Changed."
print _("enter table name to find: "), print _("enter table name to find: "),
table_name = sys.stdin.readline() table_name = sys.stdin.readline()
@ -107,16 +102,12 @@ if __name__=="__main__":
type = "cash" type = "cash"
table_kwargs = dict(table_name = table_name) table_kwargs = dict(table_name = table_name)
search_string = getTableTitleRe(config, "Full Tilt Poker", type, **table_kwargs) table = Tables.Table(config, "Full Tilt Poker", **table_kwargs)
table = Tables.Table(search_string, **table_kwargs) print table
table.gdk_handle = gtk.gdk.window_foreign_new(table.number)
print "table =", table
# print "game =", table.get_game()
fake = fake_hud(table) fake = fake_hud(table)
print "fake =", fake gobject.timeout_add(1000, table.check_game, fake)
# gobject.timeout_add(100, check_on_table, table, fake) gobject.timeout_add(100, table.check_table, fake)
print _("calling main") print "calling main"
gtk.main() gtk.main()

View File

@ -21,6 +21,9 @@
######################################################################## ########################################################################
import L10n
_ = L10n.get_translation()
# to do allow window resizing # to do allow window resizing
# to do hud to echo, but ignore non numbers # to do hud to echo, but ignore non numbers
# to do no stat window for hero # to do no stat window for hero
@ -34,18 +37,6 @@ import traceback
(options, argv) = Options.fpdb_options() (options, argv) = Options.fpdb_options()
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
if not options.errorsToConsole: if not options.errorsToConsole:
print _("Note: error output is being diverted to fpdb-error-log.txt and HUD-error.txt. Any major error will be reported there _only_.") print _("Note: error output is being diverted to fpdb-error-log.txt and HUD-error.txt. Any major error will be reported there _only_.")
errorFile = open('tourneyerror.txt', 'w', 0) errorFile = open('tourneyerror.txt', 'w', 0)

View File

@ -15,6 +15,9 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt. #In the "official" distribution you can find the license in agpl-3.0.txt.
import L10n
_ = L10n.get_translation()
import threading import threading
import pygtk import pygtk
pygtk.require('2.0') pygtk.require('2.0')
@ -29,18 +32,6 @@ from time import gmtime, mktime, strftime, strptime
import logging #logging has been set up in fpdb.py or HUD_main.py, use their settings: import logging #logging has been set up in fpdb.py or HUD_main.py, use their settings:
log = logging.getLogger("filter") log = logging.getLogger("filter")
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
#import Configuration #import Configuration
#import Database #import Database
#import SQL #import SQL

View File

@ -17,6 +17,9 @@
"""parses and stores summary sections from e.g. eMail or summary files""" """parses and stores summary sections from e.g. eMail or summary files"""
import L10n
_ = L10n.get_translation()
# TODO: check to keep only the needed modules # TODO: check to keep only the needed modules
import re import re
@ -31,18 +34,6 @@ import time,datetime
from copy import deepcopy from copy import deepcopy
from Exceptions import * from Exceptions import *
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
import pprint import pprint
import DerivedStats import DerivedStats
import Card import Card

View File

@ -18,6 +18,9 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
######################################################################## ########################################################################
import L10n
_ = L10n.get_translation()
import sys import sys
from HandHistoryConverter import * from HandHistoryConverter import *

View File

@ -18,22 +18,13 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
######################################################################## ########################################################################
import L10n
_ = L10n.get_translation()
import sys import sys
import datetime import datetime
from HandHistoryConverter import * from HandHistoryConverter import *
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
# Win2day HH Format # Win2day HH Format
class Win2day(HandHistoryConverter): class Win2day(HandHistoryConverter):

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
"""WinTables.py """Routines for detecting and handling poker client windows for MS Windows.
Routines for detecting and handling poker client windows for MS Windows.
""" """
# Copyright 2008-2010, Ray E. Barker # Copyright 2008 - 2010, Ray E. Barker
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -22,6 +20,9 @@ Routines for detecting and handling poker client windows for MS Windows.
######################################################################## ########################################################################
import L10n
_ = L10n.get_translation()
# Standard Library modules # Standard Library modules
import re import re
@ -40,18 +41,6 @@ import win32api
import win32con import win32con
import win32security import win32security
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
# FreePokerTools modules # FreePokerTools modules
from TableWindow import Table_Window from TableWindow import Table_Window
@ -62,45 +51,28 @@ tb_height = 29
class Table(Table_Window): class Table(Table_Window):
def find_table_parameters(self, search_string): def find_table_parameters(self):
"""Finds poker client window with the given table name.""" """Finds poker client window with the given table name."""
titles = {} titles = {}
win32gui.EnumWindows(win_enum_handler, titles) win32gui.EnumWindows(win_enum_handler, titles)
for hwnd in titles: for hwnd in titles:
if titles[hwnd] == "": continue if titles[hwnd] == "": continue
# print "searching ", search_string, " in ", titles[hwnd] if re.search(self.search_string, titles[hwnd]):
if re.search(search_string, titles[hwnd]): if self.check_bad_words(titles[hwnd]): continue
if 'History for table:' in titles[hwnd]: continue # Everleaf Network HH viewer window
if 'HUD:' in titles[hwnd]: continue # FPDB HUD window
if 'Chat:' in titles[hwnd]: continue # Some sites (FTP? PS? Others?) have seperable or seperately constructed chat windows
if 'FPDBHUD' in titles[hwnd]: continue # can't attach to ourselves!
self.window = hwnd self.window = hwnd
break break
try: try:
if self.window == None: if self.window == None:
log.error(_("Window %s not found. Skipping.") % search_string ) log.error( "Window %s not found. Skipping." % self.search_string )
return None return None
except AttributeError: except AttributeError:
log.error(_("self.window doesn't exist? why?")) log.error(_("self.window doesn't exist? why?"))
return None return None
(x, y, width, height) = win32gui.GetWindowRect(hwnd)
log.debug("x = %s y = %s width = %s height = %s" % (x, y, width, height))
self.x = int(x) + b_width
self.y = int(y) + tb_height
self.width = width - x
self.height = height - y
log.debug("x = %s y = %s width = %s height = %s" % (self.x, self.y, self.width, self.height))
#self.height = int(height) - b_width - tb_height
#self.width = int(width) - 2*b_width
self.exe = self.get_nt_exe(hwnd)
self.title = titles[hwnd] self.title = titles[hwnd]
self.site = ""
self.hud = None self.hud = None
self.number = hwnd self.number = hwnd
self.gdkhandle = gtk.gdk.window_foreign_new(long(self.window))
def get_geometry(self): def get_geometry(self):
if not win32gui.IsWindow(self.number): # window closed if not win32gui.IsWindow(self.number): # window closed
@ -112,8 +84,8 @@ class Table(Table_Window):
height = height - y height = height - y
return {'x' : int(x) + b_width, return {'x' : int(x) + b_width,
'y' : int(y) + tb_height, 'y' : int(y) + tb_height,
'width' : int(height) - b_width - tb_height, 'height' : int(height) - y,
'height' : int(width) - 2*b_width 'width' : int(width) - x
} }
except: except:
return None return None
@ -121,26 +93,27 @@ class Table(Table_Window):
def get_window_title(self): def get_window_title(self):
return win32gui.GetWindowText(self.window) return win32gui.GetWindowText(self.window)
def get_nt_exe(self, hwnd): # def get_nt_exe(self, hwnd):
"""Finds the name of the executable that the given window handle belongs to.""" # """Finds the name of the executable that the given window handle belongs to."""
#
# # Request privileges to enable "debug process", so we can later use PROCESS_VM_READ, retardedly required to GetModuleFileNameEx()
# priv_flags = win32security.TOKEN_ADJUST_PRIVILEGES | win32security.TOKEN_QUERY
# hToken = win32security.OpenProcessToken (win32api.GetCurrentProcess(), priv_flags)
# # enable "debug process"
# privilege_id = win32security.LookupPrivilegeValue (None, win32security.SE_DEBUG_NAME)
# old_privs = win32security.AdjustTokenPrivileges (hToken, 0, [(privilege_id, win32security.SE_PRIVILEGE_ENABLED)])
#
# # Open the process, and query it's filename
# processid = win32process.GetWindowThreadProcessId(hwnd)
# pshandle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION | win32con.PROCESS_VM_READ, False, processid[1])
# exename = win32process.GetModuleFileNameEx(pshandle, 0)
#
# # clean up
# win32api.CloseHandle(pshandle)
# win32api.CloseHandle(hToken)
#
# return exename
# Request privileges to enable "debug process", so we can later use PROCESS_VM_READ, retardedly required to GetModuleFileNameEx()
priv_flags = win32security.TOKEN_ADJUST_PRIVILEGES | win32security.TOKEN_QUERY
hToken = win32security.OpenProcessToken (win32api.GetCurrentProcess(), priv_flags)
# enable "debug process"
privilege_id = win32security.LookupPrivilegeValue (None, win32security.SE_DEBUG_NAME)
old_privs = win32security.AdjustTokenPrivileges (hToken, 0, [(privilege_id, win32security.SE_PRIVILEGE_ENABLED)])
# Open the process, and query it's filename
processid = win32process.GetWindowThreadProcessId(hwnd)
pshandle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION | win32con.PROCESS_VM_READ, False, processid[1])
exename = win32process.GetModuleFileNameEx(pshandle, 0)
# clean up
win32api.CloseHandle(pshandle)
win32api.CloseHandle(hToken)
return exename
def topify(self, hud): def topify(self, hud):
"""Set the specified gtk window to stayontop in MS Windows.""" """Set the specified gtk window to stayontop in MS Windows."""
@ -159,10 +132,10 @@ class Table(Table_Window):
# hud.main_window.gdkhandle = gtk.gdk.window_foreign_new(w[0]) # hud.main_window.gdkhandle = gtk.gdk.window_foreign_new(w[0])
hud.main_window.gdkhandle = hud.main_window.window hud.main_window.gdkhandle = hud.main_window.window
hud.main_window.gdkhandle.set_transient_for(self.gdkhandle) hud.main_window.gdkhandle.set_transient_for(self.gdkhandle)
rect = self.gdkhandle.get_frame_extents() # rect = self.gdkhandle.get_frame_extents()
(innerx, innery) = self.gdkhandle.get_origin() # (innerx, innery) = self.gdkhandle.get_origin()
b_width = rect.x - innerx # b_width = rect.x - innerx
tb_height = rect.y - innery # tb_height = rect.y - innery
# #
# style = win32gui.GetWindowLong(self.number, win32con.GWL_EXSTYLE) # style = win32gui.GetWindowLong(self.number, win32con.GWL_EXSTYLE)
# style |= win32con.WS_CLIPCHILDREN # style |= win32con.WS_CLIPCHILDREN

420
pyfpdb/WinamaxToFpdb.py Executable file
View File

@ -0,0 +1,420 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2008-2010, Carl Gherardi
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
########################################################################
import sys
import exceptions
import logging
# logging has been set up in fpdb.py or HUD_main.py, use their settings:
import Configuration
from HandHistoryConverter import *
from decimal import Decimal
import time
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
# Winamax HH Format
class Winamax(HandHistoryConverter):
def Trace(f):
def my_f(*args, **kwds):
print ( "entering " + f.__name__)
result= f(*args, **kwds)
print ( "exiting " + f.__name__)
return result
my_f.__name = f.__name__
my_f.__doc__ = f.__doc__
return my_f
filter = "Winamax"
siteName = "Winamax"
filetype = "text"
codepage = ("utf8", "cp1252")
siteId = 5 # Needs to match id entry in Sites database
mixes = { } # Legal mixed games
sym = {'USD': "\$", 'CAD': "\$", 'T$': "", "EUR": "\xe2\x82\xac", "GBP": "\xa3"} # ADD Euro, Sterling, etc HERE
substitutions = {
'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes
'LS' : "\$|\xe2\x82\xac|" # legal currency symbols - Euro(cp1252, utf-8)
}
limits = { 'no limit':'nl', 'pot limit' : 'pl','LIMIT':'fl'}
games = { # base, category
"Holdem" : ('hold','holdem'),
'Omaha' : ('hold','omahahi'),
# 'Omaha Hi/Lo' : ('hold','omahahilo'),
# 'Razz' : ('stud','razz'),
# 'RAZZ' : ('stud','razz'),
# '7 Card Stud' : ('stud','studhi'),
'SEVEN_CARD_STUD_HI_LO' : ('stud','studhilo'),
# 'Badugi' : ('draw','badugi'),
# 'Triple Draw 2-7 Lowball' : ('draw','27_3draw'),
# '5 Card Draw' : ('draw','fivedraw')
}
# Static regexes
# ***** End of hand R5-75443872-57 *****
re_SplitHands = re.compile(r'\n\n')
# Winamax Poker - CashGame - HandId: #279823-223-1285031451 - Holdem no limit (0.02€/0.05€) - 2010/09/21 03:10:51 UTC
re_HandInfo = re.compile(u"""
\s*Winamax\sPoker\s-\sCashGame\s-\sHandId:\s\#(?P<HID>[-A-Z\d]+).*\s
(?P<GAME>Holdem|Omaha)\s
(?P<LIMIT>no\slimit|pot\slimit)\s
\(
((%(LS)s)?(?P<SB>[.0-9]+)(%(LS)s)?)/
((%(LS)s)?(?P<BB>[.0-9]+)(%(LS)s)?)
\)\s-\s
(?P<DATETIME>.*)
""" % substitutions, re.MULTILINE|re.DOTALL|re.VERBOSE)
re_TailSplitHands = re.compile(r'\n\s*\n')
re_Button = re.compile(r'Seat\s#(?P<BUTTON>\d+)\sis\sthe\sbutton')
re_Board = re.compile(r"\[(?P<CARDS>.+)\]")
# 2010/09/21 03:10:51 UTC
re_DateTime = re.compile("""
(?P<Y>[0-9]{4})/
(?P<M>[0-9]+)/
(?P<D>[0-9]+)\s
(?P<H>[0-9]+):(?P<MIN>[0-9]+):(?P<S>[0-9]+)\s
UTC
""", re.MULTILINE|re.VERBOSE)
# Seat 1: floflo...76 (5€)
# Seat 2: francksp76 (6.33€)
# Seat 3: Tonton73 (4.80€)
# Seat 4: chris67poker (4.60€)
re_PlayerInfo = re.compile(u'Seat\s(?P<SEAT>[0-9]+):\s(?P<PNAME>.*)\s\((%(LS)s)?(?P<CASH>[.0-9]+)(%(LS)s)?\)' % substitutions)
def compilePlayerRegexs(self, hand):
players = set([player[1] for player in hand.players])
if not players <= self.compiledPlayers: # x <= y means 'x is subset of y'
# we need to recompile the player regexs.
# TODO: should probably rename re_HeroCards and corresponding method,
# since they are used to find all cards on lines starting with "Dealt to:"
# They still identify the hero.
self.compiledPlayers = players
#ANTES/BLINDS
#helander2222 posts blind ($0.25), lopllopl posts blind ($0.50).
player_re = "(?P<PNAME>" + "|".join(map(re.escape, players)) + ")"
subst = {'PLYR': player_re, 'CUR': self.sym[hand.gametype['currency']]}
self.re_PostSB = re.compile('%(PLYR)s posts small blind (%(CUR)s)?(?P<SB>[\.0-9]+)(%(CUR)s)?' % subst, re.MULTILINE)
self.re_PostBB = re.compile('%(PLYR)s posts big blind (%(CUR)s)?(?P<BB>[\.0-9]+)(%(CUR)s)?' % subst, re.MULTILINE)
self.re_Antes = re.compile(r"^%(PLYR)s: posts the ante (%(CUR)s)?(?P<ANTE>[\.0-9]+)(%(CUR)s)?" % subst, re.MULTILINE)
self.re_BringIn = re.compile(r"^%(PLYR)s: brings[- ]in( low|) for (%(CUR)s)?(?P<BRINGIN>[\.0-9]+(%(CUR)s)?)" % subst, re.MULTILINE)
self.re_PostBoth = re.compile('(?P<PNAME>.*): posts small \& big blind \( (%(CUR)s)?(?P<SBBB>[\.0-9]+)(%(CUR)s)?\)' % subst)
self.re_PostDead = re.compile('(?P<PNAME>.*) posts dead blind \((%(CUR)s)?(?P<DEAD>[\.0-9]+)(%(CUR)s)?\)' % subst, re.MULTILINE)
self.re_HeroCards = re.compile('Dealt\sto\s%(PLYR)s\s\[(?P<CARDS>.*)\]' % subst)
#lopllopl checks, Eurolll checks, .Lucchess checks.
#chumley. calls $0.25
self.re_Action = re.compile('(, )?(?P<PNAME>.*?)(?P<ATYPE> bets| checks| raises| calls| folds)( (%(CUR)s)?(?P<BET>[\d\.]+)(%(CUR)s)?)?( and is all-in)?' % subst)
#self.re_Board = re.compile(r"\[board cards (?P<CARDS>.+) \]")
#Uchilka shows [ KC,JD ]
self.re_ShowdownAction = re.compile('(?P<PNAME>.*) shows \[(?P<CARDS>.+)\]')
#Main pot: $3.57 won by mleo17 ($3.40)
#Side pot 1: $3.26 won by maac_5 ($3.10)
#Main pot: $2.87 won by maac_5 ($1.37), sagi34 ($1.36)
# self.re_CollectPot = re.compile('\s*(?P<PNAME>.*)\scollected\s(%(CUR)s)?(?P<POT>[\.\d]+)(%(CUR)s)?\sfrom\spot' % subst)
self.re_CollectPot = re.compile('\s*(?P<PNAME>.*)\scollected\s(%(CUR)s)?(?P<POT>[\.\d]+)(%(CUR)s)?.*' % subst)
#Seat 5: mleo17 ($3.40), net: +$2.57, [Jd, Qd] (TWO_PAIR QUEEN, JACK)
self.re_ShownCards = re.compile("^Seat (?P<SEAT>[0-9]+): %(PLYR)s showed \[(?P<CARDS>.*)\].*" % subst, re.MULTILINE)
self.re_sitsOut = re.compile('(?P<PNAME>.*) sits out')
def readSupportedGames(self):
return [
["ring", "hold", "fl"],
["ring", "hold", "nl"],
["ring", "hold", "pl"],
["ring", "stud", "fl"],
]
def determineGameType(self, handText):
# Inspect the handText and return the gametype dict
# gametype dict is: {'limitType': xxx, 'base': xxx, 'category': xxx}
info = {}
m = self.re_HandInfo.search(handText)
if not m:
tmp = handText[0:100]
log.error(_("determineGameType: Unable to recognise gametype from: '%s'") % tmp)
log.error(_("determineGameType: Raising FpdbParseError"))
raise FpdbParseError(_("Unable to recognise gametype from: '%s'") % tmp)
mg = m.groupdict()
info['type'] = 'ring'
info['currency'] = 'EUR'
if 'LIMIT' in mg:
if mg['LIMIT'] in self.limits:
info['limitType'] = self.limits[mg['LIMIT']]
else:
tmp = handText[0:100]
log.error(_("determineGameType: limit not found in self.limits(%s). hand: '%s'") % (str(mg),tmp))
log.error(_("determineGameType: Raising FpdbParseError"))
raise FpdbParseError(_("limit not found in self.limits(%s). hand: '%s'") % (str(mg),tmp))
if 'GAME' in mg:
(info['base'], info['category']) = self.games[mg['GAME']]
if 'SB' in mg:
info['sb'] = mg['SB']
if 'BB' in mg:
info['bb'] = mg['BB']
#log.debug("determinegametype: returning "+str(info))
return info
def readHandInfo(self, hand):
info = {}
m = self.re_HandInfo.search(hand.handText)
if m:
info.update(m.groupdict())
#log.debug("readHandInfo: %s" % info)
for key in info:
if key == 'DATETIME':
#'Wed Aug 18 19:45:30 GMT+0100 2010
# %a %b %d %H:%M:%S %z %Y
#hand.startTime = time.strptime(m.group('DATETIME'), "%a %b %d %H:%M:%S GMT%z %Y")
# Stupid library doesn't seem to support %z (http://docs.python.org/library/time.html?highlight=strptime#time.strptime)
# So we need to re-interpret te string to be useful
a = self.re_DateTime.search(info[key])
if a:
datetimestr = "%s/%s/%s %s:%s:%s" % (a.group('Y'),a.group('M'), a.group('D'), a.group('H'),a.group('MIN'),a.group('S'))
tzoffset = str(-time.timezone/3600)
else:
datetimestr = "2010/Jan/01 01:01:01"
log.error(_("readHandInfo: DATETIME not matched: '%s'" % info[key]))
print "DEBUG: readHandInfo: DATETIME not matched: '%s'" % info[key]
# TODO: Manually adjust time against OFFSET
hand.startTime = datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S") # also timezone at end, e.g. " ET"
# hand.startTime = HandHistoryConverter.changeTimezone(hand.startTime, tzoffset, "UTC")
if key == 'HID':
hand.handid = info[key]
# Need to remove non-alphanumerics for MySQL
hand.handid = hand.handid.replace('R','')
hand.handid = hand.handid.replace('-','')
if key == 'TABLE':
hand.tablename = info[key]
# TODO: These
hand.buttonpos = 1
hand.maxseats = 10 # Set to None - Hand.py will guessMaxSeats()
hand.mixed = None
def readPlayerStacks(self, hand):
log.info("readplayerstacks: re is '%s'" % self.re_PlayerInfo)
m = self.re_PlayerInfo.finditer(hand.handText)
for a in m:
print "DEBUG: found '%s' with '%s'" %(a.group('PNAME'), a.group('CASH'))
hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), a.group('CASH'))
def markStreets(self, hand):
# *** ANTE/BLINDS ***
# francksp76 posts small blind 0.02€
# Tonton73 posts big blind 0.05€
# Dealt to johnny_nd [5d Kh 9c Tc]
# *** PRE-FLOP ***
# chris67poker folds
# luckyluck21_ calls 0.05€
# arawak folds
# johnny_nd calls 0.05€
# KILLAROUNDER calls 0.05€
# floflo...76 folds
# francksp76 calls 0.03€
# Tonton73 checks
# *** FLOP *** [5h 8d 3h]
# francksp76 checks
# Tonton73 checks
# luckyluck21_ checks
# johnny_nd checks
# KILLAROUNDER checks
# *** TURN *** [5h 8d 3h][7h]
# francksp76 checks
# Tonton73 checks
# luckyluck21_ checks
# johnny_nd checks
# KILLAROUNDER checks
# *** RIVER *** [5h 8d 3h 7h][2d]
# francksp76 checks
# Tonton73 checks
# luckyluck21_ checks
# johnny_nd bets 0.25€
# KILLAROUNDER folds
# francksp76 folds
# Tonton73 folds
# luckyluck21_ calls 0.25€
# *** SHOW DOWN ***
# johnny_nd shows [5d Kh 9c Tc] (One pair : 5)
# luckyluck21_ shows [6h Js 9s Td] (Straight 9 high)
# luckyluck21_ collected 0.71€ from pot
# *** SUMMARY ***
# Total pot 0.71€ | Rake 0.04€
m = re.search(r"\*\*\* ANTE\/BLINDS \*\*\*(?P<PREFLOP>.+(?=\*\*\* FLOP \*\*\*)|.+)"
r"(\*\*\* FLOP \*\*\*(?P<FLOP> \[\S\S \S\S \S\S\].+(?=\*\*\* TURN \*\*\*)|.+))?"
r"(\*\*\* TURN \*\*\* \[\S\S \S\S \S\S] (?P<TURN>\[\S\S\].+(?=\*\*\* RIVER \*\*\*)|.+))?"
r"(\*\*\* RIVER \*\*\* \[\S\S \S\S \S\S \S\S] (?P<RIVER>\[\S\S\].+))?", hand.handText,re.DOTALL)
try:
hand.addStreets(m)
print "add street"
except:
print ("Failed to add streets. handtext=%s")
#Needs to return a list in the format
# ['player1name', 'player2name', ...] where player1name is the sb and player2name is bb,
# addtional players are assumed to post a bb oop
def readButton(self, hand):
m = self.re_Button.search(hand.handText)
if m:
hand.buttonpos = int(m.group('BUTTON'))
log.debug('readButton: button on pos %d'%hand.buttonpos)
else:
log.warning(_('readButton: not found'))
# def readCommunityCards(self, hand, street):
# #print hand.streets.group(street)
# if street in ('FLOP','TURN','RIVER'): # a list of streets which get dealt community cards (i.e. all but PREFLOP)
# m = self.re_Board.search(hand.streets.group(street))
# hand.setCommunityCards(street, m.group('CARDS').split(','))
def readCommunityCards(self, hand, street): # street has been matched by markStreets, so exists in this hand
if street in ('FLOP','TURN','RIVER'): # a list of streets which get dealt community cards (i.e. all but PREFLOP)
#print "DEBUG readCommunityCards:", street, hand.streets.group(street)
m = self.re_Board.search(hand.streets[street])
hand.setCommunityCards(street, m.group('CARDS').split(' '))
def readBlinds(self, hand):
try:
m = self.re_PostSB.search(hand.handText)
hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB'))
except exceptions.AttributeError: # no small blind
log.exception( _("readBlinds in noSB exception - no SB created")+str(sys.exc_info()) )
#hand.addBlind(None, None, None)
for a in self.re_PostBB.finditer(hand.handText):
hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB'))
for a in self.re_PostDead.finditer(hand.handText):
#print "DEBUG: Found dead blind: addBlind(%s, 'secondsb', %s)" %(a.group('PNAME'), a.group('DEAD'))
hand.addBlind(a.group('PNAME'), 'secondsb', a.group('DEAD'))
for a in self.re_PostBoth.finditer(hand.handText):
hand.addBlind(a.group('PNAME'), 'small & big blinds', a.group('SBBB'))
def readAntes(self, hand):
log.debug(_("reading antes"))
m = self.re_Antes.finditer(hand.handText)
for player in m:
#~ logging.debug("hand.addAnte(%s,%s)" %(player.group('PNAME'), player.group('ANTE')))
hand.addAnte(player.group('PNAME'), player.group('ANTE'))
def readBringIn(self, hand):
m = self.re_BringIn.search(hand.handText,re.DOTALL)
if m:
#~ logging.debug("readBringIn: %s for %s" %(m.group('PNAME'), m.group('BRINGIN')))
hand.addBringIn(m.group('PNAME'), m.group('BRINGIN'))
def readHeroCards(self, hand):
# streets PREFLOP, PREDRAW, and THIRD are special cases beacause
# we need to grab hero's cards
for street in ('PREFLOP', 'DEAL', 'BLINDSANTES'):
if street in hand.streets.keys():
m = self.re_HeroCards.finditer(hand.streets[street])
if m == []:
log.debug("No hole cards found for %s"%street)
for found in m:
hand.hero = found.group('PNAME')
newcards = found.group('CARDS').split(' ')
print "DEBUG: addHoleCards(%s, %s, %s)" %(street, hand.hero, newcards)
hand.addHoleCards(street, hand.hero, closed=newcards, shown=False, mucked=False, dealt=True)
log.debug("Hero cards %s: %s"%(hand.hero, newcards))
def readAction(self, hand, street):
m = self.re_Action.finditer(hand.streets[street])
for action in m:
acts = action.groupdict()
#log.debug("readaction: acts: %s" %acts)
if action.group('ATYPE') == ' raises':
hand.addRaiseBy( street, action.group('PNAME'), action.group('BET') )
elif action.group('ATYPE') == ' calls':
hand.addCall( street, action.group('PNAME'), action.group('BET') )
elif action.group('ATYPE') == ' bets':
hand.addBet( street, action.group('PNAME'), action.group('BET') )
elif action.group('ATYPE') == ' folds':
hand.addFold( street, action.group('PNAME'))
elif action.group('ATYPE') == ' checks':
hand.addCheck( street, action.group('PNAME'))
elif action.group('ATYPE') == ' discards':
hand.addDiscard(street, action.group('PNAME'), action.group('BET'), action.group('DISCARDED'))
elif action.group('ATYPE') == ' stands pat':
hand.addStandsPat( street, action.group('PNAME'))
else:
log.fatal("DEBUG: unimplemented readAction: '%s' '%s'") %(action.group('PNAME'),action.group('ATYPE'),)
def readShowdownActions(self, hand):
for shows in self.re_ShowdownAction.finditer(hand.handText):
log.debug("add show actions %s"%shows)
cards = shows.group('CARDS')
cards = cards.split(' ')
print "DEBUG: addShownCards(%s, %s)" %(cards, shows.group('PNAME'))
hand.addShownCards(cards, shows.group('PNAME'))
@Trace
def readCollectPot(self,hand):
for m in self.re_CollectPot.finditer(hand.handText):
hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT'))
@Trace
def readShownCards(self,hand):
for m in self.re_ShownCards.finditer(hand.handText):
log.debug("Read shown cards: %s"%m.group(0))
cards = m.group('CARDS')
cards = cards.split(' ') # needs to be a list, not a set--stud needs the order
(shown, mucked) = (False, False)
if m.group('CARDS') is not None:
shown = True
hand.addShownCards(cards=cards, player=m.group('PNAME'), shown=shown, mucked=mucked)
if __name__ == "__main__":
c = Configuration.Config()
if len(sys.argv) == 1:
testfile = "regression-test-files/ongame/nlhe/ong NLH handhq_0.txt"
else:
testfile = sys.argv[1]
e = Winamax(c, testfile)

View File

@ -1,12 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
"""Discover_Tables.py """XWindows specific methods for TableWindows Class.
Inspects the currently open windows and finds those of interest to us--that is
poker table windows from supported sites. Returns a list
of Table_Window objects representing the windows found.
""" """
# Copyright 2008-2010, Ray E. Barker # Copyright 2008 - 2010, Ray E. Barker
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -24,102 +20,62 @@ of Table_Window objects representing the windows found.
######################################################################## ########################################################################
import L10n
_ = L10n.get_translation()
# Standard Library modules # Standard Library modules
import re import re
import os import os
# pyGTK modules # pyGTK modules
import pygtk
import gtk import gtk
# Other Library modules # Other Library modules
import Xlib
import Xlib.display import Xlib.display
# FreePokerTools modules # FPDB modules
from TableWindow import Table_Window from TableWindow import Table_Window
# We might as well do this once and make them globals # We might as well do this once and make them globals
disp = Xlib.display.Display() disp = Xlib.display.Display()
root = disp.screen().root root = disp.screen().root
name_atom = disp.get_atom("WM_NAME", 1)
class Table(Table_Window): class Table(Table_Window):
def find_table_parameters(self, search_string): def find_table_parameters(self):
# self.window = None
# done_looping = False
# for outside in root.query_tree().children:
# for inside in outside.query_tree().children:
# if done_looping: break
# prop = inside.get_property(name_atom, Xlib.Xatom.STRING, 0, 1000)
# print prop
# if prop is None: continue
# if prop.value and re.search(search_string, prop.value):
# if self.check_bad_words(prop.value): continue
## if inside.get_wm_name() and re.search(search_string, inside.get_wm_name()):
## if self.check_bad_words(inside.get_wm_name()):
## print "bad word =", inside.get_wm_name()
## continue
# self.window = inside
# self.parent = outside
# done_looping = True
# break
window_number = None self.number = None
for listing in os.popen('xwininfo -root -tree').readlines(): for listing in os.popen('xwininfo -root -tree').readlines():
if re.search(search_string, listing): if re.search(self.search_string, listing):
# print listing
mo = re.match('\s+([\dxabcdef]+) (.+):\s\(\"([a-zA-Z0-9\-.]+)\".+ (\d+)x(\d+)\+\d+\+\d+ \+(\d+)\+(\d+)', listing) mo = re.match('\s+([\dxabcdef]+) (.+):\s\(\"([a-zA-Z0-9\-.]+)\".+ (\d+)x(\d+)\+\d+\+\d+ \+(\d+)\+(\d+)', listing)
title = re.sub('\"', '', mo.group(2))
if self.check_bad_words(title): continue
self.number = int( mo.group(1), 0) self.number = int( mo.group(1), 0)
self.width = int( mo.group(4) ) self.title = title
self.height = int( mo.group(5) ) self.hud = None # specified later
self.x = int( mo.group(6) ) break
self.y = int( mo.group(7) )
self.title = re.sub('\"', '', mo.group(2))
self.exe = "" # not used?
self.hud = None
# done_looping = False
# for outside in root.query_tree().children:
# for inside in outside.query_tree().children:
# if done_looping: break
# if inside.id == window_number:
# self.window = inside
# self.parent = outside
# done_looping = True
# break
if window_number is None: if self.number is None:
return None return None
self.window = self.get_window_from_xid(self.number)
self.parent = self.window.query_tree().parent
# my_geo = self.window.get_geometry() def get_window_from_xid(self, id):
# pa_geo = self.parent.get_geometry() for outside in root.query_tree().children:
# if outside.id == id:
# self.x = pa_geo.x + my_geo.x return outside
# self.y = pa_geo.y + my_geo.y for inside in outside.query_tree().children:
# self.width = my_geo.width if inside.id == id:
# self.height = my_geo.height return inside
# self.exe = self.window.get_wm_class()[0] return None
# self.title = self.window.get_wm_name()
# self.site = ""
# self.hud = None
# window_string = str(self.window)
mo = re.match('Xlib\.display\.Window\(([\dxabcdef]+)', window_string)
if not mo:
print "Not matched"
self.gdk_handle = None
else:
self.number = int( mo.group(1), 0)
print "number =", self.number
# self.gdk_handle = gtk.gdk.window_foreign_new(int(self.number))
def get_geometry(self): def get_geometry(self):
try: try:
my_geo = self.window.get_geometry() my_geo = self.window.get_geometry()
pa_geo = self.parent.get_geometry() pa_geo = self.parent.get_geometry()
return {'x' : pa_geo.x + my_geo.x, return {'x' : my_geo.x + pa_geo.x,
'y' : pa_geo.y + my_geo.y, 'y' : my_geo.y + pa_geo.y,
'width' : my_geo.width, 'width' : my_geo.width,
'height' : my_geo.height 'height' : my_geo.height
} }
@ -127,8 +83,14 @@ class Table(Table_Window):
return None return None
def get_window_title(self): def get_window_title(self):
return self.window.get_wm_name() s = os.popen("xwininfo -wm -id %d" % self.number).read()
mo = re.search('"(.+)"', s)
try:
return mo.group(1)
except AttributeError:
return None
def topify(self, hud): def topify(self, hud):
hud.main_window.gdkhandle = gtk.gdk.window_foreign_new(hud.main_window.window.xid) hud.main_window.gdkhandle = gtk.gdk.window_foreign_new(hud.main_window.window.xid)
hud.main_window.gdkhandle.set_transient_for(self.gdk_handle) hud.main_window.gdkhandle.set_transient_for(self.gdk_handle)

View File

@ -15,23 +15,14 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt. #In the "official" distribution you can find the license in agpl-3.0.txt.
import L10n
_ = L10n.get_translation()
import os import os
import sys import sys
import re import re
import Queue import Queue
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
# if path is set to use an old version of python look for a new one: # if path is set to use an old version of python look for a new one:
# (does this work in linux?) # (does this work in linux?)
if os.name == 'nt' and sys.version[0:3] not in ('2.5', '2.6', '2.7') and '-r' not in sys.argv: if os.name == 'nt' and sys.version[0:3] not in ('2.5', '2.6', '2.7') and '-r' not in sys.argv:

View File

@ -15,6 +15,9 @@
#along with this program. If not, see <http://www.gnu.org/licenses/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt. #In the "official" distribution you can find the license in agpl-3.0.txt.
import L10n
_ = L10n.get_translation()
# Standard Library modules # Standard Library modules
import os # todo: remove this once import_dir is in fpdb_import import os # todo: remove this once import_dir is in fpdb_import
@ -35,18 +38,6 @@ log = logging.getLogger("importer")
import pygtk import pygtk
import gtk import gtk
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
# fpdb/FreePokerTools modules # fpdb/FreePokerTools modules
import Database import Database
import Configuration import Configuration

View File

@ -19,6 +19,9 @@
######################################################################## ########################################################################
import L10n
_ = L10n.get_translation()
# This code is based on CarbonToFpdb.py by Matthew Boss # This code is based on CarbonToFpdb.py by Matthew Boss
# #
# TODO: # TODO:
@ -45,18 +48,6 @@ import logging
from HandHistoryConverter import * from HandHistoryConverter import *
from decimal import Decimal from decimal import Decimal
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
class iPoker(HandHistoryConverter): class iPoker(HandHistoryConverter):

View File

@ -3,6 +3,9 @@
# Code from http://ender.snowburst.org:4747/~jjohns/interlocks.py # Code from http://ender.snowburst.org:4747/~jjohns/interlocks.py
# Thanks JJ! # Thanks JJ!
import L10n
_ = L10n.get_translation()
import sys import sys
import os, os.path import os, os.path
import subprocess import subprocess
@ -10,18 +13,6 @@ import time
import signal import signal
import base64 import base64
import locale
lang=locale.getdefaultlocale()[0][0:2]
if lang=="en":
def _(string): return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
InterProcessLock = None InterProcessLock = None
""" """

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -0,0 +1,65 @@
Winamax Poker - CashGame - HandId: #281396-191-1285104097 - Omaha pot limit (0.02€/0.05€) - 2010/09/21 23:21:37 UTC
Table: 'Charenton-le-Pont' 9-max (real money) Seat #4 is the button
Seat 1: Player1 (8.33€)
Seat 2: Player2 (4.95€)
Seat 3: Player3 (5.46€)
Seat 4: Player4 (4.47€)
Seat 5: Player5 (5€)
Seat 6: Player6 (15.09€)
Seat 7: Player7 (2.48€)
Seat 8: Player8 (1.98€)
Seat 9: Player9 (4.74€)
*** ANTE/BLINDS ***
Player5 posts small blind 0.02€
Player6 posts big blind 0.05€
Dealt to Player2 [Ah 2c 8s Ts]
*** PRE-FLOP ***
Player7 folds
Player8 calls 0.05€
Player9 calls 0.05€
Player1 raises 0.11€ to 0.16€
Player2 folds
Player3 folds
Player4 folds
Player5 calls 0.14€
Player6 folds
Player8 calls 0.11€
Player9 calls 0.11€
*** FLOP *** [3h 9d Ks]
Player5 checks
Player8 checks
Player9 checks
Player1 bets 0.05€
Player5 calls 0.05€
Player8 folds
Player9 calls 0.05€
*** TURN *** [3h 9d Ks][Tc]
Player5 checks
Player9 checks
Player1 bets 0.05€
Player5 calls 0.05€
Player9 calls 0.05€
*** RIVER *** [3h 9d Ks Tc][6d]
Player5 checks
Player9 checks
Player1 bets 0.07€
Player5 calls 0.07€
Player9 folds
*** SHOW DOWN ***
Player5 shows [8h Kc Ac 4s] (One pair : King)
Player1 shows [Qc Th 6c 9c] (Two pairs : Ten and 9)
Player1 collected 1.07€ from pot
*** SUMMARY ***
Total pot 1.07€ | Rake 0.06€
Board: [3h 9d Ks Tc 6d]
Seat 1: Player1 showed [Qc Th 6c 9c] and won 1.07€ with Two pairs : Ten and 9
Seat 2: Player2 folded on the pre-flop
Seat 3: Player3 folded on the pre-flop
Seat 4: Player4 (button) folded on the pre-flop
Seat 5: Player5 (small blind) showed [8h Kc Ac 4s] and lost with One pair : King
Seat 6: Player6 (big blind) folded on the pre-flop
Seat 7: Player7 folded on the pre-flop
Seat 8: Player8 folded on the flop
Seat 9: Player9 folded on the river