rezemika / oh_sanitizer

A corrector for the 'opening_hours' fields from OpenStreetMap
GNU Affero General Public License v3.0
2 stars 0 forks source link

Pyhton 2.7 support #3

Closed frodrigo closed 6 years ago

frodrigo commented 6 years ago

Do you plan to support Pyhton 2.7 ? I have encoding issue with the grammar.

$ pip install oh_sanitizer
Downloading/unpacking oh-sanitizer
  Downloading oh_sanitizer-0.1.1.tar.gz
  Running setup.py (path:/tmp/pip-build-mdK1wq/oh-sanitizer/setup.py) egg_info for package oh-sanitizer
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip-build-mdK1wq/oh-sanitizer/setup.py", line 4, in <module>
        import oh_sanitizer
      File "oh_sanitizer/__init__.py", line 26, in <module>
        from oh_sanitizer.main import sanitize_field, SanitizeError, InconsistentField
      File "oh_sanitizer/main.py", line 23, in <module>
        PARSER = get_parser()
      File "oh_sanitizer/main.py", line 20, in get_parser
        return _lark.Lark(grammar, start="time_domain", parser="earley")
      File "/home/fred/frodrigo-osmose-backend/venv/local/lib/python2.7/site-packages/lark/lark.py", line 153, in __init__
        self.grammar = load_grammar(grammar, source)
      File "/home/fred/frodrigo-osmose-backend/venv/local/lib/python2.7/site-packages/lark/load_grammar.py", line 599, in load_grammar
        tree = self.canonize_tree.transform( self.parser.parse(grammar_text+'\n') )
      File "/home/fred/frodrigo-osmose-backend/venv/local/lib/python2.7/site-packages/lark/parser_frontends.py", line 37, in parse
        return self.parser.parse(token_stream)
      File "/home/fred/frodrigo-osmose-backend/venv/local/lib/python2.7/site-packages/lark/parsers/lalr_parser.py", line 69, in parse
        for i, token in enumerate(stream):
      File "/home/fred/frodrigo-osmose-backend/venv/local/lib/python2.7/site-packages/lark/lexer.py", line 100, in lex
        t = Token(type_, value, line_ctr.char_pos, line_ctr.line, line_ctr.column)
      File "/home/fred/frodrigo-osmose-backend/venv/local/lib/python2.7/site-packages/lark/lexer.py", line 29, in __new__
        self = super(Token, cls).__new__(cls, value)
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3: ordinal not in range(128)
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
rezemika commented 6 years ago

I just uploaded a 0.1.2 version which adds support for Python 2. The unit tests pass, but I'm not an expert of backporting, so let me know if there is any problem. ;)