<s> import logging <EOL> import uuid <EOL> from six . moves import range <EOL> from six . moves . urllib . parse import urlparse <EOL> from owslib . util import build_get_url <EOL> from geolinks import sniff_link <EOL> from pycsw . core import util <EOL> from pycsw . core . etree import etree <EOL> LOGGER = logging . getLogger ( __name__ ) <EOL> def parse_record ( context , record , repos = None , <EOL> mtype = '<STR_LIT>' , <EOL> identifier = None , pagesize = <NUM_LIT:10> ) : <EOL> '''<STR_LIT>''' <EOL> if identifier is None : <EOL> identifier = uuid . uuid4 ( ) . urn <EOL> if ( mtype == '<STR_LIT>' and <EOL> isinstance ( record , str ) and record . startswith ( '<STR_LIT:http>' ) ) : <EOL> LOGGER . debug ( '<STR_LIT>' ) <EOL> try : <EOL> return _parse_csw ( context , repos , record , identifier , pagesize ) <EOL> except Exception as err : <EOL> if str ( err ) . find ( '<STR_LIT>' ) != - <NUM_LIT:1> : <EOL> msg = '<STR_LIT>' % str ( err ) <EOL> LOGGER . debug ( msg ) <EOL> raise RuntimeError ( msg ) <EOL> LOGGER . debug ( '<STR_LIT>' ) <EOL> try : <EOL> content = util . http_request ( '<STR_LIT:GET>' , record ) <EOL> except Exception as err : <EOL> raise RuntimeError ( '<STR_LIT>' % str ( err ) ) <EOL> return [ _parse_dc ( context , repos , etree . fromstring ( content , context . parser ) ) ] <EOL> elif mtype == '<STR_LIT>' : <EOL> LOGGER . debug ( '<STR_LIT>' ) <EOL> return _parse_waf ( context , repos , record , identifier ) <EOL> elif mtype == '<STR_LIT>' : <EOL> LOGGER . debug ( '<STR_LIT>' ) <EOL> return _parse_wms ( context , repos , record , identifier ) <EOL> elif mtype == '<STR_LIT>' : <EOL> LOGGER . debug ( '<STR_LIT>' ) <EOL> return _parse_wmts ( context , repos , record , identifier ) <EOL> elif mtype == '<STR_LIT>' : <EOL> LOGGER . debug ( '<STR_LIT>' ) <EOL> return [ _parse_wps ( context , repos , record , identifier ) ] <EOL> elif mtype == '<STR_LIT>' : <EOL> LOGGER . debug ( '<STR_LIT>' ) <EOL> return _parse_wfs ( context , repos , record , identifier ) <EOL> elif mtype == '<STR_LIT>' : <EOL> LOGGER . debug ( '<STR_LIT>' ) <EOL> return _parse_wcs ( context , repos , record , identifier ) <EOL> elif mtype == '<STR_LIT>' : <EOL> LOGGER . debug ( '<STR_LIT>' ) <EOL> return _parse_sos ( context , repos , record , identifier , '<STR_LIT>' ) <EOL> elif mtype == '<STR_LIT>' : <EOL> LOGGER . debug ( '<STR_LIT>' ) <EOL> return _parse_sos ( context , repos , record , identifier , '<STR_LIT>' ) <EOL> elif ( mtype == '<STR_LIT>' and <EOL> record . startswith ( '<STR_LIT:http>' ) ) : <EOL> LOGGER . debug ( '<STR_LIT>' ) <EOL> record = util . http_request ( '<STR_LIT:GET>' , record ) <EOL> return _parse_metadata ( context , repos , record ) <EOL> def _set ( context , obj , name , value ) : <EOL> '''<STR_LIT>''' <EOL> setattr ( obj , context . md_core_model [ '<STR_LIT>' ] [ name ] , value ) <EOL> def _parse_metadata ( context , repos , record ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( record , str ) : <EOL> exml = etree . fromstring ( record , context . parser ) <EOL> else : <EOL> if hasattr ( record , '<STR_LIT>' ) : <EOL> exml = record . getroot ( ) <EOL> else : <EOL> exml = record <EOL> root = exml . tag <EOL> LOGGER . debug ( '<STR_LIT>' ) <EOL> if root == '<STR_LIT>' % context . namespaces [ '<STR_LIT>' ] : <EOL> return [ _parse_iso ( context , repos , exml ) ] <EOL> elif root == '<STR_LIT>' : <EOL> return [ _parse_iso ( context , repos , exml ) ] <EOL> elif root == '<STR_LIT>' : <EOL> return [ _parse_fgdc ( context , repos , exml ) ] <EOL> elif root == '<STR_LIT>' % context . namespaces [ '<STR_LIT>' ] : <EOL> return [ _parse_gm03 ( context , repos , exml ) ] <EOL> elif root == '<STR_LIT>' % context . namespaces [ '<STR_LIT>' ] : <EOL> return [ _parse_dc ( context , repos , exml ) ] <EOL> elif root == '<STR_LIT>' % context . namespaces [ '<STR_LIT>' ] : <EOL> return [ _parse_dc ( context , repos , exml ) ] <EOL> elif root == '<STR_LIT>' % context . namespaces [ '<STR_LIT>' ] : <EOL> pass <EOL> else : <EOL> raise RuntimeError ( '<STR_LIT>' ) <EOL> def _parse_csw ( context , repos , record , identifier , pagesize = <NUM_LIT:10> ) : <EOL> from owslib . csw import CatalogueServiceWeb <EOL> recobjs = [ ] <EOL> serviceobj = repos . dataset ( ) <EOL> md = CatalogueServiceWeb ( record , timeout = <NUM_LIT> ) <EOL> LOGGER . debug ( '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , identifier ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , record ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , util . get_today_and_now ( ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , util . get_anytext ( md . _exml ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . title ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . abstract ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( md . identification . keywords ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . contact . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . contact . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . contact . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . accessconstraints ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . fees ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , record ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . type ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . version ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( [ d . name for d in md . operations ] ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> links = [ <EOL> '<STR_LIT>' % ( identifier , md . url ) <EOL> ] <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' . join ( links ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , caps2iso ( serviceobj , md , context ) ) <EOL> recobjs . append ( serviceobj ) <EOL> csw_typenames = '<STR_LIT>' <EOL> csw_outputschema = '<STR_LIT>' <EOL> grop = md . get_operation_by_name ( '<STR_LIT>' ) <EOL> if all ( [ '<STR_LIT>' in grop . parameters [ '<STR_LIT>' ] [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' in grop . parameters [ '<STR_LIT>' ] [ '<STR_LIT>' ] ] ) : <EOL> LOGGER . info ( '<STR_LIT>' ) <EOL> csw_typenames = '<STR_LIT>' <EOL> csw_outputschema = '<STR_LIT>' <EOL> try : <EOL> md . getrecords2 ( typenames = csw_typenames , resulttype = '<STR_LIT>' , <EOL> outputschema = csw_outputschema ) <EOL> matches = md . results [ '<STR_LIT>' ] <EOL> except : <EOL> raise RuntimeError ( md . response ) <EOL> if pagesize > matches : <EOL> pagesize = matches <EOL> LOGGER . debug ( '<STR_LIT>' % matches ) <EOL> for r in range ( <NUM_LIT:1> , matches + <NUM_LIT:1> , pagesize ) : <EOL> try : <EOL> md . getrecords2 ( typenames = csw_typenames , startposition = r , <EOL> maxrecords = pagesize , outputschema = csw_outputschema , esn = '<STR_LIT>' ) <EOL> except Exception as err : <EOL> raise RuntimeError ( md . response ) <EOL> for k , v in md . records . items ( ) : <EOL> try : <EOL> LOGGER . debug ( '<STR_LIT>' , v . xml ) <EOL> if csw_typenames == '<STR_LIT>' : <EOL> recobjs . append ( _parse_iso ( context , repos , <EOL> etree . fromstring ( v . xml , context . parser ) ) ) <EOL> else : <EOL> recobjs . append ( _parse_dc ( context , repos , <EOL> etree . fromstring ( v . xml , context . parser ) ) ) <EOL> except Exception as err : <EOL> LOGGER . warning ( '<STR_LIT>' , err ) <EOL> return recobjs <EOL> def _parse_waf ( context , repos , record , identifier ) : <EOL> recobjs = [ ] <EOL> content = util . http_request ( '<STR_LIT:GET>' , record ) <EOL> LOGGER . debug ( content ) <EOL> try : <EOL> parser = etree . HTMLParser ( ) <EOL> tree = etree . fromstring ( content , parser ) <EOL> except Exception as err : <EOL> raise Exception ( '<STR_LIT>' % str ( err ) ) <EOL> up = urlparse ( record ) <EOL> links = [ ] <EOL> LOGGER . debug ( '<STR_LIT>' ) <EOL> for link in tree . xpath ( '<STR_LIT>' ) : <EOL> link = link . strip ( ) <EOL> if not link : <EOL> continue <EOL> if link . find ( '<STR_LIT:?>' ) != - <NUM_LIT:1> : <EOL> continue <EOL> if not link . endswith ( '<STR_LIT>' ) : <EOL> LOGGER . debug ( '<STR_LIT>' ) <EOL> continue <EOL> if '<STR_LIT:/>' in link : <EOL> if link [ - <NUM_LIT:1> ] == '<STR_LIT:/>' : <EOL> continue <EOL> if link [ <NUM_LIT:0> ] == '<STR_LIT:/>' : <EOL> link = '<STR_LIT>' % ( up . scheme , up . netloc , link ) <EOL> else : <EOL> link = '<STR_LIT>' % ( record , link ) <EOL> LOGGER . debug ( '<STR_LIT>' , link ) <EOL> links . append ( link ) <EOL> LOGGER . debug ( '<STR_LIT>' , len ( links ) ) <EOL> for link in links : <EOL> LOGGER . debug ( '<STR_LIT>' , link ) <EOL> linkcontent = util . http_request ( '<STR_LIT:GET>' , link ) <EOL> recobj = _parse_metadata ( context , repos , linkcontent ) [ <NUM_LIT:0> ] <EOL> recobj . source = link <EOL> recobj . mdsource = link <EOL> recobjs . append ( recobj ) <EOL> return recobjs <EOL> def _parse_wms ( context , repos , record , identifier ) : <EOL> from owslib . wms import WebMapService <EOL> recobjs = [ ] <EOL> serviceobj = repos . dataset ( ) <EOL> md = WebMapService ( record ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , identifier ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , record ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , util . get_today_and_now ( ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , util . get_anytext ( md . getServiceXML ( ) ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . title ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . abstract ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( md . identification . keywords ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . contact . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . contact . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . contact . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . accessconstraints ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . fees ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , record ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . type ) <EOL> for c in md . contents : <EOL> if md . contents [ c ] . parent is None : <EOL> bbox = md . contents [ c ] . boundingBoxWGS84 <EOL> tmp = '<STR_LIT>' % ( bbox [ <NUM_LIT:0> ] , bbox [ <NUM_LIT:1> ] , bbox [ <NUM_LIT:2> ] , bbox [ <NUM_LIT:3> ] ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , util . bbox2wktpolygon ( tmp ) ) <EOL> break <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . version ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( [ d . name for d in md . operations ] ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( list ( md . contents ) ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> links = [ <EOL> '<STR_LIT>' % ( identifier , md . url ) , <EOL> ] <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' . join ( links ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , caps2iso ( serviceobj , md , context ) ) <EOL> recobjs . append ( serviceobj ) <EOL> LOGGER . debug ( '<STR_LIT>' % len ( md . contents ) ) <EOL> for layer in md . contents : <EOL> recobj = repos . dataset ( ) <EOL> identifier2 = '<STR_LIT>' % ( identifier , md . contents [ layer ] . name ) <EOL> _set ( context , recobj , '<STR_LIT>' , identifier2 ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , record ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . get_today_and_now ( ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , identifier ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . contents [ layer ] . title ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . contents [ layer ] . abstract ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( md . contents [ layer ] . keywords ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , <EOL> util . get_anytext ( [ md . contents [ layer ] . title , <EOL> md . contents [ layer ] . abstract , <EOL> '<STR_LIT:U+002C>' . join ( md . contents [ layer ] . keywords ) ] ) ) <EOL> bbox = md . contents [ layer ] . boundingBoxWGS84 <EOL> if bbox is not None : <EOL> tmp = '<STR_LIT>' % ( bbox [ <NUM_LIT:0> ] , bbox [ <NUM_LIT:1> ] , bbox [ <NUM_LIT:2> ] , bbox [ <NUM_LIT:3> ] ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . bbox2wktpolygon ( tmp ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> else : <EOL> bbox = md . contents [ layer ] . boundingBox <EOL> if bbox : <EOL> tmp = '<STR_LIT>' % ( bbox [ <NUM_LIT:0> ] , bbox [ <NUM_LIT:1> ] , bbox [ <NUM_LIT:2> ] , bbox [ <NUM_LIT:3> ] ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . bbox2wktpolygon ( tmp ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' % bbox [ - <NUM_LIT:1> ] . split ( '<STR_LIT::>' ) [ <NUM_LIT:1> ] ) <EOL> times = md . contents [ layer ] . timepositions <EOL> if times is not None : <EOL> time_begin = time_end = None <EOL> if len ( times ) == <NUM_LIT:1> and len ( times [ <NUM_LIT:0> ] . split ( '<STR_LIT:/>' ) ) > <NUM_LIT:1> : <EOL> time_envelope = times [ <NUM_LIT:0> ] . split ( '<STR_LIT:/>' ) <EOL> time_begin = time_envelope [ <NUM_LIT:0> ] <EOL> time_end = time_envelope [ <NUM_LIT:1> ] <EOL> elif len ( times ) > <NUM_LIT:1> : <EOL> time_begin = times [ <NUM_LIT:0> ] <EOL> time_end = times [ - <NUM_LIT:1> ] <EOL> if all ( [ time_begin is not None , time_end is not None ] ) : <EOL> _set ( context , recobj , '<STR_LIT>' , time_begin ) <EOL> _set ( context , recobj , '<STR_LIT>' , time_end ) <EOL> params = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:version>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : md . contents [ layer ] . name , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:width>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' % ( bbox [ <NUM_LIT:0> ] , bbox [ <NUM_LIT:1> ] , bbox [ <NUM_LIT:2> ] , bbox [ <NUM_LIT:3> ] ) , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> links = [ <EOL> '<STR_LIT>' % ( md . contents [ layer ] . name , md . url ) , <EOL> '<STR_LIT>' % ( md . contents [ layer ] . name , build_get_url ( md . url , params ) ) <EOL> ] <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' . join ( links ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , caps2iso ( recobj , md , context ) ) <EOL> recobjs . append ( recobj ) <EOL> return recobjs <EOL> def _parse_wmts ( context , repos , record , identifier ) : <EOL> from owslib . wmts import WebMapTileService <EOL> recobjs = [ ] <EOL> serviceobj = repos . dataset ( ) <EOL> md = WebMapTileService ( record ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , identifier ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , record ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , util . get_today_and_now ( ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , util . get_anytext ( md . getServiceXML ( ) ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . title ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . abstract ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( md . identification . keywords ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . contact . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . contact . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . contact . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . accessconstraints ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . fees ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , record ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . type ) <EOL> for c in md . contents : <EOL> if md . contents [ c ] . parent is None : <EOL> bbox = md . contents [ c ] . boundingBoxWGS84 <EOL> tmp = '<STR_LIT>' % ( bbox [ <NUM_LIT:0> ] , bbox [ <NUM_LIT:1> ] , bbox [ <NUM_LIT:2> ] , bbox [ <NUM_LIT:3> ] ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , util . bbox2wktpolygon ( tmp ) ) <EOL> break <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . version ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( [ d . name for d in md . operations ] ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( list ( md . contents ) ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> links = [ <EOL> '<STR_LIT>' % ( identifier , md . url ) , <EOL> ] <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' . join ( links ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , caps2iso ( serviceobj , md , context ) ) <EOL> recobjs . append ( serviceobj ) <EOL> LOGGER . debug ( '<STR_LIT>' % len ( md . contents ) ) <EOL> for layer in md . contents : <EOL> recobj = repos . dataset ( ) <EOL> keywords = '<STR_LIT>' <EOL> identifier2 = '<STR_LIT>' % ( identifier , md . contents [ layer ] . name ) <EOL> _set ( context , recobj , '<STR_LIT>' , identifier2 ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , record ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . get_today_and_now ( ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , identifier ) <EOL> if md . contents [ layer ] . title : <EOL> _set ( context , recobj , '<STR_LIT>' , md . contents [ layer ] . title ) <EOL> else : <EOL> _set ( context , recobj , '<STR_LIT>' , "<STR_LIT>" ) <EOL> if md . contents [ layer ] . abstract : <EOL> _set ( context , recobj , '<STR_LIT>' , md . contents [ layer ] . abstract ) <EOL> else : <EOL> _set ( context , recobj , '<STR_LIT>' , "<STR_LIT>" ) <EOL> if hasattr ( md . contents [ layer ] , '<STR_LIT>' ) : <EOL> keywords = '<STR_LIT:U+002C>' . join ( md . contents [ layer ] . keywords ) <EOL> _set ( context , recobj , '<STR_LIT>' , keywords ) <EOL> _set ( context , recobj , '<STR_LIT>' , <EOL> util . get_anytext ( [ md . contents [ layer ] . title , <EOL> md . contents [ layer ] . abstract , <EOL> '<STR_LIT:U+002C>' . join ( keywords ) <EOL> ] ) ) <EOL> bbox = md . contents [ layer ] . boundingBoxWGS84 <EOL> if bbox is not None : <EOL> tmp = '<STR_LIT>' % ( bbox [ <NUM_LIT:0> ] , bbox [ <NUM_LIT:1> ] , bbox [ <NUM_LIT:2> ] , bbox [ <NUM_LIT:3> ] ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . bbox2wktpolygon ( tmp ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> else : <EOL> bbox = md . contents [ layer ] . boundingBox <EOL> if bbox : <EOL> tmp = '<STR_LIT>' % ( bbox [ <NUM_LIT:0> ] , bbox [ <NUM_LIT:1> ] , bbox [ <NUM_LIT:2> ] , bbox [ <NUM_LIT:3> ] ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . bbox2wktpolygon ( tmp ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' % bbox [ - <NUM_LIT:1> ] . split ( '<STR_LIT::>' ) [ <NUM_LIT:1> ] ) <EOL> params = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:version>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : md . contents [ layer ] . name , <EOL> } <EOL> links = [ <EOL> '<STR_LIT>' % ( md . contents [ layer ] . name , md . url ) , <EOL> '<STR_LIT>' % ( md . contents [ layer ] . name , build_get_url ( md . url , params ) ) <EOL> ] <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' . join ( links ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , caps2iso ( recobj , md , context ) ) <EOL> recobjs . append ( recobj ) <EOL> return recobjs <EOL> def _parse_wfs ( context , repos , record , identifier ) : <EOL> from owslib . wfs import WebFeatureService <EOL> bboxs = [ ] <EOL> recobjs = [ ] <EOL> serviceobj = repos . dataset ( ) <EOL> md = WebFeatureService ( record , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , identifier ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , record ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , util . get_today_and_now ( ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , util . get_anytext ( etree . tostring ( md . _capabilities ) ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . title ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . abstract ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( md . identification . keywords ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . contact . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . contact . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . contact . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . accessconstraints ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . fees ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , record ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . type ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . version ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( [ d . name for d in md . operations ] ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( list ( md . contents ) ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> links = [ <EOL> '<STR_LIT>' % ( identifier , md . url ) <EOL> ] <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' . join ( links ) ) <EOL> LOGGER . debug ( '<STR_LIT>' % len ( md . contents ) ) <EOL> for featuretype in md . contents : <EOL> recobj = repos . dataset ( ) <EOL> identifier2 = '<STR_LIT>' % ( identifier , md . contents [ featuretype ] . id ) <EOL> _set ( context , recobj , '<STR_LIT>' , identifier2 ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , record ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . get_today_and_now ( ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , identifier ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . contents [ featuretype ] . title ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . contents [ featuretype ] . abstract ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( md . contents [ featuretype ] . keywords ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , <EOL> util . get_anytext ( [ md . contents [ featuretype ] . title , <EOL> md . contents [ featuretype ] . abstract , <EOL> '<STR_LIT:U+002C>' . join ( md . contents [ featuretype ] . keywords ) ] ) ) <EOL> bbox = md . contents [ featuretype ] . boundingBoxWGS84 <EOL> if bbox is not None : <EOL> tmp = '<STR_LIT>' % ( bbox [ <NUM_LIT:0> ] , bbox [ <NUM_LIT:1> ] , bbox [ <NUM_LIT:2> ] , bbox [ <NUM_LIT:3> ] ) <EOL> wkt_polygon = util . bbox2wktpolygon ( tmp ) <EOL> _set ( context , recobj , '<STR_LIT>' , wkt_polygon ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> bboxs . append ( wkt_polygon ) <EOL> params = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:version>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : md . contents [ featuretype ] . id , <EOL> } <EOL> links = [ <EOL> '<STR_LIT>' % ( md . contents [ featuretype ] . id , md . url ) , <EOL> '<STR_LIT>' % ( md . contents [ featuretype ] . id , build_get_url ( md . url , params ) ) <EOL> ] <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' . join ( links ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , caps2iso ( recobj , md , context ) ) <EOL> recobjs . append ( recobj ) <EOL> bbox_agg = util . bbox_from_polygons ( bboxs ) <EOL> if bbox_agg is not None : <EOL> _set ( context , serviceobj , '<STR_LIT>' , bbox_agg ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , caps2iso ( serviceobj , md , context ) ) <EOL> recobjs . insert ( <NUM_LIT:0> , serviceobj ) <EOL> return recobjs <EOL> def _parse_wcs ( context , repos , record , identifier ) : <EOL> from owslib . wcs import WebCoverageService <EOL> bboxs = [ ] <EOL> recobjs = [ ] <EOL> serviceobj = repos . dataset ( ) <EOL> md = WebCoverageService ( record , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , identifier ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , record ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , util . get_today_and_now ( ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , util . get_anytext ( etree . tostring ( md . _capabilities ) ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . title ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . abstract ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( md . identification . keywords ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . contact . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . contact . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . contact . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . accessConstraints ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . fees ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , record ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . type ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . version ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( [ d . name for d in md . operations ] ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( list ( md . contents ) ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> links = [ <EOL> '<STR_LIT>' % ( identifier , md . url ) <EOL> ] <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' . join ( links ) ) <EOL> LOGGER . debug ( '<STR_LIT>' % len ( md . contents ) ) <EOL> for coverage in md . contents : <EOL> recobj = repos . dataset ( ) <EOL> identifier2 = '<STR_LIT>' % ( identifier , md . contents [ coverage ] . id ) <EOL> _set ( context , recobj , '<STR_LIT>' , identifier2 ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , record ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . get_today_and_now ( ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , identifier ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . contents [ coverage ] . title ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . contents [ coverage ] . abstract ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( md . contents [ coverage ] . keywords ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , <EOL> util . get_anytext ( [ md . contents [ coverage ] . title , <EOL> md . contents [ coverage ] . abstract , <EOL> '<STR_LIT:U+002C>' . join ( md . contents [ coverage ] . keywords ) ] ) ) <EOL> bbox = md . contents [ coverage ] . boundingBoxWGS84 <EOL> if bbox is not None : <EOL> tmp = '<STR_LIT>' % ( bbox [ <NUM_LIT:0> ] , bbox [ <NUM_LIT:1> ] , bbox [ <NUM_LIT:2> ] , bbox [ <NUM_LIT:3> ] ) <EOL> wkt_polygon = util . bbox2wktpolygon ( tmp ) <EOL> _set ( context , recobj , '<STR_LIT>' , wkt_polygon ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> bboxs . append ( wkt_polygon ) <EOL> links = [ <EOL> '<STR_LIT>' % ( md . contents [ coverage ] . id , md . url ) <EOL> ] <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' . join ( links ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , caps2iso ( recobj , md , context ) ) <EOL> recobjs . append ( recobj ) <EOL> bbox_agg = util . bbox_from_polygons ( bboxs ) <EOL> if bbox_agg is not None : <EOL> _set ( context , serviceobj , '<STR_LIT>' , bbox_agg ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , caps2iso ( serviceobj , md , context ) ) <EOL> recobjs . insert ( <NUM_LIT:0> , serviceobj ) <EOL> return recobjs <EOL> def _parse_wps ( context , repos , record , identifier ) : <EOL> from owslib . wps import WebProcessingService <EOL> serviceobj = repos . dataset ( ) <EOL> md = WebProcessingService ( record ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , identifier ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , record ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , util . get_today_and_now ( ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , util . get_anytext ( md . _capabilities ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . title ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . abstract ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( md . identification . keywords ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . contact . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . contact . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . contact . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . accessconstraints ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . fees ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , record ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . type ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . version ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( [ d . name for d in md . operations ] ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( [ o . identifier for o in md . processes ] ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> links = [ <EOL> '<STR_LIT>' % ( identifier , md . url ) , <EOL> '<STR_LIT>' % ( identifier , build_get_url ( md . url , { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:version>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ) ) , <EOL> ] <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' . join ( links ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , caps2iso ( serviceobj , md , context ) ) <EOL> return serviceobj <EOL> def _parse_sos ( context , repos , record , identifier , version ) : <EOL> from owslib . sos import SensorObservationService <EOL> bboxs = [ ] <EOL> recobjs = [ ] <EOL> serviceobj = repos . dataset ( ) <EOL> if version == '<STR_LIT>' : <EOL> schema = '<STR_LIT>' <EOL> else : <EOL> schema = '<STR_LIT>' <EOL> md = SensorObservationService ( record , version = version ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , identifier ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , schema ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , record ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , util . get_today_and_now ( ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , util . get_anytext ( etree . tostring ( md . _capabilities ) ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . title ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . abstract ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( md . identification . keywords ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . contact . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . contact . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . provider . contact . name ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . accessconstraints ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . fees ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , record ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . type ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , md . identification . version ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( [ d . name for d in md . operations ] ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( list ( md . contents ) ) ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> links = [ <EOL> '<STR_LIT>' % ( identifier , md . url ) , <EOL> ] <EOL> _set ( context , serviceobj , '<STR_LIT>' , '<STR_LIT>' . join ( links ) ) <EOL> LOGGER . debug ( '<STR_LIT>' , len ( md . contents ) ) <EOL> for offering in md . contents : <EOL> recobj = repos . dataset ( ) <EOL> identifier2 = '<STR_LIT>' % ( identifier , md . contents [ offering ] . id ) <EOL> _set ( context , recobj , '<STR_LIT>' , identifier2 ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , schema ) <EOL> _set ( context , recobj , '<STR_LIT>' , record ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . get_today_and_now ( ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , identifier ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . contents [ offering ] . description ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . contents [ offering ] . description ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . datetime2iso8601 ( md . contents [ offering ] . begin_position ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . datetime2iso8601 ( md . contents [ offering ] . end_position ) ) <EOL> observed_properties = [ ] <EOL> for obs in md . contents [ offering ] . observed_properties : <EOL> if obs . lower ( ) . startswith ( ( '<STR_LIT>' , '<STR_LIT>' ) ) : <EOL> observed_properties . append ( obs . rsplit ( '<STR_LIT::>' , <NUM_LIT:1> ) [ - <NUM_LIT:1> ] ) <EOL> elif obs . lower ( ) . startswith ( ( '<STR_LIT>' , '<STR_LIT>' ) ) : <EOL> observed_properties . append ( obs . rsplit ( '<STR_LIT:/>' , <NUM_LIT:1> ) [ - <NUM_LIT:1> ] ) <EOL> else : <EOL> observed_properties . append ( obs ) <EOL> anytext = [ ] <EOL> anytext . append ( md . contents [ offering ] . description ) <EOL> anytext . extend ( observed_properties ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . get_anytext ( anytext ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( observed_properties ) ) <EOL> bbox = md . contents [ offering ] . bbox <EOL> if bbox is not None : <EOL> tmp = '<STR_LIT>' % ( bbox [ <NUM_LIT:0> ] , bbox [ <NUM_LIT:1> ] , bbox [ <NUM_LIT:2> ] , bbox [ <NUM_LIT:3> ] ) <EOL> wkt_polygon = util . bbox2wktpolygon ( tmp ) <EOL> _set ( context , recobj , '<STR_LIT>' , wkt_polygon ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . contents [ offering ] . bbox_srs . id ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> bboxs . append ( wkt_polygon ) <EOL> _set ( context , recobj , '<STR_LIT>' , caps2iso ( recobj , md , context ) ) <EOL> recobjs . append ( recobj ) <EOL> bbox_agg = util . bbox_from_polygons ( bboxs ) <EOL> if bbox_agg is not None : <EOL> _set ( context , serviceobj , '<STR_LIT>' , bbox_agg ) <EOL> _set ( context , serviceobj , '<STR_LIT>' , caps2iso ( serviceobj , md , context ) ) <EOL> recobjs . insert ( <NUM_LIT:0> , serviceobj ) <EOL> return recobjs <EOL> def _parse_fgdc ( context , repos , exml ) : <EOL> from owslib . fgdc import Metadata <EOL> recobj = repos . dataset ( ) <EOL> links = [ ] <EOL> md = Metadata ( exml ) <EOL> if md . idinfo . datasetid is not None : <EOL> _set ( context , recobj , '<STR_LIT>' , md . idinfo . datasetid ) <EOL> else : <EOL> _set ( context , recobj , '<STR_LIT>' , uuid . uuid1 ( ) . urn ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , context . namespaces [ '<STR_LIT>' ] ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . get_today_and_now ( ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . xml ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . get_anytext ( exml ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> if hasattr ( md . idinfo , '<STR_LIT>' ) : <EOL> _set ( context , recobj , '<STR_LIT>' , md . idinfo . descript . abstract ) <EOL> if hasattr ( md . idinfo , '<STR_LIT>' ) : <EOL> if md . idinfo . keywords . theme : <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( md . idinfo . keywords . theme [ <NUM_LIT:0> ] [ '<STR_LIT>' ] ) ) <EOL> if hasattr ( md . idinfo . timeperd , '<STR_LIT>' ) : <EOL> if hasattr ( md . idinfo . timeperd . timeinfo , '<STR_LIT>' ) : <EOL> _set ( context , recobj , '<STR_LIT>' , <EOL> md . idinfo . timeperd . timeinfo . rngdates . begdate ) <EOL> _set ( context , recobj , '<STR_LIT>' , <EOL> md . idinfo . timeperd . timeinfo . rngdates . enddate ) <EOL> if hasattr ( md . idinfo , '<STR_LIT>' ) : <EOL> _set ( context , recobj , '<STR_LIT>' , md . idinfo . origin ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . idinfo . origin ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . idinfo . origin ) <EOL> if hasattr ( md . idinfo , '<STR_LIT>' ) : <EOL> _set ( context , recobj , '<STR_LIT>' , md . idinfo . ptcontac . cntorg ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . idinfo . accconst ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . idinfo . useconst ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . metainfo . metd ) <EOL> if hasattr ( md . idinfo , '<STR_LIT>' ) and hasattr ( md . idinfo . spdom , '<STR_LIT>' ) : <EOL> bbox = md . idinfo . spdom . bbox <EOL> else : <EOL> bbox = None <EOL> if hasattr ( md . idinfo , '<STR_LIT>' ) : <EOL> if hasattr ( md . idinfo . citation , '<STR_LIT>' ) : <EOL> _set ( context , recobj , '<STR_LIT>' , md . idinfo . citation . citeinfo [ '<STR_LIT>' ] ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . idinfo . citation . citeinfo [ '<STR_LIT:title>' ] ) <EOL> _set ( context , recobj , <EOL> '<STR_LIT>' , md . idinfo . citation . citeinfo [ '<STR_LIT>' ] ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . idinfo . citation . citeinfo [ '<STR_LIT>' ] ) <EOL> if md . idinfo . citation . citeinfo [ '<STR_LIT>' ] : <EOL> for link in md . idinfo . citation . citeinfo [ '<STR_LIT>' ] : <EOL> tmp = '<STR_LIT>' % link <EOL> links . append ( tmp ) <EOL> if hasattr ( md , '<STR_LIT>' ) and hasattr ( md . distinfo , '<STR_LIT>' ) : <EOL> for link in md . distinfo . stdorder [ '<STR_LIT>' ] : <EOL> tmp = '<STR_LIT>' % ( link [ '<STR_LIT:name>' ] , link [ '<STR_LIT:url>' ] ) <EOL> links . append ( tmp ) <EOL> if len ( links ) > <NUM_LIT:0> : <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' . join ( links ) ) <EOL> if bbox is not None : <EOL> try : <EOL> tmp = '<STR_LIT>' % ( bbox . minx , bbox . miny , bbox . maxx , bbox . maxy ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . bbox2wktpolygon ( tmp ) ) <EOL> except : <EOL> _set ( context , recobj , '<STR_LIT>' , None ) <EOL> else : <EOL> _set ( context , recobj , '<STR_LIT>' , None ) <EOL> return recobj <EOL> def _parse_gm03 ( context , repos , exml ) : <EOL> def get_value_by_language ( pt_group , language , pt_type = '<STR_LIT:text>' ) : <EOL> for ptg in pt_group : <EOL> if ptg . language == language : <EOL> if pt_type == '<STR_LIT:url>' : <EOL> val = ptg . plain_url <EOL> else : <EOL> val = ptg . plain_text <EOL> return val <EOL> from owslib . gm03 import GM03 <EOL> recobj = repos . dataset ( ) <EOL> links = [ ] <EOL> md = GM03 ( exml ) <EOL> if hasattr ( md . data , '<STR_LIT>' ) : <EOL> data = md . data . core <EOL> elif hasattr ( md . data , '<STR_LIT>' ) : <EOL> data = md . data . comprehensive <EOL> language = data . metadata . language <EOL> _set ( context , recobj , '<STR_LIT>' , data . metadata . file_identifier ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , context . namespaces [ '<STR_LIT>' ] ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . get_today_and_now ( ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . xml ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . get_anytext ( exml ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , data . metadata . language ) <EOL> _set ( context , recobj , '<STR_LIT>' , data . metadata . hierarchy_level [ <NUM_LIT:0> ] ) <EOL> _set ( context , recobj , '<STR_LIT>' , data . metadata . date_stamp ) <EOL> for dt in data . date : <EOL> if dt . date_type == '<STR_LIT>' : <EOL> _set ( context , recobj , '<STR_LIT>' , data . date . date ) <EOL> elif dt . date_type == '<STR_LIT>' : <EOL> _set ( context , recobj , '<STR_LIT>' , data . date . date ) <EOL> elif dt . date_type == '<STR_LIT>' : <EOL> _set ( context , recobj , '<STR_LIT>' , data . date . date ) <EOL> elif dt . date_type == '<STR_LIT>' : <EOL> _set ( context , recobj , '<STR_LIT>' , data . date . date ) <EOL> if hasattr ( data , '<STR_LIT>' ) : <EOL> _set ( context , recobj , '<STR_LIT>' , data . metadata_point_of_contact . role ) <EOL> _set ( context , recobj , '<STR_LIT>' , data . metadata . dataset_uri ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> if hasattr ( data , '<STR_LIT>' ) : <EOL> _set ( context , recobj , '<STR_LIT>' , get_value_by_language ( data . citation . title . pt_group , language ) ) <EOL> if hasattr ( data , '<STR_LIT>' ) : <EOL> _set ( context , recobj , '<STR_LIT>' , get_value_by_language ( data . data_identification . abstract . pt_group , language ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , data . data_identification . topic_category ) <EOL> _set ( context , recobj , '<STR_LIT>' , data . data_identification . language ) <EOL> if hasattr ( data , '<STR_LIT>' ) : <EOL> _set ( context , recobj , '<STR_LIT>' , data . format . name ) <EOL> if hasattr ( data , '<STR_LIT>' ) : <EOL> try : <EOL> tmp = '<STR_LIT>' % ( data . geographic_bounding_box . west_bound_longitude , <EOL> data . geographic_bounding_box . south_bound_latitude , <EOL> data . geographic_bounding_box . east_bound_longitude , <EOL> data . geographic_bounding_box . north_bound_latitude ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . bbox2wktpolygon ( tmp ) ) <EOL> except : <EOL> _set ( context , recobj , '<STR_LIT>' , None ) <EOL> else : <EOL> _set ( context , recobj , '<STR_LIT>' , None ) <EOL> if hasattr ( data , '<STR_LIT>' ) : <EOL> if data . temporal_extent . extent [ '<STR_LIT>' ] is not None and data . temporal_extent . extent [ '<STR_LIT:end>' ] is not None : <EOL> _set ( context , recobj , '<STR_LIT>' , data . temporal_extent . extent [ '<STR_LIT>' ] ) <EOL> _set ( context , recobj , '<STR_LIT>' , data . temporal_extent . extent [ '<STR_LIT:end>' ] ) <EOL> name = description = protocol = '<STR_LIT>' <EOL> if hasattr ( data . online_resource , '<STR_LIT:name>' ) : <EOL> name = get_value_by_language ( data . online_resource . name . pt_group , language ) <EOL> if hasattr ( data . online_resource , '<STR_LIT:description>' ) : <EOL> description = get_value_by_language ( data . online_resource . description . pt_group , language ) <EOL> linkage = get_value_by_language ( data . online_resource . linkage . pt_group , language , '<STR_LIT:url>' ) <EOL> tmp = '<STR_LIT>' % ( name , description , protocol , linkage ) <EOL> links . append ( tmp ) <EOL> if len ( links ) > <NUM_LIT:0> : <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' . join ( links ) ) <EOL> keywords = [ ] <EOL> for kw in data . keywords : <EOL> keywords . append ( get_value_by_language ( kw . keyword . pt_group , language ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( keywords ) ) <EOL> return recobj <EOL> def _parse_iso ( context , repos , exml ) : <EOL> from owslib . iso import MD_Metadata <EOL> recobj = repos . dataset ( ) <EOL> links = [ ] <EOL> md = MD_Metadata ( exml ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . identifier ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , context . namespaces [ '<STR_LIT>' ] ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . get_today_and_now ( ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . xml ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . get_anytext ( exml ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . language ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . hierarchy ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . parentidentifier ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . datestamp ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . datestamp ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . dataseturi ) <EOL> if md . referencesystem is not None : <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' % <EOL> md . referencesystem . code ) <EOL> if hasattr ( md , '<STR_LIT>' ) : <EOL> _set ( context , recobj , '<STR_LIT>' , md . identification . title ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . identification . alternatetitle ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . identification . abstract ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . identification . aggregationinfo ) <EOL> if hasattr ( md . identification , '<STR_LIT>' ) : <EOL> _set ( context , recobj , '<STR_LIT>' , md . identification . temporalextent_start ) <EOL> if hasattr ( md . identification , '<STR_LIT>' ) : <EOL> _set ( context , recobj , '<STR_LIT>' , md . identification . temporalextent_end ) <EOL> if len ( md . identification . topiccategory ) > <NUM_LIT:0> : <EOL> _set ( context , recobj , '<STR_LIT>' , md . identification . topiccategory [ <NUM_LIT:0> ] ) <EOL> if len ( md . identification . resourcelanguage ) > <NUM_LIT:0> : <EOL> _set ( context , recobj , '<STR_LIT>' , md . identification . resourcelanguage [ <NUM_LIT:0> ] ) <EOL> if hasattr ( md . identification , '<STR_LIT>' ) : <EOL> bbox = md . identification . bbox <EOL> else : <EOL> bbox = None <EOL> if ( hasattr ( md . identification , '<STR_LIT>' ) and <EOL> len ( md . identification . keywords ) > <NUM_LIT:0> ) : <EOL> all_keywords = [ item for sublist in md . identification . keywords for item in sublist [ '<STR_LIT>' ] if item is not None ] <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( all_keywords ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . identification . keywords [ <NUM_LIT:0> ] [ '<STR_LIT:type>' ] ) <EOL> if ( hasattr ( md . identification , '<STR_LIT>' ) and <EOL> len ( md . identification . creator ) > <NUM_LIT:0> ) : <EOL> all_orgs = set ( [ item . organization for item in md . identification . creator if hasattr ( item , '<STR_LIT>' ) and item . organization is not None ] ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT:;>' . join ( all_orgs ) ) <EOL> if ( hasattr ( md . identification , '<STR_LIT>' ) and <EOL> len ( md . identification . publisher ) > <NUM_LIT:0> ) : <EOL> all_orgs = set ( [ item . organization for item in md . identification . publisher if hasattr ( item , '<STR_LIT>' ) and item . organization is not None ] ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT:;>' . join ( all_orgs ) ) <EOL> if ( hasattr ( md . identification , '<STR_LIT>' ) and <EOL> len ( md . identification . contributor ) > <NUM_LIT:0> ) : <EOL> all_orgs = set ( [ item . organization for item in md . identification . contributor if hasattr ( item , '<STR_LIT>' ) and item . organization is not None ] ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT:;>' . join ( all_orgs ) ) <EOL> if ( hasattr ( md . identification , '<STR_LIT>' ) and <EOL> len ( md . identification . contact ) > <NUM_LIT:0> ) : <EOL> all_orgs = set ( [ item . organization for item in md . identification . contact if hasattr ( item , '<STR_LIT>' ) and item . organization is not None ] ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT:;>' . join ( all_orgs ) ) <EOL> if len ( md . identification . securityconstraints ) > <NUM_LIT:0> : <EOL> _set ( context , recobj , '<STR_LIT>' , <EOL> md . identification . securityconstraints [ <NUM_LIT:0> ] ) <EOL> if len ( md . identification . accessconstraints ) > <NUM_LIT:0> : <EOL> _set ( context , recobj , '<STR_LIT>' , <EOL> md . identification . accessconstraints [ <NUM_LIT:0> ] ) <EOL> if len ( md . identification . otherconstraints ) > <NUM_LIT:0> : <EOL> _set ( context , recobj , '<STR_LIT>' , md . identification . otherconstraints [ <NUM_LIT:0> ] ) <EOL> if hasattr ( md . identification , '<STR_LIT:date>' ) : <EOL> for datenode in md . identification . date : <EOL> if datenode . type == '<STR_LIT>' : <EOL> _set ( context , recobj , '<STR_LIT>' , datenode . date ) <EOL> elif datenode . type == '<STR_LIT>' : <EOL> _set ( context , recobj , '<STR_LIT>' , datenode . date ) <EOL> elif datenode . type == '<STR_LIT>' : <EOL> _set ( context , recobj , '<STR_LIT>' , datenode . date ) <EOL> if hasattr ( md . identification , '<STR_LIT>' ) and hasattr ( md . identification . extent , '<STR_LIT>' ) : <EOL> _set ( context , recobj , '<STR_LIT>' , md . identification . extent . description_code ) <EOL> if len ( md . identification . denominators ) > <NUM_LIT:0> : <EOL> _set ( context , recobj , '<STR_LIT>' , md . identification . denominators [ <NUM_LIT:0> ] ) <EOL> if len ( md . identification . distance ) > <NUM_LIT:0> : <EOL> _set ( context , recobj , '<STR_LIT>' , md . identification . distance [ <NUM_LIT:0> ] ) <EOL> if len ( md . identification . uom ) > <NUM_LIT:0> : <EOL> _set ( context , recobj , '<STR_LIT>' , md . identification . uom [ <NUM_LIT:0> ] ) <EOL> if len ( md . identification . classification ) > <NUM_LIT:0> : <EOL> _set ( context , recobj , '<STR_LIT>' , md . identification . classification [ <NUM_LIT:0> ] ) <EOL> if len ( md . identification . uselimitation ) > <NUM_LIT:0> : <EOL> _set ( context , recobj , '<STR_LIT>' , <EOL> md . identification . uselimitation [ <NUM_LIT:0> ] ) <EOL> if hasattr ( md . identification , '<STR_LIT>' ) : <EOL> _set ( context , recobj , '<STR_LIT>' , md . distribution . format ) <EOL> if md . serviceidentification is not None : <EOL> _set ( context , recobj , '<STR_LIT>' , md . serviceidentification . type ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . serviceidentification . version ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . serviceidentification . couplingtype ) <EOL> service_types = [ ] <EOL> for smd in md . identificationinfo : <EOL> if smd . identtype == '<STR_LIT>' and smd . type is not None : <EOL> service_types . append ( smd . type ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( service_types ) ) <EOL> if hasattr ( md . identification , '<STR_LIT>' ) : <EOL> _set ( context , recobj , '<STR_LIT>' , md . dataquality . conformancedegree ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . dataquality . lineage ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . dataquality . specificationtitle ) <EOL> if hasattr ( md . dataquality , '<STR_LIT>' ) : <EOL> _set ( context , recobj , '<STR_LIT>' , <EOL> md . dataquality . specificationdate [ <NUM_LIT:0> ] . date ) <EOL> _set ( context , recobj , '<STR_LIT>' , <EOL> md . dataquality . specificationdate [ <NUM_LIT:0> ] . datetype ) <EOL> if hasattr ( md , '<STR_LIT>' ) and len ( md . contact ) > <NUM_LIT:0> : <EOL> _set ( context , recobj , '<STR_LIT>' , md . contact [ <NUM_LIT:0> ] . role ) <EOL> LOGGER . info ( '<STR_LIT>' ) <EOL> if hasattr ( md , '<STR_LIT>' ) : <EOL> dist_links = [ ] <EOL> if hasattr ( md . distribution , '<STR_LIT>' ) : <EOL> LOGGER . debug ( '<STR_LIT>' ) <EOL> dist_links . extend ( md . distribution . online ) <EOL> if hasattr ( md . distribution , '<STR_LIT>' ) : <EOL> LOGGER . debug ( '<STR_LIT>' ) <EOL> for dist_member in md . distribution . distributor : <EOL> dist_links . extend ( dist_member . online ) <EOL> for link in dist_links : <EOL> if link . url is not None and link . protocol is None : <EOL> link . protocol = sniff_link ( link . url ) <EOL> linkstr = '<STR_LIT>' % ( link . name , link . description , link . protocol , link . url ) <EOL> links . append ( linkstr ) <EOL> try : <EOL> LOGGER . debug ( '<STR_LIT>' ) <EOL> for sident in md . identificationinfo : <EOL> if hasattr ( sident , '<STR_LIT>' ) : <EOL> for sops in sident . operations : <EOL> for scpt in sops [ '<STR_LIT>' ] : <EOL> LOGGER . debug ( '<STR_LIT>' , scpt . url ) <EOL> linkstr = '<STR_LIT>' % ( scpt . name , scpt . description , scpt . protocol , scpt . url ) <EOL> links . append ( linkstr ) <EOL> except Exception as err : <EOL> LOGGER . debug ( '<STR_LIT>' ) <EOL> if len ( links ) > <NUM_LIT:0> : <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' . join ( links ) ) <EOL> if bbox is not None : <EOL> try : <EOL> tmp = '<STR_LIT>' % ( bbox . minx , bbox . miny , bbox . maxx , bbox . maxy ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . bbox2wktpolygon ( tmp ) ) <EOL> except : <EOL> _set ( context , recobj , '<STR_LIT>' , None ) <EOL> else : <EOL> _set ( context , recobj , '<STR_LIT>' , None ) <EOL> return recobj <EOL> def _parse_dc ( context , repos , exml ) : <EOL> from owslib . csw import CswRecord <EOL> recobj = repos . dataset ( ) <EOL> links = [ ] <EOL> md = CswRecord ( exml ) <EOL> if md . bbox is None : <EOL> bbox = None <EOL> else : <EOL> bbox = md . bbox <EOL> _set ( context , recobj , '<STR_LIT>' , md . identifier ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , context . namespaces [ '<STR_LIT>' ] ) <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . get_today_and_now ( ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . xml ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . get_anytext ( exml ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . language ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . type ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . title ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . alternative ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . abstract ) <EOL> if len ( md . subjects ) > <NUM_LIT:0> and None not in md . subjects : <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT:U+002C>' . join ( md . subjects ) ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . ispartof ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . relation ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . temporal ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . temporal ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . language ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . creator ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . publisher ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . contributor ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . rightsholder ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . accessrights ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . license ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . date ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . created ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . issued ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . modified ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . format ) <EOL> _set ( context , recobj , '<STR_LIT>' , md . source ) <EOL> for ref in md . references : <EOL> tmp = '<STR_LIT>' % ( ref [ '<STR_LIT>' ] , ref [ '<STR_LIT:url>' ] ) <EOL> links . append ( tmp ) <EOL> for uri in md . uris : <EOL> tmp = '<STR_LIT>' % ( uri [ '<STR_LIT:name>' ] , uri [ '<STR_LIT:description>' ] , uri [ '<STR_LIT>' ] , uri [ '<STR_LIT:url>' ] ) <EOL> links . append ( tmp ) <EOL> if len ( links ) > <NUM_LIT:0> : <EOL> _set ( context , recobj , '<STR_LIT>' , '<STR_LIT>' . join ( links ) ) <EOL> if bbox is not None : <EOL> try : <EOL> tmp = '<STR_LIT>' % ( bbox . minx , bbox . miny , bbox . maxx , bbox . maxy ) <EOL> _set ( context , recobj , '<STR_LIT>' , util . bbox2wktpolygon ( tmp ) ) <EOL> except : <EOL> _set ( context , recobj , '<STR_LIT>' , None ) <EOL> else : <EOL> _set ( context , recobj , '<STR_LIT>' , None ) <EOL> return recobj <EOL> def caps2iso ( record , caps , context ) : <EOL> """<STR_LIT>""" <EOL> from pycsw . plugins . profiles . apiso . apiso import APISO <EOL> apiso_obj = APISO ( context . model , context . namespaces , context ) <EOL> apiso_obj . ogc_schemas_base = '<STR_LIT>' <EOL> apiso_obj . url = context . url <EOL> queryables = dict ( apiso_obj . repository [ '<STR_LIT>' ] [ '<STR_LIT>' ] . items ( ) ) <EOL> iso_xml = apiso_obj . write_record ( record , '<STR_LIT>' , '<STR_LIT>' , queryables , caps ) <EOL> return etree . tostring ( iso_xml ) </s>
