rezemika / humanized_opening_hours

A parser for the opening_hours fields from OpenStreetMap
GNU Affero General Public License v3.0
26 stars 20 forks source link

Allow the separator_for_readability #11

Closed jbgriesner closed 6 years ago

jbgriesner commented 6 years ago

The OSM entry for the Louvre museum in Paris has the following opening_hours:

"Mo,Th,Sa,Su 09:00-18:00; We,Fr 09:00-21:45; Tu off; Jan 1,May 1,Dec 25: off"

If you try to parse it with the hoh parser, you get the following error:

>>> hoh.OHParser("Mo,Th,Sa,Su 09:00-18:00; We,Fr 09:00-21:45; Tu off; Jan 1,May 1,Dec 25: off")

ParseError: The field could not be parsed, it may be invalid. Error happened on column 71 when parsing '5:off'.

The problem is the colon at the end just before the "off" which is not allowed by your grammar and makes the hoh parser crashing to avoid confusion with "DIGITAL_MOMENT":

This colon is allowed by the specifications as a separator_for_readability though it's an optional token.

Could you adapt your grammar to allow this separator ? Thanks :)

rezemika commented 6 years ago

Thank you!

It's corrected by a98c1b8, I just released a version 0.6.2 which should be available with pip.

PS: I am currently working on a new major version which should make parsing much closer to the specifications (see the new-parsing branch). Unfortunatly, it won't be backward-compatible.

Let me know if there is still any problem. ;)

jbgriesner commented 6 years ago

Great, it works fine now! Thanks for your fast answer. Looking forward to the new hoh version !