Merge branch 'master' of git://repo.or.cz/fpbd-bostik
This commit is contained in:
commit
98e4b598ed
|
@ -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
|
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
|
||||||
|
|
|
@ -48,6 +48,7 @@ import Configuration
|
||||||
import SQL
|
import SQL
|
||||||
import Card
|
import Card
|
||||||
import Tourney
|
import Tourney
|
||||||
|
import Charset
|
||||||
from Exceptions import *
|
from Exceptions import *
|
||||||
|
|
||||||
log = Configuration.get_logger("logging.conf")
|
log = Configuration.get_logger("logging.conf")
|
||||||
|
@ -595,7 +596,8 @@ class Database:
|
||||||
if site_id is None:
|
if site_id is None:
|
||||||
site_id = -1
|
site_id = -1
|
||||||
c = self.get_cursor()
|
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()
|
rows = c.fetchall()
|
||||||
return rows
|
return rows
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ import gobject
|
||||||
import Configuration
|
import Configuration
|
||||||
import fpdb_db
|
import fpdb_db
|
||||||
import FpdbSQLQueries
|
import FpdbSQLQueries
|
||||||
|
import Charset
|
||||||
|
|
||||||
class Filters(threading.Thread):
|
class Filters(threading.Thread):
|
||||||
def __init__(self, db, config, qdict, display = {}, debug=True):
|
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()])
|
print "DEBUG: %s was toggled %s" % (data, ("OFF", "ON")[widget.get_active()])
|
||||||
|
|
||||||
def createPlayerLine(self, hbox, site, player):
|
def createPlayerLine(self, hbox, site, player):
|
||||||
|
print 'DEBUG :: add:"%s"' % player
|
||||||
label = gtk.Label(site +" id:")
|
label = gtk.Label(site +" id:")
|
||||||
hbox.pack_start(label, False, False, 0)
|
hbox.pack_start(label, False, False, 0)
|
||||||
|
|
||||||
|
@ -258,13 +260,17 @@ class Filters(threading.Thread):
|
||||||
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) # (config=self.conf, site_id=None, like_player_name="%")
|
||||||
for n in names:
|
for n in names: # list of single-element "tuples"
|
||||||
liststore.append(n)
|
_n = Charset.to_gui(n[0])
|
||||||
|
_nt = (_n, )
|
||||||
|
liststore.append(_nt)
|
||||||
|
|
||||||
self.__set_hero_name(pname, site)
|
self.__set_hero_name(pname, site)
|
||||||
|
|
||||||
def __set_hero_name(self, w, 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])
|
# print "DEBUG: setting heroes[%s]: %s"%(site, self.heroes[site])
|
||||||
|
|
||||||
def __set_num_hands(self, w, val):
|
def __set_num_hands(self, w, val):
|
||||||
|
@ -452,7 +458,8 @@ class Filters(threading.Thread):
|
||||||
vbox.pack_start(hBox, False, True, 0)
|
vbox.pack_start(hBox, False, True, 0)
|
||||||
|
|
||||||
player = self.conf.supported_sites[site].screen_name
|
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:
|
if "GroupsAll" in display and display["GroupsAll"] == True:
|
||||||
hbox = gtk.HBox(False, 0)
|
hbox = gtk.HBox(False, 0)
|
||||||
|
|
|
@ -145,7 +145,8 @@ class GuiGraphViewer (threading.Thread):
|
||||||
if sites[site] == True:
|
if sites[site] == True:
|
||||||
sitenos.append(siteids[site])
|
sitenos.append(siteids[site])
|
||||||
c = self.db.get_cursor()
|
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()
|
result = c.fetchall()
|
||||||
if len(result) == 1:
|
if len(result) == 1:
|
||||||
playerids.append( int(result[0][0]) )
|
playerids.append( int(result[0][0]) )
|
||||||
|
|
|
@ -29,6 +29,7 @@ import fpdb_import
|
||||||
import Database
|
import Database
|
||||||
import fpdb_db
|
import fpdb_db
|
||||||
import Filters
|
import Filters
|
||||||
|
import Charset
|
||||||
|
|
||||||
colalias,colshow,colheading,colxalign,colformat,coltype = 0,1,2,3,4,5
|
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}
|
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])
|
sitenos.append(siteids[site])
|
||||||
# Nasty hack to deal with multiple sites + same player name -Eric
|
# Nasty hack to deal with multiple sites + same player name -Eric
|
||||||
que = self.sql.query['getPlayerId'] + " AND siteId=%d" % siteids[site]
|
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()
|
result = self.db.cursor.fetchall()
|
||||||
if len(result) == 1:
|
if len(result) == 1:
|
||||||
playerids.append(result[0][0])
|
playerids.append(result[0][0])
|
||||||
|
|
|
@ -47,6 +47,7 @@ import fpdb_import
|
||||||
import Database
|
import Database
|
||||||
import Filters
|
import Filters
|
||||||
import FpdbSQLQueries
|
import FpdbSQLQueries
|
||||||
|
import Charset
|
||||||
|
|
||||||
class GuiSessionViewer (threading.Thread):
|
class GuiSessionViewer (threading.Thread):
|
||||||
def __init__(self, config, querylist, mainwin, debug=True):
|
def __init__(self, config, querylist, mainwin, debug=True):
|
||||||
|
@ -181,7 +182,10 @@ class GuiSessionViewer (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])
|
||||||
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()
|
result = self.db.cursor.fetchall()
|
||||||
if len(result) == 1:
|
if len(result) == 1:
|
||||||
playerids.append(result[0][0])
|
playerids.append(result[0][0])
|
||||||
|
|
|
@ -79,7 +79,8 @@ class GuiTableViewer (threading.Thread):
|
||||||
#then the data rows
|
#then the data rows
|
||||||
for player in range(len(self.player_names)):
|
for player in range(len(self.player_names)):
|
||||||
tmp=[]
|
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)
|
seatCount=len(self.player_names)
|
||||||
if seatCount>=8:
|
if seatCount>=8:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user