idx
int64
0
63k
question
stringlengths
61
4.03k
target
stringlengths
6
1.23k
57,100
def __init ( self ) : params = { "f" : "json" } json_dict = self . _get ( url = self . _url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) attributes = [ attr for attr in dir ( self ) if not attr . startswith ( '__' ) and not attr . ...
initializes all the properties
57,101
def download ( self , itemID , savePath ) : if os . path . isdir ( savePath ) == False : os . makedirs ( savePath ) url = self . _url + "/%s/download" % itemID params = { } if len ( params . keys ( ) ) : url = url + "?%s" % urlencode ( params ) return self . _get ( url = url , param_dict = params , out_folder = savePat...
downloads an item to local disk
57,102
def reports ( self ) : if self . _metrics is None : self . __init ( ) self . _reports = [ ] for r in self . _metrics : url = self . _url + "/%s" % six . moves . urllib . parse . quote_plus ( r [ 'reportname' ] ) self . _reports . append ( UsageReport ( url = url , securityHandler = self . _securityHandler , proxy_url =...
returns a list of reports on the server
57,103
def editUsageReportSettings ( self , samplingInterval , enabled = True , maxHistory = 0 ) : params = { "f" : "json" , "maxHistory" : maxHistory , "enabled" : enabled , "samplingInterval" : samplingInterval } url = self . _url + "/settings/edit" return self . _post ( url = url , param_dict = params , securityHandler = s...
The usage reports settings are applied to the entire site . A POST request updates the usage reports settings .
57,104
def createUsageReport ( self , reportname , queries , metadata , since = "LAST_DAY" , fromValue = None , toValue = None , aggregationInterval = None ) : url = self . _url + "/add" params = { "f" : "json" , "usagereport" : { "reportname" : reportname , "since" : since , "metadata" : metadata } } if isinstance ( queries ...
Creates a new usage report . A usage report is created by submitting a JSON representation of the usage report to this operation .
57,105
def edit ( self ) : usagereport_dict = { "reportname" : self . reportname , "queries" : self . _queries , "since" : self . since , "metadata" : self . _metadata , "to" : self . _to , "from" : self . _from , "aggregationInterval" : self . _aggregationInterval } params = { "f" : "json" , "usagereport" : json . dumps ( us...
Edits the usage report . To edit a usage report you need to submit the complete JSON representation of the usage report which includes updates to the usage report properties . The name of the report cannot be changed when editing the usage report .
57,106
def __init ( self ) : params = { "f" : "json" , } json_dict = self . _get ( self . _url , params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) self . _json_dict = json_dict self . _json = json . dumps ( self . _json_dict ) attributes = [ attr for attr in...
inializes the properties
57,107
def replicasResource ( self ) : if self . _replicasResource is None : self . _replicasResource = { } for replica in self . replicas : self . _replicasResource [ "replicaName" ] = replica . name self . _replicasResource [ "replicaID" ] = replica . guid return self . _replicasResource
returns a list of replices
57,108
def services ( self ) : self . _services = [ ] params = { "f" : "json" } if not self . _url . endswith ( '/services' ) : uURL = self . _url + "/services" else : uURL = self . _url res = self . _get ( url = uURL , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_u...
returns all the service objects in the admin service s page
57,109
def refresh ( self , serviceDefinition = True ) : url = self . _url + "/MapServer/refresh" params = { "f" : "json" , "serviceDefinition" : serviceDefinition } res = self . _post ( url = self . _url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _p...
The refresh operation refreshes a service which clears the web server cache for the service .
57,110
def editTileService ( self , serviceDefinition = None , minScale = None , maxScale = None , sourceItemId = None , exportTilesAllowed = False , maxExportTileCount = 100000 ) : params = { "f" : "json" , } if not serviceDefinition is None : params [ "serviceDefinition" ] = serviceDefinition if not minScale is None : param...
This post operation updates a Tile Service s properties
57,111
def refresh ( self ) : params = { "f" : "json" } uURL = self . _url + "/refresh" res = self . _get ( url = uURL , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) self . __init ( ) return res
refreshes a service
57,112
def addToDefinition ( self , json_dict ) : params = { "f" : "json" , "addToDefinition" : json . dumps ( json_dict ) , "async" : False } uURL = self . _url + "/addToDefinition" res = self . _post ( url = uURL , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url ...
The addToDefinition operation supports adding a definition property to a hosted feature service . The result of this operation is a response indicating success or failure with error code and description .
57,113
def updateDefinition ( self , json_dict ) : definition = None if json_dict is not None : if isinstance ( json_dict , collections . OrderedDict ) == True : definition = json_dict else : definition = collections . OrderedDict ( ) if 'hasStaticData' in json_dict : definition [ 'hasStaticData' ] = json_dict [ 'hasStaticDat...
The updateDefinition operation supports updating a definition property in a hosted feature service . The result of this operation is a response indicating success or failure with error code and description .
57,114
def calc_resp ( password_hash , server_challenge ) : password_hash += b'\0' * ( 21 - len ( password_hash ) ) res = b'' dobj = des . DES ( password_hash [ 0 : 7 ] ) res = res + dobj . encrypt ( server_challenge [ 0 : 8 ] ) dobj = des . DES ( password_hash [ 7 : 14 ] ) res = res + dobj . encrypt ( server_challenge [ 0 : ...
calc_resp generates the LM response given a 16 - byte password hash and the challenge from the Type - 2 message .
57,115
def create_LM_hashed_password_v1 ( passwd ) : if re . match ( r'^[\w]{32}:[\w]{32}$' , passwd ) : return binascii . unhexlify ( passwd . split ( ':' ) [ 0 ] ) passwd = passwd . upper ( ) lm_pw = passwd + '\0' * ( 14 - len ( passwd ) ) lm_pw = passwd [ 0 : 14 ] magic_str = b"KGS!@#$%" res = b'' dobj = des . DES ( lm_pw ...
create LanManager hashed password
57,116
def _readcsv ( self , path_to_csv ) : return np . genfromtxt ( path_to_csv , dtype = None , delimiter = ',' , names = True )
reads a csv column
57,117
def queryDataCollectionByName ( self , countryName ) : var = self . _dataCollectionCodes try : return [ x [ 0 ] for x in var [ var [ 'Countries' ] == countryName ] ] except : return None
returns a list of available data collections for a given country name .
57,118
def __geometryToDict ( self , geom ) : if isinstance ( geom , dict ) : return geom elif isinstance ( geom , Point ) : pt = geom . asDictionary return { "geometry" : { "x" : pt [ 'x' ] , "y" : pt [ 'y' ] } } elif isinstance ( geom , Polygon ) : poly = geom . asDictionary return { "geometry" : { "rings" : poly [ 'rings' ...
converts a geometry object to a dictionary
57,119
def lookUpReportsByCountry ( self , countryName ) : code = self . findCountryTwoDigitCode ( countryName ) if code is None : raise Exception ( "Invalid country name." ) url = self . _base_url + self . _url_list_reports + "/%s" % code params = { "f" : "json" , } return self . _post ( url = url , param_dict = params , sec...
looks up a country by it s name Inputs countryName - name of the country to get reports list .
57,120
def createReport ( self , out_file_path , studyAreas , report = None , format = "PDF" , reportFields = None , studyAreasOptions = None , useData = None , inSR = 4326 , ) : url = self . _base_url + self . _url_create_report if isinstance ( studyAreas , list ) == False : studyAreas = [ studyAreas ] studyAreas = self . __...
The GeoEnrichment Create Report method uses the concept of a study area to define the location of the point or area that you want to enrich with generated reports . This method allows you to create many types of high - quality reports for a variety of use cases describing the input area . If a point is used as a study ...
57,121
def getVariables ( self , sourceCountry , optionalCountryDataset = None , searchText = None ) : r url = self . _base_url + self . _url_getVariables params = { "f" : "json" , "sourceCountry" : sourceCountry } if not searchText is None : params [ "searchText" ] = searchText if not optionalCountryDataset is None : params ...
r The GeoEnrichment GetVariables helper method allows you to search the data collections for variables that contain specific keywords .
57,122
def folders ( self ) : if self . _folders is None : self . __init ( ) if "/" not in self . _folders : self . _folders . append ( "/" ) return self . _folders
returns a list of all folders
57,123
def services ( self ) : self . _services = [ ] params = { "f" : "json" } json_dict = self . _get ( url = self . _currentURL , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) if "services" in json_dict . keys ( ) : for s in json_dict [ '...
returns the services in the current folder
57,124
def createService ( self , service ) : url = self . _url + "/createService" params = { "f" : "json" } if isinstance ( service , str ) : params [ 'service' ] = service elif isinstance ( service , dict ) : params [ 'service' ] = json . dumps ( service ) return self . _post ( url = url , param_dict = params , securityHand...
Creates a new GIS service in the folder . A service is created by submitting a JSON representation of the service to this operation .
57,125
def exists ( self , folderName , serviceName = None , serviceType = None ) : url = self . _url + "/exists" params = { "f" : "json" , "folderName" : folderName , "serviceName" : serviceName , "type" : serviceType } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_...
This operation allows you to check whether a folder or a service exists . To test if a folder exists supply only a folderName . To test if a service exists in a root folder supply both serviceName and serviceType with folderName = None . To test if a service exists in a folder supply all three parameters .
57,126
def __init ( self ) : params = { "f" : "json" } json_dict = self . _get ( url = self . _currentURL , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) self . _json = json . dumps ( json_dict ) self . _json_dict = json_dict attributes = [ ...
populates server admin information
57,127
def serviceManifest ( self , fileType = "json" ) : url = self . _url + "/iteminfo/manifest/manifest.%s" % fileType params = { } f = self . _get ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , out_folder = tempfile . gettem...
The service manifest resource documents the data and other resources that define the service origins and power the service . This resource will tell you underlying databases and their location along with other supplementary files that make up the service .
57,128
def startDataStoreMachine ( self , dataStoreItemName , machineName ) : url = self . _url + "/items/enterpriseDatabases/%s/machines/%s/start" % ( dataStoreItemName , machineName ) params = { "f" : "json" } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = sel...
Starts the database instance running on the Data Store machine .
57,129
def unregisterDataItem ( self , path ) : url = self . _url + "/unregisterItem" params = { "f" : "json" , "itempath" : path , "force" : "true" } return self . _post ( url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
Unregisters a data item that has been previously registered with the server s data store .
57,130
def validateDataStore ( self , dataStoreName , machineName ) : url = self . _url + "/items/enterpriseDatabases/%s/machines/%s/validate" % ( dataStoreName , machineName ) params = { "f" : "json" } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _prox...
Checks the status of ArcGIS Data Store and provides a health check response .
57,131
def layers ( self ) : if self . _layers is None : self . __init ( ) lyrs = [ ] for lyr in self . _layers : lyr [ 'object' ] = GlobeServiceLayer ( url = self . _url + "/%s" % lyr [ 'id' ] , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) lyrs . append ( lyr )...
gets the globe service layers
57,132
def loadFeatures ( self , path_to_fc ) : from . . common . spatial import featureclass_to_json v = json . loads ( featureclass_to_json ( path_to_fc ) ) self . value = v
loads a feature class features to the object
57,133
def fromFeatureClass ( fc , paramName ) : from . . common . spatial import featureclass_to_json val = json . loads ( featureclass_to_json ( fc ) ) v = GPFeatureRecordSetLayer ( ) v . value = val v . paramName = paramName return v
returns a GPFeatureRecordSetLayer object from a feature class
57,134
def asDictionary ( self ) : template = { "type" : "simple" , "symbol" : self . _symbol . asDictionary , "label" : self . _label , "description" : self . _description , "rotationType" : self . _rotationType , "rotationExpression" : self . _rotationExpression } return template
provides a dictionary representation of the object
57,135
def searchDiagrams ( self , whereClause = None , relatedObjects = None , relatedSchematicObjects = None ) : params = { "f" : "json" } if whereClause : params [ "where" ] = whereClause if relatedObjects : params [ "relatedObjects" ] = relatedObjects if relatedSchematicObjects : params [ "relatedSchematicObjects" ] = rel...
The Schematic Search Diagrams operation is performed on the schematic service resource . The result of this operation is an array of Schematic Diagram Information Object .
57,136
def _validateurl ( self , url ) : parsed = urlparse ( url ) path = parsed . path . strip ( "/" ) if path : parts = path . split ( "/" ) url_types = ( "admin" , "manager" , "rest" ) if any ( i in parts for i in url_types ) : while parts . pop ( ) not in url_types : next elif "services" in parts : while parts . pop ( ) n...
assembles the server url
57,137
def admin ( self ) : if self . _securityHandler is None : raise Exception ( "Cannot connect to adminstrative server without authentication" ) from . . manageags import AGSAdministration return AGSAdministration ( url = self . _adminUrl , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_...
points to the adminstrative side of ArcGIS Server
57,138
def addUser ( self , username , password , firstname , lastname , email , role ) : self . _invites . append ( { "username" : username , "password" : password , "firstname" : firstname , "lastname" : lastname , "fullname" : "%s %s" % ( firstname , lastname ) , "email" : email , "role" : role } )
adds a user to the invitation list
57,139
def removeByIndex ( self , index ) : if index < len ( self . _invites ) - 1 and index >= 0 : self . _invites . remove ( index )
removes a user from the invitation list by position
57,140
def fromDictionary ( value ) : if isinstance ( value , dict ) : pp = PortalParameters ( ) for k , v in value . items ( ) : setattr ( pp , "_%s" % k , v ) return pp else : raise AttributeError ( "Invalid input." )
creates the portal properties object from a dictionary
57,141
def value ( self ) : val = { } for k in self . __allowed_keys : value = getattr ( self , "_" + k ) if value is not None : val [ k ] = value return val
returns the values as a dictionary
57,142
def tile_fonts ( self , fontstack , stack_range , out_folder = None ) : url = "{url}/resources/fonts/{fontstack}/{stack_range}.pbf" . format ( url = self . _url , fontstack = fontstack , stack_range = stack_range ) params = { } if out_folder is None : out_folder = tempfile . gettempdir ( ) return self . _get ( url = ur...
This resource returns glyphs in PBF format . The template url for this fonts resource is represented in Vector Tile Style resource .
57,143
def tile_sprite ( self , out_format = "sprite.json" , out_folder = None ) : url = "{url}/resources/sprites/{f}" . format ( url = self . _url , f = out_format ) if out_folder is None : out_folder = tempfile . gettempdir ( ) return self . _get ( url = url , param_dict = { } , out_folder = out_folder , securityHandler = s...
This resource returns sprite image and metadata
57,144
def layers ( self ) : if self . _layers is None : self . __init ( ) self . _getLayers ( ) return self . _layers
gets the layers for the feature service
57,145
def _getLayers ( self ) : params = { "f" : "json" } json_dict = self . _get ( self . _url , params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) self . _layers = [ ] if 'layers' in json_dict : for l in json_dict [ "layers" ] : self . _layers . append ( l...
gets layers for the featuer service
57,146
def query ( self , layerDefsFilter = None , geometryFilter = None , timeFilter = None , returnGeometry = True , returnIdsOnly = False , returnCountOnly = False , returnZ = False , returnM = False , outSR = None ) : qurl = self . _url + "/query" params = { "f" : "json" , "returnGeometry" : returnGeometry , "returnIdsOnl...
The Query operation is performed on a feature service resource
57,147
def create_feature_layer ( ds , sql , name = "layer" ) : if arcpyFound == False : raise Exception ( "ArcPy is required to use this function" ) result = arcpy . MakeFeatureLayer_management ( in_features = ds , out_layer = name , where_clause = sql ) return result [ 0 ]
creates a feature layer object
57,148
def featureclass_to_json ( fc ) : if arcpyFound == False : raise Exception ( "ArcPy is required to use this function" ) desc = arcpy . Describe ( fc ) if desc . dataType == "Table" or desc . dataType == "TableView" : return recordset_to_json ( table = fc ) else : return arcpy . FeatureSet ( fc ) . JSON
converts a feature class to JSON
57,149
def get_attachment_data ( attachmentTable , sql , nameField = "ATT_NAME" , blobField = "DATA" , contentTypeField = "CONTENT_TYPE" , rel_object_field = "REL_OBJECTID" ) : if arcpyFound == False : raise Exception ( "ArcPy is required to use this function" ) ret_rows = [ ] with arcpy . da . SearchCursor ( attachmentTable ...
gets all the data to pass to a feature service
57,150
def get_records_with_attachments ( attachment_table , rel_object_field = "REL_OBJECTID" ) : if arcpyFound == False : raise Exception ( "ArcPy is required to use this function" ) OIDs = [ ] with arcpy . da . SearchCursor ( attachment_table , [ rel_object_field ] ) as rows : for row in rows : if not str ( row [ 0 ] ) in ...
returns a list of ObjectIDs for rows in the attachment table
57,151
def get_OID_field ( fs ) : if arcpyFound == False : raise Exception ( "ArcPy is required to use this function" ) desc = arcpy . Describe ( fs ) if desc . hasOID : return desc . OIDFieldName return None
returns a featureset s object id field
57,152
def merge_feature_class ( merges , out_fc , cleanUp = True ) : if arcpyFound == False : raise Exception ( "ArcPy is required to use this function" ) if cleanUp == False : if len ( merges ) == 0 : return None elif len ( merges ) == 1 : desc = arcpy . Describe ( merges [ 0 ] ) if hasattr ( desc , 'shapeFieldName' ) : ret...
merges featureclass into a single feature class
57,153
def insert_rows ( fc , features , fields , includeOIDField = False , oidField = None ) : if arcpyFound == False : raise Exception ( "ArcPy is required to use this function" ) icur = None if includeOIDField : arcpy . AddField_management ( fc , "FSL_OID" , "LONG" ) fields . append ( "FSL_OID" ) if len ( features ) > 0 : ...
inserts rows based on a list features object
57,154
def create_feature_class ( out_path , out_name , geom_type , wkid , fields , objectIdField ) : if arcpyFound == False : raise Exception ( "ArcPy is required to use this function" ) arcpy . env . overwriteOutput = True field_names = [ ] fc = arcpy . CreateFeatureclass_management ( out_path = out_path , out_name = out_na...
creates a feature class in a given gdb or folder
57,155
def download_arcrest ( ) : arcrest_name = "arcrest.zip" arcresthelper_name = "arcresthelper.zip" url = "https://github.com/Esri/ArcREST/archive/master.zip" file_name = os . path . join ( arcpy . env . scratchFolder , os . path . basename ( url ) ) scratch_folder = os . path . join ( arcpy . env . scratchFolder , "temp3...
downloads arcrest to disk
57,156
def handler ( self ) : if hasNTLM : if self . _handler is None : passman = request . HTTPPasswordMgrWithDefaultRealm ( ) passman . add_password ( None , self . _parsed_org_url , self . _login_username , self . _password ) self . _handler = HTTPNtlmAuthHandler . HTTPNtlmAuthHandler ( passman ) return self . _handler els...
gets the security handler for the class
57,157
def token ( self ) : return self . _portalTokenHandler . servertoken ( serverURL = self . _serverUrl , referer = self . _referer )
gets the AGS server token
57,158
def token ( self ) : if self . _token is None or datetime . datetime . now ( ) >= self . _token_expires_on : self . _generateForOAuthSecurity ( self . _client_id , self . _secret_id , self . _token_url ) return self . _token
obtains a token from the site
57,159
def _generateForOAuthSecurity ( self , client_id , secret_id , token_url = None ) : grant_type = "client_credentials" if token_url is None : token_url = "https://www.arcgis.com/sharing/rest/oauth2/token" params = { "client_id" : client_id , "client_secret" : secret_id , "grant_type" : grant_type , "f" : "json" } token ...
generates a token based on the OAuth security model
57,160
def referer_url ( self , value ) : if self . _referer_url != value : self . _token = None self . _referer_url = value
sets the referer url
57,161
def __getRefererUrl ( self , url = None ) : if url is None : url = "http://www.arcgis.com/sharing/rest/portals/self" params = { "f" : "json" , "token" : self . token } val = self . _get ( url = url , param_dict = params , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) self . _referer_url = "arcgis.co...
gets the referer url for the token handler
57,162
def servertoken ( self , serverURL , referer ) : if self . _server_token is None or self . _server_token_expires_on is None or datetime . datetime . now ( ) >= self . _server_token_expires_on or self . _server_url != serverURL : self . _server_url = serverURL result = self . _generateForServerTokenSecurity ( serverURL ...
returns the server token for the server
57,163
def exportCertificate ( self , certificate , folder ) : url = self . _url + "/sslcertificates/%s/export" % certificate params = { "f" : "json" , } return self . _get ( url = url , param_dict = params , out_folder = folder )
gets the SSL Certificates for a given machine
57,164
def currentVersion ( self ) : if self . _currentVersion is None : self . __init ( self . _url ) return self . _currentVersion
returns the current version of the site
57,165
def portals ( self ) : url = "%s/portals" % self . root return _portals . Portals ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
returns the Portals class that provides administration access into a given organization
57,166
def oauth2 ( self ) : if self . _url . endswith ( "/oauth2" ) : url = self . _url else : url = self . _url + "/oauth2" return _oauth2 . oauth2 ( oauth_url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
returns the oauth2 class
57,167
def community ( self ) : return _community . Community ( url = self . _url + "/community" , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
The portal community root covers user and group resources and operations .
57,168
def content ( self ) : return _content . Content ( url = self . _url + "/content" , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
returns access into the site s content
57,169
def search ( self , q , t = None , focus = None , bbox = None , start = 1 , num = 10 , sortField = None , sortOrder = "asc" , useSecurity = True ) : if self . _url . endswith ( "/rest" ) : url = self . _url + "/search" else : url = self . _url + "/rest/search" params = { "f" : "json" , "q" : q , "sortOrder" : sortOrder...
This operation searches for content items in the portal . The searches are performed against a high performance index that indexes the most popular fields of an item . See the Search reference page for information on the fields and the syntax of the query . The search index is updated whenever users add update or delet...
57,170
def hostingServers ( self ) : portals = self . portals portal = portals . portalSelf urls = portal . urls if 'error' in urls : print ( urls ) return services = [ ] if urls != { } : if 'urls' in urls : if 'features' in urls [ 'urls' ] : if 'https' in urls [ 'urls' ] [ 'features' ] : for https in urls [ 'urls' ] [ 'featu...
Returns the objects to manage site s hosted services . It returns AGSAdministration object if the site is Portal and it returns a hostedservice . Services object if it is AGOL .
57,171
def add_codedValue ( self , name , code ) : if self . _codedValues is None : self . _codedValues = [ ] self . _codedValues . append ( { "name" : name , "code" : code } )
adds a value to the coded value list
57,172
def __init ( self ) : res = self . _get ( url = self . _url , param_dict = { "f" : "json" } , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) self . _json_dict = res self . _json_string = json . dumps ( self . _json_dict ) for k , v in self . _json_dict . it...
loads the json values
57,173
def areasAndLengths ( self , polygons , lengthUnit , areaUnit , calculationType , ) : url = self . _url + "/areasAndLengths" params = { "f" : "json" , "lengthUnit" : lengthUnit , "areaUnit" : { "areaUnit" : areaUnit } , "calculationType" : calculationType } if isinstance ( polygons , list ) and len ( polygons ) > 0 : p...
The areasAndLengths operation is performed on a geometry service resource . This operation calculates areas and perimeter lengths for each polygon specified in the input array .
57,174
def __geometryToGeomTemplate ( self , geometry ) : template = { "geometryType" : None , "geometry" : None } if isinstance ( geometry , Polyline ) : template [ 'geometryType' ] = "esriGeometryPolyline" elif isinstance ( geometry , Polygon ) : template [ 'geometryType' ] = "esriGeometryPolygon" elif isinstance ( geometry...
Converts a single geometry object to a geometry service geometry template value .
57,175
def __geomToStringArray ( self , geometries , returnType = "str" ) : listGeoms = [ ] for g in geometries : if isinstance ( g , Point ) : listGeoms . append ( g . asDictionary ) elif isinstance ( g , Polygon ) : listGeoms . append ( g . asDictionary ) elif isinstance ( g , Polyline ) : listGeoms . append ( { 'paths' : g...
function to convert the geomtries to strings
57,176
def autoComplete ( self , polygons = [ ] , polylines = [ ] , sr = None ) : url = self . _url + "/autoComplete" params = { "f" : "json" } if sr is not None : params [ 'sr' ] = sr params [ 'polygons' ] = self . __geomToStringArray ( polygons ) params [ 'polylines' ] = self . __geomToStringArray ( polylines ) return self ...
The autoComplete operation simplifies the process of constructing new polygons that are adjacent to other polygons . It constructs polygons that fill in the gaps between existing polygons and a set of polylines .
57,177
def buffer ( self , geometries , inSR , distances , units , outSR = None , bufferSR = None , unionResults = True , geodesic = True ) : url = self . _url + "/buffer" params = { "f" : "json" , "inSR" : inSR , "geodesic" : geodesic , "unionResults" : unionResults } if isinstance ( geometries , list ) and len ( geometries ...
The buffer operation is performed on a geometry service resource The result of this operation is buffered polygons at the specified distances for the input geometry array . Options are available to union buffers and to use geodesic distance .
57,178
def findTransformation ( self , inSR , outSR , extentOfInterest = None , numOfResults = 1 ) : params = { "f" : "json" , "inSR" : inSR , "outSR" : outSR } url = self . _url + "/findTransformations" if isinstance ( numOfResults , int ) : params [ 'numOfResults' ] = numOfResults if isinstance ( extentOfInterest , Envelope...
The findTransformations operation is performed on a geometry service resource . This operation returns a list of applicable geographic transformations you should use when projecting geometries from the input spatial reference to the output spatial reference . The transformations are in JSON format and are returned in o...
57,179
def fromGeoCoordinateString ( self , sr , strings , conversionType , conversionMode = None ) : url = self . _url + "/fromGeoCoordinateString" params = { "f" : "json" , "sr" : sr , "strings" : strings , "conversionType" : conversionType } if not conversionMode is None : params [ 'conversionMode' ] = conversionMode retur...
The fromGeoCoordinateString operation is performed on a geometry service resource . The operation converts an array of well - known strings into xy - coordinates based on the conversion type and spatial reference supplied by the user . An optional conversion mode parameter is available for some conversion types .
57,180
def toGeoCoordinateString ( self , sr , coordinates , conversionType , conversionMode = "mgrsDefault" , numOfDigits = None , rounding = True , addSpaces = True ) : params = { "f" : "json" , "sr" : sr , "coordinates" : coordinates , "conversionType" : conversionType } url = self . _url + "/toGeoCoordinateString" if not ...
The toGeoCoordinateString operation is performed on a geometry service resource . The operation converts an array of xy - coordinates into well - known strings based on the conversion type and spatial reference supplied by the user . Optional parameters are available for some conversion types . Note that if an optional...
57,181
def __init_url ( self ) : portals_self_url = "{}/portals/self" . format ( self . _url ) params = { "f" : "json" } if not self . _securityHandler is None : params [ 'token' ] = self . _securityHandler . token res = self . _get ( url = portals_self_url , param_dict = params , securityHandler = self . _securityHandler , p...
loads the information into the class
57,182
def get_argument_parser ( name = None , ** kwargs ) : if name is None : name = "default" if len ( kwargs ) > 0 or name not in _parsers : init_argument_parser ( name , ** kwargs ) return _parsers [ name ]
Returns the global ArgumentParser instance with the given name . The 1st time this function is called a new ArgumentParser instance will be created for the given name and any args other than name will be passed on to the ArgumentParser constructor .
57,183
def parse ( self , stream ) : items = OrderedDict ( ) for i , line in enumerate ( stream ) : line = line . strip ( ) if not line or line [ 0 ] in [ "#" , ";" , "[" ] or line . startswith ( "---" ) : continue white_space = "\\s*" key = "(?P<key>[^:=;#\s]+?)" value = white_space + "[:=\s]" + white_space + "(?P<value>.+?)...
Parses the keys + values from a config file .
57,184
def parse ( self , stream ) : yaml = self . _load_yaml ( ) try : parsed_obj = yaml . safe_load ( stream ) except Exception as e : raise ConfigFileParserException ( "Couldn't parse config file: %s" % e ) if not isinstance ( parsed_obj , dict ) : raise ConfigFileParserException ( "The config file doesn't appear to " "con...
Parses the keys and values from a config file .
57,185
def write_config_file ( self , parsed_namespace , output_file_paths , exit_after = False ) : for output_file_path in output_file_paths : try : with open ( output_file_path , "w" ) as output_file : pass except IOError as e : raise ValueError ( "Couldn't open %s for writing: %s" % ( output_file_path , e ) ) if output_fil...
Write the given settings to output files .
57,186
def convert_item_to_command_line_arg ( self , action , key , value ) : args = [ ] if action is None : command_line_key = self . get_command_line_key_for_unknown_config_file_setting ( key ) else : command_line_key = action . option_strings [ - 1 ] if action is not None and isinstance ( action , ACTION_TYPES_THAT_DONT_NE...
Converts a config file or env var key + value to a list of commandline args to append to the commandline .
57,187
def get_possible_config_keys ( self , action ) : keys = [ ] if getattr ( action , 'is_write_out_config_file_arg' , None ) : return keys for arg in action . option_strings : if any ( [ arg . startswith ( 2 * c ) for c in self . prefix_chars ] ) : keys += [ arg [ 2 : ] , arg ] return keys
This method decides which actions can be set in a config file and what their keys will be . It returns a list of 0 or more config keys that can be used to set the given action s value in a config file .
57,188
def eval ( lisp ) : macro_values = [ ] if not isinstance ( lisp , list ) : raise EvalError ( 'eval root element must be a list' ) for item in lisp : if not isinstance ( item , list ) : raise EvalError ( 'must evaluate list of list' ) if not all ( isinstance ( i , str ) for i in item ) : raise EvalError ( 'must evaluate...
plash lisp is one dimensional lisp .
57,189
def plash_map ( * args ) : from subprocess import check_output 'thin wrapper around plash map' out = check_output ( [ 'plash' , 'map' ] + list ( args ) ) if out == '' : return None return out . decode ( ) . strip ( '\n' )
thin wrapper around plash map
57,190
def defpm ( name , * lines ) : 'define a new package manager' @ register_macro ( name , group = 'package managers' ) @ shell_escape_args def package_manager ( * packages ) : if not packages : return sh_packages = ' ' . join ( pkg for pkg in packages ) expanded_lines = [ line . format ( sh_packages ) for line in lines ]...
define a new package manager
57,191
def layer ( command = None , * args ) : 'hints the start of a new layer' if not command : return eval ( [ [ 'hint' , 'layer' ] ] ) else : lst = [ [ 'layer' ] ] for arg in args : lst . append ( [ command , arg ] ) lst . append ( [ 'layer' ] ) return eval ( lst )
hints the start of a new layer
57,192
def import_env ( * envs ) : 'import environment variables from host' for env in envs : parts = env . split ( ':' , 1 ) if len ( parts ) == 1 : export_as = env else : env , export_as = parts env_val = os . environ . get ( env ) if env_val is not None : yield '{}={}' . format ( export_as , shlex . quote ( env_val ) )
import environment variables from host
57,193
def write_file ( fname , * lines ) : 'write lines to a file' yield 'touch {}' . format ( fname ) for line in lines : yield "echo {} >> {}" . format ( line , fname )
write lines to a file
57,194
def eval_file ( file ) : 'evaluate file content as expressions' fname = os . path . realpath ( os . path . expanduser ( file ) ) with open ( fname ) as f : inscript = f . read ( ) sh = run_write_read ( [ 'plash' , 'eval' ] , inscript . encode ( ) ) . decode ( ) if sh . endswith ( '\n' ) : return sh [ : - 1 ] return sh
evaluate file content as expressions
57,195
def eval_string ( stri ) : 'evaluate expressions passed as string' tokens = shlex . split ( stri ) return run_write_read ( [ 'plash' , 'eval' ] , '\n' . join ( tokens ) . encode ( ) ) . decode ( )
evaluate expressions passed as string
57,196
def eval_stdin ( ) : 'evaluate expressions read from stdin' cmd = [ 'plash' , 'eval' ] p = subprocess . Popen ( cmd , stdin = sys . stdin , stdout = sys . stdout ) exit = p . wait ( ) if exit : raise subprocess . CalledProcessError ( exit , cmd )
evaluate expressions read from stdin
57,197
def from_map ( map_key ) : 'use resolved map as image' image_id = subprocess . check_output ( [ 'plash' , 'map' , map_key ] ) . decode ( ) . strip ( '\n' ) if not image_id : raise MapDoesNotExist ( 'map {} not found' . format ( repr ( map_key ) ) ) return hint ( 'image' , image_id )
use resolved map as image
57,198
def fields ( self ) : fields = super ( DynamicFieldsMixin , self ) . fields if not hasattr ( self , '_context' ) : return fields is_root = self . root == self parent_is_list_root = self . parent == self . root and getattr ( self . parent , 'many' , False ) if not ( is_root or parent_is_list_root ) : return fields try :...
Filters the fields according to the fields query parameter .
57,199
def setup_admin_on_rest_handlers ( admin , admin_handler ) : add_route = admin . router . add_route add_static = admin . router . add_static static_folder = str ( PROJ_ROOT / 'static' ) a = admin_handler add_route ( 'GET' , '' , a . index_page , name = 'admin.index' ) add_route ( 'POST' , '/token' , a . token , name = ...
Initialize routes .