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

Added options to return or include raw data from query #112

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Krafpy
Copy link

@Krafpy Krafpy commented Sep 2, 2023

Issue type
  • Feature
Summary

Added options to keep the raw XML or JSON response along with the parsed result, and a method to return only
the raw response.
The latter fixes #79.

Example:

api = overpy.Overpass()
result = api.query("[out:json];node[\"ISO3166-1\"=\"France\"];out;", include_raw=True)
print(result.raw)
api = overpy.Overpass()
data, content_type = api.query_raw("[out:json];node[\"ISO3166-1\"=\"France\"];out;")
print(data)

The `include_raw` parameter in the `query`, `parse_json` and `parse_xml`
methods allow to keep a copy of the raw data (str or bytes) returned
by the query in a `raw` field in the parsed result.
If `raw` is set to True when calling `query`, the raw str or bytes
of the response are returned.
Removed `raw` argument from the `query` method, which only
returns the parsed result (as originally). The `query_raw`
is used to return the raw bytes or string, along with
the response's content type.
This should fix the typing errors.
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

Successfully merging this pull request may close these issues.

Query without parsing
1 participant