Skip to content

Commit 6214f71

Browse files
committed
Remove owslib.util.log and get logger in all files
1 parent 6d24eb7 commit 6214f71

File tree

17 files changed

+82
-67
lines changed

17 files changed

+82
-67
lines changed

owslib/coverage/wcs100.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# Contact email: d.lowe@rl.ac.uk
1010
# =============================================================================
1111

12+
import logging
1213
from owslib.coverage.wcsBase import WCSBase, WCSCapabilitiesReader, ServiceException
1314
from urllib.parse import urlencode
1415
from owslib.util import openURL, testXMLValue
@@ -17,7 +18,10 @@
1718
import os
1819
import errno
1920

20-
from owslib.util import log, makeString
21+
from owslib.util import makeString
22+
23+
24+
LOGGER = logging.getLogger(__name__)
2125

2226

2327
# function to save writing out WCS namespace in full each time
@@ -108,7 +112,7 @@ def getCoverage(self, identifier=None, bbox=None, time=None, format=None, crs=No
108112
109113
"""
110114
msg = 'WCS 1.0.0 DEBUG: Parameters passed to GetCoverage: identifier={}, bbox={}, time={}, format={}, crs={}, width={}, height={}, resx={}, resy={}, resz={}, parameter={}, method={}, other_arguments={}' # noqa
111-
log.debug(msg.format(
115+
LOGGER.debug(msg.format(
112116
identifier, bbox, time, format, crs, width, height, resx, resy, resz, parameter, method, str(kwargs)))
113117

114118
try:
@@ -117,7 +121,7 @@ def getCoverage(self, identifier=None, bbox=None, time=None, format=None, crs=No
117121
except StopIteration:
118122
base_url = self.url
119123

120-
log.debug('WCS 1.0.0 DEBUG: base url of server: %s' % base_url)
124+
LOGGER.debug('WCS 1.0.0 DEBUG: base url of server: %s' % base_url)
121125

122126
# process kwargs
123127
request = {'version': self.version, 'request': 'GetCoverage', 'service': 'WCS'}
@@ -151,7 +155,7 @@ def getCoverage(self, identifier=None, bbox=None, time=None, format=None, crs=No
151155

152156
# encode and request
153157
data = urlencode(request)
154-
log.debug('WCS 1.0.0 DEBUG: Second part of URL: %s' % data)
158+
LOGGER.debug('WCS 1.0.0 DEBUG: Second part of URL: %s' % data)
155159

156160
u = openURL(base_url, data, method, self.cookies, auth=self.auth, timeout=timeout, headers=self.headers)
157161
return u

owslib/coverage/wcs110.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
from owslib.crs import Crs
2222

2323
import logging
24-
from owslib.util import log
24+
25+
26+
LOGGER = logging.getLogger(__name__)
2527

2628

2729
class Namespaces_1_1_0():
@@ -157,7 +159,7 @@ def getCoverage(self, identifier=None, bbox=None, time=None, format=None, store=
157159
if store = false, returns a multipart mime
158160
"""
159161
msg = 'WCS 1.1.0 DEBUG: Parameters passed to GetCoverage: identifier={}, bbox={}, time={}, format={}, rangesubset={}, gridbaseCRS={}, gridtype={}, gridCS={}, gridorigin={}, gridoffsets={}, method={}, other_arguments={}' # noqa
160-
log.debug(msg.format(
162+
LOGGER.debug(msg.format(
161163
identifier, bbox, time, format, rangesubset, gridbaseCRS, gridtype, gridCS,
162164
gridorigin, gridoffsets, method, str(kwargs)))
163165

owslib/coverage/wcs200.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
import dateutil.parser as parser
3030
from datetime import timedelta
3131
import logging
32-
from owslib.util import log, datetime_from_ansi, datetime_from_iso, param_list_to_url_string
32+
from owslib.util import datetime_from_ansi, datetime_from_iso, param_list_to_url_string
33+
34+
35+
LOGGER = logging.getLogger(__name__)
3336

3437

3538
# function to save writing out WCS namespace in full each time
@@ -153,7 +156,7 @@ def getCoverage(
153156
154157
155158
"""
156-
log.debug(
159+
LOGGER.debug(
157160
"WCS 2.0.0 DEBUG: Parameters passed to GetCoverage: identifier=%s, bbox=%s, time=%s, format=%s, crs=%s, width=%s, height=%s, resx=%s, resy=%s, resz=%s, parameter=%s, method=%s, other_arguments=%s" # noqa
158161
% (
159162
identifier,
@@ -183,7 +186,7 @@ def getCoverage(
183186
except StopIteration:
184187
base_url = self.url
185188

186-
log.debug("WCS 2.0.0 DEBUG: base url of server: %s" % base_url)
189+
LOGGER.debug("WCS 2.0.0 DEBUG: base url of server: %s" % base_url)
187190

188191
request = {"version": self.version, "request": "GetCoverage", "service": "WCS"}
189192
assert len(identifier) > 0
@@ -207,12 +210,12 @@ def getCoverage(
207210
if subsets:
208211
data += param_list_to_url_string(subsets, 'subset')
209212
if resolutions:
210-
log.debug('Adding vendor-specific RESOLUTION parameter.')
213+
LOGGER.debug('Adding vendor-specific RESOLUTION parameter.')
211214
data += param_list_to_url_string(resolutions, 'resolution')
212215
if sizes:
213-
log.debug('Adding vendor-specific SIZE parameter.')
216+
LOGGER.debug('Adding vendor-specific SIZE parameter.')
214217
data += param_list_to_url_string(sizes, 'size')
215-
log.debug("WCS 2.0.0 DEBUG: Second part of URL: %s" % data)
218+
LOGGER.debug("WCS 2.0.0 DEBUG: Second part of URL: %s" % data)
216219

217220
u = openURL(base_url, data, method, self.cookies, auth=self.auth, timeout=timeout, headers=self.headers)
218221
return u

owslib/coverage/wcs201.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
import dateutil.parser as parser
3030
from datetime import timedelta
3131
import logging
32-
from owslib.util import log, datetime_from_ansi, datetime_from_iso, param_list_to_url_string
32+
from owslib.util import datetime_from_ansi, datetime_from_iso, param_list_to_url_string
33+
34+
35+
LOGGER = logging.getLogger(__name__)
3336

3437

3538
# function to save writing out WCS namespace in full each time
@@ -153,7 +156,7 @@ def getCoverage(
153156
154157
155158
"""
156-
log.debug(
159+
LOGGER.debug(
157160
"WCS 2.0.1 DEBUG: Parameters passed to GetCoverage: identifier=%s, bbox=%s, time=%s, format=%s, crs=%s, width=%s, height=%s, resx=%s, resy=%s, resz=%s, parameter=%s, method=%s, other_arguments=%s" # noqa
158161
% (
159162
identifier,
@@ -183,7 +186,7 @@ def getCoverage(
183186
except StopIteration:
184187
base_url = self.url
185188

186-
log.debug("WCS 2.0.1 DEBUG: base url of server: %s" % base_url)
189+
LOGGER.debug("WCS 2.0.1 DEBUG: base url of server: %s" % base_url)
187190

188191
request = {"version": self.version, "request": "GetCoverage", "service": "WCS"}
189192
assert len(identifier) > 0
@@ -207,13 +210,13 @@ def getCoverage(
207210
if subsets:
208211
data += param_list_to_url_string(subsets, 'subset')
209212
if resolutions:
210-
log.debug('Adding vendor-specific RESOLUTION parameter.')
213+
LOGGER.debug('Adding vendor-specific RESOLUTION parameter.')
211214
data += param_list_to_url_string(resolutions, 'resolution')
212215
if sizes:
213-
log.debug('Adding vendor-specific SIZE parameter.')
216+
LOGGER.debug('Adding vendor-specific SIZE parameter.')
214217
data += param_list_to_url_string(sizes, 'size')
215218

216-
log.debug("WCS 2.0.1 DEBUG: Second part of URL: %s" % data)
219+
LOGGER.debug("WCS 2.0.1 DEBUG: Second part of URL: %s" % data)
217220

218221
u = openURL(base_url, data, method, self.cookies, auth=self.auth, timeout=timeout, headers=self.headers)
219222
return u

owslib/feature/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@
55
#
66
# =============================================================================
77

8+
import logging
9+
10+
811
from urllib.parse import urlencode
912
from owslib.crs import Crs
10-
from owslib.util import log, Authentication
13+
from owslib.util import Authentication
1114
from owslib.feature.schema import get_schema
1215
from owslib.feature.postrequest import PostRequest_1_1_0, PostRequest_2_0_0
1316

1417

18+
LOGGER = logging.getLogger(__name__)
19+
20+
1521
class WebFeatureService_(object):
1622
"""Base class for WebFeatureService implementations"""
1723

@@ -137,7 +143,7 @@ def getSRS(self, srsname, typename):
137143
return self.contents[typename].crsOptions[index]
138144
except ValueError:
139145
options = ", ".join([crs.id for crs in self.contents[typename].crsOptions])
140-
log.warning(
146+
LOGGER.warning(
141147
"Requested srsName %r is not declared as being "
142148
"allowed for requested typename %r. "
143149
"Options are: %r.",
@@ -326,7 +332,7 @@ def getPOSTGetFeatureRequest(
326332

327333
if storedQueryID:
328334
if self.version in ["1.0.0", "1.1.0"]:
329-
log.warning("Stored queries are only supported in version 2.0.0 and above.")
335+
LOGGER.warning("Stored queries are only supported in version 2.0.0 and above.")
330336
return None
331337

332338
storedQueryParams = storedQueryParams or {}

owslib/feature/wfs100.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
xmltag_split,
2121
Authentication,
2222
openURL,
23-
log,
2423
)
2524
from owslib.etree import etree
2625
from owslib.fgdc import Metadata
@@ -295,7 +294,7 @@ def getfeature(
295294
request["outputFormat"] = outputFormat
296295

297296
data = urlencode(request)
298-
log.debug("Making request: %s?%s" % (base_url, data))
297+
LOGGER.debug("Making request: %s?%s" % (base_url, data))
299298
u = openURL(base_url, data, method, timeout=self.timeout,
300299
headers=self.headers, auth=self.auth)
301300

owslib/feature/wfs110.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@
3636
AbstractContentMetadata,
3737
)
3838
from owslib.namespaces import Namespaces
39-
from owslib.util import log, openURL
39+
from owslib.util import openURL
40+
41+
import logging
42+
43+
44+
LOGGER = logging.getLogger(__name__)
4045

4146

4247
def get_namespaces():
@@ -328,7 +333,7 @@ def getfeature(
328333
request["outputFormat"] = outputFormat
329334

330335
data = urlencode(request)
331-
log.debug("Making request: %s?%s" % (base_url, data))
336+
LOGGER.debug("Making request: %s?%s" % (base_url, data))
332337

333338
elif method.lower() == "post":
334339
base_url, data = self.getPOSTGetFeatureRequest(

owslib/feature/wfs200.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
from urllib.parse import urlencode
2727

2828
import logging
29-
from owslib.util import log
29+
30+
LOGGER = logging.getLogger(__name__)
3031

3132
n = Namespaces()
3233
WFS_NAMESPACE = n.get_namespace("wfs20")
@@ -115,7 +116,7 @@ def __init__(
115116
else:
116117
auth = Authentication()
117118
super(WebFeatureService_2_0_0, self).__init__(auth)
118-
log.debug("building WFS %s" % url)
119+
LOGGER.debug("building WFS %s" % url)
119120
self.url = url
120121
self.version = version
121122
self.timeout = timeout
@@ -305,7 +306,7 @@ def getfeature(
305306
startindex,
306307
sortby,
307308
)
308-
log.debug("GetFeature WFS GET url %s" % url)
309+
LOGGER.debug("GetFeature WFS GET url %s" % url)
309310
else:
310311
url, data = self.getPOSTGetFeatureRequest(
311312
typename,

owslib/map/wms130.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
from owslib.namespaces import Namespaces
2828
from owslib.map.common import WMSCapabilitiesReader, AbstractContentMetadata
2929

30-
from owslib.util import log
3130

3231
n = Namespaces()
3332
WMS_NAMESPACE = n.get_namespace("wms")

owslib/owscontext/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@
88
place for some constants to avoid circular imports
99
"""
1010

11-
from owslib.util import log

0 commit comments

Comments
 (0)