get OnGame parser working

This commit is contained in:
sqlcoder 2010-08-21 13:44:01 +01:00
parent f250fec935
commit 683f6cee20
2 changed files with 19 additions and 12 deletions

View File

@ -150,6 +150,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
@ -571,17 +572,21 @@ or None if we fail to get the info """
@staticmethod
def changeTimezone(time, givenTimezone, wantedTimezone):
#print "raw time:",time, "given TZ:", givenTimezone
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 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
@ -615,23 +620,23 @@ 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)
localisedTime = givenTZ.localize(time)
utcTime = localisedTime.astimezone(wantedTimezone)
#print "utcTime:",utcTime
log.debug( _("utcTime:")+str(utcTime) )
return utcTime
#end @staticmethod def changeTimezone

View File

@ -65,7 +65,8 @@ class OnGame(HandHistoryConverter):
#self.rexx.setGameInfoRegex('.*Blinds \$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+)')
# Static regexes
re_SplitHands = re.compile('\n\n\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
@ -179,9 +180,10 @@ class OnGame(HandHistoryConverter):
# So we need to re-interpret te string to be useful
m1 = self.re_DateTime.finditer(info[key])
for a in m1:
datetimestr = "%s %s %s %s:%s:%s" % (a.group('M'),a.group('D'), a.group('Y'), a.group('H'),a.group('MIN'),a.group('S'))
hand.startTime = time.strptime(datetimestr, "%b %d %Y %H:%M:%S")
datetimestr = "%s/%s/%s %s:%s:%s" % (a.group('Y'),a.group('M'), a.group('D'), a.group('H'),a.group('MIN'),a.group('S'))
# TODO: Manually adjust time against OFFSET
hand.startTime = datetime.datetime.strptime(datetimestr, "%Y/%b/%d %H:%M:%S") # also timezone at end, e.g. " ET"
hand.startTime = HandHistoryConverter.changeTimezone(hand.startTime, "GMT", "UTC")
if key == 'HID':
hand.handid = info[key]
if key == 'TABLE':