Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate semicolon inserted when query ends in semicolon and whitespace #101

Closed
torfsen opened this issue Jul 19, 2018 · 2 comments
Closed

Comments

@torfsen
Copy link

torfsen commented Jul 19, 2018

If my query string ends in a semicolon plus some whitespace then overpass adds an additional semicolon before adding the out statement. This results in a syntax error:

In [20]: api.get('node["name"="Berlin"]; ')
---------------------------------------------------------------------------
OverpassSyntaxError                       Traceback (most recent call last)
<ipython-input-20-447b86aa8161> in <module>()
----> 1 api.get('node["name"="Berlin"]; ')

~/projects/reduced-maps/venv/lib/python3.5/site-packages/overpass/api.py in get(self, query, responseformat, verbosity, build)
     64 
     65         # Get the response from Overpass
---> 66         r = self._get_from_overpass(full_query)
     67         content_type = r.headers.get('content-type')
     68 

~/projects/reduced-maps/venv/lib/python3.5/site-packages/overpass/api.py in _get_from_overpass(self, query)
    144         if self._status != 200:
    145             if self._status == 400:
--> 146                 raise OverpassSyntaxError(query)
    147             elif self._status == 429:
    148                 raise MultipleRequestsError()

OverpassSyntaxError: [out:json];node["name"="Berlin"]; ;out body;

Removing the whitespace fixes this, but it would be nice if overpass would do that automatically.

@torfsen
Copy link
Author

torfsen commented Jul 19, 2018

An easy fix would be to change

raw_query = str(userquery)

into

raw_query = str(userquery).rstrip()

to remove trailing whitespace before checking for an existing semicolon.

@mvexel mvexel closed this as completed in 1c978d5 Aug 29, 2018
@mvexel
Copy link
Owner

mvexel commented Aug 29, 2018

thanks for catching!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants