get OnGame parser working
This commit is contained in:
parent
f250fec935
commit
683f6cee20
|
@ -150,6 +150,7 @@ Otherwise, finish at EOF.
|
||||||
log.debug(handText)
|
log.debug(handText)
|
||||||
else:
|
else:
|
||||||
handsList = self.allHandsAsList()
|
handsList = self.allHandsAsList()
|
||||||
|
log.debug( _("handsList is ") + str(handsList) )
|
||||||
log.info("Parsing %d hands" % len(handsList))
|
log.info("Parsing %d hands" % len(handsList))
|
||||||
# Determine if we're dealing with a HH file or a Summary file
|
# 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
|
# 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
|
@staticmethod
|
||||||
def changeTimezone(time, givenTimezone, wantedTimezone):
|
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":
|
if wantedTimezone=="UTC":
|
||||||
wantedTimezone = pytz.utc
|
wantedTimezone = pytz.utc
|
||||||
else:
|
else:
|
||||||
raise Error #TODO raise appropriate error
|
raise Error #TODO raise appropriate error
|
||||||
|
|
||||||
|
givenTZ = None
|
||||||
|
|
||||||
if givenTimezone=="ET":
|
if givenTimezone=="ET":
|
||||||
givenTimezone = timezone('US/Eastern')
|
givenTZ = timezone('US/Eastern')
|
||||||
elif givenTimezone=="CET":
|
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
|
#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
|
elif givenTimezone == 'HST': # Hawaiian Standard Time
|
||||||
pass
|
pass
|
||||||
elif givenTimezone == 'AKT': # Alaska Time
|
elif givenTimezone == 'AKT': # Alaska Time
|
||||||
|
@ -615,23 +620,23 @@ or None if we fail to get the info """
|
||||||
elif givenTimezone == 'JST': # Japan Standard Time
|
elif givenTimezone == 'JST': # Japan Standard Time
|
||||||
pass
|
pass
|
||||||
elif givenTimezone == 'AWST': # Australian Western Standard Time
|
elif givenTimezone == 'AWST': # Australian Western Standard Time
|
||||||
givenTimezone = timezone('Australia/West')
|
givenTZ = timezone('Australia/West')
|
||||||
elif givenTimezone == 'ACST': # Australian Central Standard Time
|
elif givenTimezone == 'ACST': # Australian Central Standard Time
|
||||||
givenTimezone = timezone('Australia/Darwin')
|
givenTZ = timezone('Australia/Darwin')
|
||||||
elif givenTimezone == 'AEST': # Australian Eastern Standard Time
|
elif givenTimezone == 'AEST': # Australian Eastern Standard Time
|
||||||
# Each State on the East Coast has different DSTs.
|
# Each State on the East Coast has different DSTs.
|
||||||
# Melbournce is out because I don't like AFL, Queensland doesn't have DST
|
# Melbournce is out because I don't like AFL, Queensland doesn't have DST
|
||||||
# ACT is full of politicians and Tasmania will never notice.
|
# ACT is full of politicians and Tasmania will never notice.
|
||||||
# Using Sydney.
|
# Using Sydney.
|
||||||
givenTimezone = timezone('Australia/Sydney')
|
givenTZ = timezone('Australia/Sydney')
|
||||||
elif givenTimezone == 'NZT': # New Zealand Time
|
elif givenTimezone == 'NZT': # New Zealand Time
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
raise Error #TODO raise appropriate error
|
raise Error #TODO raise appropriate error
|
||||||
|
|
||||||
localisedTime = givenTimezone.localize(time)
|
localisedTime = givenTZ.localize(time)
|
||||||
utcTime = localisedTime.astimezone(wantedTimezone)
|
utcTime = localisedTime.astimezone(wantedTimezone)
|
||||||
#print "utcTime:",utcTime
|
log.debug( _("utcTime:")+str(utcTime) )
|
||||||
return utcTime
|
return utcTime
|
||||||
#end @staticmethod def changeTimezone
|
#end @staticmethod def changeTimezone
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,8 @@ class OnGame(HandHistoryConverter):
|
||||||
|
|
||||||
#self.rexx.setGameInfoRegex('.*Blinds \$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+)')
|
#self.rexx.setGameInfoRegex('.*Blinds \$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+)')
|
||||||
# Static regexes
|
# 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 *****
|
# ***** History for hand R5-75443872-57 *****
|
||||||
# Start hand: Wed Aug 18 19:29:10 GMT+0100 2010
|
# 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
|
# So we need to re-interpret te string to be useful
|
||||||
m1 = self.re_DateTime.finditer(info[key])
|
m1 = self.re_DateTime.finditer(info[key])
|
||||||
for a in m1:
|
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'))
|
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'))
|
||||||
hand.startTime = time.strptime(datetimestr, "%b %d %Y %H:%M:%S")
|
|
||||||
# TODO: Manually adjust time against OFFSET
|
# 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':
|
if key == 'HID':
|
||||||
hand.handid = info[key]
|
hand.handid = info[key]
|
||||||
if key == 'TABLE':
|
if key == 'TABLE':
|
||||||
|
|
Loading…
Reference in New Issue
Block a user