Skip to content

Parsing a description ? (reverse parsing) #38

@raphodn

Description

@raphodn

This tool is really great for parsing (or sanitizing) strings that have the osm opening_hours format, and getting them in a readable description. 💯

hoh.OHParser(" Mo-Fr 08:30-16:30", locale="fr").description()
// ['Du lundi au vendredi : 08:30 – 16:30.']

I was wondering if it was possible to leverage this tool (or another tool ?) to do the other way around ? 👇

hoh.parse_description("Du lundi au vendredi : 08:30 – 16:30", locale="fr")
// Mo-Fr 08:30-16:30

fyi my current implementation/workaround for this is with string replace 🙃

import re

oh_description = "Du lundi au vendredi : 08:30 – 16:30"
oh_description = re.sub("du", "", oh_description, flags=re.IGNORECASE)
oh_description = re.sub("lundi", "Mo", oh_description, flags=re.IGNORECASE)
...

Thanks anyway

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions