Merge branch 'master' of git://git.assembla.com/fpdboz.git
This commit is contained in:
commit
79494ea7f9
|
@ -15,6 +15,9 @@
|
||||||
#In the "official" distribution you can find the license in
|
#In the "official" distribution you can find the license in
|
||||||
#agpl-3.0.txt in the docs folder of the package.
|
#agpl-3.0.txt in the docs folder of the package.
|
||||||
|
|
||||||
|
# Error logging
|
||||||
|
import sys
|
||||||
|
|
||||||
# String manipulation
|
# String manipulation
|
||||||
import codecs
|
import codecs
|
||||||
|
|
||||||
|
@ -26,7 +29,7 @@ encoder_to_sys = codecs.lookup(Configuration.LOCALE_ENCODING)
|
||||||
|
|
||||||
# I'm saving a few cycles with this one
|
# I'm saving a few cycles with this one
|
||||||
not_needed = False
|
not_needed = False
|
||||||
if Configuration.LOCALE_ENCODING == 'utf-8':
|
if Configuration.LOCALE_ENCODING == 'UTF8':
|
||||||
not_needed = True
|
not_needed = True
|
||||||
|
|
||||||
def to_utf8(s):
|
def to_utf8(s):
|
||||||
|
@ -37,7 +40,17 @@ def to_utf8(s):
|
||||||
_out = unicode(s, Configuration.LOCALE_ENCODING).encode('utf-8')
|
_out = unicode(s, Configuration.LOCALE_ENCODING).encode('utf-8')
|
||||||
return _out
|
return _out
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
print 'Could not convert: "%s"' % s
|
sys.stderr.write('Could not convert: "%s"\n' % s)
|
||||||
|
raise
|
||||||
|
|
||||||
|
def to_db_utf8(s):
|
||||||
|
if not_needed: return s
|
||||||
|
|
||||||
|
try:
|
||||||
|
(_out, _len) = encoder_to_utf.encode(unicode(s))
|
||||||
|
return _out
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
sys.stderr.write('Could not convert: "%s"\n' % s)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def to_gui(s):
|
def to_gui(s):
|
||||||
|
@ -47,6 +60,6 @@ def to_gui(s):
|
||||||
(_out, _len) = encoder_to_sys.encode(s)
|
(_out, _len) = encoder_to_sys.encode(s)
|
||||||
return _out
|
return _out
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
print 'Could not convert: "%s"' % s
|
sys.stderr.write('Could not convert: "%s"\n' % s)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,6 @@ from decimal import Decimal
|
||||||
import string
|
import string
|
||||||
import re
|
import re
|
||||||
import Queue
|
import Queue
|
||||||
import codecs
|
|
||||||
|
|
||||||
# pyGTK modules
|
# pyGTK modules
|
||||||
|
|
||||||
|
@ -52,7 +51,6 @@ import Charset
|
||||||
from Exceptions import *
|
from Exceptions import *
|
||||||
|
|
||||||
log = Configuration.get_logger("logging.conf")
|
log = Configuration.get_logger("logging.conf")
|
||||||
encoder = codecs.lookup('utf-8')
|
|
||||||
|
|
||||||
class Database:
|
class Database:
|
||||||
|
|
||||||
|
@ -1560,7 +1558,7 @@ class Database:
|
||||||
|
|
||||||
def insertPlayer(self, name, site_id):
|
def insertPlayer(self, name, site_id):
|
||||||
result = None
|
result = None
|
||||||
(_name, _len) = encoder.encode(unicode(name))
|
_name = Charset.to_db_utf8(name)
|
||||||
c = self.get_cursor()
|
c = self.get_cursor()
|
||||||
q = "SELECT name, id FROM Players WHERE siteid=%s and name=%s"
|
q = "SELECT name, id FROM Players WHERE siteid=%s and name=%s"
|
||||||
q = q.replace('%s', self.sql.query['placeholder'])
|
q = q.replace('%s', self.sql.query['placeholder'])
|
||||||
|
|
|
@ -51,6 +51,16 @@ class Filters(threading.Thread):
|
||||||
self.heroes = {}
|
self.heroes = {}
|
||||||
self.boxes = {}
|
self.boxes = {}
|
||||||
|
|
||||||
|
for site in self.conf.get_supported_sites():
|
||||||
|
#Get db site id for filtering later
|
||||||
|
self.cursor.execute(self.sql.query['getSiteId'], (site,))
|
||||||
|
result = self.db.cursor.fetchall()
|
||||||
|
if len(result) == 1:
|
||||||
|
self.siteid[site] = result[0][0]
|
||||||
|
else:
|
||||||
|
print "Either 0 or more than one site matched - EEK"
|
||||||
|
|
||||||
|
|
||||||
# text used on screen stored here so that it can be configured
|
# text used on screen stored here so that it can be configured
|
||||||
self.filterText = {'limitsall':'All', 'limitsnone':'None', 'limitsshow':'Show _Limits'
|
self.filterText = {'limitsall':'All', 'limitsnone':'None', 'limitsshow':'Show _Limits'
|
||||||
,'seatsbetween':'Between:', 'seatsand':'And:', 'seatsshow':'Show Number of _Players'
|
,'seatsbetween':'Between:', 'seatsand':'And:', 'seatsshow':'Show Number of _Players'
|
||||||
|
@ -259,7 +269,7 @@ class Filters(threading.Thread):
|
||||||
liststore = gtk.ListStore(gobject.TYPE_STRING)
|
liststore = gtk.ListStore(gobject.TYPE_STRING)
|
||||||
completion.set_model(liststore)
|
completion.set_model(liststore)
|
||||||
completion.set_text_column(0)
|
completion.set_text_column(0)
|
||||||
names = self.db.get_player_names(self.conf) # (config=self.conf, site_id=None, like_player_name="%")
|
names = self.db.get_player_names(self.conf, self.siteid[site]) # (config=self.conf, site_id=None, like_player_name="%")
|
||||||
for n in names: # list of single-element "tuples"
|
for n in names: # list of single-element "tuples"
|
||||||
_n = Charset.to_gui(n[0])
|
_n = Charset.to_gui(n[0])
|
||||||
_nt = (_n, )
|
_nt = (_n, )
|
||||||
|
@ -487,12 +497,12 @@ class Filters(threading.Thread):
|
||||||
vbox.pack_start(hbox, False, True, 0)
|
vbox.pack_start(hbox, False, True, 0)
|
||||||
self.createSiteLine(hbox, site)
|
self.createSiteLine(hbox, site)
|
||||||
#Get db site id for filtering later
|
#Get db site id for filtering later
|
||||||
self.cursor.execute(self.sql.query['getSiteId'], (site,))
|
#self.cursor.execute(self.sql.query['getSiteId'], (site,))
|
||||||
result = self.db.cursor.fetchall()
|
#result = self.db.cursor.fetchall()
|
||||||
if len(result) == 1:
|
#if len(result) == 1:
|
||||||
self.siteid[site] = result[0][0]
|
# self.siteid[site] = result[0][0]
|
||||||
else:
|
#else:
|
||||||
print "Either 0 or more than one site matched - EEK"
|
# print "Either 0 or more than one site matched - EEK"
|
||||||
|
|
||||||
def fillGamesFrame(self, vbox):
|
def fillGamesFrame(self, vbox):
|
||||||
self.cursor.execute(self.sql.query['getGames'])
|
self.cursor.execute(self.sql.query['getGames'])
|
||||||
|
|
|
@ -147,12 +147,10 @@ class GuiGraphViewer (threading.Thread):
|
||||||
for site in sites:
|
for site in sites:
|
||||||
if sites[site] == True:
|
if sites[site] == True:
|
||||||
sitenos.append(siteids[site])
|
sitenos.append(siteids[site])
|
||||||
c = self.db.get_cursor()
|
|
||||||
_hname = Charset.to_utf8(heroes[site])
|
_hname = Charset.to_utf8(heroes[site])
|
||||||
c.execute(self.sql.query['getPlayerId'], (_hname,))
|
result = self.db.get_player_id(self.conf, site, _hname)
|
||||||
result = c.fetchall()
|
if result is not None:
|
||||||
if len(result) == 1:
|
playerids.append(int(result))
|
||||||
playerids.append( int(result[0][0]) )
|
|
||||||
|
|
||||||
if not sitenos:
|
if not sitenos:
|
||||||
#Should probably pop up here.
|
#Should probably pop up here.
|
||||||
|
|
|
@ -189,13 +189,10 @@ class GuiPlayerStats (threading.Thread):
|
||||||
for site in sites:
|
for site in sites:
|
||||||
if sites[site] == True:
|
if sites[site] == True:
|
||||||
sitenos.append(siteids[site])
|
sitenos.append(siteids[site])
|
||||||
# Nasty hack to deal with multiple sites + same player name -Eric
|
|
||||||
que = self.sql.query['getPlayerId'] + " AND siteId=%d" % siteids[site]
|
|
||||||
_hname = Charset.to_utf8(heroes[site])
|
_hname = Charset.to_utf8(heroes[site])
|
||||||
self.cursor.execute(que, (_hname,))
|
result = self.db.get_player_id(self.conf, site, _hname)
|
||||||
result = self.db.cursor.fetchall()
|
if result is not None:
|
||||||
if len(result) == 1:
|
playerids.append(int(result))
|
||||||
playerids.append(result[0][0])
|
|
||||||
|
|
||||||
if not sitenos:
|
if not sitenos:
|
||||||
#Should probably pop up here.
|
#Should probably pop up here.
|
||||||
|
|
|
@ -440,10 +440,9 @@ or None if we fail to get the info """
|
||||||
#print "trying", kodec
|
#print "trying", kodec
|
||||||
try:
|
try:
|
||||||
in_fh = codecs.open(self.in_path, 'r', kodec)
|
in_fh = codecs.open(self.in_path, 'r', kodec)
|
||||||
in_fh.seek(self.index)
|
whole_file = in_fh.read()
|
||||||
log.debug("Opened in_path: '%s' with %s" % (self.in_path, kodec))
|
self.obs = whole_file[self.index:]
|
||||||
self.obs = in_fh.read()
|
self.index = len(whole_file)
|
||||||
self.index = in_fh.tell()
|
|
||||||
in_fh.close()
|
in_fh.close()
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
|
|
|
@ -55,22 +55,22 @@ class PartyPoker(HandHistoryConverter):
|
||||||
# $5 USD NL Texas Hold'em - Saturday, July 25, 07:53:52 EDT 2009
|
# $5 USD NL Texas Hold'em - Saturday, July 25, 07:53:52 EDT 2009
|
||||||
# NL Texas Hold'em $1 USD Buy-in Trny:45685440 Level:8 Blinds-Antes(600/1 200 -50) - Sunday, May 17, 11:25:07 MSKS 2009
|
# NL Texas Hold'em $1 USD Buy-in Trny:45685440 Level:8 Blinds-Antes(600/1 200 -50) - Sunday, May 17, 11:25:07 MSKS 2009
|
||||||
re_GameInfoRing = re.compile("""
|
re_GameInfoRing = re.compile("""
|
||||||
(?P<CURRENCY>\$|)\s*(?P<RINGLIMIT>[0-9,]+)\s*(?:USD)?\s*
|
(?P<CURRENCY>\$|)\s*(?P<RINGLIMIT>[.,0-9]+)([.,0-9/$]+)?\s*(?:USD)?\s*
|
||||||
(?P<LIMIT>(NL|PL|))\s+
|
(?P<LIMIT>(NL|PL|))\s*
|
||||||
(?P<GAME>(Texas\ Hold\'em|Omaha))
|
(?P<GAME>(Texas\ Hold\'em|Omaha))
|
||||||
\s*\-\s*
|
\s*\-\s*
|
||||||
(?P<DATETIME>.+)
|
(?P<DATETIME>.+)
|
||||||
""", re.VERBOSE)
|
""", re.VERBOSE)
|
||||||
re_GameInfoTrny = re.compile("""
|
re_GameInfoTrny = re.compile("""
|
||||||
(?P<LIMIT>(NL|PL|))\s+
|
(?P<LIMIT>(NL|PL|))\s*
|
||||||
(?P<GAME>(Texas\ Hold\'em|Omaha))\s+
|
(?P<GAME>(Texas\ Hold\'em|Omaha))\s+
|
||||||
(?P<BUYIN>\$?[.0-9]+)\s*(?P<BUYIN_CURRENCY>USD)?\s*Buy-in\s+
|
(?:(?P<BUYIN>\$?[.,0-9]+)\s*(?P<BUYIN_CURRENCY>USD)?\s*Buy-in\s+)?
|
||||||
Trny:\s?(?P<TOURNO>\d+)\s+
|
Trny:\s?(?P<TOURNO>\d+)\s+
|
||||||
Level:\s*(?P<LEVEL>\d+)\s+
|
Level:\s*(?P<LEVEL>\d+)\s+
|
||||||
Blinds(?:-Antes)?\(
|
((Blinds|Stakes)(?:-Antes)?)\(
|
||||||
(?P<SB>[.0-9 ]+)\s*
|
(?P<SB>[.,0-9 ]+)\s*
|
||||||
/(?P<BB>[.0-9 ]+)
|
/(?P<BB>[.,0-9 ]+)
|
||||||
(?:\s*-\s*(?P<ANTE>[.0-9 ]+)\$?)?
|
(?:\s*-\s*(?P<ANTE>[.,0-9 ]+)\$?)?
|
||||||
\)
|
\)
|
||||||
\s*\-\s*
|
\s*\-\s*
|
||||||
(?P<DATETIME>.+)
|
(?P<DATETIME>.+)
|
||||||
|
@ -85,10 +85,9 @@ class PartyPoker(HandHistoryConverter):
|
||||||
re.VERBOSE)
|
re.VERBOSE)
|
||||||
|
|
||||||
re_HandInfo = re.compile("""
|
re_HandInfo = re.compile("""
|
||||||
^Table\s+
|
^Table\s+(?P<TTYPE>[$a-zA-Z0-9 ]+)\s+
|
||||||
(?P<TTYPE>[a-zA-Z0-9 ]+)\s+
|
|
||||||
(?: \#|\(|)(?P<TABLE>\d+)\)?\s+
|
(?: \#|\(|)(?P<TABLE>\d+)\)?\s+
|
||||||
(?:[^ ]+\s+\#(?P<MTTTABLE>\d+).+)? # table number for mtt
|
(?:[a-zA-Z0-9 ]+\s+\#(?P<MTTTABLE>\d+).+)?
|
||||||
(\(No\sDP\)\s)?
|
(\(No\sDP\)\s)?
|
||||||
\((?P<PLAY>Real|Play)\s+Money\)\s+ # FIXME: check if play money is correct
|
\((?P<PLAY>Real|Play)\s+Money\)\s+ # FIXME: check if play money is correct
|
||||||
Seat\s+(?P<BUTTON>\d+)\sis\sthe\sbutton
|
Seat\s+(?P<BUTTON>\d+)\sis\sthe\sbutton
|
||||||
|
@ -136,17 +135,17 @@ class PartyPoker(HandHistoryConverter):
|
||||||
log.debug("CUR_SYM: '%s'" % subst['CUR_SYM'])
|
log.debug("CUR_SYM: '%s'" % subst['CUR_SYM'])
|
||||||
log.debug("CUR: '%s'" % subst['CUR'])
|
log.debug("CUR: '%s'" % subst['CUR'])
|
||||||
self.re_PostSB = re.compile(
|
self.re_PostSB = re.compile(
|
||||||
r"^%(PLYR)s posts small blind \[%(CUR_SYM)s(?P<SB>[.0-9]+) ?%(CUR)s\]\." % subst,
|
r"^%(PLYR)s posts small blind \[%(CUR_SYM)s(?P<SB>[.,0-9]+) ?%(CUR)s\]\." % subst,
|
||||||
re.MULTILINE)
|
re.MULTILINE)
|
||||||
self.re_PostBB = re.compile(
|
self.re_PostBB = re.compile(
|
||||||
r"^%(PLYR)s posts big blind \[%(CUR_SYM)s(?P<BB>[.0-9]+) ?%(CUR)s\]\." % subst,
|
r"^%(PLYR)s posts big blind \[%(CUR_SYM)s(?P<BB>[.,0-9]+) ?%(CUR)s\]\." % subst,
|
||||||
re.MULTILINE)
|
re.MULTILINE)
|
||||||
# NOTE: comma is used as a fraction part delimeter in re below
|
# NOTE: comma is used as a fraction part delimeter in re below
|
||||||
self.re_PostDead = re.compile(
|
self.re_PostDead = re.compile(
|
||||||
r"^%(PLYR)s posts big blind \+ dead \[(?P<BBNDEAD>[.,0-9]+) ?%(CUR_SYM)s\]\." % subst,
|
r"^%(PLYR)s posts big blind \+ dead \[(?P<BBNDEAD>[.,0-9]+) ?%(CUR_SYM)s\]\." % subst,
|
||||||
re.MULTILINE)
|
re.MULTILINE)
|
||||||
self.re_Antes = re.compile(
|
self.re_Antes = re.compile(
|
||||||
r"^%(PLYR)s posts ante \[%(CUR_SYM)s(?P<ANTE>[.0-9]+) ?%(CUR)s\]" % subst,
|
r"^%(PLYR)s posts ante \[%(CUR_SYM)s(?P<ANTE>[.,0-9]+) ?%(CUR)s\]" % subst,
|
||||||
re.MULTILINE)
|
re.MULTILINE)
|
||||||
self.re_HeroCards = re.compile(
|
self.re_HeroCards = re.compile(
|
||||||
r"^Dealt to %(PLYR)s \[\s*(?P<NEWCARDS>.+)\s*\]" % subst,
|
r"^Dealt to %(PLYR)s \[\s*(?P<NEWCARDS>.+)\s*\]" % subst,
|
||||||
|
@ -310,6 +309,10 @@ class PartyPoker(HandHistoryConverter):
|
||||||
hand.handid = info[key]
|
hand.handid = info[key]
|
||||||
if key == 'TABLE':
|
if key == 'TABLE':
|
||||||
hand.tablename = info[key]
|
hand.tablename = info[key]
|
||||||
|
if key == 'MTTTABLE':
|
||||||
|
if info[key] != None:
|
||||||
|
hand.tablename = info[key]
|
||||||
|
hand.tourNo = info['TABLE']
|
||||||
if key == 'BUTTON':
|
if key == 'BUTTON':
|
||||||
hand.buttonpos = info[key]
|
hand.buttonpos = info[key]
|
||||||
if key == 'TOURNO':
|
if key == 'TOURNO':
|
||||||
|
@ -317,6 +320,9 @@ class PartyPoker(HandHistoryConverter):
|
||||||
if key == 'BUYIN':
|
if key == 'BUYIN':
|
||||||
# FIXME: it's dirty hack T_T
|
# FIXME: it's dirty hack T_T
|
||||||
# code below assumes that tournament rake is equal to zero
|
# code below assumes that tournament rake is equal to zero
|
||||||
|
if info[key] == None:
|
||||||
|
hand.buyin = '$0+$0'
|
||||||
|
else:
|
||||||
cur = info[key][0] if info[key][0] not in '0123456789' else ''
|
cur = info[key][0] if info[key][0] not in '0123456789' else ''
|
||||||
hand.buyin = info[key] + '+%s0' % cur
|
hand.buyin = info[key] + '+%s0' % cur
|
||||||
if key == 'LEVEL':
|
if key == 'LEVEL':
|
||||||
|
|
Loading…
Reference in New Issue
Block a user