本文整理汇总了Python中urllib.request.lower函数的典型用法代码示例。如果您正苦于以下问题:Python lower函数的具体用法?Python lower怎么用?Python lower使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lower函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wmts_request_compare_project
def wmts_request_compare_project(self, project, request, version='', extra_query_string='', reference_base_name=None):
query_string = 'https://www.qgis.org/?SERVICE=WMTS&REQUEST=%s' % (request)
if version:
query_string += '&VERSION=%s' % version
if extra_query_string:
query_string += '&%s' % extra_query_string
header, body = self._execute_request_project(query_string, project)
self.assert_headers(header, body)
response = header + body
if reference_base_name is not None:
reference_name = reference_base_name
else:
reference_name = 'wmts_' + request.lower()
reference_name += '.txt'
reference_path = self.testdata_path + reference_name
self.store_reference(reference_path, response)
f = open(reference_path, 'rb')
expected = f.read()
f.close()
response = re.sub(RE_STRIP_UNCHECKABLE, b'', response)
expected = re.sub(RE_STRIP_UNCHECKABLE, b'', expected)
self.assertXMLEqual(response, expected, msg="request %s failed.\n Query: %s" % (query_string, request))
示例2: wms_request_compare
def wms_request_compare(self, request, extra=None, reference_file=None):
project = self.testdata_path + "test_project.qgs"
assert os.path.exists(project), "Project file not found: " + project
query_string = 'MAP=%s&SERVICE=WMS&VERSION=1.3&REQUEST=%s' % (urllib.parse.quote(project), request)
if extra is not None:
query_string += extra
header, body = self.server.handleRequest(query_string)
response = header + body
reference_path = self.testdata_path + (request.lower() if not reference_file else reference_file) + '.txt'
f = open(reference_path, 'rb')
expected = f.read()
f.close()
# Store the output for debug or to regenerate the reference documents:
"""
f = open(reference_path, 'wb+')
f.write(response)
f.close()
f = open(os.path.dirname(__file__) + '/expected.txt', 'w+')
f.write(expected)
f.close()
f = open(os.path.dirname(__file__) + '/response.txt', 'w+')
f.write(response)
f.close()
#"""
response = re.sub(RE_STRIP_UNCHECKABLE, b'*****', response)
expected = re.sub(RE_STRIP_UNCHECKABLE, b'*****', expected)
# for older GDAL versions (<2.0), id field will be integer type
if int(osgeo.gdal.VersionInfo()[:1]) < 2:
expected = expected.replace(b'typeName="Integer64" precision="0" length="10" editType="TextEdit" type="qlonglong"', b'typeName="Integer" precision="0" length="10" editType="TextEdit" type="int"')
self.assertXMLEqual(response, expected, msg="request %s failed.\n Query: %s\n Expected:\n%s\n\n Response:\n%s" % (query_string, request, expected.decode('utf-8'), response.decode('utf-8')))
示例3: wfs_request_compare
def wfs_request_compare(self, request):
project = self.testdata_path + "test_project_wfs.qgs"
assert os.path.exists(project), "Project file not found: " + project
query_string = 'MAP=%s&SERVICE=WFS&VERSION=1.0.0&REQUEST=%s' % (urllib.parse.quote(project), request)
header, body = self.server.handleRequest(query_string)
self.assert_headers(header, body)
response = header + body
f = open(self.testdata_path + 'wfs_' + request.lower() + '.txt', 'rb')
expected = f.read()
f.close()
# Store the output for debug or to regenerate the reference documents:
"""
f = open(os.path.dirname(__file__) + '/wfs_' + request.lower() + '_expected.txt', 'w+')
f.write(expected)
f.close()
f = open(os.path.dirname(__file__) + '/wfs_' + request.lower() + '_response.txt', 'w+')
f.write(response)
f.close()
"""
response = re.sub(RE_STRIP_UNCHECKABLE, b'', response)
expected = re.sub(RE_STRIP_UNCHECKABLE, b'', expected)
# for older GDAL versions (<2.0), id field will be integer type
if int(osgeo.gdal.VersionInfo()[:1]) < 2:
expected = expected.replace(b'<element type="long" name="id"/>', b'<element type="integer" name="id"/>')
self.assertXMLEqual(response, expected, msg="request %s failed.\n Query: %s\n Expected:\n%s\n\n Response:\n%s" % (query_string, request, expected.decode('utf-8'), response.decode('utf-8')))
示例4: wms_request_compare
def wms_request_compare(self, request, extra=None, reference_file=None):
project = self.testdata_path + "test_project.qgs"
assert os.path.exists(project), "Project file not found: " + project
query_string = 'MAP=%s&SERVICE=WMS&VERSION=1.3&REQUEST=%s' % (urllib.parse.quote(project), request)
if extra is not None:
query_string += extra
header, body = self.server.handleRequest(query_string)
response = header + body
reference_path = self.testdata_path + (request.lower() if not reference_file else reference_file) + '.txt'
f = open(reference_path, 'rb')
expected = f.read()
f.close()
# Store the output for debug or to regenerate the reference documents:
"""
f = open(reference_path, 'wb+')
f.write(response)
f.close()
f = open(os.path.dirname(__file__) + '/expected.txt', 'w+')
f.write(expected)
f.close()
f = open(os.path.dirname(__file__) + '/response.txt', 'w+')
f.write(response)
f.close()
#"""
response = re.sub(RE_STRIP_UNCHECKABLE, b'*****', response)
expected = re.sub(RE_STRIP_UNCHECKABLE, b'*****', expected)
self.assertXMLEqual(response, expected, msg="request %s failed.\n Query: %s\n Expected:\n%s\n\n Response:\n%s" % (query_string, request, expected.decode('utf-8'), response.decode('utf-8')))
示例5: wms_inspire_request_compare
def wms_inspire_request_compare(self, request):
"""WMS INSPIRE tests"""
project = self.testdata_path + "test_project_inspire.qgs"
assert os.path.exists(project), "Project file not found: " + project
query_string = "MAP=%s&SERVICE=WMS&VERSION=1.3.0&REQUEST=%s" % (urllib.parse.quote(project), request)
header, body = self.server.handleRequest(query_string)
response = header + body
f = open(self.testdata_path + request.lower() + "_inspire.txt", "rb")
expected = f.read()
f.close()
# Store the output for debug or to regenerate the reference documents:
"""
f = open(os.path.dirname(__file__) + '/expected.txt', 'w+')
f.write(expected)
f.close()
f = open(os.path.dirname(__file__) + '/response.txt', 'w+')
f.write(response)
f.close()
"""
response = re.sub(RE_STRIP_UNCHECKABLE, b"", response)
expected = re.sub(RE_STRIP_UNCHECKABLE, b"", expected)
self.assertXMLEqual(
response,
expected,
msg="request %s failed.\n Query: %s\n Expected:\n%s\n\n Response:\n%s"
% (query_string, request, expected.decode("utf-8"), response.decode("utf-8")),
)
示例6: wms_request_compare
def wms_request_compare(self, request, extra=None, reference_file=None, project='test_project.qgs', version='1.3.0', ignoreExtent=False, normalizeJson=False):
response_header, response_body, query_string = self.wms_request(request, extra, project, version)
response = response_header + response_body
reference_path = self.testdata_path + (request.lower() if not reference_file else reference_file) + '.txt'
self.store_reference(reference_path, response)
f = open(reference_path, 'rb')
expected = f.read()
def _n(r):
lines = r.split(b'\n')
b = lines[2:]
h = lines[:2]
try:
return b'\n'.join(h) + json.dumps(json.loads(b'\n'.join(b))).encode('utf8')
except:
return r
response = _n(response)
expected = _n(expected)
f.close()
response = re.sub(RE_STRIP_UNCHECKABLE, b'*****', response)
expected = re.sub(RE_STRIP_UNCHECKABLE, b'*****', expected)
if ignoreExtent:
response = re.sub(RE_STRIP_EXTENTS, b'*****', response)
expected = re.sub(RE_STRIP_EXTENTS, b'*****', expected)
msg = "request %s failed.\nQuery: %s\nExpected file: %s\nResponse:\n%s" % (query_string, request, reference_path, response.decode('utf-8'))
self.assertXMLEqual(response, expected, msg=msg)
示例7: wms_request_compare
def wms_request_compare(self, request, extra=None, reference_file=None, project='test_project.qgs', version='1.3.0'):
response_header, response_body, query_string = self.wms_request(request, extra, project, version)
response = response_header + response_body
reference_path = self.testdata_path + (request.lower() if not reference_file else reference_file) + '.txt'
self.store_reference(reference_path, response)
f = open(reference_path, 'rb')
expected = f.read()
f.close()
response = re.sub(RE_STRIP_UNCHECKABLE, b'*****', response)
expected = re.sub(RE_STRIP_UNCHECKABLE, b'*****', expected)
msg = "request %s failed.\nQuery: %s\nExpected file: %s\nResponse:\n%s" % (query_string, request, reference_path, response.decode('utf-8'))
self.assertXMLEqual(response, expected, msg=msg)
示例8: wms_inspire_request_compare
def wms_inspire_request_compare(self, request):
"""WMS INSPIRE tests"""
project = self.testdata_path + "test_project_inspire.qgs"
assert os.path.exists(project), "Project file not found: " + project
query_string = '?MAP=%s&SERVICE=WMS&VERSION=1.3.0&REQUEST=%s' % (urllib.parse.quote(project), request)
header, body = self._execute_request(query_string)
response = header + body
reference_path = self.testdata_path + request.lower() + '_inspire.txt'
self.store_reference(reference_path, response)
f = open(reference_path, 'rb')
expected = f.read()
f.close()
response = re.sub(RE_STRIP_UNCHECKABLE, b'', response)
expected = re.sub(RE_STRIP_UNCHECKABLE, b'', expected)
self.assertXMLEqual(response, expected, msg="request %s failed.\nQuery: %s\nExpected file: %s\nResponse:\n%s" % (query_string, request, reference_path, response.decode('utf-8')))
示例9: wcs_request_compare
def wcs_request_compare(self, request):
project = self.projectPath
assert os.path.exists(project), "Project file not found: " + project
query_string = '?MAP=%s&SERVICE=WCS&VERSION=1.0.0&REQUEST=%s' % (urllib.parse.quote(project), request)
header, body = self._execute_request(query_string)
self.assert_headers(header, body)
response = header + body
reference_path = self.testdata_path + 'wcs_' + request.lower() + '.txt'
f = open(reference_path, 'rb')
self.store_reference(reference_path, response)
expected = f.read()
f.close()
response = re.sub(RE_STRIP_UNCHECKABLE, b'', response)
expected = re.sub(RE_STRIP_UNCHECKABLE, b'', expected)
self.assertXMLEqual(response, expected, msg="request %s failed.\n Query: %s\n Expected:\n%s\n\n Response:\n%s" % (query_string, request, expected.decode('utf-8'), response.decode('utf-8')))
示例10: wms_request_compare
def wms_request_compare(self, request, extra=None, reference_file=None, project='test_project.qgs'):
project = self.testdata_path + project
assert os.path.exists(project), "Project file not found: " + project
query_string = 'https://www.qgis.org/?MAP=%s&SERVICE=WMS&VERSION=1.3&REQUEST=%s' % (urllib.parse.quote(project), request)
if extra is not None:
query_string += extra
header, body = self._execute_request(query_string)
response = header + body
reference_path = self.testdata_path + (request.lower() if not reference_file else reference_file) + '.txt'
self.store_reference(reference_path, response)
f = open(reference_path, 'rb')
expected = f.read()
f.close()
response = re.sub(RE_STRIP_UNCHECKABLE, b'*****', response)
expected = re.sub(RE_STRIP_UNCHECKABLE, b'*****', expected)
self.assertXMLEqual(response, expected, msg="request %s failed.\nQuery: %s\nExpected file: %s\nResponse:\n%s" % (query_string, request, reference_path, response.decode('utf-8')))