Merge branch 'tomkralidis-master'
This commit is contained in:
commit
3f2c87a665
|
@ -6,6 +6,7 @@ for convenience.
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from owslib.etree import etree
|
from owslib.etree import etree
|
||||||
|
from owslib.fes import PropertyIsEqualTo
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -64,23 +65,26 @@ class CswService(OwsService):
|
||||||
"""
|
"""
|
||||||
Perform various operations on a CSW service
|
Perform various operations on a CSW service
|
||||||
"""
|
"""
|
||||||
from owslib.csw import CatalogueServiceWeb as _Implementation
|
|
||||||
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,
|
|
||||||
"typenames": typenames,
|
"typenames": typenames,
|
||||||
"esn": esn,
|
"esn": esn,
|
||||||
"startposition": skip,
|
"startposition": skip,
|
||||||
"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,10 +96,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,
|
|
||||||
"typenames": typenames,
|
"typenames": typenames,
|
||||||
"esn": esn,
|
"esn": esn,
|
||||||
"startposition": startposition,
|
"startposition": startposition,
|
||||||
|
@ -105,9 +113,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
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
GeoAlchemy>=0.6
|
GeoAlchemy>=0.6
|
||||||
Shapely>=1.2.13
|
Shapely>=1.2.13
|
||||||
# Temporal requirement until there is an OWSLib release
|
OWSLib==0.8.2
|
||||||
# that requires python-dateutil<2.0
|
|
||||||
-e git+https://github.com/geopython/OWSLib.git@4b0a62cd37a5a03aafc5c0cd9606e0658d5ac664#egg=owslib
|
|
||||||
lxml>=2.3
|
lxml>=2.3
|
||||||
argparse
|
argparse
|
||||||
pyparsing==1.5.6
|
pyparsing==1.5.6
|
||||||
|
|
Loading…
Reference in New Issue