Merge branch 'master' of git://git.assembla.com/fpdboz.git
This commit is contained in:
commit
193c59b15d
|
@ -1,8 +1,8 @@
|
|||
free-poker-tools (0.12-1) unstable; urgency=low
|
||||
free-poker-tools (0.12~git20100122) unstable; urgency=low
|
||||
|
||||
* New release
|
||||
* New snapshot release with reworked import code
|
||||
|
||||
-- Mika Bostrom <bostik+fpdb@bostik.iki.fi> Mon, 26 Oct 2009 17:49:07 +0200
|
||||
-- Mika Bostrom <bostik+fpdb@bostik.iki.fi> Fri, 22 Jan 2010 09:25:27 +0200
|
||||
|
||||
free-poker-tools (0.11.3+git20091023) unstable; urgency=low
|
||||
|
||||
|
|
52
pyfpdb/Charset.py
Normal file
52
pyfpdb/Charset.py
Normal file
|
@ -0,0 +1,52 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
#Copyright 2010 Mika Bostrom
|
||||
#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 in the docs folder of the package.
|
||||
|
||||
# String manipulation
|
||||
import codecs
|
||||
|
||||
# Settings
|
||||
import Configuration
|
||||
|
||||
encoder_to_utf = codecs.lookup('utf-8')
|
||||
encoder_to_sys = codecs.lookup(Configuration.LOCALE_ENCODING)
|
||||
|
||||
# I'm saving a few cycles with this one
|
||||
not_needed = False
|
||||
if Configuration.LOCALE_ENCODING == 'utf-8':
|
||||
not_needed = True
|
||||
|
||||
def to_utf8(s):
|
||||
if not_needed: return s
|
||||
|
||||
try:
|
||||
#(_out, _len) = encoder_to_utf.encode(s)
|
||||
_out = unicode(s, Configuration.LOCALE_ENCODING).encode('utf-8')
|
||||
return _out
|
||||
except UnicodeDecodeError:
|
||||
print 'Could not convert: "%s"' % s
|
||||
raise
|
||||
|
||||
def to_gui(s):
|
||||
if not_needed: return s
|
||||
|
||||
try:
|
||||
(_out, _len) = encoder_to_sys.encode(s)
|
||||
return _out
|
||||
except UnicodeDecodeError:
|
||||
print 'Could not convert: "%s"' % s
|
||||
raise
|
||||
|
|
@ -126,7 +126,6 @@ DATABASE_TYPES = (
|
|||
DATABASE_TYPE_MYSQL,
|
||||
)
|
||||
|
||||
NEWIMPORT = True
|
||||
LOCALE_ENCODING = locale.getdefaultlocale()[1]
|
||||
|
||||
########################################################################
|
||||
|
|
|
@ -48,6 +48,7 @@ import Configuration
|
|||
import SQL
|
||||
import Card
|
||||
import Tourney
|
||||
import Charset
|
||||
from Exceptions import *
|
||||
|
||||
log = Configuration.get_logger("logging.conf")
|
||||
|
@ -359,28 +360,6 @@ class Database:
|
|||
cards['common'] = c.fetchone()
|
||||
return cards
|
||||
|
||||
def convert_cards(self, d):
|
||||
ranks = ('', '', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A')
|
||||
cards = ""
|
||||
for i in xrange(1, 8):
|
||||
# key = 'card' + str(i) + 'Value'
|
||||
# if not d.has_key(key): continue
|
||||
# if d[key] == None:
|
||||
# break
|
||||
# elif d[key] == 0:
|
||||
# cards += "xx"
|
||||
# else:
|
||||
# cards += ranks[d['card' + str(i) + 'Value']] + d['card' +str(i) + 'Suit']
|
||||
cv = "card%dvalue" % i
|
||||
if cv not in d or d[cv] is None:
|
||||
break
|
||||
elif d[cv] == 0:
|
||||
cards += "xx"
|
||||
else:
|
||||
cs = "card%dsuit" % i
|
||||
cards = "%s%s%s" % (cards, ranks[d[cv]], d[cs])
|
||||
return cards
|
||||
|
||||
def get_action_from_hand(self, hand_no):
|
||||
action = [ [], [], [], [], [] ]
|
||||
c = self.connection.cursor()
|
||||
|
@ -617,7 +596,8 @@ class Database:
|
|||
if site_id is None:
|
||||
site_id = -1
|
||||
c = self.get_cursor()
|
||||
c.execute(self.sql.query['get_player_names'], (like_player_name, site_id, site_id))
|
||||
p_name = Charset.to_utf8(like_player_name)
|
||||
c.execute(self.sql.query['get_player_names'], (p_name, site_id, site_id))
|
||||
rows = c.fetchall()
|
||||
return rows
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import gobject
|
|||
import Configuration
|
||||
import fpdb_db
|
||||
import FpdbSQLQueries
|
||||
import Charset
|
||||
|
||||
class Filters(threading.Thread):
|
||||
def __init__(self, db, config, qdict, display = {}, debug=True):
|
||||
|
@ -242,6 +243,7 @@ class Filters(threading.Thread):
|
|||
print "DEBUG: %s was toggled %s" % (data, ("OFF", "ON")[widget.get_active()])
|
||||
|
||||
def createPlayerLine(self, hbox, site, player):
|
||||
print 'DEBUG :: add:"%s"' % player
|
||||
label = gtk.Label(site +" id:")
|
||||
hbox.pack_start(label, False, False, 0)
|
||||
|
||||
|
@ -258,13 +260,17 @@ class Filters(threading.Thread):
|
|||
completion.set_model(liststore)
|
||||
completion.set_text_column(0)
|
||||
names = self.db.get_player_names(self.conf) # (config=self.conf, site_id=None, like_player_name="%")
|
||||
for n in names:
|
||||
liststore.append(n)
|
||||
for n in names: # list of single-element "tuples"
|
||||
_n = Charset.to_gui(n[0])
|
||||
_nt = (_n, )
|
||||
liststore.append(_nt)
|
||||
|
||||
self.__set_hero_name(pname, site)
|
||||
|
||||
def __set_hero_name(self, w, site):
|
||||
self.heroes[site] = w.get_text()
|
||||
_name = w.get_text()
|
||||
_guiname = Charset.to_gui(_name)
|
||||
self.heroes[site] = _guiname
|
||||
# print "DEBUG: setting heroes[%s]: %s"%(site, self.heroes[site])
|
||||
|
||||
def __set_num_hands(self, w, val):
|
||||
|
@ -452,7 +458,8 @@ class Filters(threading.Thread):
|
|||
vbox.pack_start(hBox, False, True, 0)
|
||||
|
||||
player = self.conf.supported_sites[site].screen_name
|
||||
self.createPlayerLine(hBox, site, player)
|
||||
_pname = Charset.to_gui(player)
|
||||
self.createPlayerLine(hBox, site, _pname)
|
||||
|
||||
if "GroupsAll" in display and display["GroupsAll"] == True:
|
||||
hbox = gtk.HBox(False, 0)
|
||||
|
|
|
@ -44,6 +44,7 @@ except ImportError, inst:
|
|||
import fpdb_import
|
||||
import Database
|
||||
import Filters
|
||||
import Charset
|
||||
|
||||
class GuiGraphViewer (threading.Thread):
|
||||
|
||||
|
@ -137,6 +138,8 @@ class GuiGraphViewer (threading.Thread):
|
|||
heroes = self.filters.getHeroes()
|
||||
siteids = self.filters.getSiteIds()
|
||||
limits = self.filters.getLimits()
|
||||
games = self.filters.getGames()
|
||||
|
||||
for i in ('show', 'none'):
|
||||
if i in limits:
|
||||
limits.remove(i)
|
||||
|
@ -145,7 +148,8 @@ class GuiGraphViewer (threading.Thread):
|
|||
if sites[site] == True:
|
||||
sitenos.append(siteids[site])
|
||||
c = self.db.get_cursor()
|
||||
c.execute(self.sql.query['getPlayerId'], (heroes[site],))
|
||||
_hname = Charset.to_utf8(heroes[site])
|
||||
c.execute(self.sql.query['getPlayerId'], (_hname,))
|
||||
result = c.fetchall()
|
||||
if len(result) == 1:
|
||||
playerids.append( int(result[0][0]) )
|
||||
|
@ -171,7 +175,7 @@ class GuiGraphViewer (threading.Thread):
|
|||
|
||||
#Get graph data from DB
|
||||
starttime = time()
|
||||
(green, blue, red) = self.getRingProfitGraph(playerids, sitenos, limits)
|
||||
(green, blue, red) = self.getRingProfitGraph(playerids, sitenos, limits, games)
|
||||
print "Graph generated in: %s" %(time() - starttime)
|
||||
|
||||
self.ax.set_title("Profit graph for ring games")
|
||||
|
@ -212,7 +216,7 @@ class GuiGraphViewer (threading.Thread):
|
|||
|
||||
#end of def showClicked
|
||||
|
||||
def getRingProfitGraph(self, names, sites, limits):
|
||||
def getRingProfitGraph(self, names, sites, limits, games):
|
||||
tmp = self.sql.query['getRingProfitAllHandsPlayerIdSite']
|
||||
# print "DEBUG: getRingProfitGraph"
|
||||
start_date, end_date = self.filters.getDates()
|
||||
|
@ -224,6 +228,22 @@ class GuiGraphViewer (threading.Thread):
|
|||
sitetest = str(tuple(sites))
|
||||
#nametest = nametest.replace("L", "")
|
||||
|
||||
q = []
|
||||
for m in self.filters.display.items():
|
||||
if m[0] == 'Games' and m[1]:
|
||||
for n in games:
|
||||
if games[n]:
|
||||
q.append(n)
|
||||
if len(q) > 0:
|
||||
gametest = str(tuple(q))
|
||||
gametest = gametest.replace("L", "")
|
||||
gametest = gametest.replace(",)",")")
|
||||
gametest = gametest.replace("u'","'")
|
||||
gametest = "and gt.category in %s" % gametest
|
||||
else:
|
||||
gametest = "and gt.category IS NULL"
|
||||
tmp = tmp.replace("<game_test>", gametest)
|
||||
|
||||
lims = [int(x) for x in limits if x.isdigit()]
|
||||
potlims = [int(x[0:-2]) for x in limits if len(x) > 2 and x[-2:] == 'pl']
|
||||
nolims = [int(x[0:-2]) for x in limits if len(x) > 2 and x[-2:] == 'nl']
|
||||
|
|
|
@ -29,6 +29,7 @@ import fpdb_import
|
|||
import Database
|
||||
import fpdb_db
|
||||
import Filters
|
||||
import Charset
|
||||
|
||||
colalias,colshow,colheading,colxalign,colformat,coltype = 0,1,2,3,4,5
|
||||
ranks = {'x':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}
|
||||
|
@ -190,7 +191,8 @@ class GuiPlayerStats (threading.Thread):
|
|||
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]
|
||||
self.cursor.execute(que, (heroes[site],))
|
||||
_hname = Charset.to_utf8(heroes[site])
|
||||
self.cursor.execute(que, (_hname,))
|
||||
result = self.db.cursor.fetchall()
|
||||
if len(result) == 1:
|
||||
playerids.append(result[0][0])
|
||||
|
@ -474,11 +476,14 @@ class GuiPlayerStats (threading.Thread):
|
|||
for n in games:
|
||||
if games[n]:
|
||||
q.append(n)
|
||||
if len(q) > 0:
|
||||
gametest = str(tuple(q))
|
||||
gametest = gametest.replace("L", "")
|
||||
gametest = gametest.replace(",)",")")
|
||||
gametest = gametest.replace("u'","'")
|
||||
gametest = "and gt.category in %s" % gametest
|
||||
else:
|
||||
gametest = "and gt.category IS NULL"
|
||||
query = query.replace("<game_test>", gametest)
|
||||
|
||||
if seats:
|
||||
|
|
|
@ -47,6 +47,7 @@ import fpdb_import
|
|||
import Database
|
||||
import Filters
|
||||
import FpdbSQLQueries
|
||||
import Charset
|
||||
|
||||
class GuiSessionViewer (threading.Thread):
|
||||
def __init__(self, config, querylist, mainwin, debug=True):
|
||||
|
@ -181,7 +182,10 @@ class GuiSessionViewer (threading.Thread):
|
|||
for site in sites:
|
||||
if sites[site] == True:
|
||||
sitenos.append(siteids[site])
|
||||
self.cursor.execute(self.sql.query['getPlayerId'], (heroes[site],))
|
||||
_q = self.sql.query['getPlayerId']
|
||||
_name = Charset.to_utf8(heroes[site])
|
||||
print 'DEBUG(_name) :: %s' % _name
|
||||
self.cursor.execute(_q, (_name,)) # arg = tuple
|
||||
result = self.db.cursor.fetchall()
|
||||
if len(result) == 1:
|
||||
playerids.append(result[0][0])
|
||||
|
|
|
@ -79,7 +79,8 @@ class GuiTableViewer (threading.Thread):
|
|||
#then the data rows
|
||||
for player in range(len(self.player_names)):
|
||||
tmp=[]
|
||||
tmp.append(self.player_names[player][0])
|
||||
p_name = Charset.to_gui(self.player_names[player][0])
|
||||
tmp.append(p_name)
|
||||
|
||||
seatCount=len(self.player_names)
|
||||
if seatCount>=8:
|
||||
|
|
|
@ -681,7 +681,6 @@ class HoldemOmahaHand(Hand):
|
|||
|
||||
def join_holecards(self, player, asList=False):
|
||||
"""With asList = True it returns the set cards for a player including down cards if they aren't know"""
|
||||
# FIXME: This should actually return
|
||||
hcs = [u'0x', u'0x', u'0x', u'0x']
|
||||
|
||||
for street in self.holeStreets:
|
||||
|
|
|
@ -292,8 +292,7 @@ which it expects to find at self.re_TailSplitHands -- see for e.g. Everleaf.py.
|
|||
log.info("Unsupported game type: %s" % gametype)
|
||||
|
||||
if hand:
|
||||
if Configuration.NEWIMPORT == False:
|
||||
hand.writeHand(self.out_fh)
|
||||
#hand.writeHand(self.out_fh)
|
||||
return hand
|
||||
else:
|
||||
log.info("Unsupported game type: %s" % gametype)
|
||||
|
|
|
@ -676,6 +676,11 @@ class Stat_Window:
|
|||
return True
|
||||
|
||||
if event.button == 1: # left button event
|
||||
# close on double click for a stat window
|
||||
# for those that don't have a mouse with middle button
|
||||
if event.type == gtk.gdk._2BUTTON_PRESS:
|
||||
self.window.hide()
|
||||
return True
|
||||
# TODO: make position saving save sizes as well?
|
||||
if event.state & gtk.gdk.SHIFT_MASK:
|
||||
self.window.begin_resize_drag(gtk.gdk.WINDOW_EDGE_SOUTH_EAST, event.button, int(event.x_root), int(event.y_root), event.time)
|
||||
|
|
|
@ -2576,6 +2576,7 @@ class Sql:
|
|||
AND h.handStart > '<startdate_test>'
|
||||
AND h.handStart < '<enddate_test>'
|
||||
<limit_test>
|
||||
<game_test>
|
||||
AND hp.tourneysPlayersId IS NULL
|
||||
GROUP BY h.handStart, hp.handId, hp.sawShowdown, hp.totalProfit
|
||||
ORDER BY h.handStart"""
|
||||
|
|
|
@ -98,8 +98,6 @@ class Importer:
|
|||
for i in xrange(self.settings['threads']):
|
||||
self.writerdbs.append( Database.Database(self.config, sql = self.sql) )
|
||||
|
||||
self.NEWIMPORT = Configuration.NEWIMPORT
|
||||
|
||||
clock() # init clock in windows
|
||||
|
||||
#Set functions
|
||||
|
@ -433,7 +431,7 @@ class Importer:
|
|||
else:
|
||||
self.pos_in_file[file] = 0
|
||||
hhc = obj(in_path = file, out_path = out_path, index = idx, starsArchive = self.settings['starsArchive'])
|
||||
if hhc.getStatus() and self.NEWIMPORT == True:
|
||||
if hhc.getStatus():
|
||||
handlist = hhc.getProcessedHands()
|
||||
self.pos_in_file[file] = hhc.getLastCharacterRead()
|
||||
to_hud = []
|
||||
|
|
|
@ -178,10 +178,6 @@ def testDrawImport():
|
|||
(stored, dups, partial, errs, ttime) = importer.runImport()
|
||||
importer.clearFileList()
|
||||
except FpdbError:
|
||||
if Configuration.NEWIMPORT == False:
|
||||
#Old import code doesn't support draw
|
||||
pass
|
||||
else:
|
||||
assert 0 == 1
|
||||
|
||||
# Should actually do some testing here
|
||||
|
|
Loading…
Reference in New Issue
Block a user