Commit 259f8eb6 authored by Laurent Bachelier's avatar Laurent Bachelier 🐧 Committed by ntome

mareeinfo: Fix crash due to strict dates

All dates are at least missing the year, but it is implied they are
current year, current day, etc.
Also tested under Python 3.
parent 67ad05d7
Pipeline #2754 failed with stages
in 2 minutes and 45 seconds
......@@ -69,12 +69,12 @@ class IndexPage(HTMLPage):
def _get_coef_value(self, AM=True, jour=0):
if AM:
time = DateTime(CleanText('//tr[@id="MareeJours_%s"]/td[1]/b[1]' % jour))(self)
time = DateTime(CleanText('//tr[@id="MareeJours_%s"]/td[1]/b[1]' % jour), strict=False)(self)
value = CleanText('//tr[@id="MareeJours_%s"]/td[3]/b[1]' % jour)(self)
else:
time, value = None, None
if len(XPath('//tr[@id="MareeJours_%s"]/td[1]/b' % jour)(self)) > 1:
time = DateTime(CleanText('//tr[@id="MareeJours_%s"]/td[1]/b[2]' % jour))(self)
time = DateTime(CleanText('//tr[@id="MareeJours_%s"]/td[1]/b[2]' % jour), strict=False)(self)
value = CleanText('//tr[@id="MareeJours_%s"]/td[3]/b[2]' % jour)(self)
if time and value:
......@@ -105,13 +105,13 @@ class IndexPage(HTMLPage):
def _get_high_tide_value(self, AM=True, jour=0):
if AM:
time = DateTime(CleanText('//tr[@id="MareeJours_%s"]/td[1]/b[1]' % jour))(self)
time = DateTime(CleanText('//tr[@id="MareeJours_%s"]/td[1]/b[1]' % jour), strict=False)(self)
value = CleanDecimal('//tr[@id="MareeJours_0"]/td[2]/b[1]', replace_dots=True)(self)
else:
time, value = None, None
if len(XPath('//tr[@id="MareeJours_%s"]/td[1]/b' % jour)(self)) > 1:
time = DateTime(CleanText('//tr[@id="MareeJours_%s"]/td[1]/b[2]' % jour),
default=None)(self)
strict=False, default=None)(self)
value = CleanDecimal('//tr[@id="MareeJours_0"]/td[2]/b[2]', replace_dots=True,
default=None)(self)
......@@ -157,7 +157,7 @@ class IndexPage(HTMLPage):
if AM:
time = DateTime(Regexp(CleanText('//tr[@id="MareeJours_%s"]/td[1]' % jour),
re_time,
'\\%s' % slow_tide_pos))(self)
'\\%s' % slow_tide_pos), strict=False)(self)
value = CleanDecimal(Regexp(CleanText('//tr[@id="MareeJours_%s"]/td[2]' % jour),
re_value,
......@@ -170,7 +170,7 @@ class IndexPage(HTMLPage):
if len(m) > slow_tide_pos - 1:
time = DateTime(Regexp(CleanText('//tr[@id="MareeJours_%s"]/td[1]' % jour),
re_time,
'\\%s' % slow_tide_pos))(self)
'\\%s' % slow_tide_pos), strict=False)(self)
value = CleanDecimal(Regexp(CleanText('//tr[@id="MareeJours_%s"]/td[2]' % jour),
re_value,
......
......@@ -109,6 +109,7 @@ lucca
lutim
lyricsmode
manpower
mareeinfo
marmiton
materielnet
mediawiki
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment