<s> '''<STR_LIT>''' <EOL> __author__ = "<STR_LIT>" <EOL> __copyright__ = "<STR_LIT>" <EOL> __license__ = "<STR_LIT>" <EOL> from geoserver . support import ResourceInfo , DimensionInfo , xml_property , write_string , bbox , metadata , write_metadata , write_bbox , string_list , write_string_list , attribute_list , write_bool , url <EOL> def md_link ( node ) : <EOL> """<STR_LIT>""" <EOL> mimetype = node . find ( "<STR_LIT:type>" ) <EOL> mdtype = node . find ( "<STR_LIT>" ) <EOL> content = node . find ( "<STR_LIT:content>" ) <EOL> if None in [ mimetype , mdtype , content ] : <EOL> return None <EOL> else : <EOL> return ( mimetype . text , mdtype . text , content . text ) <EOL> def metadata_link_list ( node ) : <EOL> if node is not None : <EOL> return [ md_link ( n ) for n in node . findall ( "<STR_LIT>" ) ] <EOL> def write_metadata_link_list ( name ) : <EOL> def write ( builder , md_links ) : <EOL> builder . start ( name , dict ( ) ) <EOL> if md_links : <EOL> for ( mime , md_type , content_url ) in md_links : <EOL> if md_type not in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> mime = '<STR_LIT>' <EOL> md_type = '<STR_LIT>' <EOL> builder . start ( "<STR_LIT>" , dict ( ) ) <EOL> builder . start ( "<STR_LIT:type>" , dict ( ) ) <EOL> builder . data ( mime ) <EOL> builder . end ( "<STR_LIT:type>" ) <EOL> builder . start ( "<STR_LIT>" , dict ( ) ) <EOL> builder . data ( md_type ) <EOL> builder . end ( "<STR_LIT>" ) <EOL> builder . start ( "<STR_LIT:content>" , dict ( ) ) <EOL> builder . data ( content_url ) <EOL> builder . end ( "<STR_LIT:content>" ) <EOL> builder . end ( "<STR_LIT>" ) <EOL> builder . end ( name ) <EOL> return write <EOL> def featuretype_from_index ( catalog , workspace , store , node ) : <EOL> name = node . find ( "<STR_LIT:name>" ) <EOL> return FeatureType ( catalog , workspace , store , name . text ) <EOL> def coverage_from_index ( catalog , workspace , store , node ) : <EOL> name = node . find ( "<STR_LIT:name>" ) <EOL> return Coverage ( catalog , workspace , store , name . text ) <EOL> def wmslayer_from_index ( catalog , workspace , store , node ) : <EOL> name = node . find ( "<STR_LIT:name>" ) <EOL> return WmsLayer ( catalog , workspace , store , name . text ) <EOL> class _ResourceBase ( ResourceInfo ) : <EOL> save_method = '<STR_LIT>' <EOL> def __init__ ( self , catalog , workspace , store , name , href = None ) : <EOL> super ( _ResourceBase , self ) . __init__ ( ) <EOL> if not href : <EOL> assert isinstance ( store , ResourceInfo ) <EOL> assert isinstance ( name , basestring ) <EOL> assert workspace is not None <EOL> else : <EOL> parts = href . split ( '<STR_LIT:/>' ) <EOL> self . _workspace_name = parts [ parts . index ( '<STR_LIT>' ) + <NUM_LIT:1> ] <EOL> self . _store_name = parts [ parts . index ( self . url_part_stores ) + <NUM_LIT:1> ] <EOL> name = parts [ - <NUM_LIT:1> ] . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . _href = href <EOL> self . catalog = catalog <EOL> self . _workspace = workspace <EOL> self . _store = store <EOL> self . name = name <EOL> @ property <EOL> def workspace ( self ) : <EOL> if not self . _workspace : <EOL> self . _workspace = self . catalog . get_workspace ( self . _workspace_name ) <EOL> return self . _workspace <EOL> @ property <EOL> def store ( self ) : <EOL> if not self . _store : <EOL> self . _store = self . catalog . get_store ( self . _store_name , self . _workspace_name ) <EOL> return self . _store <EOL> @ property <EOL> def href ( self ) : <EOL> return self . _href or url ( self . catalog . service_url , <EOL> [ "<STR_LIT>" , self . workspace . name , <EOL> self . url_part_stores , self . store . name , <EOL> self . url_part_types , self . name + "<STR_LIT>" ] ) <EOL> class FeatureType ( _ResourceBase ) : <EOL> resource_type = "<STR_LIT>" <EOL> url_part_stores = '<STR_LIT>' <EOL> url_part_types = '<STR_LIT>' <EOL> title = xml_property ( "<STR_LIT:title>" ) <EOL> native_name = xml_property ( "<STR_LIT>" ) <EOL> abstract = xml_property ( "<STR_LIT>" ) <EOL> enabled = xml_property ( "<STR_LIT>" ) <EOL> advertised = xml_property ( "<STR_LIT>" , default = "<STR_LIT:true>" ) <EOL> native_bbox = xml_property ( "<STR_LIT>" , bbox ) <EOL> latlon_bbox = xml_property ( "<STR_LIT>" , bbox ) <EOL> projection = xml_property ( "<STR_LIT>" ) <EOL> projection_policy = xml_property ( "<STR_LIT>" ) <EOL> keywords = xml_property ( "<STR_LIT>" , string_list ) <EOL> attributes = xml_property ( "<STR_LIT>" , attribute_list ) <EOL> metadata_links = xml_property ( "<STR_LIT>" , metadata_link_list ) <EOL> metadata = xml_property ( "<STR_LIT>" , metadata ) <EOL> writers = dict ( <EOL> name = write_string ( "<STR_LIT:name>" ) , <EOL> nativeName = write_string ( "<STR_LIT>" ) , <EOL> title = write_string ( "<STR_LIT:title>" ) , <EOL> abstract = write_string ( "<STR_LIT>" ) , <EOL> enabled = write_bool ( "<STR_LIT>" ) , <EOL> advertised = write_bool ( "<STR_LIT>" ) , <EOL> nativeBoundingBox = write_bbox ( "<STR_LIT>" ) , <EOL> latLonBoundingBox = write_bbox ( "<STR_LIT>" ) , <EOL> srs = write_string ( "<STR_LIT>" ) , <EOL> nativeCRS = write_string ( "<STR_LIT>" ) , <EOL> projectionPolicy = write_string ( "<STR_LIT>" ) , <EOL> keywords = write_string_list ( "<STR_LIT>" ) , <EOL> metadataLinks = write_metadata_link_list ( "<STR_LIT>" ) , <EOL> metadata = write_metadata ( "<STR_LIT>" ) <EOL> ) <EOL> class CoverageDimension ( object ) : <EOL> def __init__ ( self , name , description , dimension_range ) : <EOL> self . name = name <EOL> self . description = description <EOL> self . dimension_range = dimension_range <EOL> def coverage_dimension ( node ) : <EOL> name = node . find ( "<STR_LIT:name>" ) <EOL> name = name . text if name is not None else None <EOL> description = node . find ( "<STR_LIT:description>" ) <EOL> description = description . text if description is not None else None <EOL> range_min = node . find ( "<STR_LIT>" ) <EOL> range_max = node . find ( "<STR_LIT>" ) <EOL> dimension_range = None <EOL> if None not in [ min , max ] : <EOL> dimension_range = float ( range_min . text ) , float ( range_max . text ) <EOL> if None not in [ name , description ] : <EOL> return CoverageDimension ( name , description , dimension_range ) <EOL> else : <EOL> return None <EOL> def coverage_dimension_xml ( builder , dimension ) : <EOL> builder . start ( "<STR_LIT>" , dict ( ) ) <EOL> builder . start ( "<STR_LIT:name>" , dict ( ) ) <EOL> builder . data ( dimension . name ) <EOL> builder . end ( "<STR_LIT:name>" ) <EOL> builder . start ( "<STR_LIT:description>" , dict ( ) ) <EOL> builder . data ( dimension . description ) <EOL> builder . end ( "<STR_LIT:description>" ) <EOL> if dimension . range is not None : <EOL> builder . start ( "<STR_LIT>" , dict ( ) ) <EOL> builder . start ( "<STR_LIT>" , dict ( ) ) <EOL> builder . data ( str ( dimension . range [ <NUM_LIT:0> ] ) ) <EOL> builder . end ( "<STR_LIT>" ) <EOL> builder . start ( "<STR_LIT>" , dict ( ) ) <EOL> builder . data ( str ( dimension . range [ <NUM_LIT:1> ] ) ) <EOL> builder . end ( "<STR_LIT>" ) <EOL> builder . end ( "<STR_LIT>" ) <EOL> builder . end ( "<STR_LIT>" ) <EOL> class Coverage ( _ResourceBase ) : <EOL> resource_type = "<STR_LIT>" <EOL> url_part_stores = '<STR_LIT>' <EOL> url_part_types = '<STR_LIT>' <EOL> title = xml_property ( "<STR_LIT:title>" ) <EOL> abstract = xml_property ( "<STR_LIT>" ) <EOL> enabled = xml_property ( "<STR_LIT>" ) <EOL> advertised = xml_property ( "<STR_LIT>" , default = "<STR_LIT:true>" ) <EOL> native_bbox = xml_property ( "<STR_LIT>" , bbox ) <EOL> latlon_bbox = xml_property ( "<STR_LIT>" , bbox ) <EOL> projection = xml_property ( "<STR_LIT>" ) <EOL> projection_policy = xml_property ( "<STR_LIT>" ) <EOL> keywords = xml_property ( "<STR_LIT>" , string_list ) <EOL> request_srs_list = xml_property ( "<STR_LIT>" , string_list ) <EOL> response_srs_list = xml_property ( "<STR_LIT>" , string_list ) <EOL> supported_formats = xml_property ( "<STR_LIT>" , string_list ) <EOL> metadata_links = xml_property ( "<STR_LIT>" , metadata_link_list ) <EOL> metadata = xml_property ( "<STR_LIT>" , metadata ) <EOL> writers = dict ( <EOL> title = write_string ( "<STR_LIT:title>" ) , <EOL> abstract = write_string ( "<STR_LIT>" ) , <EOL> enabled = write_bool ( "<STR_LIT>" ) , <EOL> advertised = write_bool ( "<STR_LIT>" ) , <EOL> nativeBoundingBox = write_bbox ( "<STR_LIT>" ) , <EOL> latLonBoundingBox = write_bbox ( "<STR_LIT>" ) , <EOL> srs = write_string ( "<STR_LIT>" ) , <EOL> projection_policy = write_string ( "<STR_LIT>" ) , <EOL> keywords = write_string_list ( "<STR_LIT>" ) , <EOL> metadataLinks = write_metadata_link_list ( "<STR_LIT>" ) , <EOL> requestSRS = write_string_list ( "<STR_LIT>" ) , <EOL> responseSRS = write_string_list ( "<STR_LIT>" ) , <EOL> supportedFormats = write_string_list ( "<STR_LIT>" ) , <EOL> metadata = write_metadata ( "<STR_LIT>" ) <EOL> ) <EOL> class WmsLayer ( ResourceInfo ) : <EOL> resource_type = "<STR_LIT>" <EOL> save_method = "<STR_LIT>" <EOL> def __init__ ( self , catalog , workspace , store , name ) : <EOL> super ( WmsLayer , self ) . __init__ ( ) <EOL> self . catalog = catalog <EOL> self . workspace = workspace <EOL> self . store = store <EOL> self . name = name <EOL> @ property <EOL> def href ( self ) : <EOL> return "<STR_LIT>" % ( <EOL> self . catalog . service_url , <EOL> self . workspace . name , <EOL> self . store . name , <EOL> self . name <EOL> ) <EOL> title = xml_property ( "<STR_LIT:title>" ) <EOL> description = xml_property ( "<STR_LIT:description>" ) <EOL> abstract = xml_property ( "<STR_LIT>" ) <EOL> keywords = xml_property ( "<STR_LIT>" , string_list ) <EOL> projection = xml_property ( "<STR_LIT>" ) <EOL> native_bbox = xml_property ( "<STR_LIT>" , bbox ) <EOL> latlon_bbox = xml_property ( "<STR_LIT>" , bbox ) <EOL> projection_policy = xml_property ( "<STR_LIT>" ) <EOL> enabled = xml_property ( "<STR_LIT>" , lambda x : x . text == "<STR_LIT:true>" ) <EOL> advertised = xml_property ( "<STR_LIT>" , lambda x : x . text == "<STR_LIT:true>" , default = True ) <EOL> metadata_links = xml_property ( "<STR_LIT>" , metadata_link_list ) <EOL> writers = dict ( <EOL> title = write_string ( "<STR_LIT:title>" ) , <EOL> description = write_string ( "<STR_LIT:description>" ) , <EOL> abstract = write_string ( "<STR_LIT>" ) , <EOL> keywords = write_string_list ( "<STR_LIT>" ) , <EOL> srs = write_string ( "<STR_LIT>" ) , <EOL> nativeBoundingBox = write_bbox ( "<STR_LIT>" ) , <EOL> latLonBoundingBox = write_bbox ( "<STR_LIT>" ) , <EOL> projectionPolicy = write_string ( "<STR_LIT>" ) , <EOL> enabled = write_bool ( "<STR_LIT>" ) , <EOL> advertised = write_bool ( "<STR_LIT>" ) , <EOL> metadataLinks = write_metadata_link_list ( "<STR_LIT>" ) <EOL> ) </s>
