11from datetime import datetime
22from decimal import Decimal
3- from functools import partial
4- from urllib .request import urlopen
3+ from urllib .request import urlopen , Request
54from urllib .error import HTTPError
65from xml .sax import handler , make_parser
76import xml .etree .ElementTree
@@ -60,7 +59,6 @@ class Overpass:
6059 """
6160 Class to access the Overpass API
6261
63- :param read_chunk_size: Max size of each chunk read from the server response
6462 :param url: Optional URL of the Overpass server. Defaults to http://overpass-api.de/api/interpreter
6563 :param xml_parser: The xml parser to use
6664 :param max_retry_count: Max number of retries (Default: default_max_retry_count)
@@ -70,9 +68,6 @@ class Overpass:
7068 #: Global max number of retries (Default: 0)
7169 default_max_retry_count : ClassVar [int ] = 0
7270
73- #: Max size of each chunk read from the server response
74- default_read_chunk_size : ClassVar [int ] = 4096
75-
7671 #: Global time to wait between tries (Default: 1.0s)
7772 default_retry_timeout : ClassVar [float ] = 1.0
7873
@@ -81,7 +76,6 @@ class Overpass:
8176
8277 def __init__ (
8378 self ,
84- read_chunk_size : Optional [int ] = None ,
8579 url : Optional [str ] = None ,
8680 xml_parser : int = XML_PARSER_SAX ,
8781 max_retry_count : int = None ,
@@ -94,11 +88,6 @@ def __init__(
9488
9589 self ._regex_extract_error_msg = re .compile (br"\<p\>(?P<msg>\<strong\s.*?)\</p\>" )
9690 self ._regex_remove_tag = re .compile (b"<[^>]*?>" )
97- if read_chunk_size is None :
98- read_chunk_size = self .default_read_chunk_size
99-
100- #: The chunk size for this instance
101- self .read_chunk_size = read_chunk_size
10291
10392 if max_retry_count is None :
10493 max_retry_count = self .default_max_retry_count
@@ -151,9 +140,7 @@ def query(self, query: Union[bytes, str]) -> "Result":
151140 response = b""
152141 try :
153142 with urlopen (self .url , query ) as f :
154- f_read = partial (f .read , self .read_chunk_size )
155- for data in iter (f_read , b"" ):
156- response += data
143+ response = f .read ()
157144 except HTTPError as exc :
158145 f = exc
159146
0 commit comments