Merge branch 'tomkralidis-master'

This commit is contained in:
amercader 2013-10-16 13:59:12 +01:00
commit 3f2c87a665
3 changed files with 24 additions and 16 deletions

View File

@ -6,6 +6,7 @@ for convenience.
import logging
from owslib.etree import etree
from owslib.fes import PropertyIsEqualTo
log = logging.getLogger(__name__)
@ -64,23 +65,26 @@ class CswService(OwsService):
"""
Perform various operations on a CSW service
"""
from owslib.csw import CatalogueServiceWeb as _Implementation
def getrecords(self, qtype=None, keywords=[],
typenames="csw:Record", esn="brief",
skip=0, count=10, outputschema="gmd", **kw):
from owslib.csw import namespaces
constraints = []
csw = self._ows(**kw)
if qtype is not None:
constraints.append(PropertyIsEqualTo("dc:type", qtype))
kwa = {
"qtype": qtype,
"keywords": keywords,
"constraints": constraints,
"typenames": typenames,
"esn": esn,
"startposition": skip,
"maxrecords": count,
"outputschema": namespaces[outputschema],
}
log.info('Making CSW request: getrecords %r', kwa)
csw.getrecords(**kwa)
log.info('Making CSW request: getrecords2 %r', kwa)
csw.getrecords2(**kwa)
if csw.exceptionreport:
err = 'Error getting records: %r' % \
csw.exceptionreport.exceptions
@ -92,10 +96,14 @@ class CswService(OwsService):
keywords=[], limit=None, page=10, outputschema="gmd",
startposition=0, **kw):
from owslib.csw import namespaces
constraints = []
csw = self._ows(**kw)
if qtype is not None:
constraints.append(PropertyIsEqualTo("dc:type", qtype))
kwa = {
"qtype": qtype,
"keywords": keywords,
"constraints": constraints,
"typenames": typenames,
"esn": esn,
"startposition": startposition,
@ -105,9 +113,9 @@ class CswService(OwsService):
i = 0
matches = 0
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:
err = 'Error getting identifiers: %r' % \
csw.exceptionreport.exceptions

View File

@ -4,6 +4,7 @@ from urllib2 import urlopen
import os
from owslib.csw import CatalogueServiceWeb
from owslib.fes import PropertyIsEqualTo
from owslib.iso import MD_Metadata
from pylons import config
from nose.plugins.skip import SkipTest
@ -137,7 +138,7 @@ class TestCswClient(CkanProcess):
# NB: This test fails because no records have been setup...
raise SkipTest() # therefore skip
csw = CatalogueServiceWeb(service)
csw.getrecords(outputschema=GMD, startposition=1, maxrecords=5)
csw.getrecords2(outputschema=GMD, startposition=1, maxrecords=5)
nrecords = len(csw.records)
#print csw.response[:1024]
assert nrecords == 5, nrecords
@ -147,19 +148,20 @@ class TestCswClient(CkanProcess):
def test_GetRecords_dataset(self):
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)
# TODO
def test_GetRecords_brief(self):
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)
# TODO
def test_GetRecords_summary(self):
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)
# TODO

View File

@ -1,8 +1,6 @@
GeoAlchemy>=0.6
Shapely>=1.2.13
# Temporal requirement until there is an OWSLib release
# that requires python-dateutil<2.0
-e git+https://github.com/geopython/OWSLib.git@4b0a62cd37a5a03aafc5c0cd9606e0658d5ac664#egg=owslib
OWSLib==0.8.2
lxml>=2.3
argparse
pyparsing==1.5.6