diff --git a/pyfpdb/GuiBulkImport.py b/pyfpdb/GuiBulkImport.py index 72e5e463..dc023e01 100755 --- a/pyfpdb/GuiBulkImport.py +++ b/pyfpdb/GuiBulkImport.py @@ -294,7 +294,7 @@ class GuiBulkImport(): self.cb_drophudcache.show() # button - Import - self.load_button = gtk.Button(_('Import')) # todo: rename variables to import too + self.load_button = gtk.Button(_('_Bulk Import')) # todo: rename variables to import too self.load_button.connect('clicked', self.load_clicked, _('Import clicked')) self.table.attach(self.load_button, 2, 3, 4, 5, xpadding=0, ypadding=0, diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index 64831d61..860d05e1 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -70,6 +70,7 @@ class HandHistoryConverter(): # "utf_8" is more likely if there are funny characters codepage = "cp1252" + re_tzOffset = re.compile('^\w+[+-]\d{4}$') def __init__(self, config, in_path = '-', out_path = '-', follow=False, index=0, autostart=True, starsArchive=False, ftpArchive=False): """\ @@ -150,6 +151,7 @@ Otherwise, finish at EOF. log.debug(handText) else: handsList = self.allHandsAsList() + log.debug( _("handsList is ") + str(handsList) ) log.info("Parsing %d hands" % len(handsList)) # Determine if we're dealing with a HH file or a Summary file # quick fix : empty files make the handsList[0] fail ==> If empty file, go on with HH parsing @@ -568,17 +570,32 @@ or None if we fail to get the info """ @staticmethod def changeTimezone(time, givenTimezone, wantedTimezone): - #print "raw time:",time, "given TZ:", givenTimezone + """Takes a givenTimezone in format AAA or AAA+HHMM where AAA is a standard timezone + and +HHMM is an optional offset (+/-) in hours (HH) and minutes (MM) + (See OnGameToFpdb.py for example use of the +HHMM part) + Tries to convert the time parameter (with no timezone) from the givenTimezone to + the wantedTimeZone (currently only allows "UTC") + """ + log.debug( _("raw time:")+str(time) + _(" given TZ:")+str(givenTimezone) ) if wantedTimezone=="UTC": wantedTimezone = pytz.utc else: raise Error #TODO raise appropriate error - + + givenTZ = None + if HandHistoryConverter.re_tzOffset.match(givenTimezone): + offset = int(givenTimezone[-5:]) + givenTimezone = givenTimezone[0:-5] + log.debug( _("changeTimeZone: offset=") + str(offset) ) + else: offset=0 + if givenTimezone=="ET": - givenTimezone = timezone('US/Eastern') + givenTZ = timezone('US/Eastern') elif givenTimezone=="CET": - givenTimezone = timezone('Europe/Berlin') + givenTZ = timezone('Europe/Berlin') #Note: Daylight Saving Time is standardised across the EU so this should be fine + elif givenTimezone == 'GMT': # Greenwich Mean Time (same as UTC - no change to time) + givenTZ = timezone('GMT') elif givenTimezone == 'HST': # Hawaiian Standard Time pass elif givenTimezone == 'AKT': # Alaska Time @@ -612,23 +629,27 @@ or None if we fail to get the info """ elif givenTimezone == 'JST': # Japan Standard Time pass elif givenTimezone == 'AWST': # Australian Western Standard Time - givenTimezone = timezone('Australia/West') + givenTZ = timezone('Australia/West') elif givenTimezone == 'ACST': # Australian Central Standard Time - givenTimezone = timezone('Australia/Darwin') + givenTZ = timezone('Australia/Darwin') elif givenTimezone == 'AEST': # Australian Eastern Standard Time # Each State on the East Coast has different DSTs. # Melbournce is out because I don't like AFL, Queensland doesn't have DST # ACT is full of politicians and Tasmania will never notice. # Using Sydney. - givenTimezone = timezone('Australia/Sydney') + givenTZ = timezone('Australia/Sydney') elif givenTimezone == 'NZT': # New Zealand Time pass else: raise Error #TODO raise appropriate error - localisedTime = givenTimezone.localize(time) - utcTime = localisedTime.astimezone(wantedTimezone) - #print "utcTime:",utcTime + if givenTZ is None: + raise Error #TODO raise appropriate error + # (or just return time unchanged?) + + localisedTime = givenTZ.localize(time) + utcTime = localisedTime.astimezone(wantedTimezone) + datetime.timedelta(seconds=-3600*(offset/100)-60*(offset%100)) + log.debug( _("utcTime:")+str(utcTime) ) return utcTime #end @staticmethod def changeTimezone diff --git a/pyfpdb/OnGameToFpdb.py b/pyfpdb/OnGameToFpdb.py index 26a2ecc9..088920d3 100755 --- a/pyfpdb/OnGameToFpdb.py +++ b/pyfpdb/OnGameToFpdb.py @@ -43,6 +43,8 @@ class OnGame(HandHistoryConverter): codepage = ("utf8", "cp1252") siteId = 5 # Needs to match id entry in Sites database + mixes = { } # Legal mixed games + sym = {'USD': "\$", 'CAD': "\$", 'T$': "", "EUR": "\xe2\x82\xac", "GBP": "\xa3"} # ADD Euro, Sterling, etc HERE substitutions = { 'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes 'LS' : "\$|\xe2\x82\xac|" # legal currency symbols - Euro(cp1252, utf-8) @@ -65,7 +67,8 @@ class OnGame(HandHistoryConverter): #self.rexx.setGameInfoRegex('.*Blinds \$?(?P[.0-9]+)/\$?(?P[.0-9]+)') # Static regexes - re_SplitHands = re.compile(r'End of hand .{2}-\d{7,9}-\d+ \*\*\*\*\*\n') + # ***** End of hand R5-75443872-57 ***** + re_SplitHands = re.compile(u'\*\*\*\*\*\sEnd\sof\shand\s[-A-Z\d]+.*\n(?=\*)') # ***** History for hand R5-75443872-57 ***** # Start hand: Wed Aug 18 19:29:10 GMT+0100 2010 @@ -73,7 +76,7 @@ class OnGame(HandHistoryConverter): re_HandInfo = re.compile(u""" \*\*\*\*\*\sHistory\sfor\shand\s(?P[-A-Z\d]+).* Start\shand:\s(?P.*) - Table:\s(?P[\'\w]+)\s\[\d+\]\s\( + Table:\s(?P
[\'\w\s]+)\s\[\d+\]\s\( ( (?PNo\sLimit|Limit|LIMIT|Pot\sLimit)\s (?PTEXAS_HOLDEM|RAZZ)\s @@ -82,20 +85,24 @@ class OnGame(HandHistoryConverter): )? """ % substitutions, re.MULTILINE|re.DOTALL|re.VERBOSE) + re_TailSplitHands = re.compile(u'(\*\*\*\*\*\sEnd\sof\shand\s[-A-Z\d]+.*\n)(?=\*)') + re_Button = re.compile('Button: seat (?P