Bad assert duration=PT120M
Closed this issue · 3 comments
frodrigo commented
This rule try to validate an undocumented duration format
https://github.com/Jungle-Bus/transport_mapcss/blob/master/transport.validator.mapcss#L324-L342
More over the assert not working
According to the regex
assertNoMatch: "relation type=route route=ferry duration=PT120M";
cannot be true.
nlehuby commented
frodrigo commented
The regex does not return the same result depending the version of pyhton (or soming else).
osm110, venv
Python 3.7.3 (default, Dec 20 2019, 18:57:59)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import regex
>>> print(regex.__version__)
2.5.84
>>>
>>> re_181de9b6 = regex.compile(r'^([0-9][0-9]?[0-9]?|(PT)?[0-2][0-9]:[0-5][0-9](:[0-5][0-9])?|P(?!$)((\d+Y)|(\d+\.\d+Y$))?((\d+M)|(\d+\.\d+M$))?((\d+W)|(\d+\.\d+W$))?((\d+D)|(\d+\.\d+D$))?(T(?=\d)((\d+H)|(\d+\.\d+H$))?((\d+M)|(\d+\.\d+M$))?(\d+(\.\d+)?S)?)??)$')
>>> print(re_181de9b6.match('PT120M'))
None
>>> print(re_181de9b6.match('PT20M'))
None
osmose docker
Python 3.7.9 (default, Sep 10 2020, 17:09:36)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import regex
>>> print(regex.__version__)
2.5.84
>>>
>>> re_181de9b6 = regex.compile(r'^([0-9][0-9]?[0-9]?|(PT)?[0-2][0-9]:[0-5][0-9](:[0-5][0-9])?|P(?!$)((\d+Y)|(\d+\.\d+Y$))?((\d+M)|(\d+\.\d+M$))?((\d+W)|(\d+\.\d+W$))?((\d+D)|(\d+\.\d+D$))?(T(?=\d)((\d+H)|(\d+\.\d+H$))?((\d+M)|(\d+\.\d+M$))?(\d+(\.\d+)?S)?)??)$')
>>> print(re_181de9b6.match('PT120M'))
None
>>> print(re_181de9b6.match('PT20M'))
None
@home
Python 3.8.5 (default, Jul 27 2020, 08:42:51)
[GCC 10.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import regex
>>> print(regex.__version__)
2.5.83
>>>
>>> re_181de9b6 = regex.compile(r'^([0-9][0-9]?[0-9]?|(PT)?[0-2][0-9]:[0-5][0-9](:[0-5][0-9])?|P(?!$)((\d+Y)|(\d+\.\d+Y$))?((\d+M)|(\d+\.\d+M$))?((\d+W)|(\d+\.\d+W$))?((\d+D)|(\d+\.\d+D$))?(T(?=\d)((\d+H)|(\d+\.\d+H$))?((\d+M)|(\d+\.\d+M$))?(\d+(\.\d+)?S)?)??)$')
>>> print(re_181de9b6.match('PT120M'))
<regex.Match object; span=(0, 6), match='PT120M'>
>>> print(re_181de9b6.match('PT20M'))
<regex.Match object; span=(0, 5), match='PT20M'>
It also matchs on travis (py 3.6 and 3.8)
I found multiple alternative regex on the the web, allowing 120M. But the ISO 8601 does not allow it.
cc @jocelynj
nlehuby commented
not relevant anymore I think