From d22dbb1238df37140005662b5a4b87e8ee7e10dd Mon Sep 17 00:00:00 2001 From: Worros Date: Fri, 3 Sep 2010 14:05:50 +0800 Subject: [PATCH] Carbon: Make carbon crash less. --- pyfpdb/CarbonToFpdb.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/pyfpdb/CarbonToFpdb.py b/pyfpdb/CarbonToFpdb.py index 49523ba6..624b8074 100644 --- a/pyfpdb/CarbonToFpdb.py +++ b/pyfpdb/CarbonToFpdb.py @@ -53,6 +53,19 @@ import logging from HandHistoryConverter import * from decimal import Decimal +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 Carbon(HandHistoryConverter): sitename = "Carbon" @@ -119,7 +132,15 @@ or None if we fail to get the info """ # a hand history file; hence it is not supplied with the second # and subsequent hands. In these cases we use the value previously # stored. - return self.info + try: + self.info + return self.info + except AttributeError: + tmp = handText[0:100] + log.error(_("determineGameType: Unable to recognise gametype from: '%s'") % tmp) + log.error(_("determineGameType: Raising FpdbParseError")) + raise FpdbParseError(_("Unable to recognise gametype from: '%s'") % tmp) + self.info = {} mg = m.groupdict()