From f27396ea12def4620870539f745ad131ad84db2c Mon Sep 17 00:00:00 2001 From: Mika Bostrom Date: Sun, 29 Aug 2010 20:18:01 +0300 Subject: [PATCH 1/2] Generalise .po file updates This should catch all future translations too --- pyfpdb/locale/update-po-files.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pyfpdb/locale/update-po-files.sh b/pyfpdb/locale/update-po-files.sh index f39b143d..0b6956e6 100755 --- a/pyfpdb/locale/update-po-files.sh +++ b/pyfpdb/locale/update-po-files.sh @@ -1,3 +1,12 @@ -msgmerge --update fpdb-hu_HU.po fpdb-en_GB.po -msgmerge --update fpdb-de_DE.po fpdb-en_GB.po +#!/bin/sh + +# Our master file +REFERENCE_PO=fpdb-en_GB.po + +# Update all .po files +for po in *.po; do + if [ ${po} != ${REFERENCE_PO} ]; then + msgmerge --update ${po} ${REFERENCE_PO} + fi +done From 2b97d938f1f549bfb7eb69ca7b364766892b7f0e Mon Sep 17 00:00:00 2001 From: Mika Bostrom Date: Mon, 30 Aug 2010 12:35:49 +0300 Subject: [PATCH 2/2] Fix HUD bug with specified decimals If any stat in HUD had manually specified number of decimal places, the entire hand processing stopped when the first such stat was encountered. Now really do the decimal place formatting as it was supposed to work. Also, for future reference: tuples are immutable - you can't overwrite any tuple member. Hence the need for new routine, __stat_override() --- pyfpdb/Stats.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/pyfpdb/Stats.py b/pyfpdb/Stats.py index 285a45ea..3616fa87 100755 --- a/pyfpdb/Stats.py +++ b/pyfpdb/Stats.py @@ -83,14 +83,29 @@ re_Places = re.compile("_[0-9]$") import codecs encoder = codecs.lookup(Configuration.LOCALE_ENCODING) + +# Since tuples are immutable, we have to create a new one when +# overriding any decimal placements. Copy old ones and recreate the +# second value in tuple to specified format- +def __stat_override(decimals, stat_vals): + s = '%.*f' % (decimals, 100.0*stat_vals[0]) + res = (stat_vals[0], s, stat_vals[2], + stat_vals[3], stat_vals[4], stat_vals[5]) + return res + + def do_tip(widget, tip): _tip = Charset.to_utf8(tip) widget.set_tooltip_text(_tip) def do_stat(stat_dict, player = 24, stat = 'vpip'): + statname = stat match = re_Places.search(stat) - result = eval("%(stat)s(stat_dict, %(player)d)" % {'stat': stat, 'player': player}) + if match: # override if necessary + statname = stat[0:-2] + + result = eval("%(stat)s(stat_dict, %(player)d)" % {'stat': statname, 'player': player}) # If decimal places have been defined, override result[1] # NOTE: decimal place override ALWAYS assumes the raw result is a @@ -99,9 +114,8 @@ def do_stat(stat_dict, player = 24, stat = 'vpip'): # to three decimal places anyhow, so they are unlikely override # candidates. if match: - base = stat[0:-2] places = int(stat[-1:]) - result[1] = '%.*f' % (places, 100.0*result[0]) + result = __stat_override(places, result) return result # OK, for reference the tuple returned by the stat is: