From d5f230e4e8ad896f0bc36000dbf06327cb726b5c Mon Sep 17 00:00:00 2001 From: Worros Date: Fri, 3 Sep 2010 11:49:41 +0800 Subject: [PATCH] Absolute: a couple of cleanups and some prep work for AP I've changed re_GameInfo to be a verbose regex, so I may have broken working hand histories. No test files at the moment so it is hard to tell. --- pyfpdb/AbsoluteToFpdb.py | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/pyfpdb/AbsoluteToFpdb.py b/pyfpdb/AbsoluteToFpdb.py index 7cef8c68..145a0971 100755 --- a/pyfpdb/AbsoluteToFpdb.py +++ b/pyfpdb/AbsoluteToFpdb.py @@ -23,6 +23,18 @@ import sys import logging 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 Absolute(HandHistoryConverter): @@ -42,7 +54,13 @@ class Absolute(HandHistoryConverter): #Seat 6 - FETS63 ($0.75 in chips) #Board [10s 5d Kh Qh 8c] - re_GameInfo = re.compile(ur"^Stage #(C?[0-9]+): (?PHoldem|HORSE)(?: \(1 on 1\)|)? ?(?PNo Limit|Pot Limit|Normal|)? ?(?P\$| €|)(?P[.0-9]+)/?(?:\$| €|)(?P[.0-9]+)?", re.MULTILINE) + re_GameInfo = re.compile(ur"""^Stage #(C?[0-9]+):\s+ + (?PHoldem|Seven\sCard\sHi\/L|HORSE) + (?:\s\(1\son\s1\)|)?\s+? + (?PNo Limit|Pot\sLimit|Normal|)?\s? + (?P\$|\s€|) + (?P[.0-9]+)/?(?:\$|\s€|)(?P[.0-9]+)? + """, re.MULTILINE|re.VERBOSE) re_HorseGameInfo = re.compile(ur"^Game Type: (?PLimit) (?PHoldem)", re.MULTILINE) # TODO: can set max seats via (1 on 1) to a known 2 .. re_HandInfo = re.compile(ur"^Stage #C?(?P[0-9]+): .*(?P\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d).*\n(Table: (?P.*) \(Real Money\))?", re.MULTILINE) @@ -50,12 +68,6 @@ class Absolute(HandHistoryConverter): re_Button = re.compile(ur"Seat #(?P
.+$)", re.MULTILINE) -# re_Button = re.compile(ur"^Seat (?P