Skip to content

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

Open
nmisyats wants to merge 7 commits intoDinoTools:masterfrom
nmisyats:master
Open

Added options to return or include raw data from query#112
nmisyats wants to merge 7 commits intoDinoTools:masterfrom
nmisyats:master

Conversation

@nmisyats
Copy link

@nmisyats nmisyats 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