mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-07 00:03:52 -05:00
do not translate log messages
This commit is contained in:
parent
e9695d8007
commit
afb31e66a5
@ -50,8 +50,7 @@ class MetaSearchPlugin:
|
|||||||
"""startup"""
|
"""startup"""
|
||||||
|
|
||||||
# run
|
# run
|
||||||
log_message(QCoreApplication.translate(
|
log_message('Initializing plugin', Qgis.Info)
|
||||||
'MetaSearch', 'Initializing plugin'), Qgis.Info)
|
|
||||||
|
|
||||||
run_icon = QIcon('{}/{}'.format(self.context.ppath, 'images/MetaSearch.svg'))
|
run_icon = QIcon('{}/{}'.format(self.context.ppath, 'images/MetaSearch.svg'))
|
||||||
self.action_run = QAction(run_icon, 'MetaSearch',
|
self.action_run = QAction(run_icon, 'MetaSearch',
|
||||||
@ -83,8 +82,7 @@ class MetaSearchPlugin:
|
|||||||
def unload(self):
|
def unload(self):
|
||||||
"""teardown"""
|
"""teardown"""
|
||||||
|
|
||||||
log_message(QCoreApplication.translate(
|
log_message('Unloading plugin', Qgis.Info)
|
||||||
'MetaSearch', 'Unloading plugin'), Qgis.Info)
|
|
||||||
|
|
||||||
# remove the plugin menu item and icon
|
# remove the plugin menu item and icon
|
||||||
self.iface.removePluginWebMenu(self.web_menu, self.action_run)
|
self.iface.removePluginWebMenu(self.web_menu, self.action_run)
|
||||||
@ -94,8 +92,7 @@ class MetaSearchPlugin:
|
|||||||
def run(self):
|
def run(self):
|
||||||
"""open MetaSearch"""
|
"""open MetaSearch"""
|
||||||
|
|
||||||
log_message(QCoreApplication.translate(
|
log_message('Running plugin', Qgis.Info)
|
||||||
'MetaSearch', 'Running plugin'), Qgis.Info)
|
|
||||||
|
|
||||||
self.dialog.exec()
|
self.dialog.exec()
|
||||||
|
|
||||||
|
|||||||
@ -35,7 +35,6 @@ with warnings.catch_warnings():
|
|||||||
from owslib.csw import CatalogueServiceWeb # spellok
|
from owslib.csw import CatalogueServiceWeb # spellok
|
||||||
|
|
||||||
from qgis.core import Qgis
|
from qgis.core import Qgis
|
||||||
from qgis.PyQt.QtCore import QCoreApplication
|
|
||||||
|
|
||||||
if owslib.__version__ < '0.25':
|
if owslib.__version__ < '0.25':
|
||||||
OWSLIB_OAREC_SUPPORTED = False
|
OWSLIB_OAREC_SUPPORTED = False
|
||||||
@ -89,8 +88,7 @@ class CSW202Search(SearchBase):
|
|||||||
self.record_info_template = 'record_metadata_dc.html'
|
self.record_info_template = 'record_metadata_dc.html'
|
||||||
self.constraints = []
|
self.constraints = []
|
||||||
|
|
||||||
log_message(QCoreApplication.translate(
|
log_message(f'Connecting to CSW: {self.url}', Qgis.Info)
|
||||||
'MetaSearch', f'Connecting to CSW: {self.url}'), Qgis.Info)
|
|
||||||
self.conn = CatalogueServiceWeb(self.url, # spellok
|
self.conn = CatalogueServiceWeb(self.url, # spellok
|
||||||
timeout=self.timeout,
|
timeout=self.timeout,
|
||||||
username=self.username,
|
username=self.username,
|
||||||
@ -108,8 +106,7 @@ class CSW202Search(SearchBase):
|
|||||||
# even for a global bbox, if a spatial filter is applied, then
|
# even for a global bbox, if a spatial filter is applied, then
|
||||||
# the CSW server will skip records without a bbox
|
# the CSW server will skip records without a bbox
|
||||||
if bbox and bbox != ['-180', '-90', '180', '90']:
|
if bbox and bbox != ['-180', '-90', '180', '90']:
|
||||||
log_message(QCoreApplication.translate(
|
log_message(f'Setting bbox filter ({bbox})', Qgis.Info)
|
||||||
'MetaSearch', f'Setting bbox filter ({bbox})'), Qgis.Info)
|
|
||||||
minx, miny, maxx, maxy = bbox
|
minx, miny, maxx, maxy = bbox
|
||||||
self.constraints.append(BBox([miny, minx, maxy, maxx],
|
self.constraints.append(BBox([miny, minx, maxy, maxx],
|
||||||
crs='urn:ogc:def:crs:EPSG::4326'))
|
crs='urn:ogc:def:crs:EPSG::4326'))
|
||||||
@ -117,25 +114,20 @@ class CSW202Search(SearchBase):
|
|||||||
# keywords
|
# keywords
|
||||||
if keywords:
|
if keywords:
|
||||||
# TODO: handle multiple word searches
|
# TODO: handle multiple word searches
|
||||||
log_message(QCoreApplication.translate(
|
log_message(f'Setting csw:AnyText filter {keywords}', Qgis.Info)
|
||||||
'MetaSearch', f'Setting csw:AnyText filter {keywords}'),
|
|
||||||
Qgis.Info)
|
|
||||||
self.constraints.append(PropertyIsLike('csw:AnyText', keywords))
|
self.constraints.append(PropertyIsLike('csw:AnyText', keywords))
|
||||||
|
|
||||||
if len(self.constraints) > 1: # exclusive search (a && b)
|
if len(self.constraints) > 1: # exclusive search (a && b)
|
||||||
self.constraints = [self.constraints]
|
self.constraints = [self.constraints]
|
||||||
|
|
||||||
log_message(QCoreApplication.translate(
|
log_message('Searching CSW: {self.url}', Qgis.Info)
|
||||||
'MetaSearch', f'Searching CSW: {self.url}'), Qgis.Info)
|
|
||||||
self.conn.getrecords2(constraints=self.constraints, maxrecords=limit,
|
self.conn.getrecords2(constraints=self.constraints, maxrecords=limit,
|
||||||
startposition=offset, esn='full')
|
startposition=offset, esn='full')
|
||||||
|
|
||||||
self.matches = self.conn.results['matches']
|
self.matches = self.conn.results['matches']
|
||||||
self.returned = self.conn.results['returned']
|
self.returned = self.conn.results['returned']
|
||||||
log_message(QCoreApplication.translate(
|
log_message(f'Matches: {self.matches}', Qgis.Info)
|
||||||
'MetaSearch', f'Matches: {self.matches}'), Qgis.Info)
|
log_message(f'Returned: {self.returned}', Qgis.Info)
|
||||||
log_message(QCoreApplication.translate(
|
|
||||||
'MetaSearch', f'Returned: {self.returned}'), Qgis.Info)
|
|
||||||
|
|
||||||
self.request = self.conn.request
|
self.request = self.conn.request
|
||||||
self.response = self.conn.response
|
self.response = self.conn.response
|
||||||
@ -169,9 +161,7 @@ class CSW202Search(SearchBase):
|
|||||||
return recs
|
return recs
|
||||||
|
|
||||||
def get_record(self, identifier):
|
def get_record(self, identifier):
|
||||||
log_message(QCoreApplication.translate(
|
log_message(f'Searching CSW for record: {identifier}', Qgis.Info)
|
||||||
'MetaSearch', f'Searching CSW for record: {identifier}'),
|
|
||||||
Qgis.Info)
|
|
||||||
self.conn.getrecordbyid([identifier])
|
self.conn.getrecordbyid([identifier])
|
||||||
|
|
||||||
return self.conn.records[identifier]
|
return self.conn.records[identifier]
|
||||||
@ -195,8 +185,7 @@ class OARecSearch(SearchBase):
|
|||||||
self.record_collection = None
|
self.record_collection = None
|
||||||
|
|
||||||
if '/collections/' in self.url: # catalog is a collection
|
if '/collections/' in self.url: # catalog is a collection
|
||||||
log_message(QCoreApplication.translate(
|
log_message('OARec endpoint is a collection', Qgis.Info)
|
||||||
'MetaSearch', 'OARec endpoint is a collection'), Qgis.Info)
|
|
||||||
self.base_url, self.record_collection = self.url.split('/collections/') # noqa
|
self.base_url, self.record_collection = self.url.split('/collections/') # noqa
|
||||||
self.conn = Records(
|
self.conn = Records(
|
||||||
self.base_url, timeout=self.timeout, auth=self.auth)
|
self.base_url, timeout=self.timeout, auth=self.auth)
|
||||||
@ -209,8 +198,7 @@ class OARecSearch(SearchBase):
|
|||||||
pass
|
pass
|
||||||
self.request = self.conn.request
|
self.request = self.conn.request
|
||||||
else:
|
else:
|
||||||
log_message(QCoreApplication.translate(
|
log_message('OARec endpoint is not a collection', Qgis.Info)
|
||||||
'MetaSearch', 'OARec endpoint is not a collection'), Qgis.Info)
|
|
||||||
self.conn = Records(self.url, timeout=self.timeout, auth=self.auth)
|
self.conn = Records(self.url, timeout=self.timeout, auth=self.auth)
|
||||||
self.request = None
|
self.request = None
|
||||||
|
|
||||||
@ -228,26 +216,21 @@ class OARecSearch(SearchBase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
if keywords:
|
if keywords:
|
||||||
log_message(QCoreApplication.translate(
|
log_message(f'Setting keyword search {keywords}', Qgis.Info)
|
||||||
'MetaSearch', f'Setting keyword search {keywords}'), Qgis.Info)
|
|
||||||
params['q'] = keywords
|
params['q'] = keywords
|
||||||
if bbox and bbox != ['-180', '-90', '180', '90']:
|
if bbox and bbox != ['-180', '-90', '180', '90']:
|
||||||
log_message(QCoreApplication.translate(
|
log_message(f'Setting bbox search {bbox}', Qgis.Info)
|
||||||
'MetaSearch', f'Setting bbox search {bbox}'), Qgis.Info)
|
|
||||||
params['bbox'] = bbox
|
params['bbox'] = bbox
|
||||||
|
|
||||||
log_message(QCoreApplication.translate(
|
log_message(f'Searching OARec: {self.url}', Qgis.Info)
|
||||||
'MetaSearch', f'Searching OARec: {self.url}'), Qgis.Info)
|
|
||||||
self.response = self.conn.collection_items(**params)
|
self.response = self.conn.collection_items(**params)
|
||||||
|
|
||||||
self.matches = self.response.get('numberMatched', 0)
|
self.matches = self.response.get('numberMatched', 0)
|
||||||
self.returned = self.response.get('numberReturned', 0)
|
self.returned = self.response.get('numberReturned', 0)
|
||||||
self.request = self.conn.request
|
self.request = self.conn.request
|
||||||
|
|
||||||
log_message(QCoreApplication.translate(
|
log_message(f'Matches: {self.matches}', Qgis.Info)
|
||||||
'MetaSearch', f'Matches: {self.matches}'), Qgis.Info)
|
log_message(f'Returned: {self.returned}', Qgis.Info)
|
||||||
log_message(QCoreApplication.translate(
|
|
||||||
'MetaSearch', f'Returned: {self.returned}'), Qgis.Info)
|
|
||||||
|
|
||||||
def records(self):
|
def records(self):
|
||||||
recs = []
|
recs = []
|
||||||
@ -276,8 +259,7 @@ class OARecSearch(SearchBase):
|
|||||||
return recs
|
return recs
|
||||||
|
|
||||||
def get_record(self, identifier):
|
def get_record(self, identifier):
|
||||||
log_message(QCoreApplication.translate(
|
log_message(f'Searching OARec endpoint for item {identifier}',
|
||||||
'MetaSearch', f'Searching OARec endpoint for item {identifier}'),
|
|
||||||
Qgis.Info)
|
Qgis.Info)
|
||||||
return self.conn.collection_item(self.record_collection, identifier)
|
return self.conn.collection_item(self.record_collection, identifier)
|
||||||
|
|
||||||
@ -297,12 +279,10 @@ class OARecSearch(SearchBase):
|
|||||||
def get_catalog_service(url, catalog_type, timeout, username, password,
|
def get_catalog_service(url, catalog_type, timeout, username, password,
|
||||||
auth=None):
|
auth=None):
|
||||||
if catalog_type in [None, CATALOG_TYPES[0]]:
|
if catalog_type in [None, CATALOG_TYPES[0]]:
|
||||||
log_message(QCoreApplication.translate(
|
log_message('CSW endpoint detected', Qgis.Info)
|
||||||
'MetaSearch', 'CSW endpoint detected'), Qgis.Info)
|
|
||||||
return CSW202Search(url, timeout, username, password, auth)
|
return CSW202Search(url, timeout, username, password, auth)
|
||||||
elif catalog_type == CATALOG_TYPES[1]:
|
elif catalog_type == CATALOG_TYPES[1]:
|
||||||
log_message(QCoreApplication.translate(
|
log_message('OARec endpoint detected', Qgis.Info)
|
||||||
'MetaSearch', 'OARec endpoint detected'), Qgis.Info)
|
|
||||||
if not OWSLIB_OAREC_SUPPORTED:
|
if not OWSLIB_OAREC_SUPPORTED:
|
||||||
raise ValueError("OGC API - Records requires OWSLib 0.25 or above")
|
raise ValueError("OGC API - Records requires OWSLib 0.25 or above")
|
||||||
return OARecSearch(url, timeout, auth)
|
return OARecSearch(url, timeout, auth)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user