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

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): ...@@ -69,12 +69,12 @@ class IndexPage(HTMLPage):
def _get_coef_value(self, AM=True, jour=0): def _get_coef_value(self, AM=True, jour=0):
if AM: 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) value = CleanText('//tr[@id="MareeJours_%s"]/td[3]/b[1]' % jour)(self)
else: else:
time, value = None, None time, value = None, None
if len(XPath('//tr[@id="MareeJours_%s"]/td[1]/b' % jour)(self)) > 1: 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) value = CleanText('//tr[@id="MareeJours_%s"]/td[3]/b[2]' % jour)(self)
if time and value: if time and value:
...@@ -105,13 +105,13 @@ class IndexPage(HTMLPage): ...@@ -105,13 +105,13 @@ class IndexPage(HTMLPage):
def _get_high_tide_value(self, AM=True, jour=0): def _get_high_tide_value(self, AM=True, jour=0):
if AM: 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) value = CleanDecimal('//tr[@id="MareeJours_0"]/td[2]/b[1]', replace_dots=True)(self)
else: else:
time, value = None, None time, value = None, None
if len(XPath('//tr[@id="MareeJours_%s"]/td[1]/b' % jour)(self)) > 1: 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), 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, value = CleanDecimal('//tr[@id="MareeJours_0"]/td[2]/b[2]', replace_dots=True,
default=None)(self) default=None)(self)
...@@ -157,7 +157,7 @@ class IndexPage(HTMLPage): ...@@ -157,7 +157,7 @@ class IndexPage(HTMLPage):
if AM: if AM:
time = DateTime(Regexp(CleanText('//tr[@id="MareeJours_%s"]/td[1]' % jour), time = DateTime(Regexp(CleanText('//tr[@id="MareeJours_%s"]/td[1]' % jour),
re_time, 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), value = CleanDecimal(Regexp(CleanText('//tr[@id="MareeJours_%s"]/td[2]' % jour),
re_value, re_value,
...@@ -170,7 +170,7 @@ class IndexPage(HTMLPage): ...@@ -170,7 +170,7 @@ class IndexPage(HTMLPage):
if len(m) > slow_tide_pos - 1: if len(m) > slow_tide_pos - 1:
time = DateTime(Regexp(CleanText('//tr[@id="MareeJours_%s"]/td[1]' % jour), time = DateTime(Regexp(CleanText('//tr[@id="MareeJours_%s"]/td[1]' % jour),
re_time, 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), value = CleanDecimal(Regexp(CleanText('//tr[@id="MareeJours_%s"]/td[2]' % jour),
re_value, re_value,
......
...@@ -109,6 +109,7 @@ lucca ...@@ -109,6 +109,7 @@ lucca
lutim lutim
lyricsmode lyricsmode
manpower manpower
mareeinfo
marmiton marmiton
materielnet materielnet
mediawiki 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