s/owslib.csw.getrecords/owslib.csw.getrecords2/g
This commit is contained in:
parent
662abc87e5
commit
1fdf0cde4c
|
@ -65,13 +65,19 @@ class CswService(OwsService):
|
||||||
Perform various operations on a CSW service
|
Perform various operations on a CSW service
|
||||||
"""
|
"""
|
||||||
from owslib.csw import CatalogueServiceWeb as _Implementation
|
from owslib.csw import CatalogueServiceWeb as _Implementation
|
||||||
|
from owslib.fes import PropertyIsEqualTo
|
||||||
def getrecords(self, qtype=None, keywords=[],
|
def getrecords(self, qtype=None, keywords=[],
|
||||||
typenames="csw:Record", esn="brief",
|
typenames="csw:Record", esn="brief",
|
||||||
skip=0, count=10, outputschema="gmd", **kw):
|
skip=0, count=10, outputschema="gmd", **kw):
|
||||||
from owslib.csw import namespaces
|
from owslib.csw import namespaces
|
||||||
|
constraints = []
|
||||||
csw = self._ows(**kw)
|
csw = self._ows(**kw)
|
||||||
|
|
||||||
|
if qtype is not None:
|
||||||
|
constraints.append(PropertyIsEqualTo("dc:type", qtype))
|
||||||
|
|
||||||
kwa = {
|
kwa = {
|
||||||
"qtype": qtype,
|
"constraints": constraints,
|
||||||
"keywords": keywords,
|
"keywords": keywords,
|
||||||
"typenames": typenames,
|
"typenames": typenames,
|
||||||
"esn": esn,
|
"esn": esn,
|
||||||
|
@ -79,8 +85,8 @@ class CswService(OwsService):
|
||||||
"maxrecords": count,
|
"maxrecords": count,
|
||||||
"outputschema": namespaces[outputschema],
|
"outputschema": namespaces[outputschema],
|
||||||
}
|
}
|
||||||
log.info('Making CSW request: getrecords %r', kwa)
|
log.info('Making CSW request: getrecords2 %r', kwa)
|
||||||
csw.getrecords(**kwa)
|
csw.getrecords2(**kwa)
|
||||||
if csw.exceptionreport:
|
if csw.exceptionreport:
|
||||||
err = 'Error getting records: %r' % \
|
err = 'Error getting records: %r' % \
|
||||||
csw.exceptionreport.exceptions
|
csw.exceptionreport.exceptions
|
||||||
|
@ -92,9 +98,14 @@ class CswService(OwsService):
|
||||||
keywords=[], limit=None, page=10, outputschema="gmd",
|
keywords=[], limit=None, page=10, outputschema="gmd",
|
||||||
startposition=0, **kw):
|
startposition=0, **kw):
|
||||||
from owslib.csw import namespaces
|
from owslib.csw import namespaces
|
||||||
|
constraints = []
|
||||||
csw = self._ows(**kw)
|
csw = self._ows(**kw)
|
||||||
|
|
||||||
|
if qtype is not None:
|
||||||
|
constraints.append(PropertyIsEqualTo("dc:type", qtype))
|
||||||
|
|
||||||
kwa = {
|
kwa = {
|
||||||
"qtype": qtype,
|
"constraints": constraints,
|
||||||
"keywords": keywords,
|
"keywords": keywords,
|
||||||
"typenames": typenames,
|
"typenames": typenames,
|
||||||
"esn": esn,
|
"esn": esn,
|
||||||
|
@ -105,9 +116,9 @@ class CswService(OwsService):
|
||||||
i = 0
|
i = 0
|
||||||
matches = 0
|
matches = 0
|
||||||
while True:
|
while True:
|
||||||
log.info('Making CSW request: getrecords %r', kwa)
|
log.info('Making CSW request: getrecords2 %r', kwa)
|
||||||
|
|
||||||
csw.getrecords(**kwa)
|
csw.getrecords2(**kwa)
|
||||||
if csw.exceptionreport:
|
if csw.exceptionreport:
|
||||||
err = 'Error getting identifiers: %r' % \
|
err = 'Error getting identifiers: %r' % \
|
||||||
csw.exceptionreport.exceptions
|
csw.exceptionreport.exceptions
|
||||||
|
|
|
@ -4,6 +4,7 @@ from urllib2 import urlopen
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from owslib.csw import CatalogueServiceWeb
|
from owslib.csw import CatalogueServiceWeb
|
||||||
|
from owslib.fes import PropertyIsEqualTo
|
||||||
from owslib.iso import MD_Metadata
|
from owslib.iso import MD_Metadata
|
||||||
from pylons import config
|
from pylons import config
|
||||||
from nose.plugins.skip import SkipTest
|
from nose.plugins.skip import SkipTest
|
||||||
|
@ -137,7 +138,7 @@ class TestCswClient(CkanProcess):
|
||||||
# NB: This test fails because no records have been setup...
|
# NB: This test fails because no records have been setup...
|
||||||
raise SkipTest() # therefore skip
|
raise SkipTest() # therefore skip
|
||||||
csw = CatalogueServiceWeb(service)
|
csw = CatalogueServiceWeb(service)
|
||||||
csw.getrecords(outputschema=GMD, startposition=1, maxrecords=5)
|
csw.getrecords2(outputschema=GMD, startposition=1, maxrecords=5)
|
||||||
nrecords = len(csw.records)
|
nrecords = len(csw.records)
|
||||||
#print csw.response[:1024]
|
#print csw.response[:1024]
|
||||||
assert nrecords == 5, nrecords
|
assert nrecords == 5, nrecords
|
||||||
|
@ -147,19 +148,20 @@ class TestCswClient(CkanProcess):
|
||||||
|
|
||||||
def test_GetRecords_dataset(self):
|
def test_GetRecords_dataset(self):
|
||||||
csw = CatalogueServiceWeb(service)
|
csw = CatalogueServiceWeb(service)
|
||||||
csw.getrecords(qtype="dataset", outputschema=GMD, startposition=1, maxrecords=5)
|
constraints = [PropertyIsEqualTo("dc:type", "dataset")]
|
||||||
|
csw.getrecords2(constraints=constraints, outputschema=GMD, startposition=1, maxrecords=5)
|
||||||
nrecords = len(csw.records)
|
nrecords = len(csw.records)
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
def test_GetRecords_brief(self):
|
def test_GetRecords_brief(self):
|
||||||
csw = CatalogueServiceWeb(service)
|
csw = CatalogueServiceWeb(service)
|
||||||
csw.getrecords(outputschema=GMD, startposition=1, maxrecords=5, esn="brief")
|
csw.getrecords2(outputschema=GMD, startposition=1, maxrecords=5, esn="brief")
|
||||||
nrecords = len(csw.records)
|
nrecords = len(csw.records)
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
def test_GetRecords_summary(self):
|
def test_GetRecords_summary(self):
|
||||||
csw = CatalogueServiceWeb(service)
|
csw = CatalogueServiceWeb(service)
|
||||||
csw.getrecords(outputschema=GMD, startposition=1, maxrecords=5, esn="summary")
|
csw.getrecords2(outputschema=GMD, startposition=1, maxrecords=5, esn="summary")
|
||||||
nrecords = len(csw.records)
|
nrecords = len(csw.records)
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue