<s> """<STR_LIT>""" <EOL> import cgi <EOL> import json <EOL> import mimetypes <EOL> import os <EOL> import re <EOL> import uuid <EOL> from . import compat <EOL> from . import geometry <EOL> from . import gptypes <EOL> from . import utils <EOL> USER_AGENT = "<STR_LIT>" <EOL> REQUEST_REFERER_MAGIC_NAME = "<STR_LIT>" <EOL> class RestURL ( object ) : <EOL> """<STR_LIT>""" <EOL> __cache_request__ = False <EOL> __urldata__ = Ellipsis <EOL> __json_struct__ = Ellipsis <EOL> __headers__ = Ellipsis <EOL> __has_json__ = True <EOL> __token__ = None <EOL> __lazy_fetch__ = True <EOL> __parent_type__ = None <EOL> __post__ = False <EOL> _parent = None <EOL> _referer = None <EOL> _pwdmgr = compat . urllib2 . HTTPPasswordMgrWithDefaultRealm ( ) <EOL> _cookiejar = compat . cookielib . CookieJar ( ) <EOL> _basic_handler = compat . urllib2 . HTTPBasicAuthHandler ( _pwdmgr ) <EOL> _digest_handler = compat . urllib2 . HTTPDigestAuthHandler ( _pwdmgr ) <EOL> _cookie_handler = compat . urllib2 . HTTPCookieProcessor ( _cookiejar ) <EOL> _opener = compat . urllib2 . build_opener ( _basic_handler , <EOL> _digest_handler , <EOL> _cookie_handler ) <EOL> compat . urllib2 . install_opener ( _opener ) <EOL> def __init__ ( self , url , file_data = None ) : <EOL> if isinstance ( url , compat . string_type ) : <EOL> url = compat . urlsplit ( url ) <EOL> self . __urldata__ = Ellipsis <EOL> urllist = list ( url ) <EOL> query_dict = { } <EOL> for k , v in cgi . parse_qs ( urllist [ <NUM_LIT:3> ] ) . items ( ) : <EOL> query_dict [ k ] = v [ <NUM_LIT:0> ] <EOL> if k . lower ( ) == '<STR_LIT>' : <EOL> self . __token__ = v [ <NUM_LIT:0> ] <EOL> elif k == REQUEST_REFERER_MAGIC_NAME : <EOL> self . _referer = v [ <NUM_LIT:0> ] <EOL> del query_dict [ REQUEST_REFERER_MAGIC_NAME ] <EOL> if self . __has_json__ is True : <EOL> query_dict [ '<STR_LIT:f>' ] = '<STR_LIT>' <EOL> if self . __token__ is not None : <EOL> query_dict [ '<STR_LIT>' ] = self . __token__ <EOL> urllist [ <NUM_LIT:3> ] = compat . urlencode ( query_dict ) <EOL> self . _url = urllist <EOL> self . _file_data = file_data <EOL> if file_data : <EOL> self . __cache_request__ = True <EOL> if self . __lazy_fetch__ is False and self . __cache_request__ is True : <EOL> self . _contents <EOL> def __repr__ ( self ) : <EOL> url = self . url <EOL> if len ( url ) > <NUM_LIT:100> : <EOL> url = url [ : <NUM_LIT> ] + "<STR_LIT>" <EOL> return "<STR_LIT>" % ( self . __class__ . __name__ , url ) <EOL> def _get_subfolder ( self , foldername , returntype , <EOL> params = None , file_data = None ) : <EOL> """<STR_LIT>""" <EOL> newurl = compat . urljoin ( self . url , compat . quote ( foldername ) , False ) <EOL> params = params or { } <EOL> file_data = file_data or { } <EOL> query_dict = { } <EOL> url_tuple = compat . urlsplit ( newurl ) <EOL> urllist = list ( url_tuple ) <EOL> if params : <EOL> query_dict = dict ( ( k , v [ <NUM_LIT:0> ] ) for k , v in <EOL> cgi . parse_qs ( urllist [ <NUM_LIT:3> ] ) . items ( ) ) <EOL> for key , val in params . items ( ) : <EOL> if isinstance ( val , bool ) : <EOL> query_dict [ key ] = str ( val ) . lower ( ) <EOL> elif isinstance ( val , geometry . Envelope ) : <EOL> query_dict [ key ] = val . bbox <EOL> elif isinstance ( val , gptypes . GPString ) : <EOL> query_dict [ key ] = val . value <EOL> elif isinstance ( val , geometry . SpatialReference ) : <EOL> query_dict [ key ] = val . wkid <EOL> elif isinstance ( val , ( list , tuple , set ) ) : <EOL> val = "<STR_LIT:U+002C>" . join ( [ str ( v . id ) <EOL> if isinstance ( v , Layer ) <EOL> else str ( v ) for v in val ] ) <EOL> elif isinstance ( val , dict ) : <EOL> val = json . dumps ( val ) <EOL> elif val is not None : <EOL> query_dict [ key ] = str ( val ) <EOL> if self . __token__ is not None : <EOL> query_dict [ '<STR_LIT>' ] = self . __token__ <EOL> query_dict [ REQUEST_REFERER_MAGIC_NAME ] = self . _referer or self . url <EOL> urllist [ <NUM_LIT:3> ] = compat . urlencode ( query_dict ) <EOL> newurl = urllist <EOL> rt = returntype ( newurl , file_data ) <EOL> try : <EOL> rt . parent = self <EOL> except : <EOL> rt . _parent = self <EOL> return rt <EOL> def _clear_cache ( self ) : <EOL> self . __json_struct__ = Ellipsis <EOL> self . __urldata__ = Ellipsis <EOL> @ property <EOL> def url ( self ) : <EOL> """<STR_LIT>""" <EOL> urlparts = self . _url <EOL> if self . __post__ : <EOL> urlparts = list ( urlparts ) <EOL> urlparts [ <NUM_LIT:3> ] = '<STR_LIT>' <EOL> if self . __token__ is not None : <EOL> urlparts [ <NUM_LIT:3> ] = compat . urlencode ( { '<STR_LIT>' : self . __token__ } ) <EOL> return compat . urlunsplit ( urlparts ) <EOL> @ property <EOL> def query ( self ) : <EOL> return compat . ensure_bytes ( self . _url [ <NUM_LIT:3> ] ) <EOL> @ property <EOL> def _headers ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . __headers__ is Ellipsis : <EOL> self . _contents <EOL> return self . __headers__ <EOL> @ property <EOL> def _contents ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . __urldata__ is Ellipsis or self . __cache_request__ is False : <EOL> if self . _file_data : <EOL> self . __post__ = True <EOL> boundary = "<STR_LIT:->" * <NUM_LIT:12> + str ( uuid . uuid4 ( ) ) + "<STR_LIT:$>" <EOL> multipart_data = '<STR_LIT>' <EOL> for k , v in cgi . parse_qs ( self . query ) . items ( ) : <EOL> if not isinstance ( v , list ) : <EOL> v = [ v ] <EOL> for val in v : <EOL> multipart_data += boundary + "<STR_LIT:\r\n>" <EOL> multipart_data += ( '<STR_LIT>' <EOL> '<STR_LIT>' % k ) <EOL> multipart_data += val + "<STR_LIT:\r\n>" <EOL> for k , v in self . _file_data . items ( ) : <EOL> fn = os . path . basename ( getattr ( v , '<STR_LIT:name>' , '<STR_LIT:file>' ) ) <EOL> ct = ( mimetypes . guess_type ( fn ) <EOL> or ( "<STR_LIT>" , ) ) [ <NUM_LIT:0> ] <EOL> multipart_data += boundary + "<STR_LIT:\r\n>" <EOL> multipart_data += ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % <EOL> ( k , fn , ct ) ) <EOL> multipart_data += v . read ( ) + "<STR_LIT:\r\n>" <EOL> multipart_data += boundary + "<STR_LIT>" <EOL> req_dict = { '<STR_LIT>' : USER_AGENT , <EOL> '<STR_LIT:Content-Type>' : <EOL> '<STR_LIT>' + boundary [ <NUM_LIT:2> : ] , <EOL> '<STR_LIT>' : str ( len ( multipart_data ) ) <EOL> } <EOL> if self . _referer : <EOL> req_dict [ '<STR_LIT>' ] = self . _referer <EOL> request = compat . urllib2 . Request ( self . url , <EOL> multipart_data , <EOL> req_dict ) <EOL> else : <EOL> req_dict = { '<STR_LIT>' : USER_AGENT } <EOL> if self . _referer : <EOL> req_dict [ '<STR_LIT>' ] = self . _referer <EOL> request = compat . urllib2 . Request ( self . url , self . query <EOL> if self . __post__ <EOL> else None , <EOL> req_dict ) <EOL> handle = compat . urllib2 . urlopen ( request ) <EOL> fetched_url = list ( compat . urlsplit ( handle . url ) [ : <NUM_LIT:3> ] ) <EOL> if fetched_url != list ( self . _url [ : <NUM_LIT:3> ] ) : <EOL> self . _url [ : <NUM_LIT:3> ] = fetched_url <EOL> return self . _contents <EOL> self . __headers__ = compat . get_headers ( handle ) <EOL> self . __urldata__ = handle . read ( ) <EOL> data = self . __urldata__ <EOL> if self . __cache_request__ is False : <EOL> self . __urldata__ = Ellipsis <EOL> return data <EOL> @ property <EOL> def _json_struct ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . __has_json__ : <EOL> if self . __cache_request__ : <EOL> if self . __json_struct__ is Ellipsis : <EOL> if self . _contents is not Ellipsis : <EOL> self . __json_struct__ = json . loads ( <EOL> compat . ensure_string ( self . _contents ) <EOL> . strip ( ) or '<STR_LIT:{}>' ) <EOL> else : <EOL> return { } <EOL> return self . __json_struct__ <EOL> else : <EOL> return json . loads ( compat . ensure_string ( self . _contents ) ) <EOL> else : <EOL> return { } <EOL> @ property <EOL> def parent ( self ) : <EOL> "<STR_LIT>" <EOL> if self . _parent : <EOL> return self . _parent <EOL> elif getattr ( self , '<STR_LIT>' , None ) : <EOL> return self . _get_subfolder ( '<STR_LIT:..>' if self . _url [ <NUM_LIT:2> ] . endswith ( '<STR_LIT:/>' ) <EOL> else '<STR_LIT:.>' , self . __parent_type__ ) <EOL> else : <EOL> raise AttributeError ( "<STR_LIT>" % type ( self ) ) <EOL> @ parent . setter <EOL> def parent ( self , val ) : <EOL> self . _parent = val <EOL> class AGOLoginToken ( RestURL ) : <EOL> """<STR_LIT>""" <EOL> __post__ = True <EOL> __cache_request__ = True <EOL> __lazy_fetch__ = False <EOL> __has_json__ = False <EOL> def __init__ ( self , origin_url , username , password ) : <EOL> if username is not None and password is not None : <EOL> self . _pwdmgr . add_password ( None , <EOL> origin_url , <EOL> username , <EOL> password ) <EOL> class GenerateToken ( RestURL ) : <EOL> """<STR_LIT>""" <EOL> __post__ = True <EOL> __cache_request__ = True <EOL> __lazy_fetch__ = False <EOL> def __init__ ( self , origin_url , username , password , expiration = <NUM_LIT> , <EOL> html_login = True ) : <EOL> if username is not None and password is not None : <EOL> self . _pwdmgr . add_password ( None , <EOL> origin_url , <EOL> username , <EOL> password ) <EOL> self . _html_login = html_login <EOL> self . _expiration = expiration <EOL> url1 = compat . urljoin ( origin_url , '<STR_LIT>' , False ) <EOL> url2 = compat . urljoin ( origin_url , '<STR_LIT>' , False ) <EOL> url3 = compat . urljoin ( origin_url , '<STR_LIT>' , False ) <EOL> url4 = compat . urljoin ( origin_url , '<STR_LIT>' , False ) <EOL> url5 = compat . urljoin ( origin_url , '<STR_LIT>' , False ) <EOL> self . _referer = url1 <EOL> for url in ( url1 , url2 , url3 , url4 , url5 ) : <EOL> try : <EOL> self . _referer = url <EOL> url_tuple = compat . urlsplit ( url ) <EOL> urllist = list ( url_tuple ) <EOL> query_dict = dict ( ( k , v [ <NUM_LIT:0> ] ) for k , v in <EOL> cgi . parse_qs ( urllist [ <NUM_LIT:3> ] ) . items ( ) ) <EOL> query_dict [ '<STR_LIT:username>' ] = username <EOL> query_dict [ '<STR_LIT:password>' ] = password <EOL> self . _username = username <EOL> self . _password = password <EOL> query_dict [ '<STR_LIT>' ] = str ( self . _expiration ) <EOL> query_dict [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> urllist [ <NUM_LIT:3> ] = compat . urlencode ( query_dict ) <EOL> url = compat . urlunsplit ( urllist ) <EOL> super ( GenerateToken , self ) . __init__ ( url ) <EOL> self . _json_struct [ '<STR_LIT>' ] <EOL> return <EOL> except compat . urllib2 . HTTPError : <EOL> pass <EOL> except KeyError : <EOL> pass <EOL> raise compat . urllib2 . HTTPError ( origin_url , <NUM_LIT> , "<STR_LIT>" <EOL> . format ( origin_url ) , None , None ) <EOL> @ property <EOL> def token ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def _contents ( self ) : <EOL> try : <EOL> return super ( GenerateToken , self ) . _contents <EOL> except compat . urllib2 . HTTPError : <EOL> if self . _html_login : <EOL> username , password = self . _username , self . _password <EOL> payload = { '<STR_LIT:username>' : username , <EOL> '<STR_LIT:password>' : password , <EOL> '<STR_LIT>' : '<STR_LIT:/>' } <EOL> for formurl in re . findall ( '<STR_LIT>' , <EOL> compat . urllib2 . urlopen ( self . _referer ) <EOL> . read ( ) ) : <EOL> relurl = compat . urljoin ( self . _referer , formurl ) <EOL> try : <EOL> html_request = compat . urllib2 . Request ( relurl , <EOL> compat . urlencode ( <EOL> payload ) , <EOL> { '<STR_LIT>' : <EOL> self . _referer } ) <EOL> html_response = compat . urllib2 . urlopen ( html_request ) . read ( ) <EOL> redirect_value = [ re . findall ( '<STR_LIT>' , input ) <EOL> for input in <EOL> re . findall ( <EOL> '<STR_LIT>' , <EOL> html_response ) ] <EOL> if redirect_value : <EOL> redirect = redirect_value [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] <EOL> else : <EOL> redirect = None <EOL> for href in re . findall ( '<STR_LIT>' , <EOL> html_response ) : <EOL> if '<STR_LIT>' in href . lower ( ) : <EOL> try : <EOL> gentokenurl = compat . urljoin ( relurl , <EOL> href ) <EOL> gentokenpayload = { '<STR_LIT:username>' : username , <EOL> '<STR_LIT:password>' : password , <EOL> '<STR_LIT>' : <EOL> str ( <EOL> self . _expiration ) , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:f>' : '<STR_LIT>' } <EOL> if redirect : <EOL> gentokenpayload [ '<STR_LIT>' ] = redirect <EOL> self . __urldata__ = compat . urlopen ( <EOL> gentokenurl , <EOL> compat . urlencode ( <EOL> gentokenpayload ) <EOL> ) . read ( ) <EOL> if self . __urldata__ : <EOL> return self . __urldata__ <EOL> except compat . HTTPError : <EOL> pass <EOL> except compat . urllib2 . HTTPError : <EOL> pass <EOL> return self . __urldata__ or '<STR_LIT:{}>' <EOL> else : <EOL> raise <EOL> class Folder ( RestURL ) : <EOL> """<STR_LIT>""" <EOL> __cache_request__ = True <EOL> _service_type_mapping = { } <EOL> @ classmethod <EOL> def _register_service_type ( cls , subclass ) : <EOL> """<STR_LIT>""" <EOL> if hasattr ( subclass , '<STR_LIT>' ) : <EOL> cls . _service_type_mapping [ subclass . __service_type__ ] = subclass <EOL> if subclass . __service_type__ : <EOL> setattr ( subclass , <EOL> subclass . __service_type__ , <EOL> property ( lambda x : x ) ) <EOL> return subclass <EOL> @ property <EOL> def __members__ ( self ) : <EOL> return sorted ( self . foldernames + <EOL> list ( self . servicenames ) + <EOL> self . clusternames ) <EOL> @ property <EOL> def foldernames ( self ) : <EOL> "<STR_LIT>" <EOL> return [ folder . strip ( '<STR_LIT:/>' ) . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] for folder <EOL> in self . _json_struct . get ( '<STR_LIT>' , [ ] ) ] <EOL> @ property <EOL> def folders ( self ) : <EOL> "<STR_LIT>" <EOL> return [ self . _get_subfolder ( fn + '<STR_LIT:/>' , Folder ) for fn in self . foldernames ] <EOL> @ property <EOL> def clusternames ( self ) : <EOL> "<STR_LIT>" <EOL> return [ cluster . strip ( '<STR_LIT:/>' ) . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] for cluster <EOL> in self . _json_struct . get ( '<STR_LIT>' , [ ] ) ] <EOL> @ property <EOL> def clusters ( self ) : <EOL> "<STR_LIT>" <EOL> return [ self . _get_subfolder ( fn + '<STR_LIT:/>' , Folder ) for fn in self . clusternames ] <EOL> @ property <EOL> def servicenames ( self ) : <EOL> "<STR_LIT>" <EOL> return set ( [ service [ '<STR_LIT:name>' ] . rstrip ( '<STR_LIT:/>' ) . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] <EOL> for service in self . _json_struct . get ( '<STR_LIT>' , [ ] ) ] ) <EOL> @ property <EOL> def services ( self ) : <EOL> "<STR_LIT>" <EOL> return [ self . _get_subfolder ( "<STR_LIT>" % <EOL> ( s [ '<STR_LIT:name>' ] . rstrip ( '<STR_LIT:/>' ) . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] , s [ '<STR_LIT:type>' ] ) , <EOL> self . _service_type_mapping . get ( s [ '<STR_LIT:type>' ] , Service ) ) for s <EOL> in self . _json_struct . get ( '<STR_LIT>' , [ ] ) ] <EOL> @ property <EOL> def url ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . _url [ <NUM_LIT:2> ] . endswith ( '<STR_LIT:/>' ) : <EOL> self . _url [ <NUM_LIT:2> ] += '<STR_LIT:/>' <EOL> return RestURL . url . __get__ ( self ) <EOL> def __getattr__ ( self , attr ) : <EOL> return self [ attr ] <EOL> def __getitem__ ( self , attr ) : <EOL> if attr in self . foldernames : <EOL> return self . _get_subfolder ( attr , Folder ) <EOL> elif attr in self . clusternames : <EOL> return self . _get_subfolder ( attr , Folder ) <EOL> services = [ x . copy ( ) for x in self . _json_struct [ '<STR_LIT>' ] ] <EOL> for service in services : <EOL> service [ '<STR_LIT:name>' ] = service [ '<STR_LIT:name>' ] . rstrip ( '<STR_LIT:/>' ) . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] <EOL> if '<STR_LIT:_>' in attr : <EOL> al = attr . rstrip ( '<STR_LIT:/>' ) . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] . split ( '<STR_LIT:_>' ) <EOL> servicetype = al . pop ( ) <EOL> untyped_attr = '<STR_LIT:_>' . join ( al ) <EOL> matchingservices = [ svc for svc in services <EOL> if svc [ '<STR_LIT:name>' ] == untyped_attr <EOL> and svc [ '<STR_LIT:type>' ] == servicetype ] <EOL> if len ( matchingservices ) == <NUM_LIT:1> : <EOL> return self . _get_subfolder ( "<STR_LIT>" % <EOL> ( untyped_attr , servicetype ) , <EOL> self . _service_type_mapping . get ( servicetype , Service ) ) <EOL> matchingservices = [ svc for svc in services if svc [ '<STR_LIT:name>' ] == attr ] <EOL> if len ( matchingservices ) > <NUM_LIT:1> : <EOL> class AmbiguousService ( object ) : <EOL> """<STR_LIT>""" <EOL> ambiguous = AmbiguousService ( ) <EOL> for svc in matchingservices : <EOL> attr , servicetype = svc [ '<STR_LIT:name>' ] , svc [ '<STR_LIT:type>' ] <EOL> service = self . _get_subfolder ( "<STR_LIT>" % ( attr , servicetype ) , <EOL> self . _service_type_mapping . get ( servicetype , Service ) ) <EOL> setattr ( ambiguous , servicetype , service ) <EOL> return ambiguous <EOL> elif len ( matchingservices ) == <NUM_LIT:1> : <EOL> servicetype = matchingservices [ <NUM_LIT:0> ] [ '<STR_LIT:type>' ] <EOL> return self . _get_subfolder ( "<STR_LIT>" % ( attr , servicetype ) , <EOL> self . _service_type_mapping . get ( servicetype , Service ) ) <EOL> raise AttributeError ( "<STR_LIT>" % attr ) <EOL> class Catalog ( Folder ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , url , username = None , password = None , token = None , <EOL> generate_token = False , expiration = <NUM_LIT> , ago_login = False ) : <EOL> """<STR_LIT>""" <EOL> if username is not None and password is not None : <EOL> self . _pwdmgr . add_password ( None , <EOL> url , <EOL> username , <EOL> password ) <EOL> url_ = list ( compat . urlsplit ( url ) ) <EOL> if not url_ [ <NUM_LIT:2> ] . endswith ( '<STR_LIT:/>' ) : <EOL> url_ [ <NUM_LIT:2> ] += "<STR_LIT:/>" <EOL> if token is not None : <EOL> self . __token__ = token <EOL> elif ago_login and generate_token : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> elif ago_login : <EOL> new_url = compat . urlunsplit ( url_ ) <EOL> agologin = AGOLoginToken ( url , username , password ) <EOL> self . __token__ = agologin . token <EOL> elif generate_token : <EOL> new_url = compat . urlunsplit ( url_ ) <EOL> gentoken = GenerateToken ( url , username , password , expiration ) <EOL> self . _referer = gentoken . _referer <EOL> self . __token__ = gentoken . token <EOL> super ( Catalog , self ) . __init__ ( url_ ) <EOL> assert '<STR_LIT>' in self . _json_struct , "<STR_LIT>" <EOL> assert '<STR_LIT>' in self . _json_struct , "<STR_LIT>" <EOL> @ property <EOL> def currentVersion ( self ) : <EOL> return self . _json_struct . get ( '<STR_LIT>' , <NUM_LIT> ) <EOL> class Service ( RestURL ) : <EOL> """<STR_LIT>""" <EOL> __cache_request__ = True <EOL> __service_type__ = None <EOL> __parent_type__ = Folder <EOL> def __init__ ( self , url , file_data = None ) : <EOL> if not isinstance ( url , ( tuple , list ) ) : <EOL> url_ = list ( compat . urlsplit ( url ) ) <EOL> else : <EOL> url_ = url <EOL> if not url_ [ <NUM_LIT:2> ] . endswith ( '<STR_LIT:/>' ) : <EOL> url_ [ <NUM_LIT:2> ] += "<STR_LIT:/>" <EOL> super ( Service , self ) . __init__ ( url_ , file_data ) <EOL> @ property <EOL> def serviceDescription ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _json_struct . get ( '<STR_LIT>' , None ) <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . __service_type__ , <EOL> "<STR_LIT>" % self . serviceDescription <EOL> if self . serviceDescription <EOL> else '<STR_LIT>' , <EOL> self . url ) <EOL> class ServerError ( Exception ) : <EOL> """<STR_LIT>""" <EOL> class Result ( RestURL ) : <EOL> """<STR_LIT>""" <EOL> __cache_request__ = True <EOL> __lazy_fetch__ = False <EOL> class BinaryResult ( Result ) : <EOL> """<STR_LIT>""" <EOL> __has_json__ = False <EOL> @ property <EOL> def data ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _contents <EOL> def save ( self , outfile ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( outfile , compat . string_type ) : <EOL> outfile = open ( outfile , '<STR_LIT:wb>' ) <EOL> outfile . write ( self . _contents ) <EOL> class JsonResult ( Result ) : <EOL> """<STR_LIT>""" <EOL> __has_json__ = True <EOL> def __init__ ( self , url , file_data = None ) : <EOL> super ( JsonResult , self ) . __init__ ( url , file_data ) <EOL> js = self . _json_struct <EOL> if '<STR_LIT:error>' in js : <EOL> detailstring = "<STR_LIT:U+002CU+0020>" . join ( js [ '<STR_LIT:error>' ] . get ( '<STR_LIT>' , [ ] ) ) <EOL> if detailstring : <EOL> detailstring = "<STR_LIT>" + detailstring <EOL> raise ServerError ( "<STR_LIT>" % <EOL> ( js [ '<STR_LIT:error>' ] [ '<STR_LIT:code>' ] , <EOL> js [ '<STR_LIT:error>' ] [ '<STR_LIT:message>' ] or <EOL> '<STR_LIT>' , <EOL> detailstring , <EOL> self . url ) ) <EOL> elif "<STR_LIT:status>" in js : <EOL> if js [ '<STR_LIT:status>' ] == "<STR_LIT:error>" : <EOL> raise ServerError ( '<STR_LIT>' . join ( <EOL> js . get ( '<STR_LIT>' , <EOL> [ js . get ( '<STR_LIT:message>' , <EOL> '<STR_LIT>' ) ] ) ) ) <EOL> class JsonPostResult ( JsonResult ) : <EOL> """<STR_LIT>""" <EOL> __post__ = True <EOL> pass <EOL> class Layer ( RestURL ) : <EOL> """<STR_LIT>""" <EOL> __cache_request__ = True <EOL> __lazy_fetch__ = False <EOL> class AttachmentData ( BinaryResult ) : <EOL> """<STR_LIT>""" <EOL> __lazy_fetch__ = True <EOL> class AttachmentInfos ( JsonResult ) : <EOL> """<STR_LIT>""" <EOL> @ property <EOL> def attachments ( self ) : <EOL> for attachment in self . _json_struct [ '<STR_LIT>' ] : <EOL> attachment_dict = attachment . copy ( ) <EOL> attachment_dict [ '<STR_LIT>' ] = self . _get_subfolder ( "<STR_LIT>" % attachment_dict [ '<STR_LIT:id>' ] , <EOL> AttachmentData ) <EOL> class MapLayer ( Layer ) : <EOL> """<STR_LIT>""" <EOL> def QueryLayer ( self , text = None , Geometry = None , inSR = None , <EOL> spatialRel = '<STR_LIT>' , where = None , <EOL> outFields = None , returnGeometry = None , outSR = None , <EOL> objectIds = None , time = None , maxAllowableOffset = None , <EOL> returnIdsOnly = None ) : <EOL> """<STR_LIT>""" <EOL> if not inSR : <EOL> if Geometry : <EOL> inSR = Geometry . spatialReference <EOL> out = self . _get_subfolder ( "<STR_LIT>" , JsonResult , { <EOL> '<STR_LIT:text>' : text , <EOL> '<STR_LIT>' : geometry , <EOL> '<STR_LIT>' : inSR , <EOL> '<STR_LIT>' : spatialRel , <EOL> '<STR_LIT>' : where , <EOL> '<STR_LIT>' : outFields , <EOL> '<STR_LIT>' : <EOL> returnGeometry , <EOL> '<STR_LIT>' : outSR , <EOL> '<STR_LIT>' : objectIds , <EOL> '<STR_LIT:time>' : <EOL> utils . pythonvaluetotime ( <EOL> time ) , <EOL> '<STR_LIT>' : <EOL> maxAllowableOffset , <EOL> '<STR_LIT>' : <EOL> returnIdsOnly <EOL> } ) <EOL> return gptypes . GPFeatureRecordSetLayer . fromJson ( out . _json_struct ) <EOL> @ property <EOL> def id ( self ) : <EOL> return self . _json_struct [ '<STR_LIT:id>' ] <EOL> @ property <EOL> def name ( self ) : <EOL> return self . _json_struct [ '<STR_LIT:name>' ] <EOL> @ property <EOL> def type ( self ) : <EOL> return self . _json_struct [ '<STR_LIT:type>' ] <EOL> @ property <EOL> def geometryType ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def copyrightText ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def parentLayer ( self ) : <EOL> return self . _get_subfolder ( "<STR_LIT>" % <EOL> self . _json_struct [ '<STR_LIT>' ] [ '<STR_LIT:id>' ] , <EOL> MapLayer ) <EOL> @ property <EOL> def subLayers ( self ) : <EOL> return [ self . _get_subfolder ( "<STR_LIT>" % <EOL> layer [ '<STR_LIT>' ] [ '<STR_LIT:id>' ] , <EOL> MapLayer ) <EOL> for layer in self . _json_struct [ '<STR_LIT>' ] ] <EOL> @ property <EOL> def minScale ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def maxScale ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def extent ( self ) : <EOL> return geometry . fromJson ( self . _json_struct [ '<STR_LIT>' ] ) <EOL> @ property <EOL> def displayField ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def fields ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def types ( self ) : <EOL> return self . _json_struct . get ( '<STR_LIT>' , [ ] ) <EOL> @ property <EOL> def relationships ( self ) : <EOL> return self . _json_struct . get ( '<STR_LIT>' , [ ] ) <EOL> @ property <EOL> def timeInfo ( self ) : <EOL> """<STR_LIT>""" <EOL> time_info = self . _json_struct . get ( '<STR_LIT>' , { } ) <EOL> if not time_info : <EOL> return None <EOL> time_info = time_info . copy ( ) <EOL> if '<STR_LIT>' in time_info : <EOL> time_info [ '<STR_LIT>' ] = utils . timetopythonvalue ( <EOL> time_info [ '<STR_LIT>' ] ) <EOL> return time_info <EOL> @ property <EOL> def hasAttachments ( self ) : <EOL> return self . _json_struct . get ( '<STR_LIT>' , False ) <EOL> @ property <EOL> def attachments ( self ) : <EOL> if not self . hasAttachments : <EOL> return [ ] <EOL> return self . _get_subfolder ( "<STR_LIT>" , AttachmentInfos ) . attachments <EOL> class MapTile ( BinaryResult ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class ExportMapResult ( JsonResult ) : <EOL> """<STR_LIT>""" <EOL> @ property <EOL> def href ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def width ( self ) : <EOL> return self . _json_struct [ '<STR_LIT:width>' ] <EOL> @ property <EOL> def height ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def extent ( self ) : <EOL> return geometry . fromJson ( self . _json_struct [ '<STR_LIT>' ] ) <EOL> @ property <EOL> def scale ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def data ( self ) : <EOL> if not hasattr ( self , '<STR_LIT>' ) : <EOL> self . _data = compat . urllib2 . urlopen ( self . href ) . read ( ) <EOL> return self . _data <EOL> def save ( self , outfile ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( outfile , compat . string_type ) : <EOL> outfile = open ( outfile , '<STR_LIT:wb>' ) <EOL> assert hasattr ( outfile , '<STR_LIT>' ) and callable ( outfile . write ) , "<STR_LIT>" <EOL> outfile . write ( self . data ) <EOL> class IdentifyOrFindResult ( JsonResult ) : <EOL> """<STR_LIT>""" <EOL> @ property <EOL> def results ( self ) : <EOL> def resiter ( ) : <EOL> for result in self . _json_struct [ '<STR_LIT>' ] : <EOL> if '<STR_LIT>' in result : <EOL> geom = geometry . fromJson ( result [ '<STR_LIT>' ] ) <EOL> else : <EOL> geom = geometry . NullGeometry ( ) <EOL> geom . attributes = result . get ( '<STR_LIT>' ) <EOL> for key in ( '<STR_LIT>' , '<STR_LIT:value>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ) : <EOL> geom . attributes [ key ] = result [ key ] <EOL> yield geom <EOL> return gptypes . GPFeatureRecordSetLayer ( list ( resiter ( ) ) , <EOL> self . parent . spatialReference ) <EOL> class ExportKMLResult ( BinaryResult ) : <EOL> """<STR_LIT>""" <EOL> @ Folder . _register_service_type <EOL> class MapService ( Service ) : <EOL> """<STR_LIT>""" <EOL> __service_type__ = "<STR_LIT>" <EOL> def ExportMap ( self , bbox , size = None , dpi = None , imageSR = None , bboxSR = None , <EOL> format = None , layerDefs = None , layers = None , transparent = False , <EOL> time = None ) : <EOL> """<STR_LIT>""" <EOL> return self . _get_subfolder ( '<STR_LIT>' , ExportMapResult , <EOL> { '<STR_LIT>' : bbox , <EOL> '<STR_LIT:size>' : size , <EOL> '<STR_LIT>' : dpi , <EOL> '<STR_LIT>' : imageSR , <EOL> '<STR_LIT>' : bboxSR , <EOL> '<STR_LIT>' : format , <EOL> '<STR_LIT>' : layerDefs , <EOL> '<STR_LIT>' : layers , <EOL> '<STR_LIT>' : transparent , <EOL> '<STR_LIT:time>' : <EOL> utils . pythonvaluetotime ( <EOL> time ) <EOL> } ) <EOL> def Identify ( self , Geometry , sr = None , layers = None , tolerance = <NUM_LIT:1> , <EOL> mapExtent = None , imageDisplay = None , returnGeometry = True ) : <EOL> """<STR_LIT>""" <EOL> assert hasattr ( Geometry , '<STR_LIT>' ) , "<STR_LIT>" <EOL> gt = Geometry . __geometry_type__ <EOL> if sr is None : <EOL> sr = Geometry . spatialReference . wkid <EOL> geo_json = json . dumps ( Geometry . _json_struct_without_sr ) <EOL> return self . _get_subfolder ( '<STR_LIT>' , IdentifyOrFindResult , <EOL> { '<STR_LIT>' : geo_json , <EOL> '<STR_LIT>' : gt , <EOL> '<STR_LIT>' : sr , <EOL> '<STR_LIT>' : layers , <EOL> '<STR_LIT>' : tolerance , <EOL> '<STR_LIT>' : mapExtent , <EOL> '<STR_LIT>' : <EOL> imageDisplay , <EOL> '<STR_LIT>' : <EOL> returnGeometry } ) <EOL> def Find ( self , searchText , contains = True , searchFields = None , sr = None , <EOL> layers = None , returnGeometry = True ) : <EOL> """<STR_LIT>""" <EOL> return self . _get_subfolder ( '<STR_LIT>' , IdentifyOrFindResult , <EOL> { '<STR_LIT>' : searchText , <EOL> '<STR_LIT>' : contains , <EOL> '<STR_LIT>' : searchFields , <EOL> '<STR_LIT>' : sr , <EOL> '<STR_LIT>' : layers , <EOL> '<STR_LIT>' : returnGeometry } ) <EOL> def GenerateKML ( self , docName , layers , layerOptions = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> return self . _get_subfolder ( '<STR_LIT>' , GenerateKMLResult , <EOL> { '<STR_LIT>' : docName , <EOL> '<STR_LIT>' : layers , <EOL> '<STR_LIT>' : layerOptions } ) <EOL> def tile ( self , row , col , zoomlevel ) : <EOL> """<STR_LIT>""" <EOL> return self . _get_subfolder ( "<STR_LIT>" % ( row , col , zoomlevel ) , <EOL> MapTile ) <EOL> @ property <EOL> def mapName ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def description ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _json_struct [ '<STR_LIT:description>' ] <EOL> @ property <EOL> def copyrightText ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def spatialReference ( self ) : <EOL> """<STR_LIT>""" <EOL> return geometry . fromJson ( <EOL> self . _json_struct [ '<STR_LIT>' ] ) <EOL> @ property <EOL> def initialExtent ( self ) : <EOL> """<STR_LIT>""" <EOL> return geometry . fromJson ( <EOL> self . _json_struct [ '<STR_LIT>' ] ) <EOL> @ property <EOL> def fullExtent ( self ) : <EOL> """<STR_LIT>""" <EOL> return geometry . fromJson ( <EOL> self . _json_struct [ '<STR_LIT>' ] ) <EOL> @ property <EOL> def layernames ( self ) : <EOL> """<STR_LIT>""" <EOL> return [ layer [ '<STR_LIT:name>' ] for layer in self . _json_struct [ '<STR_LIT>' ] ] <EOL> @ property <EOL> def layers ( self ) : <EOL> """<STR_LIT>""" <EOL> return [ self . _get_subfolder ( "<STR_LIT>" % layer [ '<STR_LIT:id>' ] , MapLayer ) <EOL> for layer in self . _json_struct [ '<STR_LIT>' ] ] <EOL> @ property <EOL> def tablenames ( self ) : <EOL> """<STR_LIT>""" <EOL> return [ table [ '<STR_LIT:name>' ] for table in self . _json_struct . get ( '<STR_LIT>' , [ ] ) ] <EOL> @ property <EOL> def tables ( self ) : <EOL> """<STR_LIT>""" <EOL> return [ self . _get_subfolder ( "<STR_LIT>" % table [ '<STR_LIT:id>' ] , MapLayer ) <EOL> for table in self . _json_struct . get ( '<STR_LIT>' , [ ] ) ] <EOL> @ property <EOL> def timeInfo ( self ) : <EOL> """<STR_LIT>""" <EOL> time_info = self . _json_struct . get ( '<STR_LIT>' , { } ) <EOL> if not time_info : <EOL> return None <EOL> time_info = time_info . copy ( ) <EOL> if '<STR_LIT>' in time_info : <EOL> time_info [ '<STR_LIT>' ] = utils . timetopythonvalue ( <EOL> time_info [ '<STR_LIT>' ] ) <EOL> return time_info <EOL> @ property <EOL> def supportedImageFormatTypes ( self ) : <EOL> """<STR_LIT>""" <EOL> return [ x . strip ( ) <EOL> for x in <EOL> self . _json_struct [ '<STR_LIT>' ] . split ( '<STR_LIT:U+002C>' ) ] <EOL> class FindAddressCandidatesResult ( JsonResult ) : <EOL> """<STR_LIT>""" <EOL> @ property <EOL> def candidates ( self ) : <EOL> """<STR_LIT>""" <EOL> def cditer ( ) : <EOL> for candidate in self . _json_struct [ '<STR_LIT>' ] : <EOL> newcandidate = candidate . copy ( ) <EOL> newcandidate [ '<STR_LIT:location>' ] = geometry . fromJson ( newcandidate [ '<STR_LIT:location>' ] ) <EOL> yield newcandidate <EOL> return list ( cditer ( ) ) <EOL> class ReverseGeocodeResult ( JsonResult ) : <EOL> """<STR_LIT>""" <EOL> @ property <EOL> def address ( self ) : <EOL> return self . _json_struct [ '<STR_LIT:address>' ] <EOL> @ property <EOL> def location ( self ) : <EOL> return geometry . fromJson ( self . _json_struct [ '<STR_LIT:location>' ] ) <EOL> def __getitem__ ( self , attr ) : <EOL> return self . _json_struct [ '<STR_LIT:address>' ] [ attr ] <EOL> def __getattr__ ( self , attr ) : <EOL> try : <EOL> return self [ attr ] <EOL> except KeyError as e : <EOL> raise AttributeError ( str ( e ) ) <EOL> @ Folder . _register_service_type <EOL> class GeocodeService ( Service ) : <EOL> """<STR_LIT>""" <EOL> __service_type__ = "<STR_LIT>" <EOL> def FindAddressCandidates ( self , outFields = [ ] , outSR = None , ** fields ) : <EOL> """<STR_LIT>""" <EOL> required_unset_fields = [ ] <EOL> for field in self . _json_struct [ '<STR_LIT>' ] : <EOL> if field [ '<STR_LIT>' ] and field [ '<STR_LIT:name>' ] not in fields : <EOL> required_unset_fields . append ( field [ '<STR_LIT:name>' ] ) <EOL> if required_unset_fields : <EOL> raise ValueError ( "<STR_LIT>" % <EOL> ( '<STR_LIT>' if len ( required_unset_fields ) == <NUM_LIT:1> <EOL> else '<STR_LIT:s>' , '<STR_LIT:U+002CU+0020>' . join ( required_unset_fields ) ) ) <EOL> query = fields . copy ( ) <EOL> query [ '<STR_LIT>' ] = outFields <EOL> if outSR : <EOL> query [ '<STR_LIT>' ] = ( outSR . wkid <EOL> if isinstance ( outSR , geometry . SpatialReference ) <EOL> else outSR ) <EOL> return self . _get_subfolder ( '<STR_LIT>' , <EOL> FindAddressCandidatesResult , query ) <EOL> def ReverseGeocode ( self , location , distance , outSR = None ) : <EOL> """<STR_LIT>""" <EOL> if outSR : <EOL> outSR = ( outSR . wkid <EOL> if isinstance ( outSR , geometry . SpatialReference ) <EOL> else outSR ) <EOL> return self . _get_subfolder ( '<STR_LIT>' , ReverseGeocodeResult , <EOL> { '<STR_LIT:location>' : location , <EOL> '<STR_LIT>' : distance , <EOL> '<STR_LIT>' : outSR } ) <EOL> class GPMessage ( object ) : <EOL> """<STR_LIT>""" <EOL> __message_types = set ( [ "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ] ) <EOL> def __init__ ( self , description , type = None ) : <EOL> if isinstance ( description , dict ) : <EOL> description , type = ( description . get ( '<STR_LIT:description>' ) , <EOL> description . get ( '<STR_LIT:type>' ) ) <EOL> elif isinstance ( description , ( tuple , list ) ) : <EOL> description , type = description [ <NUM_LIT:0> ] , description [ <NUM_LIT:1> ] <EOL> self . description , self . type = description , type <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" . format ( self . type [ len ( '<STR_LIT>' ) : ] , <EOL> self . description ) <EOL> def __str__ ( self ) : <EOL> return self . description <EOL> @ Folder . _register_service_type <EOL> class GPService ( Service ) : <EOL> """<STR_LIT>""" <EOL> __service_type__ = "<STR_LIT>" <EOL> @ property <EOL> def tasknames ( self ) : <EOL> return [ task for task in self . _json_struct [ '<STR_LIT>' ] ] <EOL> @ property <EOL> def tasks ( self ) : <EOL> return [ self . _get_subfolder ( taskname + '<STR_LIT:/>' , GPTask ) <EOL> for taskname in self . tasknames ] <EOL> @ property <EOL> def executionType ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def synchronous ( self ) : <EOL> """<STR_LIT>""" <EOL> sv = self . _json_struct [ '<STR_LIT>' ] <EOL> if sv == '<STR_LIT>' : <EOL> return True <EOL> elif sv == '<STR_LIT>' : <EOL> return False <EOL> raise ValueError ( "<STR_LIT>" % sv ) <EOL> def __getitem__ ( self , attr ) : <EOL> for task in self . tasknames : <EOL> if task == attr : <EOL> return self . _get_subfolder ( task + '<STR_LIT:/>' , GPTask ) <EOL> raise KeyError ( "<STR_LIT>" % attr ) <EOL> def __getattr__ ( self , attr ) : <EOL> try : <EOL> return self [ attr ] <EOL> except KeyError : <EOL> return Service . __getattr__ ( self , attr ) <EOL> class GPJobStatus ( RestURL ) : <EOL> """<STR_LIT>""" <EOL> __cache_request__ = False <EOL> _results = None <EOL> job_statuses = set ( [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) <EOL> _still_running = set ( [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) <EOL> _error_status = set ( [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] ) <EOL> @ property <EOL> def _json_struct ( self ) : <EOL> js = RestURL . _json_struct . __get__ ( self ) <EOL> if js [ '<STR_LIT>' ] not in self . _still_running : <EOL> self . __cache_request__ = True <EOL> self . __json_struct__ = js <EOL> return js <EOL> @ property <EOL> def jobId ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def jobStatus ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def running ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] in self . _still_running <EOL> @ property <EOL> def results ( self ) : <EOL> assert ( not self . running ) , "<STR_LIT>" <EOL> if self . jobStatus in self . _error_status : <EOL> raise ServerError ( "<STR_LIT>" % self . jobStatus ) <EOL> if self . _results is None : <EOL> def item_iterator ( ) : <EOL> for resref in self . _json_struct [ '<STR_LIT>' ] . itervalues ( ) : <EOL> rel = self . _get_subfolder ( resref [ '<STR_LIT>' ] , RestURL ) <EOL> result = rel . _json_struct <EOL> datatype = None <EOL> conversion = None <EOL> for param in self . parent . parent . parameters : <EOL> if param [ '<STR_LIT:name>' ] == result [ '<STR_LIT>' ] : <EOL> datatype = param [ '<STR_LIT>' ] <EOL> if datatype is None : <EOL> conversion = str <EOL> else : <EOL> conversion = datatype . fromJson <EOL> dt = result [ '<STR_LIT>' ] <EOL> val = conversion ( result [ '<STR_LIT:value>' ] ) <EOL> yield ( dt , val ) <EOL> self . _results = dict ( item_iterator ( ) ) <EOL> return self . _results <EOL> @ property <EOL> def messages ( self ) : <EOL> "<STR_LIT>" <EOL> return map ( GPMessage , self . _json_struct [ '<STR_LIT>' ] ) <EOL> def __getitem__ ( self , key ) : <EOL> return self . __class__ . results . __get__ ( self ) [ key ] <EOL> def __getattr__ ( self , attr ) : <EOL> return self . __class__ . results . __get__ ( self ) [ attr ] <EOL> class GPJob ( JsonPostResult ) : <EOL> """<STR_LIT>""" <EOL> _jobstatus = None <EOL> def __init__ ( self , url , file_data = None ) : <EOL> super ( GPJob , self ) . __init__ ( url , file_data ) <EOL> self . _jobstatus = self . _get_subfolder ( '<STR_LIT>' % <EOL> self . _json_struct [ '<STR_LIT>' ] , <EOL> GPJobStatus ) <EOL> @ property <EOL> def jobId ( self ) : <EOL> "<STR_LIT>" <EOL> return self . _jobstatus . jobId <EOL> @ property <EOL> def jobStatus ( self ) : <EOL> return self . _jobstatus . jobStatus <EOL> @ property <EOL> def running ( self ) : <EOL> "<STR_LIT>" <EOL> return self . _jobstatus . running <EOL> @ property <EOL> def results ( self ) : <EOL> "<STR_LIT>" <EOL> return self . _jobstatus . results <EOL> @ property <EOL> def messages ( self ) : <EOL> "<STR_LIT>" <EOL> return self . _jobstatus . messages <EOL> def __getitem__ ( self , key ) : <EOL> return self . _jobstatus . results [ key ] <EOL> def __getattr__ ( self , attr ) : <EOL> return self . _jobstatus . results [ attr ] <EOL> class GPExecutionResult ( JsonResult ) : <EOL> """<STR_LIT>""" <EOL> _results = None <EOL> @ property <EOL> def messages ( self ) : <EOL> "<STR_LIT>" <EOL> return map ( GPMessage , self . _json_struct [ '<STR_LIT>' ] ) <EOL> @ property <EOL> def results ( self ) : <EOL> "<STR_LIT>" <EOL> if self . _results is None : <EOL> results = self . _json_struct [ '<STR_LIT>' ] <EOL> def result_iterator ( ) : <EOL> for result in results : <EOL> datatype = None <EOL> conversion = None <EOL> for param in self . parent . parameters : <EOL> if param [ '<STR_LIT:name>' ] == result [ '<STR_LIT>' ] : <EOL> datatype = param [ '<STR_LIT>' ] <EOL> if datatype is None : <EOL> conversion = str <EOL> else : <EOL> conversion = datatype . fromJson <EOL> dt = result [ '<STR_LIT>' ] <EOL> val = conversion ( result [ '<STR_LIT:value>' ] ) <EOL> yield ( dt , val ) <EOL> self . _results = dict ( res for res in result_iterator ( ) ) <EOL> return self . _results <EOL> @ property <EOL> def running ( self ) : <EOL> "<STR_LIT>" <EOL> return False <EOL> def __getitem__ ( self , key ) : <EOL> return self . __class__ . results . __get__ ( self ) [ key ] <EOL> def __getattr__ ( self , attr ) : <EOL> return self . __class__ . results . __get__ ( self ) [ attr ] <EOL> class GPTask ( RestURL ) : <EOL> """<STR_LIT>""" <EOL> __parent_type__ = GPService <EOL> __cache_request__ = True <EOL> def __init__ ( self , url , file_data = None ) : <EOL> if isinstance ( url , compat . string_type ) : <EOL> url = list ( compat . urlsplit ( url ) ) <EOL> if not url [ <NUM_LIT:2> ] . endswith ( '<STR_LIT:/>' ) : <EOL> url [ <NUM_LIT:2> ] += '<STR_LIT:/>' <EOL> super ( GPTask , self ) . __init__ ( url , file_data ) <EOL> def __expandparamstodict ( self , params , kw ) : <EOL> self_parameters = self . parameters <EOL> parametervalues = dict ( zip ( ( p [ '<STR_LIT:name>' ] for p in self_parameters ) , <EOL> params ) ) <EOL> for kw , kwval in kw . items ( ) : <EOL> if kw in parametervalues : <EOL> raise KeyError ( "<STR_LIT>" % kw ) <EOL> parametervalues [ kw ] = kwval <EOL> for param_to_convert in self_parameters : <EOL> if param_to_convert [ '<STR_LIT:name>' ] in parametervalues : <EOL> val = parametervalues [ param_to_convert [ '<STR_LIT:name>' ] ] <EOL> if val is None : <EOL> parametervalues [ param_to_convert [ '<STR_LIT:name>' ] ] = '<STR_LIT>' <EOL> elif not isinstance ( val , param_to_convert [ '<STR_LIT>' ] ) : <EOL> conversion = param_to_convert [ '<STR_LIT>' ] ( val ) <EOL> parametervalues [ param_to_convert [ '<STR_LIT:name>' ] ] = getattr ( conversion , '<STR_LIT>' , conversion ) <EOL> elif param_to_convert [ '<STR_LIT>' ] != '<STR_LIT>' : <EOL> parametervalues [ param_to_convert [ '<STR_LIT:name>' ] ] = '<STR_LIT>' <EOL> return parametervalues <EOL> def Execute ( self , * params , ** kw ) : <EOL> """<STR_LIT>""" <EOL> fp = self . __expandparamstodict ( params , kw ) <EOL> return self . _get_subfolder ( '<STR_LIT>' , GPExecutionResult , fp ) <EOL> def SubmitJob ( self , * params , ** kw ) : <EOL> """<STR_LIT>""" <EOL> fp = self . __expandparamstodict ( params , kw ) <EOL> return self . _get_subfolder ( '<STR_LIT>' , GPJob , fp ) . _jobstatus <EOL> def __call__ ( self , * params , ** kw ) : <EOL> """<STR_LIT>""" <EOL> if self . synchronous : <EOL> return self . Execute ( * params , ** kw ) <EOL> else : <EOL> return self . SubmitJob ( * params , ** kw ) <EOL> @ property <EOL> def name ( self ) : <EOL> return self . _json_struct . get ( '<STR_LIT:name>' , '<STR_LIT>' ) <EOL> @ property <EOL> def displayName ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def category ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def helpUrl ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def parameters ( self ) : <EOL> parameters = self . _json_struct [ '<STR_LIT>' ] <EOL> for parameter in parameters : <EOL> dt = parameter [ '<STR_LIT>' ] <EOL> parameter [ '<STR_LIT>' ] = gptypes . GPBaseType . _get_type_by_name ( <EOL> dt ) . _from_json_def ( parameter ) <EOL> return parameters <EOL> @ property <EOL> def executionType ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . parent . executionType <EOL> @ property <EOL> def synchronous ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . parent . synchronous <EOL> class GeometryResult ( JsonResult ) : <EOL> """<STR_LIT>""" <EOL> @ property <EOL> def geometries ( self ) : <EOL> return [ geometry . fromJson ( geo ) <EOL> for geo in self . _json_struct [ '<STR_LIT>' ] ] <EOL> class LengthsResult ( JsonResult ) : <EOL> """<STR_LIT>""" <EOL> @ property <EOL> def lengths ( self ) : <EOL> return map ( float ( length ) for length in self . _json_struct [ '<STR_LIT>' ] ) <EOL> class AreasAndLengthsResult ( LengthsResult ) : <EOL> """<STR_LIT>""" <EOL> @ property <EOL> def areas ( self ) : <EOL> return map ( float ( area ) for area in self . _json_struct [ '<STR_LIT>' ] ) <EOL> class LabelPointsResult ( JsonResult ) : <EOL> """<STR_LIT>""" <EOL> @ property <EOL> def labelPoints ( self ) : <EOL> """<STR_LIT>""" <EOL> return [ geometry . fromJson ( geo ) <EOL> for geo in self . _json_struct [ '<STR_LIT>' ] ] <EOL> @ Folder . _register_service_type <EOL> class GeometryService ( Service ) : <EOL> """<STR_LIT>""" <EOL> __service_type__ = "<STR_LIT>" <EOL> def Project ( self , geometries , inSR = None , outSR = None ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( geometries , geometry . Geometry ) : <EOL> geometries = [ geometries ] <EOL> if inSR is None : <EOL> inSR = geometries [ <NUM_LIT:0> ] . spatialReference . wkid <EOL> assert outSR , "<STR_LIT>" <EOL> geometry_types = set ( [ x . __geometry_type__ for x in geometries ] ) <EOL> assert len ( geometry_types ) == <NUM_LIT:1> , "<STR_LIT>" <EOL> geo_json = json . dumps ( { '<STR_LIT>' : list ( geometry_types ) [ <NUM_LIT:0> ] , <EOL> '<STR_LIT>' : [ geo . _json_struct_without_sr <EOL> for geo in geometries ] <EOL> } ) <EOL> return self . _get_subfolder ( '<STR_LIT>' , GeometryResult , <EOL> { '<STR_LIT>' : geo_json , <EOL> '<STR_LIT>' : inSR , <EOL> '<STR_LIT>' : outSR <EOL> } ) <EOL> def Simplify ( self , geometries , sr = None ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( geometries , geometry . Geometry ) : <EOL> geometries = [ geometries ] <EOL> if sr is None : <EOL> sr = geometries [ <NUM_LIT:0> ] . spatialReference . wkid <EOL> geometry_types = set ( [ x . __geometry_type__ for x in geometries ] ) <EOL> assert len ( geometry_types ) == <NUM_LIT:1> , "<STR_LIT>" <EOL> geo_json = json . dumps ( { '<STR_LIT>' : list ( geometry_types ) [ <NUM_LIT:0> ] , <EOL> '<STR_LIT>' : [ geo . _json_struct_without_sr <EOL> for geo in geometries ] <EOL> } ) <EOL> return self . _get_subfolder ( '<STR_LIT>' , GeometryResult , <EOL> { '<STR_LIT>' : geo_json , <EOL> '<STR_LIT>' : sr <EOL> } ) <EOL> def Buffer ( self , geometries , distances , unit = None , unionResults = False , <EOL> inSR = None , outSR = None , bufferSR = None ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( geometries , geometry . Geometry ) : <EOL> geometries = [ geometries ] <EOL> if isinstance ( distances , ( list , tuple ) ) : <EOL> distances = "<STR_LIT:U+002C>" . join ( str ( distance ) for distance in distances ) <EOL> geometry_types = set ( [ x . __geometry_type__ for x in geometries ] ) <EOL> assert len ( geometry_types ) == <NUM_LIT:1> , "<STR_LIT>" <EOL> geo_json = json . dumps ( { '<STR_LIT>' : list ( geometry_types ) [ <NUM_LIT:0> ] , <EOL> '<STR_LIT>' : [ geo . _json_struct_without_sr <EOL> for geo in geometries ] <EOL> } ) <EOL> if inSR is None : <EOL> inSR = geometries [ <NUM_LIT:0> ] . spatialReference . wkid <EOL> if outSR is None : <EOL> outSR = geometries [ <NUM_LIT:0> ] . spatialReference . wkid <EOL> if bufferSR is None : <EOL> bufferSR = geometries [ <NUM_LIT:0> ] . spatialReference . wkid <EOL> return self . _get_subfolder ( '<STR_LIT>' , GeometryResult , <EOL> { '<STR_LIT>' : geo_json , <EOL> '<STR_LIT>' : distances , <EOL> '<STR_LIT>' : unit , <EOL> '<STR_LIT>' : unionResults , <EOL> '<STR_LIT>' : inSR , <EOL> '<STR_LIT>' : outSR , <EOL> '<STR_LIT>' : bufferSR <EOL> } ) <EOL> def AreasAndLengths ( self , polygons , sr = None , lengthUnit = None , <EOL> areaUnit = None ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( polygons , geometry . Geometry ) : <EOL> polygons = [ polygons ] <EOL> assert all ( isinstance ( polygon , geometry . Polygon ) <EOL> for polygon in polygons ) , "<STR_LIT>" <EOL> if sr is None : <EOL> sr = polygons [ <NUM_LIT:0> ] . spatialReference . wkid <EOL> geo_json = json . dumps ( [ polygon . _json_struct_without_sr <EOL> for polygon in polygons ] ) <EOL> return self . _get_subfolder ( '<STR_LIT>' , AreasAndLengthsResult , <EOL> { '<STR_LIT>' : geo_json , <EOL> '<STR_LIT>' : sr , <EOL> '<STR_LIT>' : lengthUnit , <EOL> '<STR_LIT>' : areaUnit <EOL> } ) <EOL> def Lengths ( self , polylines , sr = None , lengthUnit = None , geodesic = None ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( polylines , geometry . Geometry ) : <EOL> polylines = [ polylines ] <EOL> assert all ( isinstance ( polyline , geometry . Polyline ) <EOL> for polyline in polylines ) , "<STR_LIT>" <EOL> if sr is None : <EOL> sr = polylines [ <NUM_LIT:0> ] . spatialReference . wkid <EOL> geo_json = json . dumps ( [ polyline . _json_struct_without_sr <EOL> for polyline in polylines ] ) <EOL> if geodesic is not None : <EOL> geodesic = bool ( geodesic ) <EOL> return self . _get_subfolder ( '<STR_LIT>' , LengthsResult , <EOL> { '<STR_LIT>' : geo_json , <EOL> '<STR_LIT>' : sr , <EOL> '<STR_LIT>' : lengthUnit , <EOL> '<STR_LIT>' : geodesic <EOL> } ) <EOL> def LabelPoints ( self , polygons , sr ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( polygons , geometry . Geometry ) : <EOL> polygons = [ polygons ] <EOL> assert all ( isinstance ( polygon , geometry . Polygon ) <EOL> for polygon in polygons ) , "<STR_LIT>" <EOL> if sr is None : <EOL> sr = polygons [ <NUM_LIT:0> ] . spatialReference . wkid <EOL> geo_json = json . dumps ( [ polygon . _json_struct_without_sr <EOL> for polygon in polygons ] ) <EOL> return self . _get_subfolder ( '<STR_LIT>' , LabelPointsResult , <EOL> { '<STR_LIT>' : geo_json , <EOL> '<STR_LIT>' : sr <EOL> } ) <EOL> def ConvexHull ( self , geometries = None , sr = None ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( geometries , geometry . Geometry ) : <EOL> geometries = [ geometries ] <EOL> geometry_types = set ( [ x . __geometry_type__ for x in geometries ] ) <EOL> assert len ( geometry_types ) == <NUM_LIT:1> , "<STR_LIT>" <EOL> geo_json = json . dumps ( { '<STR_LIT>' : list ( geometry_types ) [ <NUM_LIT:0> ] , <EOL> '<STR_LIT>' : [ geo . _json_struct_without_sr <EOL> for geo in geometries ] <EOL> } ) <EOL> if sr is None : <EOL> sr = geometries [ <NUM_LIT:0> ] . spatialReference . wkid <EOL> return self . _get_subfolder ( '<STR_LIT>' , GeometryResult , <EOL> { '<STR_LIT>' : geo_json , '<STR_LIT>' : sr } ) <EOL> def Densify ( self , geometries = None , sr = None , maxSegmentLength = None , <EOL> geodesic = None , lengthUnit = None ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( geometries , geometry . Geometry ) : <EOL> geometries = [ geometries ] <EOL> geometry_types = set ( [ x . __geometry_type__ for x in geometries ] ) <EOL> assert len ( geometry_types ) == <NUM_LIT:1> , "<STR_LIT>" <EOL> geo_json = json . dumps ( { '<STR_LIT>' : list ( geometry_types ) [ <NUM_LIT:0> ] , <EOL> '<STR_LIT>' : [ geo . _json_struct_without_sr <EOL> for geo in geometries ] <EOL> } ) <EOL> if sr is None : <EOL> sr = geometries [ <NUM_LIT:0> ] . spatialReference . wkid <EOL> return self . _get_subfolder ( '<STR_LIT>' , GeometryResult , <EOL> { '<STR_LIT>' : geo_json , <EOL> '<STR_LIT>' : sr , <EOL> '<STR_LIT>' : maxSegmentLength , <EOL> '<STR_LIT>' : geodesic , <EOL> '<STR_LIT>' : lengthUnit <EOL> } ) <EOL> def Distance ( self , geometry1 = None , geometry2 = None , sr = None , <EOL> distanceUnit = None , geodesic = None ) : <EOL> """<STR_LIT>""" <EOL> if not sr : <EOL> sr = ( geometry1 . spatialReference . wkid or <EOL> geometry2 . spatialReference . wkid ) <EOL> geo_json_1 = json . dumps ( { '<STR_LIT>' : geometry1 . __geometry_type__ , <EOL> '<STR_LIT>' : geometry1 . _json_struct } ) <EOL> geo_json_2 = json . dumps ( { '<STR_LIT>' : geometry2 . __geometry_type__ , <EOL> '<STR_LIT>' : geometry2 . _json_struct } ) <EOL> folder = self . _get_subfolder ( '<STR_LIT>' , JsonResult , <EOL> { '<STR_LIT>' : geo_json_1 , <EOL> '<STR_LIT>' : geo_json_2 , <EOL> '<STR_LIT>' : sr , <EOL> '<STR_LIT>' : distanceUnit , <EOL> '<STR_LIT>' : geodesic , <EOL> } ) <EOL> return folder . _json_struct [ '<STR_LIT>' ] <EOL> def Generalize ( self , geometries = None , sr = None , maxDeviation = None , <EOL> deviationUnit = None ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( geometries , geometry . Geometry ) : <EOL> geometries = [ geometries ] <EOL> geometry_types = set ( [ x . __geometry_type__ for x in geometries ] ) <EOL> assert len ( geometry_types ) == <NUM_LIT:1> , "<STR_LIT>" <EOL> geo_json = json . dumps ( { '<STR_LIT>' : list ( geometry_types ) [ <NUM_LIT:0> ] , <EOL> '<STR_LIT>' : [ geo . _json_struct_without_sr <EOL> for geo in geometries ] <EOL> } ) <EOL> if sr is None : <EOL> sr = geometries [ <NUM_LIT:0> ] . spatialReference . wkid <EOL> return self . _get_subfolder ( '<STR_LIT>' , GeometryResult , <EOL> { '<STR_LIT>' : geo_json , <EOL> '<STR_LIT>' : sr , <EOL> '<STR_LIT>' : maxDeviation , <EOL> '<STR_LIT>' : deviationUnit <EOL> } ) <EOL> def Offset ( self , geometries = None , sr = None , offsetDistance = None , <EOL> offsetUnit = None , offsetHow = None , bevelRatio = None ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( geometries , geometry . Geometry ) : <EOL> geometries = [ geometries ] <EOL> geometry_types = set ( [ x . __geometry_type__ for x in geometries ] ) <EOL> assert len ( geometry_types ) == <NUM_LIT:1> , "<STR_LIT>" <EOL> geo_json = json . dumps ( { '<STR_LIT>' : list ( geometry_types ) [ <NUM_LIT:0> ] , <EOL> '<STR_LIT>' : [ geo . _json_struct_without_sr <EOL> for geo in geometries ] <EOL> } ) <EOL> if sr is None : <EOL> sr = geometries [ <NUM_LIT:0> ] . spatialReference . wkid <EOL> return self . _get_subfolder ( '<STR_LIT>' , GeometryResult , <EOL> { '<STR_LIT>' : geo_json , <EOL> '<STR_LIT>' : sr , <EOL> '<STR_LIT>' : offsetUnit , <EOL> '<STR_LIT>' : offsetHow , <EOL> '<STR_LIT>' : bevelRatio <EOL> } ) <EOL> def TrimExtend ( self , polylines = None , trimExtendTo = None , sr = None , <EOL> extendHow = None ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( polylines , geometry . Geometry ) : <EOL> polylines = [ polylines ] <EOL> assert all ( isinstance ( polyline , geometry . Polyline ) <EOL> for polyline in polylines ) , "<STR_LIT>" <EOL> if sr is None : <EOL> sr = polylines [ <NUM_LIT:0> ] . spatialReference . wkid <EOL> geo_json = json . dumps ( [ polyline . _json_struct_without_sr <EOL> for polyline in polylines ] ) <EOL> return self . _get_subfolder ( '<STR_LIT>' , GeometryResult , <EOL> { '<STR_LIT>' : geo_json , <EOL> '<STR_LIT>' : trimExtendTo , <EOL> '<STR_LIT>' : extendHow , <EOL> '<STR_LIT>' : sr <EOL> } ) <EOL> def AutoComplete ( self , polygons = None , polylines = None , sr = None ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def Cut ( self , cutter = None , target = None , sr = None ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def Difference ( self , geometries = None , geometry = None , sr = None ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def Intersect ( self , geometries = None , geometry = None , sr = None ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def Reshape ( self , target = None , reshaper = None , sr = None ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def Union ( self , geometries = None , sr = None ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> class ExportImageResult ( JsonResult ) : <EOL> """<STR_LIT>""" <EOL> @ property <EOL> def href ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def width ( self ) : <EOL> return self . _json_struct [ '<STR_LIT:width>' ] <EOL> @ property <EOL> def height ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def extent ( self ) : <EOL> return geometry . fromJson ( self . _json_struct [ '<STR_LIT>' ] ) <EOL> def save ( self , outfile ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( outfile , compat . string_type ) : <EOL> outfile = open ( outfile , '<STR_LIT:wb>' ) <EOL> outfile . write ( compat . urllib2 . urlopen ( self . href ) . read ( ) ) <EOL> @ Folder . _register_service_type <EOL> class ImageService ( Service ) : <EOL> """<STR_LIT>""" <EOL> __service_type__ = "<STR_LIT>" <EOL> def ExportImage ( self , bbox = None , size = None , imageSR = None , bboxSR = None , <EOL> format = None , pixelType = None , noData = None , <EOL> interpolation = None , compressionQuality = None , bandIds = None , <EOL> mosaicProperties = None , viewpointProperties = None , <EOL> mosaicRule = None , renderingRule = None ) : <EOL> """<STR_LIT>""" <EOL> return self . _get_subfolder ( '<STR_LIT>' , ExportImageResult , <EOL> { '<STR_LIT>' : bbox , <EOL> '<STR_LIT:size>' : size , <EOL> '<STR_LIT>' : imageSR , <EOL> '<STR_LIT>' : bboxSR , <EOL> '<STR_LIT>' : format , <EOL> '<STR_LIT>' : pixelType , <EOL> '<STR_LIT>' : noData , <EOL> '<STR_LIT>' : interpolation , <EOL> '<STR_LIT>' : compressionQuality , <EOL> '<STR_LIT>' : bandIds , <EOL> '<STR_LIT>' : mosaicProperties , <EOL> '<STR_LIT>' : viewpointProperties , <EOL> '<STR_LIT>' : mosaicRule , <EOL> '<STR_LIT>' : renderingRule <EOL> } ) <EOL> @ Folder . _register_service_type <EOL> class NetworkService ( Service ) : <EOL> """<STR_LIT>""" <EOL> __service_type__ = "<STR_LIT>" <EOL> @ property <EOL> def routeLayers ( self ) : <EOL> return [ self . _get_subfolder ( "<STR_LIT>" % layer , RouteNetworkLayer ) <EOL> for layer in self . _json_struct [ '<STR_LIT>' ] ] <EOL> @ property <EOL> def serviceAreaLayers ( self ) : <EOL> return [ self . _get_subfolder ( "<STR_LIT>" % layer , NetworkLayer ) <EOL> for layer in self . _json_struct [ '<STR_LIT>' ] ] <EOL> @ property <EOL> def closestFacilityLayers ( self ) : <EOL> return [ self . _get_subfolder ( "<STR_LIT>" % layer , NetworkLayer ) <EOL> for layer in self . _json_struct [ '<STR_LIT>' ] ] <EOL> def __getitem__ ( self , attr ) : <EOL> layer_names = set ( self . _json_struct [ '<STR_LIT>' ] + <EOL> self . _json_struct [ '<STR_LIT>' ] + <EOL> self . _json_struct [ '<STR_LIT>' ] ) <EOL> if attr in layer_names : <EOL> self . _get_subfolder ( "<STR_LIT>" % attr , NetworkLayer ) <EOL> raise KeyError ( "<STR_LIT>" % attr ) <EOL> def __getattr__ ( self , attr ) : <EOL> try : <EOL> return self [ attr ] <EOL> except KeyError as e : <EOL> raise AttributeError ( str ( e ) ) <EOL> class DirectionResult ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , direction ) : <EOL> self . _json_struct = direction <EOL> @ property <EOL> def routeId ( self ) : <EOL> return self . _json_struct [ "<STR_LIT>" ] <EOL> @ property <EOL> def routeName ( self ) : <EOL> return self . _json_struct [ "<STR_LIT>" ] <EOL> @ property <EOL> def summary ( self ) : <EOL> return self . _json_struct [ "<STR_LIT>" ] <EOL> @ property <EOL> def features ( self ) : <EOL> return gptypes . GPFeatureRecordSetLayer . fromJson ( self . _json_struct ) <EOL> class NetworkSolveResult ( JsonResult ) : <EOL> """<STR_LIT>""" <EOL> @ property <EOL> def directions ( self ) : <EOL> return [ DirectionResult ( direction ) <EOL> for direction in self . _json_struct [ '<STR_LIT>' ] ] <EOL> @ property <EOL> def routes ( self ) : <EOL> return gptypes . GPFeatureRecordSetLayer . fromJson ( <EOL> self . _json_struct [ '<STR_LIT>' ] ) <EOL> @ property <EOL> def stops ( self ) : <EOL> return gptypes . GPFeatureRecordSetLayer . fromJson ( <EOL> self . _json_struct [ '<STR_LIT>' ] ) <EOL> @ property <EOL> def barriers ( self ) : <EOL> return gptypes . GPFeatureRecordSetLayer . fromJson ( <EOL> self . _json_struct [ '<STR_LIT>' ] ) <EOL> @ property <EOL> def messages ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> class NetworkLayer ( Layer ) : <EOL> """<STR_LIT>""" <EOL> __parent_type__ = NetworkService <EOL> @ property <EOL> def layerName ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def layerType ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def impedance ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def useStartTime ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def useTimeWindows ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def preserveFirstStop ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def preserveLastStop ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def restrictUTurns ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def outputLineType ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def useHierarchy ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def ignoreInvalidLocations ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def restrictions ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def distanceUnits ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def useTimeAttribute ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def networkClasses ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> def SolveClosestFacility ( self , facilities = None , <EOL> incidents = None , <EOL> barriers = None , <EOL> polylineBarriers = None , <EOL> polygonBarriers = None , <EOL> attributeParameterValues = None , <EOL> returnDirections = None , <EOL> directionsLanguage = None , <EOL> directionsStyleName = None , <EOL> directionsLengthUnits = None , <EOL> directionsTimeAttributeName = None , <EOL> returnCFRoutes = None , <EOL> returnFacilities = None , <EOL> returnIncidents = None , <EOL> returnBarriers = None , <EOL> returnPolylineBarriers = None , <EOL> returnPolygonBarriers = None , <EOL> facilityReturnType = None , <EOL> outputLines = None , <EOL> defaultCutoff = None , <EOL> defaultTargetFacilityCount = None , <EOL> travelDirection = None , <EOL> outSR = None , <EOL> impedanceAttributeName = None , <EOL> restrictionAttributeNames = None , <EOL> restrictUTurns = None , <EOL> useHierarchy = None , <EOL> outputGeometryPrecision = None , <EOL> outputGeometryPrecisionUnits = None ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def SolveServiceArea ( self , facilities = None , <EOL> barriers = None , <EOL> polylineBarriers = None , <EOL> polygonBarriers = None , <EOL> attributeParameterValues = None , <EOL> defaultBreaks = None , <EOL> excludeSourcesFromPolygons = None , <EOL> mergeSimilarPolygonRanges = None , <EOL> outputLines = None , <EOL> outputPolygons = None , <EOL> overlapLines = None , <EOL> overlapPolygons = None , <EOL> splitLinesAtBreaks = None , <EOL> splitPolygonsAtBreaks = None , <EOL> travelDirection = None , <EOL> trimOuterPolygon = None , <EOL> trimPolygonDistance = None , <EOL> trimPolygonDistanceUnits = None , <EOL> accumulateAttributeNames = None , <EOL> impedanceAttributeName = None , <EOL> restrictionAttributeNames = None , <EOL> restrictUTurns = None , <EOL> outputGeometryPrecision = None , <EOL> outputGeometryPrecisionUnits = None ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> class RouteNetworkLayer ( NetworkLayer ) : <EOL> """<STR_LIT>""" <EOL> def Solve ( self , stops = None , barriers = None , returnDirections = None , <EOL> returnRoutes = None , returnStops = None , returnBarriers = None , <EOL> outSR = None , ignoreInvalidLocations = None , outputLines = None , <EOL> findBestSequence = None , preserveFirstStop = None , <EOL> preserveLastStop = None , useTimeWindows = None , startTime = None , <EOL> accumulateAttributeNames = None , impedanceAttributeName = None , <EOL> restrictionAttributeNames = None , restrictUTurns = None , <EOL> useHierarchy = None , directionsLanguage = None , <EOL> outputGeometryPrecision = None , directionsLengthUnits = None , <EOL> directionsTimeAttributeName = None , attributeParameterValues = None , <EOL> polylineBarriers = None , polygonBarriers = None ) : <EOL> """<STR_LIT>""" <EOL> def ptlist_as_semilist ( lst ) : <EOL> if isinstance ( lst , geometry . Point ) : <EOL> lst = [ lst ] <EOL> if isinstance ( lst , ( list , tuple ) ) : <EOL> return "<STR_LIT:;>" . join ( '<STR_LIT:U+002C>' . join ( str ( x ) for x in pt ) for pt in lst ) <EOL> return lst <EOL> if self . layerType != "<STR_LIT>" : <EOL> raise TypeError ( "<STR_LIT>" <EOL> % self . layerType ) <EOL> return self . _get_subfolder ( '<STR_LIT>' , NetworkSolveResult , <EOL> { '<STR_LIT>' : ptlist_as_semilist ( stops ) , <EOL> '<STR_LIT>' : ptlist_as_semilist ( barriers ) , <EOL> '<STR_LIT>' : returnDirections , <EOL> '<STR_LIT>' : returnRoutes , <EOL> '<STR_LIT>' : returnStops , <EOL> '<STR_LIT>' : returnBarriers , <EOL> '<STR_LIT>' : outSR , <EOL> '<STR_LIT>' : ignoreInvalidLocations , <EOL> '<STR_LIT>' : outputLines , <EOL> '<STR_LIT>' : findBestSequence , <EOL> '<STR_LIT>' : preserveFirstStop , <EOL> '<STR_LIT>' : preserveLastStop , <EOL> '<STR_LIT>' : useTimeWindows , <EOL> '<STR_LIT>' : startTime , <EOL> '<STR_LIT>' : accumulateAttributeNames , <EOL> '<STR_LIT>' : impedanceAttributeName , <EOL> '<STR_LIT>' : restrictionAttributeNames , <EOL> '<STR_LIT>' : restrictUTurns , <EOL> '<STR_LIT>' : useHierarchy , <EOL> '<STR_LIT>' : directionsLanguage , <EOL> '<STR_LIT>' : outputGeometryPrecision , <EOL> '<STR_LIT>' : directionsLengthUnits , <EOL> '<STR_LIT>' : <EOL> directionsTimeAttributeName , <EOL> '<STR_LIT>' : attributeParameterValues , <EOL> '<STR_LIT>' : polylineBarriers , <EOL> '<STR_LIT>' : polygonBarriers } ) <EOL> class GeoDataVersion ( RestURL ) : <EOL> """<STR_LIT>""" <EOL> @ property <EOL> def name ( self ) : <EOL> return self . _json_struct [ '<STR_LIT:name>' ] <EOL> @ property <EOL> def description ( self ) : <EOL> return self . _json_struct [ '<STR_LIT:description>' ] <EOL> @ property <EOL> def created ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def modified ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def access ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def parentVersion ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def childVersions ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def children ( self ) : <EOL> return [ self . _get_subfolder ( "<STR_LIT>" % version_name , <EOL> GeoDataVersion ) <EOL> for version_name in <EOL> self . _json_struct [ '<STR_LIT>' ] ] <EOL> @ property <EOL> def ancestorVersions ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def ancestors ( self ) : <EOL> return [ self . _get_subfolder ( "<STR_LIT>" % version_name , <EOL> GeoDataVersion ) <EOL> for version_name in <EOL> self . _json_struct [ '<STR_LIT>' ] ] <EOL> class GeoDataReplica ( RestURL ) : <EOL> """<STR_LIT>""" <EOL> @ property <EOL> def name ( self ) : <EOL> return self . _json_struct [ '<STR_LIT:name>' ] <EOL> @ property <EOL> def id ( self ) : <EOL> return self . _json_struct [ '<STR_LIT:id>' ] <EOL> @ property <EOL> def replicaVersion ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def guid ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def role ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def accessType ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def myGenerationNumber ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def sibGenerationNumber ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def sibMyGenerationNumber ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def replicaState ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def sibConnectionString ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def modelType ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def singleGeneration ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def spatialRelation ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def queryGeometryType ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def queryGeometry ( self ) : <EOL> return geometry . fromJson ( self . _json_struct [ '<STR_LIT>' ] ) <EOL> @ property <EOL> def transferRelatedObjects ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def reconcilePolicy ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ Folder . _register_service_type <EOL> class GeoDataService ( Service ) : <EOL> """<STR_LIT>""" <EOL> __service_type__ = "<STR_LIT>" <EOL> @ property <EOL> def workspaceType ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def defaultWorkingVersionName ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def defaultWorkingVersion ( self ) : <EOL> return self . _get_subfolder ( "<STR_LIT>" % <EOL> self . defaultWorkingVersionName , <EOL> GeoDataVersion ) <EOL> @ property <EOL> def versionNames ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def versions ( self ) : <EOL> return [ self . _get_subfolder ( "<STR_LIT>" % version , GeoDataVersion ) <EOL> for version in self . versionNames ] <EOL> @ property <EOL> def replicaNames ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def replicas ( self ) : <EOL> return [ self . _get_subfolder ( "<STR_LIT>" % version , GeoDataReplica ) <EOL> for replica in self . replicaNames ] <EOL> class GlobeLayer ( Layer ) : <EOL> """<STR_LIT>""" <EOL> @ property <EOL> def id ( self ) : <EOL> return self . _json_struct [ '<STR_LIT:id>' ] <EOL> @ property <EOL> def name ( self ) : <EOL> return self . _json_struct [ '<STR_LIT:name>' ] <EOL> @ property <EOL> def type ( self ) : <EOL> return self . _json_struct [ '<STR_LIT:type>' ] <EOL> @ property <EOL> def description ( self ) : <EOL> return self . _json_struct [ '<STR_LIT:description>' ] <EOL> @ property <EOL> def extent ( self ) : <EOL> return geometry . fromJson ( self . _json_struct [ '<STR_LIT>' ] ) <EOL> @ property <EOL> def dataType ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def maxDistance ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def minDistance ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def samplingMode ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def baseID ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def baseOption ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def extrusionType ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def extrusionExpression ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def cullMode ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def copyrightText ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def displayField ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def fields ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] <EOL> @ property <EOL> def parentLayer ( self ) : <EOL> return self . _get_subfolder ( "<STR_LIT>" % <EOL> self . _json_struct [ '<STR_LIT>' ] [ '<STR_LIT:id>' ] , <EOL> GlobeLayer ) <EOL> @ property <EOL> def subLayers ( self ) : <EOL> return [ self . _get_subfolder ( "<STR_LIT>" % layer [ '<STR_LIT:id>' ] , GlobeLayer ) <EOL> for layer in self . _json_struct [ '<STR_LIT>' ] ] <EOL> @ Folder . _register_service_type <EOL> class GlobeService ( Service ) : <EOL> """<STR_LIT>""" <EOL> __service_type__ = "<STR_LIT>" <EOL> @ property <EOL> def layernames ( self ) : <EOL> """<STR_LIT>""" <EOL> return [ layer [ '<STR_LIT:name>' ] for layer in self . _json_struct [ '<STR_LIT>' ] ] <EOL> @ property <EOL> def layers ( self ) : <EOL> """<STR_LIT>""" <EOL> return [ self . _get_subfolder ( "<STR_LIT>" % layer [ '<STR_LIT:id>' ] , GlobeLayer ) <EOL> for layer in self . _json_struct [ '<STR_LIT>' ] ] <EOL> @ Folder . _register_service_type <EOL> class FeatureLayerFeature ( object ) : <EOL> """<STR_LIT>""" <EOL> @ property <EOL> def geometry ( self ) : <EOL> if '<STR_LIT>' in self . _json_struct [ '<STR_LIT>' ] : <EOL> geom = geometry . fromJson ( <EOL> self . _json_struct [ '<STR_LIT>' ] . get ( '<STR_LIT>' , <EOL> None ) , <EOL> self . _json_struct [ '<STR_LIT>' ] . get ( '<STR_LIT>' , <EOL> { } ) ) <EOL> else : <EOL> geom = geometry . NullGeometry ( ) <EOL> geom . attributes = self . _json_struct [ '<STR_LIT>' ] . get ( '<STR_LIT>' , <EOL> { } ) <EOL> return geom <EOL> @ property <EOL> def attributes ( self ) : <EOL> return self . _json_struct [ '<STR_LIT>' ] . get ( '<STR_LIT>' , <EOL> { } ) <EOL> @ property <EOL> def attachments ( self ) : <EOL> return self . _get_subfolder ( "<STR_LIT>" , AttachmentInfos ) <EOL> def AddAttachment ( self , attachment = None ) : <EOL> """<STR_LIT>""" <EOL> return self . _get_subfolder ( "<STR_LIT>" , JsonPostResult , <EOL> { '<STR_LIT>' : attachment } ) <EOL> def UpdateAttachment ( self , attachmentId = None , attachment = None ) : <EOL> """<STR_LIT>""" <EOL> return self . _get_subfolder ( "<STR_LIT>" , JsonPostResult , <EOL> { '<STR_LIT>' : attachment , <EOL> '<STR_LIT>' : attachmentId } ) <EOL> def DeleteAttachments ( self , attachmentIds = None ) : <EOL> """<STR_LIT>""" <EOL> return self . _get_subfolder ( "<STR_LIT>" , JsonPostResult , <EOL> { '<STR_LIT>' : attachmentIds } ) <EOL> class FeatureLayer ( MapLayer ) : <EOL> """<STR_LIT>""" <EOL> def __getitem__ ( self , index ) : <EOL> """<STR_LIT>""" <EOL> return self . _get_subfolder ( str ( index ) , FeatureLayerFeature ) <EOL> def Feature ( self , featureId ) : <EOL> """<STR_LIT>""" <EOL> return self [ featureId ] <EOL> def QueryRelatedRecords ( self , objectIds = None , relationshipId = None , <EOL> outFields = None , definitionExpression = None , <EOL> returnGeometry = None , outSR = None ) : <EOL> """<STR_LIT>""" <EOL> out = self . _get_subfolder ( "<STR_LIT>" , JsonResult , { <EOL> '<STR_LIT>' : <EOL> objectIds , <EOL> '<STR_LIT>' : <EOL> relationshipId , <EOL> '<STR_LIT>' : <EOL> outFields , <EOL> '<STR_LIT>' : <EOL> definitionExpression , <EOL> '<STR_LIT>' : <EOL> returnGeometry , <EOL> '<STR_LIT>' : outSR <EOL> } ) <EOL> return out . _json_struct <EOL> def AddFeatures ( self , features ) : <EOL> """<STR_LIT>""" <EOL> fd = { '<STR_LIT>' : "<STR_LIT:U+002C>" . join ( json . dumps ( <EOL> feature . _json_struct_for_featureset ) <EOL> for feature in features ) } <EOL> return self . _get_subfolder ( "<STR_LIT>" , JsonPostResult , fd ) <EOL> def UpdateFeatures ( self , features ) : <EOL> """<STR_LIT>""" <EOL> fd = { '<STR_LIT>' : "<STR_LIT:U+002C>" . join ( json . dumps ( <EOL> feature . _json_struct_for_featureset ) <EOL> for feature in features ) } <EOL> return self . _get_subfolder ( "<STR_LIT>" , JsonPostResult , fd ) <EOL> def DeleteFeatures ( self , objectIds = None , where = None , geometry = None , <EOL> inSR = None , spatialRel = None ) : <EOL> """<STR_LIT>""" <EOL> gt = geometry . __geometry_type__ <EOL> if sr is None : <EOL> sr = geometry . spatialReference . wkid <EOL> geo_json = json . dumps ( Geometry . _json_struct_without_sr ) <EOL> return self . _get_subfolder ( "<STR_LIT>" , JsonPostResult , { <EOL> '<STR_LIT>' : objectIds , <EOL> '<STR_LIT>' : where , <EOL> '<STR_LIT>' : geo_json , <EOL> '<STR_LIT>' : <EOL> geometryType , <EOL> '<STR_LIT>' : inSR , <EOL> '<STR_LIT>' : spatialRel <EOL> } ) <EOL> def ApplyEdits ( self , adds = None , updates = None , deletes = None ) : <EOL> """<STR_LIT>""" <EOL> add_str , update_str = None , None <EOL> if adds : <EOL> add_str = "<STR_LIT:U+002C>" . join ( json . dumps ( <EOL> feature . _json_struct_for_featureset ) <EOL> for feature in adds ) <EOL> if updates : <EOL> update_str = "<STR_LIT:U+002C>" . join ( json . dumps ( <EOL> feature . _json_struct_for_featureset ) <EOL> for feature in updates ) <EOL> return self . _get_subfolder ( "<STR_LIT>" , JsonPostResult , <EOL> { '<STR_LIT>' : <EOL> add_str , <EOL> '<STR_LIT>' : <EOL> update_str , <EOL> '<STR_LIT>' : <EOL> deletes <EOL> } ) <EOL> @ Folder . _register_service_type <EOL> class FeatureService ( Service ) : <EOL> """<STR_LIT>""" <EOL> __service_type__ = "<STR_LIT>" <EOL> @ property <EOL> def layernames ( self ) : <EOL> """<STR_LIT>""" <EOL> return [ layer [ '<STR_LIT:name>' ] for layer in self . _json_struct [ '<STR_LIT>' ] ] <EOL> @ property <EOL> def layers ( self ) : <EOL> """<STR_LIT>""" <EOL> return [ self . _get_subfolder ( "<STR_LIT>" % layer [ '<STR_LIT:id>' ] , FeatureLayer ) <EOL> for layer in self . _json_struct [ '<STR_LIT>' ] ] <EOL> @ property <EOL> def tablenames ( self ) : <EOL> """<STR_LIT>""" <EOL> return [ table [ '<STR_LIT:name>' ] for table in self . _json_struct . get ( '<STR_LIT>' , [ ] ) ] <EOL> @ property <EOL> def tables ( self ) : <EOL> """<STR_LIT>""" <EOL> return [ self . _get_subfolder ( "<STR_LIT>" % table [ '<STR_LIT:id>' ] , FeatureLayer ) <EOL> for table in self . _json_struct . get ( '<STR_LIT>' , [ ] ) ] </s>
