id
int32 0
252k
| repo
stringlengths 7
55
| path
stringlengths 4
127
| func_name
stringlengths 1
88
| original_string
stringlengths 75
19.8k
| language
stringclasses 1
value | code
stringlengths 75
19.8k
| code_tokens
list | docstring
stringlengths 3
17.3k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 87
242
|
|---|---|---|---|---|---|---|---|---|---|---|---|
13,100
|
Esri/ArcREST
|
src/arcrest/webmap/symbols.py
|
SimpleMarkerSymbol.color
|
def color(self, value):
""" sets the color """
if isinstance(value, (list, Color)):
if value is list:
self._color = value
else:
self._color = value.asList
|
python
|
def color(self, value):
""" sets the color """
if isinstance(value, (list, Color)):
if value is list:
self._color = value
else:
self._color = value.asList
|
[
"def",
"color",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"list",
",",
"Color",
")",
")",
":",
"if",
"value",
"is",
"list",
":",
"self",
".",
"_color",
"=",
"value",
"else",
":",
"self",
".",
"_color",
"=",
"value",
".",
"asList"
] |
sets the color
|
[
"sets",
"the",
"color"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/webmap/symbols.py#L157-L163
|
13,101
|
Esri/ArcREST
|
src/arcrest/webmap/symbols.py
|
SimpleMarkerSymbol.outlineColor
|
def outlineColor(self, value):
""" sets the outline color """
if isinstance(value, (list, Color)):
if value is list:
self._outlineColor = value
else:
self._outlineColor = value.asList
|
python
|
def outlineColor(self, value):
""" sets the outline color """
if isinstance(value, (list, Color)):
if value is list:
self._outlineColor = value
else:
self._outlineColor = value.asList
|
[
"def",
"outlineColor",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"list",
",",
"Color",
")",
")",
":",
"if",
"value",
"is",
"list",
":",
"self",
".",
"_outlineColor",
"=",
"value",
"else",
":",
"self",
".",
"_outlineColor",
"=",
"value",
".",
"asList"
] |
sets the outline color
|
[
"sets",
"the",
"outline",
"color"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/webmap/symbols.py#L229-L235
|
13,102
|
Esri/ArcREST
|
src/arcrest/webmap/symbols.py
|
SimpleFillSymbol.outline
|
def outline(self, value):
""" sets the outline """
if isinstance(value, SimpleLineSymbol):
self._outline = value.asDictionary
|
python
|
def outline(self, value):
""" sets the outline """
if isinstance(value, SimpleLineSymbol):
self._outline = value.asDictionary
|
[
"def",
"outline",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"SimpleLineSymbol",
")",
":",
"self",
".",
"_outline",
"=",
"value",
".",
"asDictionary"
] |
sets the outline
|
[
"sets",
"the",
"outline"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/webmap/symbols.py#L389-L392
|
13,103
|
Esri/ArcREST
|
src/arcrest/webmap/symbols.py
|
PictureMarkerSymbol.base64ToImage
|
def base64ToImage(imgData, out_path, out_file):
""" converts a base64 string to a file """
fh = open(os.path.join(out_path, out_file), "wb")
fh.write(imgData.decode('base64'))
fh.close()
del fh
return os.path.join(out_path, out_file)
|
python
|
def base64ToImage(imgData, out_path, out_file):
""" converts a base64 string to a file """
fh = open(os.path.join(out_path, out_file), "wb")
fh.write(imgData.decode('base64'))
fh.close()
del fh
return os.path.join(out_path, out_file)
|
[
"def",
"base64ToImage",
"(",
"imgData",
",",
"out_path",
",",
"out_file",
")",
":",
"fh",
"=",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"out_path",
",",
"out_file",
")",
",",
"\"wb\"",
")",
"fh",
".",
"write",
"(",
"imgData",
".",
"decode",
"(",
"'base64'",
")",
")",
"fh",
".",
"close",
"(",
")",
"del",
"fh",
"return",
"os",
".",
"path",
".",
"join",
"(",
"out_path",
",",
"out_file",
")"
] |
converts a base64 string to a file
|
[
"converts",
"a",
"base64",
"string",
"to",
"a",
"file"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/webmap/symbols.py#L448-L454
|
13,104
|
Esri/ArcREST
|
src/arcrest/ags/_geocodeservice.py
|
GeocodeService.find
|
def find(self,
text,
magicKey=None,
sourceCountry=None,
bbox=None,
location=None,
distance=3218.69,
outSR=102100,
category=None,
outFields="*",
maxLocations=20,
forStorage=False):
"""
The find operation geocodes one location per request; the input
address is specified in a single parameter.
Inputs:
text - Specifies the location to be geocoded. This can be a
street address, place name, postal code, or POI.
magicKey - The find operation retrieves results quicker when you
pass in valid text and magicKey values than when you don't pass
in magicKey. However, to get these advantages, you need to make
a prior request to suggest, which provides a magicKey. This may
or may not be relevant to your workflow.
sourceCountry - A value representing the country. Providing this
value increases geocoding speed. Acceptable values include the
full country name in English or the official language of the
country, the ISO 3166-1 2-digit country code, or the
ISO 3166-1 3-digit country code.
bbox - A set of bounding box coordinates that limit the search
area to a specific region. This is especially useful for
applications in which a user will search for places and
addresses only within the current map extent.
location - Defines an origin point location that is used with
the distance parameter to sort geocoding candidates based upon
their proximity to the location. The distance parameter
specifies the radial distance from the location in meters. The
priority of candidates within this radius is boosted relative
to those outside the radius.
distance - Specifies the radius of an area around a point
location which is used to boost the rank of geocoding
candidates so that candidates closest to the location are
returned first. The distance value is in meters.
outSR - The spatial reference of the x/y coordinates returned by
a geocode request. This is useful for applications using a map
with a spatial reference different than that of the geocode
service.
category - A place or address type which can be used to filter
find results. The parameter supports input of single category
values or multiple comma-separated values. The category
parameter can be passed in a request with or without the text
parameter.
outFields - The list of fields to be returned in the response.
maxLocation - The maximum number of locations to be returned by
a search, up to the maximum number allowed by the service. If
not specified, then one location will be returned.
forStorage - Specifies whether the results of the operation will
be persisted. The default value is false, which indicates the
results of the operation can't be stored, but they can be
temporarily displayed on a map for instance. If you store the
results, in a database for example, you need to set this
parameter to true.
"""
if isinstance(self._securityHandler, (AGOLTokenSecurityHandler, OAuthSecurityHandler)):
url = self._url + "/find"
params = {
"f" : "json",
"text" : text,
#"token" : self._securityHandler.token
}
if not magicKey is None:
params['magicKey'] = magicKey
if not sourceCountry is None:
params['sourceCountry'] = sourceCountry
if not bbox is None:
params['bbox'] = bbox
if not location is None:
if isinstance(location, Point):
params['location'] = location.asDictionary
if isinstance(location, list):
params['location'] = "%s,%s" % (location[0], location[1])
if not distance is None:
params['distance'] = distance
if not outSR is None:
params['outSR'] = outSR
if not category is None:
params['category'] = category
if outFields is None:
params['outFields'] = "*"
else:
params['outFields'] = outFields
if not maxLocations is None:
params['maxLocations'] = maxLocations
if not forStorage is None:
params['forStorage'] = forStorage
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
else:
raise Exception("This function works on the ArcGIS Online World Geocoder")
|
python
|
def find(self,
text,
magicKey=None,
sourceCountry=None,
bbox=None,
location=None,
distance=3218.69,
outSR=102100,
category=None,
outFields="*",
maxLocations=20,
forStorage=False):
"""
The find operation geocodes one location per request; the input
address is specified in a single parameter.
Inputs:
text - Specifies the location to be geocoded. This can be a
street address, place name, postal code, or POI.
magicKey - The find operation retrieves results quicker when you
pass in valid text and magicKey values than when you don't pass
in magicKey. However, to get these advantages, you need to make
a prior request to suggest, which provides a magicKey. This may
or may not be relevant to your workflow.
sourceCountry - A value representing the country. Providing this
value increases geocoding speed. Acceptable values include the
full country name in English or the official language of the
country, the ISO 3166-1 2-digit country code, or the
ISO 3166-1 3-digit country code.
bbox - A set of bounding box coordinates that limit the search
area to a specific region. This is especially useful for
applications in which a user will search for places and
addresses only within the current map extent.
location - Defines an origin point location that is used with
the distance parameter to sort geocoding candidates based upon
their proximity to the location. The distance parameter
specifies the radial distance from the location in meters. The
priority of candidates within this radius is boosted relative
to those outside the radius.
distance - Specifies the radius of an area around a point
location which is used to boost the rank of geocoding
candidates so that candidates closest to the location are
returned first. The distance value is in meters.
outSR - The spatial reference of the x/y coordinates returned by
a geocode request. This is useful for applications using a map
with a spatial reference different than that of the geocode
service.
category - A place or address type which can be used to filter
find results. The parameter supports input of single category
values or multiple comma-separated values. The category
parameter can be passed in a request with or without the text
parameter.
outFields - The list of fields to be returned in the response.
maxLocation - The maximum number of locations to be returned by
a search, up to the maximum number allowed by the service. If
not specified, then one location will be returned.
forStorage - Specifies whether the results of the operation will
be persisted. The default value is false, which indicates the
results of the operation can't be stored, but they can be
temporarily displayed on a map for instance. If you store the
results, in a database for example, you need to set this
parameter to true.
"""
if isinstance(self._securityHandler, (AGOLTokenSecurityHandler, OAuthSecurityHandler)):
url = self._url + "/find"
params = {
"f" : "json",
"text" : text,
#"token" : self._securityHandler.token
}
if not magicKey is None:
params['magicKey'] = magicKey
if not sourceCountry is None:
params['sourceCountry'] = sourceCountry
if not bbox is None:
params['bbox'] = bbox
if not location is None:
if isinstance(location, Point):
params['location'] = location.asDictionary
if isinstance(location, list):
params['location'] = "%s,%s" % (location[0], location[1])
if not distance is None:
params['distance'] = distance
if not outSR is None:
params['outSR'] = outSR
if not category is None:
params['category'] = category
if outFields is None:
params['outFields'] = "*"
else:
params['outFields'] = outFields
if not maxLocations is None:
params['maxLocations'] = maxLocations
if not forStorage is None:
params['forStorage'] = forStorage
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
else:
raise Exception("This function works on the ArcGIS Online World Geocoder")
|
[
"def",
"find",
"(",
"self",
",",
"text",
",",
"magicKey",
"=",
"None",
",",
"sourceCountry",
"=",
"None",
",",
"bbox",
"=",
"None",
",",
"location",
"=",
"None",
",",
"distance",
"=",
"3218.69",
",",
"outSR",
"=",
"102100",
",",
"category",
"=",
"None",
",",
"outFields",
"=",
"\"*\"",
",",
"maxLocations",
"=",
"20",
",",
"forStorage",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"_securityHandler",
",",
"(",
"AGOLTokenSecurityHandler",
",",
"OAuthSecurityHandler",
")",
")",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/find\"",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
",",
"\"text\"",
":",
"text",
",",
"#\"token\" : self._securityHandler.token",
"}",
"if",
"not",
"magicKey",
"is",
"None",
":",
"params",
"[",
"'magicKey'",
"]",
"=",
"magicKey",
"if",
"not",
"sourceCountry",
"is",
"None",
":",
"params",
"[",
"'sourceCountry'",
"]",
"=",
"sourceCountry",
"if",
"not",
"bbox",
"is",
"None",
":",
"params",
"[",
"'bbox'",
"]",
"=",
"bbox",
"if",
"not",
"location",
"is",
"None",
":",
"if",
"isinstance",
"(",
"location",
",",
"Point",
")",
":",
"params",
"[",
"'location'",
"]",
"=",
"location",
".",
"asDictionary",
"if",
"isinstance",
"(",
"location",
",",
"list",
")",
":",
"params",
"[",
"'location'",
"]",
"=",
"\"%s,%s\"",
"%",
"(",
"location",
"[",
"0",
"]",
",",
"location",
"[",
"1",
"]",
")",
"if",
"not",
"distance",
"is",
"None",
":",
"params",
"[",
"'distance'",
"]",
"=",
"distance",
"if",
"not",
"outSR",
"is",
"None",
":",
"params",
"[",
"'outSR'",
"]",
"=",
"outSR",
"if",
"not",
"category",
"is",
"None",
":",
"params",
"[",
"'category'",
"]",
"=",
"category",
"if",
"outFields",
"is",
"None",
":",
"params",
"[",
"'outFields'",
"]",
"=",
"\"*\"",
"else",
":",
"params",
"[",
"'outFields'",
"]",
"=",
"outFields",
"if",
"not",
"maxLocations",
"is",
"None",
":",
"params",
"[",
"'maxLocations'",
"]",
"=",
"maxLocations",
"if",
"not",
"forStorage",
"is",
"None",
":",
"params",
"[",
"'forStorage'",
"]",
"=",
"forStorage",
"return",
"self",
".",
"_post",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")",
"else",
":",
"raise",
"Exception",
"(",
"\"This function works on the ArcGIS Online World Geocoder\"",
")"
] |
The find operation geocodes one location per request; the input
address is specified in a single parameter.
Inputs:
text - Specifies the location to be geocoded. This can be a
street address, place name, postal code, or POI.
magicKey - The find operation retrieves results quicker when you
pass in valid text and magicKey values than when you don't pass
in magicKey. However, to get these advantages, you need to make
a prior request to suggest, which provides a magicKey. This may
or may not be relevant to your workflow.
sourceCountry - A value representing the country. Providing this
value increases geocoding speed. Acceptable values include the
full country name in English or the official language of the
country, the ISO 3166-1 2-digit country code, or the
ISO 3166-1 3-digit country code.
bbox - A set of bounding box coordinates that limit the search
area to a specific region. This is especially useful for
applications in which a user will search for places and
addresses only within the current map extent.
location - Defines an origin point location that is used with
the distance parameter to sort geocoding candidates based upon
their proximity to the location. The distance parameter
specifies the radial distance from the location in meters. The
priority of candidates within this radius is boosted relative
to those outside the radius.
distance - Specifies the radius of an area around a point
location which is used to boost the rank of geocoding
candidates so that candidates closest to the location are
returned first. The distance value is in meters.
outSR - The spatial reference of the x/y coordinates returned by
a geocode request. This is useful for applications using a map
with a spatial reference different than that of the geocode
service.
category - A place or address type which can be used to filter
find results. The parameter supports input of single category
values or multiple comma-separated values. The category
parameter can be passed in a request with or without the text
parameter.
outFields - The list of fields to be returned in the response.
maxLocation - The maximum number of locations to be returned by
a search, up to the maximum number allowed by the service. If
not specified, then one location will be returned.
forStorage - Specifies whether the results of the operation will
be persisted. The default value is false, which indicates the
results of the operation can't be stored, but they can be
temporarily displayed on a map for instance. If you store the
results, in a database for example, you need to set this
parameter to true.
|
[
"The",
"find",
"operation",
"geocodes",
"one",
"location",
"per",
"request",
";",
"the",
"input",
"address",
"is",
"specified",
"in",
"a",
"single",
"parameter",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_geocodeservice.py#L160-L261
|
13,105
|
Esri/ArcREST
|
src/arcrest/ags/_geocodeservice.py
|
GeocodeService.geocodeAddresses
|
def geocodeAddresses(self,
addresses,
outSR=4326,
sourceCountry=None,
category=None):
"""
The geocodeAddresses operation is performed on a Geocode Service
resource. The result of this operation is a resource representing
the list of geocoded addresses. This resource provides information
about the addresses including the address, location, score, and
other geocode service-specific attributes.You can provide arguments
to the geocodeAddresses operation as query parameters defined in
the following parameters table.
Inputs:
addresses - A record set representing the addresses to be
geocoded. Each record must include an OBJECTID attribute with a
unique value, as well as various address fields accepted by the
corresponding geocode service. The field names that should be
used can be found in the JSON representation of the geocode
service resource under the addressFields property, for multiple
input field geocoding, or the singleLineAddressField property,
for single input field geocoding. The OBJECTID specified in the
request is reflected as ResultID in the response.
The maximum number of addresses that can be geocoded in a
single request is limited to the SuggestedBatchSize property of
the locator.
Syntax:
{
"records" : [
{
"attributes" : {"<OBJECTID>" : "<OID11>",
"<field1>" : "<value11>",
"<field2>" : "<value12>",
"<field3>" : "<value13>"
}
},
{
"attributes" : {"<OBJECTID>" : "<OID12>",
"<field1>" : "<value11>",
"<field2>" : "<value12>",
"<field3>" : "<value13>"
}
}
]
}
outSR - The well-known ID of the spatial reference, or a spatial
reference json object for the returned addresses. For a list of
valid WKID values, see Projected coordinate systems and
Geographic coordinate systems.
sourceCountry - The sourceCountry parameter is only supported by
geocode services published using StreetMap Premium locators.
Added at 10.3 and only supported by geocode services published
with ArcGIS 10.3 for Server and later versions.
category - The category parameter is only supported by geocode
services published using StreetMap Premium locators.
"""
params = {
"f" : "json"
}
url = self._url + "/geocodeAddresses"
params['outSR'] = outSR
params['sourceCountry'] = sourceCountry
params['category'] = category
params['addresses'] = addresses
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
python
|
def geocodeAddresses(self,
addresses,
outSR=4326,
sourceCountry=None,
category=None):
"""
The geocodeAddresses operation is performed on a Geocode Service
resource. The result of this operation is a resource representing
the list of geocoded addresses. This resource provides information
about the addresses including the address, location, score, and
other geocode service-specific attributes.You can provide arguments
to the geocodeAddresses operation as query parameters defined in
the following parameters table.
Inputs:
addresses - A record set representing the addresses to be
geocoded. Each record must include an OBJECTID attribute with a
unique value, as well as various address fields accepted by the
corresponding geocode service. The field names that should be
used can be found in the JSON representation of the geocode
service resource under the addressFields property, for multiple
input field geocoding, or the singleLineAddressField property,
for single input field geocoding. The OBJECTID specified in the
request is reflected as ResultID in the response.
The maximum number of addresses that can be geocoded in a
single request is limited to the SuggestedBatchSize property of
the locator.
Syntax:
{
"records" : [
{
"attributes" : {"<OBJECTID>" : "<OID11>",
"<field1>" : "<value11>",
"<field2>" : "<value12>",
"<field3>" : "<value13>"
}
},
{
"attributes" : {"<OBJECTID>" : "<OID12>",
"<field1>" : "<value11>",
"<field2>" : "<value12>",
"<field3>" : "<value13>"
}
}
]
}
outSR - The well-known ID of the spatial reference, or a spatial
reference json object for the returned addresses. For a list of
valid WKID values, see Projected coordinate systems and
Geographic coordinate systems.
sourceCountry - The sourceCountry parameter is only supported by
geocode services published using StreetMap Premium locators.
Added at 10.3 and only supported by geocode services published
with ArcGIS 10.3 for Server and later versions.
category - The category parameter is only supported by geocode
services published using StreetMap Premium locators.
"""
params = {
"f" : "json"
}
url = self._url + "/geocodeAddresses"
params['outSR'] = outSR
params['sourceCountry'] = sourceCountry
params['category'] = category
params['addresses'] = addresses
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
[
"def",
"geocodeAddresses",
"(",
"self",
",",
"addresses",
",",
"outSR",
"=",
"4326",
",",
"sourceCountry",
"=",
"None",
",",
"category",
"=",
"None",
")",
":",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
"}",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/geocodeAddresses\"",
"params",
"[",
"'outSR'",
"]",
"=",
"outSR",
"params",
"[",
"'sourceCountry'",
"]",
"=",
"sourceCountry",
"params",
"[",
"'category'",
"]",
"=",
"category",
"params",
"[",
"'addresses'",
"]",
"=",
"addresses",
"return",
"self",
".",
"_post",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] |
The geocodeAddresses operation is performed on a Geocode Service
resource. The result of this operation is a resource representing
the list of geocoded addresses. This resource provides information
about the addresses including the address, location, score, and
other geocode service-specific attributes.You can provide arguments
to the geocodeAddresses operation as query parameters defined in
the following parameters table.
Inputs:
addresses - A record set representing the addresses to be
geocoded. Each record must include an OBJECTID attribute with a
unique value, as well as various address fields accepted by the
corresponding geocode service. The field names that should be
used can be found in the JSON representation of the geocode
service resource under the addressFields property, for multiple
input field geocoding, or the singleLineAddressField property,
for single input field geocoding. The OBJECTID specified in the
request is reflected as ResultID in the response.
The maximum number of addresses that can be geocoded in a
single request is limited to the SuggestedBatchSize property of
the locator.
Syntax:
{
"records" : [
{
"attributes" : {"<OBJECTID>" : "<OID11>",
"<field1>" : "<value11>",
"<field2>" : "<value12>",
"<field3>" : "<value13>"
}
},
{
"attributes" : {"<OBJECTID>" : "<OID12>",
"<field1>" : "<value11>",
"<field2>" : "<value12>",
"<field3>" : "<value13>"
}
}
]
}
outSR - The well-known ID of the spatial reference, or a spatial
reference json object for the returned addresses. For a list of
valid WKID values, see Projected coordinate systems and
Geographic coordinate systems.
sourceCountry - The sourceCountry parameter is only supported by
geocode services published using StreetMap Premium locators.
Added at 10.3 and only supported by geocode services published
with ArcGIS 10.3 for Server and later versions.
category - The category parameter is only supported by geocode
services published using StreetMap Premium locators.
|
[
"The",
"geocodeAddresses",
"operation",
"is",
"performed",
"on",
"a",
"Geocode",
"Service",
"resource",
".",
"The",
"result",
"of",
"this",
"operation",
"is",
"a",
"resource",
"representing",
"the",
"list",
"of",
"geocoded",
"addresses",
".",
"This",
"resource",
"provides",
"information",
"about",
"the",
"addresses",
"including",
"the",
"address",
"location",
"score",
"and",
"other",
"geocode",
"service",
"-",
"specific",
"attributes",
".",
"You",
"can",
"provide",
"arguments",
"to",
"the",
"geocodeAddresses",
"operation",
"as",
"query",
"parameters",
"defined",
"in",
"the",
"following",
"parameters",
"table",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_geocodeservice.py#L422-L491
|
13,106
|
Esri/ArcREST
|
src/arcrest/ags/_networkservice.py
|
NetworkService.__init
|
def __init(self):
""" initializes the properties """
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 dir(self)
if not attr.startswith('__') and \
not attr.startswith('_')]
for k,v in json_dict.items():
if k in attributes:
if k == "routeLayers" and json_dict[k]:
self._routeLayers = []
for rl in v:
self._routeLayers.append(
RouteNetworkLayer(url=self._url + "/%s" % rl,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=False))
elif k == "serviceAreaLayers" and json_dict[k]:
self._serviceAreaLayers = []
for sal in v:
self._serviceAreaLayers.append(
ServiceAreaNetworkLayer(url=self._url + "/%s" % sal,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=False))
elif k == "closestFacilityLayers" and json_dict[k]:
self._closestFacilityLayers = []
for cf in v:
self._closestFacilityLayers.append(
ClosestFacilityNetworkLayer(url=self._url + "/%s" % cf,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=False))
else:
setattr(self, "_"+ k, v)
else:
print ("attribute %s is not implemented." % k)
|
python
|
def __init(self):
""" initializes the properties """
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 dir(self)
if not attr.startswith('__') and \
not attr.startswith('_')]
for k,v in json_dict.items():
if k in attributes:
if k == "routeLayers" and json_dict[k]:
self._routeLayers = []
for rl in v:
self._routeLayers.append(
RouteNetworkLayer(url=self._url + "/%s" % rl,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=False))
elif k == "serviceAreaLayers" and json_dict[k]:
self._serviceAreaLayers = []
for sal in v:
self._serviceAreaLayers.append(
ServiceAreaNetworkLayer(url=self._url + "/%s" % sal,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=False))
elif k == "closestFacilityLayers" and json_dict[k]:
self._closestFacilityLayers = []
for cf in v:
self._closestFacilityLayers.append(
ClosestFacilityNetworkLayer(url=self._url + "/%s" % cf,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=False))
else:
setattr(self, "_"+ k, v)
else:
print ("attribute %s is not implemented." % k)
|
[
"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",
"dir",
"(",
"self",
")",
"if",
"not",
"attr",
".",
"startswith",
"(",
"'__'",
")",
"and",
"not",
"attr",
".",
"startswith",
"(",
"'_'",
")",
"]",
"for",
"k",
",",
"v",
"in",
"json_dict",
".",
"items",
"(",
")",
":",
"if",
"k",
"in",
"attributes",
":",
"if",
"k",
"==",
"\"routeLayers\"",
"and",
"json_dict",
"[",
"k",
"]",
":",
"self",
".",
"_routeLayers",
"=",
"[",
"]",
"for",
"rl",
"in",
"v",
":",
"self",
".",
"_routeLayers",
".",
"append",
"(",
"RouteNetworkLayer",
"(",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/%s\"",
"%",
"rl",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"False",
")",
")",
"elif",
"k",
"==",
"\"serviceAreaLayers\"",
"and",
"json_dict",
"[",
"k",
"]",
":",
"self",
".",
"_serviceAreaLayers",
"=",
"[",
"]",
"for",
"sal",
"in",
"v",
":",
"self",
".",
"_serviceAreaLayers",
".",
"append",
"(",
"ServiceAreaNetworkLayer",
"(",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/%s\"",
"%",
"sal",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"False",
")",
")",
"elif",
"k",
"==",
"\"closestFacilityLayers\"",
"and",
"json_dict",
"[",
"k",
"]",
":",
"self",
".",
"_closestFacilityLayers",
"=",
"[",
"]",
"for",
"cf",
"in",
"v",
":",
"self",
".",
"_closestFacilityLayers",
".",
"append",
"(",
"ClosestFacilityNetworkLayer",
"(",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/%s\"",
"%",
"cf",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"False",
")",
")",
"else",
":",
"setattr",
"(",
"self",
",",
"\"_\"",
"+",
"k",
",",
"v",
")",
"else",
":",
"print",
"(",
"\"attribute %s is not implemented.\"",
"%",
"k",
")"
] |
initializes the properties
|
[
"initializes",
"the",
"properties"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_networkservice.py#L47-L96
|
13,107
|
Esri/ArcREST
|
src/arcrest/ags/_networkservice.py
|
RouteNetworkLayer.__init
|
def __init(self):
""" initializes all the properties """
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.startswith('_')]
for k,v in json_dict.items():
if k in attributes:
setattr(self, "_"+ k, json_dict[k])
else:
print( k, " - attribute not implemented in RouteNetworkLayer.")
del k,v
|
python
|
def __init(self):
""" initializes all the properties """
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.startswith('_')]
for k,v in json_dict.items():
if k in attributes:
setattr(self, "_"+ k, json_dict[k])
else:
print( k, " - attribute not implemented in RouteNetworkLayer.")
del k,v
|
[
"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",
".",
"startswith",
"(",
"'_'",
")",
"]",
"for",
"k",
",",
"v",
"in",
"json_dict",
".",
"items",
"(",
")",
":",
"if",
"k",
"in",
"attributes",
":",
"setattr",
"(",
"self",
",",
"\"_\"",
"+",
"k",
",",
"json_dict",
"[",
"k",
"]",
")",
"else",
":",
"print",
"(",
"k",
",",
"\" - attribute not implemented in RouteNetworkLayer.\"",
")",
"del",
"k",
",",
"v"
] |
initializes all the properties
|
[
"initializes",
"all",
"the",
"properties"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_networkservice.py#L440-L457
|
13,108
|
Esri/ArcREST
|
src/arcrest/ags/_uploads.py
|
Uploads.download
|
def download(self, itemID, savePath):
"""
downloads an item to local disk
Inputs:
itemID - unique id of item to download
savePath - folder to save the file in
"""
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=savePath,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
python
|
def download(self, itemID, savePath):
"""
downloads an item to local disk
Inputs:
itemID - unique id of item to download
savePath - folder to save the file in
"""
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=savePath,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
[
"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",
"=",
"savePath",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] |
downloads an item to local disk
Inputs:
itemID - unique id of item to download
savePath - folder to save the file in
|
[
"downloads",
"an",
"item",
"to",
"local",
"disk"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_uploads.py#L109-L129
|
13,109
|
Esri/ArcREST
|
src/arcrest/manageags/_usagereports.py
|
UsageReports.reports
|
def reports(self):
"""returns a list of reports on the server"""
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=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True))
del url
return self._reports
|
python
|
def reports(self):
"""returns a list of reports on the server"""
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=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True))
del url
return self._reports
|
[
"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",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"True",
")",
")",
"del",
"url",
"return",
"self",
".",
"_reports"
] |
returns a list of reports on the server
|
[
"returns",
"a",
"list",
"of",
"reports",
"on",
"the",
"server"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/_usagereports.py#L70-L83
|
13,110
|
Esri/ArcREST
|
src/arcrest/manageags/_usagereports.py
|
UsageReports.editUsageReportSettings
|
def editUsageReportSettings(self, samplingInterval,
enabled=True, maxHistory=0):
"""
The usage reports settings are applied to the entire site. A POST
request updates the usage reports settings.
Inputs:
samplingInterval - Defines the duration (in minutes) for which
the usage statistics are aggregated or sampled, in-memory,
before being written out to the statistics database.
enabled - default True - Can be true or false. When usage
reports are enabled, service usage statistics are collected
and persisted to a statistics database. When usage reports are
disabled, the statistics are not collected.
maxHistory - default 0 - Represents the number of days after
which usage statistics are deleted after the statistics
database. If the maxHistory parameter is set to 0, the
statistics are persisted forever.
"""
params = {
"f" : "json",
"maxHistory" : maxHistory,
"enabled" : enabled,
"samplingInterval" : samplingInterval
}
url = self._url + "/settings/edit"
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
python
|
def editUsageReportSettings(self, samplingInterval,
enabled=True, maxHistory=0):
"""
The usage reports settings are applied to the entire site. A POST
request updates the usage reports settings.
Inputs:
samplingInterval - Defines the duration (in minutes) for which
the usage statistics are aggregated or sampled, in-memory,
before being written out to the statistics database.
enabled - default True - Can be true or false. When usage
reports are enabled, service usage statistics are collected
and persisted to a statistics database. When usage reports are
disabled, the statistics are not collected.
maxHistory - default 0 - Represents the number of days after
which usage statistics are deleted after the statistics
database. If the maxHistory parameter is set to 0, the
statistics are persisted forever.
"""
params = {
"f" : "json",
"maxHistory" : maxHistory,
"enabled" : enabled,
"samplingInterval" : samplingInterval
}
url = self._url + "/settings/edit"
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
[
"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",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] |
The usage reports settings are applied to the entire site. A POST
request updates the usage reports settings.
Inputs:
samplingInterval - Defines the duration (in minutes) for which
the usage statistics are aggregated or sampled, in-memory,
before being written out to the statistics database.
enabled - default True - Can be true or false. When usage
reports are enabled, service usage statistics are collected
and persisted to a statistics database. When usage reports are
disabled, the statistics are not collected.
maxHistory - default 0 - Represents the number of days after
which usage statistics are deleted after the statistics
database. If the maxHistory parameter is set to 0, the
statistics are persisted forever.
|
[
"The",
"usage",
"reports",
"settings",
"are",
"applied",
"to",
"the",
"entire",
"site",
".",
"A",
"POST",
"request",
"updates",
"the",
"usage",
"reports",
"settings",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/_usagereports.py#L110-L140
|
13,111
|
Esri/ArcREST
|
src/arcrest/manageags/_usagereports.py
|
UsageReports.createUsageReport
|
def createUsageReport(self,
reportname,
queries,
metadata,
since="LAST_DAY",
fromValue=None,
toValue=None,
aggregationInterval=None
):
"""
Creates a new usage report. A usage report is created by submitting
a JSON representation of the usage report to this operation.
Inputs:
reportname - the unique name of the report
since - the time duration of the report. The supported values
are: LAST_DAY, LAST_WEEK, LAST_MONTH, LAST_YEAR, CUSTOM
LAST_DAY represents a time range spanning the previous 24
hours.
LAST_WEEK represents a time range spanning the previous 7
days.
LAST_MONTH represents a time range spanning the previous 30
days.
LAST_YEAR represents a time range spanning the previous 365
days.
CUSTOM represents a time range that is specified using the
from and to parameters.
fromValue - optional value - The timestamp (milliseconds since
UNIX epoch, namely January 1, 1970, 00:00:00 GMT) for the
beginning period of the report. Only valid when since is
CUSTOM
toValue - optional value - The timestamp (milliseconds since
UNIX epoch, namely January 1, 1970, 00:00:00 GMT) for the
ending period of the report.Only valid when since is
CUSTOM.
aggregationInterval - Optional. Aggregation interval in minutes.
Server metrics are aggregated and returned for time slices
aggregated using the specified aggregation interval. The time
range for the report, specified using the since parameter
(and from and to when since is CUSTOM) is split into multiple
slices, each covering an aggregation interval. Server metrics
are then aggregated for each time slice and returned as data
points in the report data.
When the aggregationInterval is not specified, the following
defaults are used:
LAST_DAY: 30 minutes
LAST_WEEK: 4 hours
LAST_MONTH: 24 hours
LAST_YEAR: 1 week
CUSTOM: 30 minutes up to 1 day, 4 hours up to 1 week, 1
day up to 30 days, and 1 week for longer periods.
If the samplingInterval specified in Usage Reports Settings is
more than the aggregationInterval, the samplingInterval is
used instead.
queries - A list of queries for which to generate the report.
You need to specify the list as an array of JSON objects
representing the queries. Each query specifies the list of
metrics to be queries for a given set of resourceURIs.
The queries parameter has the following sub-parameters:
resourceURIs - Comma separated list of resource URIs for
which to report metrics. Specifies services or folders
for which to gather metrics.
The resourceURI is formatted as below:
services/ - Entire Site
services/Folder/ - Folder within a Site. Reports
metrics aggregated across all services within that
Folder and Sub-Folders.
services/Folder/ServiceName.ServiceType - Service in
a specified folder, for example:
services/Map_bv_999.MapServer.
services/ServiceName.ServiceType - Service in the
root folder, for example: Map_bv_999.MapServer.
metrics - Comma separated list of metrics to be reported.
Supported metrics are:
RequestCount - the number of requests received
RequestsFailed - the number of requests that failed
RequestsTimedOut - the number of requests that timed out
RequestMaxResponseTime - the maximum response time
RequestAvgResponseTime - the average response time
ServiceActiveInstances - the maximum number of active
(running) service instances sampled at 1 minute
intervals, for a specified service
metadata - Can be any JSON Object. Typically used for storing
presentation tier data for the usage report, such as report
title, colors, line-styles, etc. Also used to denote
visibility in ArcGIS Server Manager for reports created with
the Administrator Directory. To make any report created in
the Administrator Directory visible to Manager, include
"managerReport":true in the metadata JSON object. When this
value is not set (default), reports are not visible in
Manager. This behavior can be extended to any client that
wants to interact with the Administrator Directory. Any
user-created value will need to be processed by the client.
Example:
>>> queryObj = [{
"resourceURIs": ["services/Map_bv_999.MapServer"],
"metrics": ["RequestCount"]
}]
>>> obj.createReport(
reportname="SampleReport",
queries=queryObj,
metadata="This could be any String or JSON Object.",
since="LAST_DAY"
)
"""
url = self._url + "/add"
params = {
"f" : "json",
"usagereport": {
"reportname" : reportname,
"since" : since,
"metadata" : metadata}
}
if isinstance(queries, dict):
params["usagereport"]["queries"] = [queries]
elif isinstance(queries, list):
params["usagereport"]["queries"] = queries
if aggregationInterval is not None:
params["usagereport"]['aggregationInterval'] = aggregationInterval
if since.lower() == "custom":
params["usagereport"]['to'] = toValue
params["usagereport"]['from'] = fromValue
res = self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url)
# Refresh the metrics object
self.__init()
return res
|
python
|
def createUsageReport(self,
reportname,
queries,
metadata,
since="LAST_DAY",
fromValue=None,
toValue=None,
aggregationInterval=None
):
"""
Creates a new usage report. A usage report is created by submitting
a JSON representation of the usage report to this operation.
Inputs:
reportname - the unique name of the report
since - the time duration of the report. The supported values
are: LAST_DAY, LAST_WEEK, LAST_MONTH, LAST_YEAR, CUSTOM
LAST_DAY represents a time range spanning the previous 24
hours.
LAST_WEEK represents a time range spanning the previous 7
days.
LAST_MONTH represents a time range spanning the previous 30
days.
LAST_YEAR represents a time range spanning the previous 365
days.
CUSTOM represents a time range that is specified using the
from and to parameters.
fromValue - optional value - The timestamp (milliseconds since
UNIX epoch, namely January 1, 1970, 00:00:00 GMT) for the
beginning period of the report. Only valid when since is
CUSTOM
toValue - optional value - The timestamp (milliseconds since
UNIX epoch, namely January 1, 1970, 00:00:00 GMT) for the
ending period of the report.Only valid when since is
CUSTOM.
aggregationInterval - Optional. Aggregation interval in minutes.
Server metrics are aggregated and returned for time slices
aggregated using the specified aggregation interval. The time
range for the report, specified using the since parameter
(and from and to when since is CUSTOM) is split into multiple
slices, each covering an aggregation interval. Server metrics
are then aggregated for each time slice and returned as data
points in the report data.
When the aggregationInterval is not specified, the following
defaults are used:
LAST_DAY: 30 minutes
LAST_WEEK: 4 hours
LAST_MONTH: 24 hours
LAST_YEAR: 1 week
CUSTOM: 30 minutes up to 1 day, 4 hours up to 1 week, 1
day up to 30 days, and 1 week for longer periods.
If the samplingInterval specified in Usage Reports Settings is
more than the aggregationInterval, the samplingInterval is
used instead.
queries - A list of queries for which to generate the report.
You need to specify the list as an array of JSON objects
representing the queries. Each query specifies the list of
metrics to be queries for a given set of resourceURIs.
The queries parameter has the following sub-parameters:
resourceURIs - Comma separated list of resource URIs for
which to report metrics. Specifies services or folders
for which to gather metrics.
The resourceURI is formatted as below:
services/ - Entire Site
services/Folder/ - Folder within a Site. Reports
metrics aggregated across all services within that
Folder and Sub-Folders.
services/Folder/ServiceName.ServiceType - Service in
a specified folder, for example:
services/Map_bv_999.MapServer.
services/ServiceName.ServiceType - Service in the
root folder, for example: Map_bv_999.MapServer.
metrics - Comma separated list of metrics to be reported.
Supported metrics are:
RequestCount - the number of requests received
RequestsFailed - the number of requests that failed
RequestsTimedOut - the number of requests that timed out
RequestMaxResponseTime - the maximum response time
RequestAvgResponseTime - the average response time
ServiceActiveInstances - the maximum number of active
(running) service instances sampled at 1 minute
intervals, for a specified service
metadata - Can be any JSON Object. Typically used for storing
presentation tier data for the usage report, such as report
title, colors, line-styles, etc. Also used to denote
visibility in ArcGIS Server Manager for reports created with
the Administrator Directory. To make any report created in
the Administrator Directory visible to Manager, include
"managerReport":true in the metadata JSON object. When this
value is not set (default), reports are not visible in
Manager. This behavior can be extended to any client that
wants to interact with the Administrator Directory. Any
user-created value will need to be processed by the client.
Example:
>>> queryObj = [{
"resourceURIs": ["services/Map_bv_999.MapServer"],
"metrics": ["RequestCount"]
}]
>>> obj.createReport(
reportname="SampleReport",
queries=queryObj,
metadata="This could be any String or JSON Object.",
since="LAST_DAY"
)
"""
url = self._url + "/add"
params = {
"f" : "json",
"usagereport": {
"reportname" : reportname,
"since" : since,
"metadata" : metadata}
}
if isinstance(queries, dict):
params["usagereport"]["queries"] = [queries]
elif isinstance(queries, list):
params["usagereport"]["queries"] = queries
if aggregationInterval is not None:
params["usagereport"]['aggregationInterval'] = aggregationInterval
if since.lower() == "custom":
params["usagereport"]['to'] = toValue
params["usagereport"]['from'] = fromValue
res = self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url)
# Refresh the metrics object
self.__init()
return res
|
[
"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",
",",
"dict",
")",
":",
"params",
"[",
"\"usagereport\"",
"]",
"[",
"\"queries\"",
"]",
"=",
"[",
"queries",
"]",
"elif",
"isinstance",
"(",
"queries",
",",
"list",
")",
":",
"params",
"[",
"\"usagereport\"",
"]",
"[",
"\"queries\"",
"]",
"=",
"queries",
"if",
"aggregationInterval",
"is",
"not",
"None",
":",
"params",
"[",
"\"usagereport\"",
"]",
"[",
"'aggregationInterval'",
"]",
"=",
"aggregationInterval",
"if",
"since",
".",
"lower",
"(",
")",
"==",
"\"custom\"",
":",
"params",
"[",
"\"usagereport\"",
"]",
"[",
"'to'",
"]",
"=",
"toValue",
"params",
"[",
"\"usagereport\"",
"]",
"[",
"'from'",
"]",
"=",
"fromValue",
"res",
"=",
"self",
".",
"_post",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
")",
"# Refresh the metrics object",
"self",
".",
"__init",
"(",
")",
"return",
"res"
] |
Creates a new usage report. A usage report is created by submitting
a JSON representation of the usage report to this operation.
Inputs:
reportname - the unique name of the report
since - the time duration of the report. The supported values
are: LAST_DAY, LAST_WEEK, LAST_MONTH, LAST_YEAR, CUSTOM
LAST_DAY represents a time range spanning the previous 24
hours.
LAST_WEEK represents a time range spanning the previous 7
days.
LAST_MONTH represents a time range spanning the previous 30
days.
LAST_YEAR represents a time range spanning the previous 365
days.
CUSTOM represents a time range that is specified using the
from and to parameters.
fromValue - optional value - The timestamp (milliseconds since
UNIX epoch, namely January 1, 1970, 00:00:00 GMT) for the
beginning period of the report. Only valid when since is
CUSTOM
toValue - optional value - The timestamp (milliseconds since
UNIX epoch, namely January 1, 1970, 00:00:00 GMT) for the
ending period of the report.Only valid when since is
CUSTOM.
aggregationInterval - Optional. Aggregation interval in minutes.
Server metrics are aggregated and returned for time slices
aggregated using the specified aggregation interval. The time
range for the report, specified using the since parameter
(and from and to when since is CUSTOM) is split into multiple
slices, each covering an aggregation interval. Server metrics
are then aggregated for each time slice and returned as data
points in the report data.
When the aggregationInterval is not specified, the following
defaults are used:
LAST_DAY: 30 minutes
LAST_WEEK: 4 hours
LAST_MONTH: 24 hours
LAST_YEAR: 1 week
CUSTOM: 30 minutes up to 1 day, 4 hours up to 1 week, 1
day up to 30 days, and 1 week for longer periods.
If the samplingInterval specified in Usage Reports Settings is
more than the aggregationInterval, the samplingInterval is
used instead.
queries - A list of queries for which to generate the report.
You need to specify the list as an array of JSON objects
representing the queries. Each query specifies the list of
metrics to be queries for a given set of resourceURIs.
The queries parameter has the following sub-parameters:
resourceURIs - Comma separated list of resource URIs for
which to report metrics. Specifies services or folders
for which to gather metrics.
The resourceURI is formatted as below:
services/ - Entire Site
services/Folder/ - Folder within a Site. Reports
metrics aggregated across all services within that
Folder and Sub-Folders.
services/Folder/ServiceName.ServiceType - Service in
a specified folder, for example:
services/Map_bv_999.MapServer.
services/ServiceName.ServiceType - Service in the
root folder, for example: Map_bv_999.MapServer.
metrics - Comma separated list of metrics to be reported.
Supported metrics are:
RequestCount - the number of requests received
RequestsFailed - the number of requests that failed
RequestsTimedOut - the number of requests that timed out
RequestMaxResponseTime - the maximum response time
RequestAvgResponseTime - the average response time
ServiceActiveInstances - the maximum number of active
(running) service instances sampled at 1 minute
intervals, for a specified service
metadata - Can be any JSON Object. Typically used for storing
presentation tier data for the usage report, such as report
title, colors, line-styles, etc. Also used to denote
visibility in ArcGIS Server Manager for reports created with
the Administrator Directory. To make any report created in
the Administrator Directory visible to Manager, include
"managerReport":true in the metadata JSON object. When this
value is not set (default), reports are not visible in
Manager. This behavior can be extended to any client that
wants to interact with the Administrator Directory. Any
user-created value will need to be processed by the client.
Example:
>>> queryObj = [{
"resourceURIs": ["services/Map_bv_999.MapServer"],
"metrics": ["RequestCount"]
}]
>>> obj.createReport(
reportname="SampleReport",
queries=queryObj,
metadata="This could be any String or JSON Object.",
since="LAST_DAY"
)
|
[
"Creates",
"a",
"new",
"usage",
"report",
".",
"A",
"usage",
"report",
"is",
"created",
"by",
"submitting",
"a",
"JSON",
"representation",
"of",
"the",
"usage",
"report",
"to",
"this",
"operation",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/_usagereports.py#L142-L273
|
13,112
|
Esri/ArcREST
|
src/arcrest/manageags/_usagereports.py
|
UsageReport.edit
|
def edit(self):
"""
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.
Values are changed in the class, to edit a property like
metrics, pass in a new value. Changed values to not take until the
edit() is called.
Inputs:
None
"""
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(usagereport_dict)
}
url = self._url + "/edit"
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
python
|
def edit(self):
"""
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.
Values are changed in the class, to edit a property like
metrics, pass in a new value. Changed values to not take until the
edit() is called.
Inputs:
None
"""
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(usagereport_dict)
}
url = self._url + "/edit"
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
[
"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",
"(",
"usagereport_dict",
")",
"}",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/edit\"",
"return",
"self",
".",
"_post",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] |
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.
Values are changed in the class, to edit a property like
metrics, pass in a new value. Changed values to not take until the
edit() is called.
Inputs:
None
|
[
"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",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/_usagereports.py#L419-L452
|
13,113
|
Esri/ArcREST
|
src/arcrest/ags/_geodataservice.py
|
GeoDataService.__init
|
def __init(self):
""" inializes the properties """
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 dir(self)
if not attr.startswith('__') and \
not attr.startswith('_')]
for k,v in json_dict.items():
if k in attributes:
if k == "versions" and json_dict[k]:
self._versions = []
for version in v:
self._versions.append(
Version(url=self._url + "/versions/%s" % version,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=False))
elif k == "replicas" and json_dict[k]:
self._replicas = []
for version in v:
self._replicas.append(
Replica(url=self._url + "/replicas/%s" % version,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=False))
else:
setattr(self, "_"+ k, v)
else:
print (k, " - attribute not implemented for GeoData Service")
|
python
|
def __init(self):
""" inializes the properties """
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 dir(self)
if not attr.startswith('__') and \
not attr.startswith('_')]
for k,v in json_dict.items():
if k in attributes:
if k == "versions" and json_dict[k]:
self._versions = []
for version in v:
self._versions.append(
Version(url=self._url + "/versions/%s" % version,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=False))
elif k == "replicas" and json_dict[k]:
self._replicas = []
for version in v:
self._replicas.append(
Replica(url=self._url + "/replicas/%s" % version,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=False))
else:
setattr(self, "_"+ k, v)
else:
print (k, " - attribute not implemented for GeoData Service")
|
[
"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",
"dir",
"(",
"self",
")",
"if",
"not",
"attr",
".",
"startswith",
"(",
"'__'",
")",
"and",
"not",
"attr",
".",
"startswith",
"(",
"'_'",
")",
"]",
"for",
"k",
",",
"v",
"in",
"json_dict",
".",
"items",
"(",
")",
":",
"if",
"k",
"in",
"attributes",
":",
"if",
"k",
"==",
"\"versions\"",
"and",
"json_dict",
"[",
"k",
"]",
":",
"self",
".",
"_versions",
"=",
"[",
"]",
"for",
"version",
"in",
"v",
":",
"self",
".",
"_versions",
".",
"append",
"(",
"Version",
"(",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/versions/%s\"",
"%",
"version",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"False",
")",
")",
"elif",
"k",
"==",
"\"replicas\"",
"and",
"json_dict",
"[",
"k",
"]",
":",
"self",
".",
"_replicas",
"=",
"[",
"]",
"for",
"version",
"in",
"v",
":",
"self",
".",
"_replicas",
".",
"append",
"(",
"Replica",
"(",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/replicas/%s\"",
"%",
"version",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"False",
")",
")",
"else",
":",
"setattr",
"(",
"self",
",",
"\"_\"",
"+",
"k",
",",
"v",
")",
"else",
":",
"print",
"(",
"k",
",",
"\" - attribute not implemented for GeoData Service\"",
")"
] |
inializes the properties
|
[
"inializes",
"the",
"properties"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_geodataservice.py#L36-L73
|
13,114
|
Esri/ArcREST
|
src/arcrest/ags/_geodataservice.py
|
GeoDataService.replicasResource
|
def replicasResource(self):
"""returns a list of replices"""
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
|
python
|
def replicasResource(self):
"""returns a list of replices"""
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
|
[
"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
|
[
"returns",
"a",
"list",
"of",
"replices"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_geodataservice.py#L111-L118
|
13,115
|
Esri/ArcREST
|
src/arcrest/hostedservice/service.py
|
Services.services
|
def services(self):
""" returns all the service objects in the admin service's page """
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_url=self._proxy_url)
for k, v in res.items():
if k == "foldersDetail":
for item in v:
if 'isDefault' in item and item['isDefault'] == False:
fURL = self._url + "/services/" + item['folderName']
resFolder = self._get(url=fURL, param_dict=params,
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url)
for k1, v1 in resFolder.items():
if k1 == "services":
self._checkservice(k1,v1,fURL)
elif k == "services":
self._checkservice(k,v,uURL)
return self._services
|
python
|
def services(self):
""" returns all the service objects in the admin service's page """
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_url=self._proxy_url)
for k, v in res.items():
if k == "foldersDetail":
for item in v:
if 'isDefault' in item and item['isDefault'] == False:
fURL = self._url + "/services/" + item['folderName']
resFolder = self._get(url=fURL, param_dict=params,
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url)
for k1, v1 in resFolder.items():
if k1 == "services":
self._checkservice(k1,v1,fURL)
elif k == "services":
self._checkservice(k,v,uURL)
return self._services
|
[
"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_url",
"=",
"self",
".",
"_proxy_url",
")",
"for",
"k",
",",
"v",
"in",
"res",
".",
"items",
"(",
")",
":",
"if",
"k",
"==",
"\"foldersDetail\"",
":",
"for",
"item",
"in",
"v",
":",
"if",
"'isDefault'",
"in",
"item",
"and",
"item",
"[",
"'isDefault'",
"]",
"==",
"False",
":",
"fURL",
"=",
"self",
".",
"_url",
"+",
"\"/services/\"",
"+",
"item",
"[",
"'folderName'",
"]",
"resFolder",
"=",
"self",
".",
"_get",
"(",
"url",
"=",
"fURL",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
")",
"for",
"k1",
",",
"v1",
"in",
"resFolder",
".",
"items",
"(",
")",
":",
"if",
"k1",
"==",
"\"services\"",
":",
"self",
".",
"_checkservice",
"(",
"k1",
",",
"v1",
",",
"fURL",
")",
"elif",
"k",
"==",
"\"services\"",
":",
"self",
".",
"_checkservice",
"(",
"k",
",",
"v",
",",
"uURL",
")",
"return",
"self",
".",
"_services"
] |
returns all the service objects in the admin service's page
|
[
"returns",
"all",
"the",
"service",
"objects",
"in",
"the",
"admin",
"service",
"s",
"page"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/hostedservice/service.py#L144-L170
|
13,116
|
Esri/ArcREST
|
src/arcrest/hostedservice/service.py
|
AdminMapService.refresh
|
def refresh(self, serviceDefinition=True):
"""
The refresh operation refreshes a service, which clears the web
server cache for the service.
"""
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._proxy_port)
self.__init()
return res
|
python
|
def refresh(self, serviceDefinition=True):
"""
The refresh operation refreshes a service, which clears the web
server cache for the service.
"""
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._proxy_port)
self.__init()
return res
|
[
"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",
".",
"_proxy_port",
")",
"self",
".",
"__init",
"(",
")",
"return",
"res"
] |
The refresh operation refreshes a service, which clears the web
server cache for the service.
|
[
"The",
"refresh",
"operation",
"refreshes",
"a",
"service",
"which",
"clears",
"the",
"web",
"server",
"cache",
"for",
"the",
"service",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/hostedservice/service.py#L535-L552
|
13,117
|
Esri/ArcREST
|
src/arcrest/hostedservice/service.py
|
AdminMapService.editTileService
|
def editTileService(self,
serviceDefinition=None,
minScale=None,
maxScale=None,
sourceItemId=None,
exportTilesAllowed=False,
maxExportTileCount=100000):
"""
This post operation updates a Tile Service's properties
Inputs:
serviceDefinition - updates a service definition
minScale - sets the services minimum scale for caching
maxScale - sets the service's maximum scale for caching
sourceItemId - The Source Item ID is the GeoWarehouse Item ID of the map service
exportTilesAllowed - sets the value to let users export tiles
maxExportTileCount - sets the maximum amount of tiles to be exported
from a single call.
"""
params = {
"f" : "json",
}
if not serviceDefinition is None:
params["serviceDefinition"] = serviceDefinition
if not minScale is None:
params['minScale'] = float(minScale)
if not maxScale is None:
params['maxScale'] = float(maxScale)
if not sourceItemId is None:
params["sourceItemId"] = sourceItemId
if not exportTilesAllowed is None:
params["exportTilesAllowed"] = exportTilesAllowed
if not maxExportTileCount is None:
params["maxExportTileCount"] = int(maxExportTileCount)
url = self._url + "/edit"
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._securityHandler.proxy_url,
proxy_port=self._securityHandler.proxy_port)
|
python
|
def editTileService(self,
serviceDefinition=None,
minScale=None,
maxScale=None,
sourceItemId=None,
exportTilesAllowed=False,
maxExportTileCount=100000):
"""
This post operation updates a Tile Service's properties
Inputs:
serviceDefinition - updates a service definition
minScale - sets the services minimum scale for caching
maxScale - sets the service's maximum scale for caching
sourceItemId - The Source Item ID is the GeoWarehouse Item ID of the map service
exportTilesAllowed - sets the value to let users export tiles
maxExportTileCount - sets the maximum amount of tiles to be exported
from a single call.
"""
params = {
"f" : "json",
}
if not serviceDefinition is None:
params["serviceDefinition"] = serviceDefinition
if not minScale is None:
params['minScale'] = float(minScale)
if not maxScale is None:
params['maxScale'] = float(maxScale)
if not sourceItemId is None:
params["sourceItemId"] = sourceItemId
if not exportTilesAllowed is None:
params["exportTilesAllowed"] = exportTilesAllowed
if not maxExportTileCount is None:
params["maxExportTileCount"] = int(maxExportTileCount)
url = self._url + "/edit"
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._securityHandler.proxy_url,
proxy_port=self._securityHandler.proxy_port)
|
[
"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",
":",
"params",
"[",
"'minScale'",
"]",
"=",
"float",
"(",
"minScale",
")",
"if",
"not",
"maxScale",
"is",
"None",
":",
"params",
"[",
"'maxScale'",
"]",
"=",
"float",
"(",
"maxScale",
")",
"if",
"not",
"sourceItemId",
"is",
"None",
":",
"params",
"[",
"\"sourceItemId\"",
"]",
"=",
"sourceItemId",
"if",
"not",
"exportTilesAllowed",
"is",
"None",
":",
"params",
"[",
"\"exportTilesAllowed\"",
"]",
"=",
"exportTilesAllowed",
"if",
"not",
"maxExportTileCount",
"is",
"None",
":",
"params",
"[",
"\"maxExportTileCount\"",
"]",
"=",
"int",
"(",
"maxExportTileCount",
")",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/edit\"",
"return",
"self",
".",
"_post",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_securityHandler",
".",
"proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_securityHandler",
".",
"proxy_port",
")"
] |
This post operation updates a Tile Service's properties
Inputs:
serviceDefinition - updates a service definition
minScale - sets the services minimum scale for caching
maxScale - sets the service's maximum scale for caching
sourceItemId - The Source Item ID is the GeoWarehouse Item ID of the map service
exportTilesAllowed - sets the value to let users export tiles
maxExportTileCount - sets the maximum amount of tiles to be exported
from a single call.
|
[
"This",
"post",
"operation",
"updates",
"a",
"Tile",
"Service",
"s",
"properties"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/hostedservice/service.py#L591-L630
|
13,118
|
Esri/ArcREST
|
src/arcrest/hostedservice/service.py
|
AdminFeatureService.refresh
|
def refresh(self):
""" refreshes a service """
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
|
python
|
def refresh(self):
""" refreshes a service """
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
|
[
"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
|
[
"refreshes",
"a",
"service"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/hostedservice/service.py#L822-L831
|
13,119
|
Esri/ArcREST
|
src/arcrest/hostedservice/service.py
|
AdminFeatureService.addToDefinition
|
def addToDefinition(self, json_dict):
"""
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.
This function will allow users to change add additional values
to an already published service.
Input:
json_dict - part to add to host service. The part format can
be derived from the asDictionary property. For
layer level modifications, run updates on each
individual feature service layer object.
Output:
JSON message as dictionary
"""
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=self._proxy_url)
self.refresh()
return res
|
python
|
def addToDefinition(self, json_dict):
"""
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.
This function will allow users to change add additional values
to an already published service.
Input:
json_dict - part to add to host service. The part format can
be derived from the asDictionary property. For
layer level modifications, run updates on each
individual feature service layer object.
Output:
JSON message as dictionary
"""
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=self._proxy_url)
self.refresh()
return res
|
[
"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",
"=",
"self",
".",
"_proxy_url",
")",
"self",
".",
"refresh",
"(",
")",
"return",
"res"
] |
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.
This function will allow users to change add additional values
to an already published service.
Input:
json_dict - part to add to host service. The part format can
be derived from the asDictionary property. For
layer level modifications, run updates on each
individual feature service layer object.
Output:
JSON message as dictionary
|
[
"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",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/hostedservice/service.py#L1025-L1054
|
13,120
|
Esri/ArcREST
|
src/arcrest/hostedservice/service.py
|
AdminFeatureService.updateDefinition
|
def updateDefinition(self, json_dict):
"""
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.
Input:
json_dict - part to add to host service. The part format can
be derived from the asDictionary property. For
layer level modifications, run updates on each
individual feature service layer object.
Output:
JSON Message as dictionary
"""
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['hasStaticData']
if 'allowGeometryUpdates' in json_dict:
definition['allowGeometryUpdates'] = json_dict['allowGeometryUpdates']
if 'capabilities' in json_dict:
definition['capabilities'] = json_dict['capabilities']
if 'editorTrackingInfo' in json_dict:
definition['editorTrackingInfo'] = collections.OrderedDict()
if 'enableEditorTracking' in json_dict['editorTrackingInfo']:
definition['editorTrackingInfo']['enableEditorTracking'] = json_dict['editorTrackingInfo']['enableEditorTracking']
if 'enableOwnershipAccessControl' in json_dict['editorTrackingInfo']:
definition['editorTrackingInfo']['enableOwnershipAccessControl'] = json_dict['editorTrackingInfo']['enableOwnershipAccessControl']
if 'allowOthersToUpdate' in json_dict['editorTrackingInfo']:
definition['editorTrackingInfo']['allowOthersToUpdate'] = json_dict['editorTrackingInfo']['allowOthersToUpdate']
if 'allowOthersToDelete' in json_dict['editorTrackingInfo']:
definition['editorTrackingInfo']['allowOthersToDelete'] = json_dict['editorTrackingInfo']['allowOthersToDelete']
if 'allowOthersToQuery' in json_dict['editorTrackingInfo']:
definition['editorTrackingInfo']['allowOthersToQuery'] = json_dict['editorTrackingInfo']['allowOthersToQuery']
if isinstance(json_dict['editorTrackingInfo'],dict):
for k,v in json_dict['editorTrackingInfo'].items():
if k not in definition['editorTrackingInfo']:
definition['editorTrackingInfo'][k] = v
if isinstance(json_dict,dict):
for k,v in json_dict.items():
if k not in definition:
definition[k] = v
params = {
"f" : "json",
"updateDefinition" : json.dumps(obj=definition,separators=(',', ':')),
"async" : False
}
uURL = self._url + "/updateDefinition"
res = self._post(url=uURL, param_dict=params,
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url)
self.refresh()
return res
|
python
|
def updateDefinition(self, json_dict):
"""
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.
Input:
json_dict - part to add to host service. The part format can
be derived from the asDictionary property. For
layer level modifications, run updates on each
individual feature service layer object.
Output:
JSON Message as dictionary
"""
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['hasStaticData']
if 'allowGeometryUpdates' in json_dict:
definition['allowGeometryUpdates'] = json_dict['allowGeometryUpdates']
if 'capabilities' in json_dict:
definition['capabilities'] = json_dict['capabilities']
if 'editorTrackingInfo' in json_dict:
definition['editorTrackingInfo'] = collections.OrderedDict()
if 'enableEditorTracking' in json_dict['editorTrackingInfo']:
definition['editorTrackingInfo']['enableEditorTracking'] = json_dict['editorTrackingInfo']['enableEditorTracking']
if 'enableOwnershipAccessControl' in json_dict['editorTrackingInfo']:
definition['editorTrackingInfo']['enableOwnershipAccessControl'] = json_dict['editorTrackingInfo']['enableOwnershipAccessControl']
if 'allowOthersToUpdate' in json_dict['editorTrackingInfo']:
definition['editorTrackingInfo']['allowOthersToUpdate'] = json_dict['editorTrackingInfo']['allowOthersToUpdate']
if 'allowOthersToDelete' in json_dict['editorTrackingInfo']:
definition['editorTrackingInfo']['allowOthersToDelete'] = json_dict['editorTrackingInfo']['allowOthersToDelete']
if 'allowOthersToQuery' in json_dict['editorTrackingInfo']:
definition['editorTrackingInfo']['allowOthersToQuery'] = json_dict['editorTrackingInfo']['allowOthersToQuery']
if isinstance(json_dict['editorTrackingInfo'],dict):
for k,v in json_dict['editorTrackingInfo'].items():
if k not in definition['editorTrackingInfo']:
definition['editorTrackingInfo'][k] = v
if isinstance(json_dict,dict):
for k,v in json_dict.items():
if k not in definition:
definition[k] = v
params = {
"f" : "json",
"updateDefinition" : json.dumps(obj=definition,separators=(',', ':')),
"async" : False
}
uURL = self._url + "/updateDefinition"
res = self._post(url=uURL, param_dict=params,
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url)
self.refresh()
return res
|
[
"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",
"[",
"'hasStaticData'",
"]",
"if",
"'allowGeometryUpdates'",
"in",
"json_dict",
":",
"definition",
"[",
"'allowGeometryUpdates'",
"]",
"=",
"json_dict",
"[",
"'allowGeometryUpdates'",
"]",
"if",
"'capabilities'",
"in",
"json_dict",
":",
"definition",
"[",
"'capabilities'",
"]",
"=",
"json_dict",
"[",
"'capabilities'",
"]",
"if",
"'editorTrackingInfo'",
"in",
"json_dict",
":",
"definition",
"[",
"'editorTrackingInfo'",
"]",
"=",
"collections",
".",
"OrderedDict",
"(",
")",
"if",
"'enableEditorTracking'",
"in",
"json_dict",
"[",
"'editorTrackingInfo'",
"]",
":",
"definition",
"[",
"'editorTrackingInfo'",
"]",
"[",
"'enableEditorTracking'",
"]",
"=",
"json_dict",
"[",
"'editorTrackingInfo'",
"]",
"[",
"'enableEditorTracking'",
"]",
"if",
"'enableOwnershipAccessControl'",
"in",
"json_dict",
"[",
"'editorTrackingInfo'",
"]",
":",
"definition",
"[",
"'editorTrackingInfo'",
"]",
"[",
"'enableOwnershipAccessControl'",
"]",
"=",
"json_dict",
"[",
"'editorTrackingInfo'",
"]",
"[",
"'enableOwnershipAccessControl'",
"]",
"if",
"'allowOthersToUpdate'",
"in",
"json_dict",
"[",
"'editorTrackingInfo'",
"]",
":",
"definition",
"[",
"'editorTrackingInfo'",
"]",
"[",
"'allowOthersToUpdate'",
"]",
"=",
"json_dict",
"[",
"'editorTrackingInfo'",
"]",
"[",
"'allowOthersToUpdate'",
"]",
"if",
"'allowOthersToDelete'",
"in",
"json_dict",
"[",
"'editorTrackingInfo'",
"]",
":",
"definition",
"[",
"'editorTrackingInfo'",
"]",
"[",
"'allowOthersToDelete'",
"]",
"=",
"json_dict",
"[",
"'editorTrackingInfo'",
"]",
"[",
"'allowOthersToDelete'",
"]",
"if",
"'allowOthersToQuery'",
"in",
"json_dict",
"[",
"'editorTrackingInfo'",
"]",
":",
"definition",
"[",
"'editorTrackingInfo'",
"]",
"[",
"'allowOthersToQuery'",
"]",
"=",
"json_dict",
"[",
"'editorTrackingInfo'",
"]",
"[",
"'allowOthersToQuery'",
"]",
"if",
"isinstance",
"(",
"json_dict",
"[",
"'editorTrackingInfo'",
"]",
",",
"dict",
")",
":",
"for",
"k",
",",
"v",
"in",
"json_dict",
"[",
"'editorTrackingInfo'",
"]",
".",
"items",
"(",
")",
":",
"if",
"k",
"not",
"in",
"definition",
"[",
"'editorTrackingInfo'",
"]",
":",
"definition",
"[",
"'editorTrackingInfo'",
"]",
"[",
"k",
"]",
"=",
"v",
"if",
"isinstance",
"(",
"json_dict",
",",
"dict",
")",
":",
"for",
"k",
",",
"v",
"in",
"json_dict",
".",
"items",
"(",
")",
":",
"if",
"k",
"not",
"in",
"definition",
":",
"definition",
"[",
"k",
"]",
"=",
"v",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
",",
"\"updateDefinition\"",
":",
"json",
".",
"dumps",
"(",
"obj",
"=",
"definition",
",",
"separators",
"=",
"(",
"','",
",",
"':'",
")",
")",
",",
"\"async\"",
":",
"False",
"}",
"uURL",
"=",
"self",
".",
"_url",
"+",
"\"/updateDefinition\"",
"res",
"=",
"self",
".",
"_post",
"(",
"url",
"=",
"uURL",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
")",
"self",
".",
"refresh",
"(",
")",
"return",
"res"
] |
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.
Input:
json_dict - part to add to host service. The part format can
be derived from the asDictionary property. For
layer level modifications, run updates on each
individual feature service layer object.
Output:
JSON Message as dictionary
|
[
"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",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/hostedservice/service.py#L1056-L1120
|
13,121
|
Esri/ArcREST
|
src/arcrest/packages/ntlm3/ntlm.py
|
calc_resp
|
def calc_resp(password_hash, server_challenge):
"""calc_resp generates the LM response given a 16-byte password hash and the
challenge from the Type-2 message.
@param password_hash
16-byte password hash
@param server_challenge
8-byte challenge from Type-2 message
returns
24-byte buffer to contain the LM response upon return
"""
# padding with zeros to make the hash 21 bytes long
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:8])
dobj = des.DES(password_hash[14:21])
res = res + dobj.encrypt(server_challenge[0:8])
return res
|
python
|
def calc_resp(password_hash, server_challenge):
"""calc_resp generates the LM response given a 16-byte password hash and the
challenge from the Type-2 message.
@param password_hash
16-byte password hash
@param server_challenge
8-byte challenge from Type-2 message
returns
24-byte buffer to contain the LM response upon return
"""
# padding with zeros to make the hash 21 bytes long
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:8])
dobj = des.DES(password_hash[14:21])
res = res + dobj.encrypt(server_challenge[0:8])
return res
|
[
"def",
"calc_resp",
"(",
"password_hash",
",",
"server_challenge",
")",
":",
"# padding with zeros to make the hash 21 bytes long",
"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",
":",
"8",
"]",
")",
"dobj",
"=",
"des",
".",
"DES",
"(",
"password_hash",
"[",
"14",
":",
"21",
"]",
")",
"res",
"=",
"res",
"+",
"dobj",
".",
"encrypt",
"(",
"server_challenge",
"[",
"0",
":",
"8",
"]",
")",
"return",
"res"
] |
calc_resp generates the LM response given a 16-byte password hash and the
challenge from the Type-2 message.
@param password_hash
16-byte password hash
@param server_challenge
8-byte challenge from Type-2 message
returns
24-byte buffer to contain the LM response upon return
|
[
"calc_resp",
"generates",
"the",
"LM",
"response",
"given",
"a",
"16",
"-",
"byte",
"password",
"hash",
"and",
"the",
"challenge",
"from",
"the",
"Type",
"-",
"2",
"message",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/packages/ntlm3/ntlm.py#L323-L345
|
13,122
|
Esri/ArcREST
|
src/arcrest/packages/ntlm3/ntlm.py
|
create_LM_hashed_password_v1
|
def create_LM_hashed_password_v1(passwd):
"""create LanManager hashed password"""
# if the passwd provided is already a hash, we just return the first half
if re.match(r'^[\w]{32}:[\w]{32}$', passwd):
return binascii.unhexlify(passwd.split(':')[0])
# fix the password length to 14 bytes
passwd = passwd.upper()
lm_pw = passwd + '\0' * (14 - len(passwd))
lm_pw = passwd[0:14]
# do hash
magic_str = b"KGS!@#$%" # page 57 in [MS-NLMP]
res = b''
dobj = des.DES(lm_pw[0:7])
res = res + dobj.encrypt(magic_str)
dobj = des.DES(lm_pw[7:14])
res = res + dobj.encrypt(magic_str)
return res
|
python
|
def create_LM_hashed_password_v1(passwd):
"""create LanManager hashed password"""
# if the passwd provided is already a hash, we just return the first half
if re.match(r'^[\w]{32}:[\w]{32}$', passwd):
return binascii.unhexlify(passwd.split(':')[0])
# fix the password length to 14 bytes
passwd = passwd.upper()
lm_pw = passwd + '\0' * (14 - len(passwd))
lm_pw = passwd[0:14]
# do hash
magic_str = b"KGS!@#$%" # page 57 in [MS-NLMP]
res = b''
dobj = des.DES(lm_pw[0:7])
res = res + dobj.encrypt(magic_str)
dobj = des.DES(lm_pw[7:14])
res = res + dobj.encrypt(magic_str)
return res
|
[
"def",
"create_LM_hashed_password_v1",
"(",
"passwd",
")",
":",
"# if the passwd provided is already a hash, we just return the first half",
"if",
"re",
".",
"match",
"(",
"r'^[\\w]{32}:[\\w]{32}$'",
",",
"passwd",
")",
":",
"return",
"binascii",
".",
"unhexlify",
"(",
"passwd",
".",
"split",
"(",
"':'",
")",
"[",
"0",
"]",
")",
"# fix the password length to 14 bytes",
"passwd",
"=",
"passwd",
".",
"upper",
"(",
")",
"lm_pw",
"=",
"passwd",
"+",
"'\\0'",
"*",
"(",
"14",
"-",
"len",
"(",
"passwd",
")",
")",
"lm_pw",
"=",
"passwd",
"[",
"0",
":",
"14",
"]",
"# do hash",
"magic_str",
"=",
"b\"KGS!@#$%\"",
"# page 57 in [MS-NLMP]",
"res",
"=",
"b''",
"dobj",
"=",
"des",
".",
"DES",
"(",
"lm_pw",
"[",
"0",
":",
"7",
"]",
")",
"res",
"=",
"res",
"+",
"dobj",
".",
"encrypt",
"(",
"magic_str",
")",
"dobj",
"=",
"des",
".",
"DES",
"(",
"lm_pw",
"[",
"7",
":",
"14",
"]",
")",
"res",
"=",
"res",
"+",
"dobj",
".",
"encrypt",
"(",
"magic_str",
")",
"return",
"res"
] |
create LanManager hashed password
|
[
"create",
"LanManager",
"hashed",
"password"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/packages/ntlm3/ntlm.py#L372-L394
|
13,123
|
Esri/ArcREST
|
src/arcrest/enrichment/_geoenrichment.py
|
GeoEnrichment._readcsv
|
def _readcsv(self, path_to_csv):
"""reads a csv column"""
return np.genfromtxt(path_to_csv,
dtype=None,
delimiter=',',
names=True)
|
python
|
def _readcsv(self, path_to_csv):
"""reads a csv column"""
return np.genfromtxt(path_to_csv,
dtype=None,
delimiter=',',
names=True)
|
[
"def",
"_readcsv",
"(",
"self",
",",
"path_to_csv",
")",
":",
"return",
"np",
".",
"genfromtxt",
"(",
"path_to_csv",
",",
"dtype",
"=",
"None",
",",
"delimiter",
"=",
"','",
",",
"names",
"=",
"True",
")"
] |
reads a csv column
|
[
"reads",
"a",
"csv",
"column"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/enrichment/_geoenrichment.py#L56-L61
|
13,124
|
Esri/ArcREST
|
src/arcrest/enrichment/_geoenrichment.py
|
GeoEnrichment.queryDataCollectionByName
|
def queryDataCollectionByName(self, countryName):
"""
returns a list of available data collections for a given country
name.
Inputs:
countryName - name of the country to file the data collection.
Output:
list or None. None implies could not find the countryName
"""
var = self._dataCollectionCodes
try:
return [x[0] for x in var[var['Countries'] == countryName]]
except:
return None
|
python
|
def queryDataCollectionByName(self, countryName):
"""
returns a list of available data collections for a given country
name.
Inputs:
countryName - name of the country to file the data collection.
Output:
list or None. None implies could not find the countryName
"""
var = self._dataCollectionCodes
try:
return [x[0] for x in var[var['Countries'] == countryName]]
except:
return None
|
[
"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.
Inputs:
countryName - name of the country to file the data collection.
Output:
list or None. None implies could not find the countryName
|
[
"returns",
"a",
"list",
"of",
"available",
"data",
"collections",
"for",
"a",
"given",
"country",
"name",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/enrichment/_geoenrichment.py#L83-L97
|
13,125
|
Esri/ArcREST
|
src/arcrest/enrichment/_geoenrichment.py
|
GeoEnrichment.__geometryToDict
|
def __geometryToDict(self, geom):
"""converts a geometry object to a dictionary"""
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'],
'spatialReference' : poly['spatialReference']
}
}
elif isinstance(geom, list):
return [self.__geometryToDict(g) for g in geom]
|
python
|
def __geometryToDict(self, geom):
"""converts a geometry object to a dictionary"""
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'],
'spatialReference' : poly['spatialReference']
}
}
elif isinstance(geom, list):
return [self.__geometryToDict(g) for g in geom]
|
[
"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'",
"]",
",",
"'spatialReference'",
":",
"poly",
"[",
"'spatialReference'",
"]",
"}",
"}",
"elif",
"isinstance",
"(",
"geom",
",",
"list",
")",
":",
"return",
"[",
"self",
".",
"__geometryToDict",
"(",
"g",
")",
"for",
"g",
"in",
"geom",
"]"
] |
converts a geometry object to a dictionary
|
[
"converts",
"a",
"geometry",
"object",
"to",
"a",
"dictionary"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/enrichment/_geoenrichment.py#L129-L145
|
13,126
|
Esri/ArcREST
|
src/arcrest/enrichment/_geoenrichment.py
|
GeoEnrichment.lookUpReportsByCountry
|
def lookUpReportsByCountry(self, countryName):
"""
looks up a country by it's name
Inputs
countryName - name of the country to get reports list.
"""
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,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
python
|
def lookUpReportsByCountry(self, countryName):
"""
looks up a country by it's name
Inputs
countryName - name of the country to get reports list.
"""
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,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
[
"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",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] |
looks up a country by it's name
Inputs
countryName - name of the country to get reports list.
|
[
"looks",
"up",
"a",
"country",
"by",
"it",
"s",
"name",
"Inputs",
"countryName",
"-",
"name",
"of",
"the",
"country",
"to",
"get",
"reports",
"list",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/enrichment/_geoenrichment.py#L147-L166
|
13,127
|
Esri/ArcREST
|
src/arcrest/enrichment/_geoenrichment.py
|
GeoEnrichment.createReport
|
def createReport(self,
out_file_path,
studyAreas,
report=None,
format="PDF",
reportFields=None,
studyAreasOptions=None,
useData=None,
inSR=4326,
):
"""
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 area, the
service will create a 1-mile ring buffer around the point to
collect and append enrichment data. Optionally, you can create a
buffer ring or drive-time service area around the points to prepare
PDF or Excel reports for the study areas.
Note:
For full examples for each input, please review the following:
http://resources.arcgis.com/en/help/arcgis-rest-api/#/Create_report/02r30000022q000000/
Inputs:
out_file_path - save location of the report
studyAreas - Required parameter to specify a list of input
features to be enriched. The input can be a Point, Polygon,
Adress, or named administrative boundary. The locations can be
passed in as a single object or as a list of objects.
report - Default report to generate.
format - specify the generated report. Options are: XLSX or PDF
reportFields - Optional parameter specifies additional choices to
customize reports. See the URL above to see all the options.
studyAreasOptions - Optional parameter to specify enrichment
behavior. For points described as map coordinates, a 1-mile
ring area centered on each site will be used by default. You
can use this parameter to change these default settings.
With this parameter, the caller can override the default
behavior describing how the enrichment attributes are appended
to the input features described in studyAreas. For example,
you can change the output ring buffer to 5 miles, change the
number of output buffers created around each point, and also
change the output buffer type to a drive-time service area
rather than a simple ring buffer.
useData - By default, the service will automatically determine
the country or dataset that is associated with each location or
area submitted in the studyAreas parameter; however, there is
an associated computational cost which may lengthen the time it
takes to return a response. To skip this intermediate step and
potentially improve the speed and performance of the service,
the caller can specify the country or dataset information up
front through this parameter.
inSR - parameter to define the input geometries in the studyAreas
parameter in a specified spatial reference system.
"""
url = self._base_url + self._url_create_report
if isinstance(studyAreas, list) == False:
studyAreas = [studyAreas]
studyAreas = self.__geometryToDict(studyAreas)
params = {
"f" : "bin",
"studyAreas" : studyAreas,
"inSR" : inSR,
}
if not report is None:
params['report'] = report
if format is None:
format = "pdf"
elif format.lower() in ['pdf', 'xlsx']:
params['format'] = format.lower()
else:
raise AttributeError("Invalid format value.")
if not reportFields is None:
params['reportFields'] = reportFields
if not studyAreasOptions is None:
params['studyAreasOptions'] = studyAreasOptions
if not useData is None:
params['useData'] = useData
result = self._get(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
out_folder=os.path.dirname(out_file_path))
return result
|
python
|
def createReport(self,
out_file_path,
studyAreas,
report=None,
format="PDF",
reportFields=None,
studyAreasOptions=None,
useData=None,
inSR=4326,
):
"""
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 area, the
service will create a 1-mile ring buffer around the point to
collect and append enrichment data. Optionally, you can create a
buffer ring or drive-time service area around the points to prepare
PDF or Excel reports for the study areas.
Note:
For full examples for each input, please review the following:
http://resources.arcgis.com/en/help/arcgis-rest-api/#/Create_report/02r30000022q000000/
Inputs:
out_file_path - save location of the report
studyAreas - Required parameter to specify a list of input
features to be enriched. The input can be a Point, Polygon,
Adress, or named administrative boundary. The locations can be
passed in as a single object or as a list of objects.
report - Default report to generate.
format - specify the generated report. Options are: XLSX or PDF
reportFields - Optional parameter specifies additional choices to
customize reports. See the URL above to see all the options.
studyAreasOptions - Optional parameter to specify enrichment
behavior. For points described as map coordinates, a 1-mile
ring area centered on each site will be used by default. You
can use this parameter to change these default settings.
With this parameter, the caller can override the default
behavior describing how the enrichment attributes are appended
to the input features described in studyAreas. For example,
you can change the output ring buffer to 5 miles, change the
number of output buffers created around each point, and also
change the output buffer type to a drive-time service area
rather than a simple ring buffer.
useData - By default, the service will automatically determine
the country or dataset that is associated with each location or
area submitted in the studyAreas parameter; however, there is
an associated computational cost which may lengthen the time it
takes to return a response. To skip this intermediate step and
potentially improve the speed and performance of the service,
the caller can specify the country or dataset information up
front through this parameter.
inSR - parameter to define the input geometries in the studyAreas
parameter in a specified spatial reference system.
"""
url = self._base_url + self._url_create_report
if isinstance(studyAreas, list) == False:
studyAreas = [studyAreas]
studyAreas = self.__geometryToDict(studyAreas)
params = {
"f" : "bin",
"studyAreas" : studyAreas,
"inSR" : inSR,
}
if not report is None:
params['report'] = report
if format is None:
format = "pdf"
elif format.lower() in ['pdf', 'xlsx']:
params['format'] = format.lower()
else:
raise AttributeError("Invalid format value.")
if not reportFields is None:
params['reportFields'] = reportFields
if not studyAreasOptions is None:
params['studyAreasOptions'] = studyAreasOptions
if not useData is None:
params['useData'] = useData
result = self._get(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
out_folder=os.path.dirname(out_file_path))
return result
|
[
"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",
".",
"__geometryToDict",
"(",
"studyAreas",
")",
"params",
"=",
"{",
"\"f\"",
":",
"\"bin\"",
",",
"\"studyAreas\"",
":",
"studyAreas",
",",
"\"inSR\"",
":",
"inSR",
",",
"}",
"if",
"not",
"report",
"is",
"None",
":",
"params",
"[",
"'report'",
"]",
"=",
"report",
"if",
"format",
"is",
"None",
":",
"format",
"=",
"\"pdf\"",
"elif",
"format",
".",
"lower",
"(",
")",
"in",
"[",
"'pdf'",
",",
"'xlsx'",
"]",
":",
"params",
"[",
"'format'",
"]",
"=",
"format",
".",
"lower",
"(",
")",
"else",
":",
"raise",
"AttributeError",
"(",
"\"Invalid format value.\"",
")",
"if",
"not",
"reportFields",
"is",
"None",
":",
"params",
"[",
"'reportFields'",
"]",
"=",
"reportFields",
"if",
"not",
"studyAreasOptions",
"is",
"None",
":",
"params",
"[",
"'studyAreasOptions'",
"]",
"=",
"studyAreasOptions",
"if",
"not",
"useData",
"is",
"None",
":",
"params",
"[",
"'useData'",
"]",
"=",
"useData",
"result",
"=",
"self",
".",
"_get",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"out_folder",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"out_file_path",
")",
")",
"return",
"result"
] |
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 area, the
service will create a 1-mile ring buffer around the point to
collect and append enrichment data. Optionally, you can create a
buffer ring or drive-time service area around the points to prepare
PDF or Excel reports for the study areas.
Note:
For full examples for each input, please review the following:
http://resources.arcgis.com/en/help/arcgis-rest-api/#/Create_report/02r30000022q000000/
Inputs:
out_file_path - save location of the report
studyAreas - Required parameter to specify a list of input
features to be enriched. The input can be a Point, Polygon,
Adress, or named administrative boundary. The locations can be
passed in as a single object or as a list of objects.
report - Default report to generate.
format - specify the generated report. Options are: XLSX or PDF
reportFields - Optional parameter specifies additional choices to
customize reports. See the URL above to see all the options.
studyAreasOptions - Optional parameter to specify enrichment
behavior. For points described as map coordinates, a 1-mile
ring area centered on each site will be used by default. You
can use this parameter to change these default settings.
With this parameter, the caller can override the default
behavior describing how the enrichment attributes are appended
to the input features described in studyAreas. For example,
you can change the output ring buffer to 5 miles, change the
number of output buffers created around each point, and also
change the output buffer type to a drive-time service area
rather than a simple ring buffer.
useData - By default, the service will automatically determine
the country or dataset that is associated with each location or
area submitted in the studyAreas parameter; however, there is
an associated computational cost which may lengthen the time it
takes to return a response. To skip this intermediate step and
potentially improve the speed and performance of the service,
the caller can specify the country or dataset information up
front through this parameter.
inSR - parameter to define the input geometries in the studyAreas
parameter in a specified spatial reference system.
|
[
"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",
"area",
"the",
"service",
"will",
"create",
"a",
"1",
"-",
"mile",
"ring",
"buffer",
"around",
"the",
"point",
"to",
"collect",
"and",
"append",
"enrichment",
"data",
".",
"Optionally",
"you",
"can",
"create",
"a",
"buffer",
"ring",
"or",
"drive",
"-",
"time",
"service",
"area",
"around",
"the",
"points",
"to",
"prepare",
"PDF",
"or",
"Excel",
"reports",
"for",
"the",
"study",
"areas",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/enrichment/_geoenrichment.py#L293-L380
|
13,128
|
Esri/ArcREST
|
src/arcrest/enrichment/_geoenrichment.py
|
GeoEnrichment.getVariables
|
def getVariables(self,
sourceCountry,
optionalCountryDataset=None,
searchText=None):
r"""
The GeoEnrichment GetVariables helper method allows you to search
the data collections for variables that contain specific keywords.
To see the comprehensive set of global Esri Demographics data that
are available, use the interactive data browser:
http://resources.arcgis.com/en/help/arcgis-rest-api/02r3/02r300000266000000.htm#GUID-2D66F7F8-83A9-4EAA-B5E2-F09D629939CE
Inputs:
sourceCountry - specify the source country for the search. Use this
parameter to limit the search and query of standard geographic
features to one country. This parameter supports both the
two-digit and three-digit country codes illustrated in the
coverage table.
Examples
Example 1 - Set source country to the United States:
sourceCountry=US
Example 2 - Set source country to the Canada:
sourceCountry=CA
Additional notes
Currently, the service is available for Canada, the
United States and a number of European countries. Other
countries will be added in the near future.
The list of available countries and their associated
IDS are listed in the coverage section.
optionalCountryDataset - Optional parameter to specify a specific
dataset within a defined country. This parameter will not be used
in the Beta release. In the future, some countries may have two or
more datasets that may have different vintages and standard
geography areas. For example, in the United States, there may be
an optional dataset with historic census data from previous years.
Examples
optionalCountryDataset=USA_ESRI_2013
Additional notes
Most countries only have a single dataset.
The United States has multiple datasets.
searchText - Optional parameter to specify the text to query and
search the data collections for the country and datasets
specified. You can use this parameter to query and find specific
keywords that are contained in a data collection.
Default value
(null or empty)
Examples
Example 1 - Return all the data collections and variabels that contain the word furniture:
searchText=furniture
Search terms
A query is broken up into terms and operators. There are two types of terms: Single Terms and Phrases.
A Single Term is a single word such as "Income" or "Households".
A Phrase is a group of words surrounded by double quotes such as "Household Income".
Multiple terms can be combined together with Boolean operators to form a more complex query (see below).
Fields
Geography search supports fielded data. When performing a search, you can either specify a field or use search through all fields.
You can search any field by typing the field name followed by a colon ":" then the term you are looking for.
For example, to search for "Income" in the Alias field:
Alias:Income
The search supports single and multiple character wildcard searches within single terms (not within phrase queries).
To perform a single character wildcard search, use the "?" symbol.
To perform a multiple character wildcard search, use the "*" symbol.
The single character wildcard search looks for terms that match that with the single character replaced. For example, to search for "San" or "Sen" you can use the search:
Fuzzy searches
Fuzzy searches are based on the Levenshtein Distance or Edit Distance algorithm. To perform a fuzzy search, you can explicitly set a fuzzy search by using the tilde symbol "~" at the end of a Single Term.
For example, a term similar in spelling to "Hous" uses the fuzzy search:
Hous~
An additional (optional) numeric parameter can be specified after the tilde symbol ("~") to set the similarity tolerance. The value is between 0 and 1; with a value closer to 1, only terms with a higher similarity will be matched.
For example, if you only want to match terms with a similarity of 0.0 or higher, you can set the fuzzy search as follows:
hous~0.8
The default that is used if the optional similarity number is not provided is 0.5.
Boolean operators
Boolean operators allow terms to be combined through logic operators. The search supports AND, "+", OR, NOT and "-" as Boolean operators. Boolean operators must be ALL CAPS.
In searchText , the AND operator is the default conjunction operator. This means that if there is no Boolean operator between two or more terms, the AND operator is used. The AND operator matches items where both terms exist anywhere in the list of standard geography features. The symbol "&" can be used in place of the word AND.
The OR operator links two terms and finds a matching variable if either of the terms exist. This is equivalent to a union with using sets. The symbol "||" can be used in place of the word OR.
To search for features that contain either "Income" or "Wealth" use the following query:
Income OR Wealth
The "+" or required operator requires that the term after the "+" symbol exist somewhere in the attributes of a variable.
To search for features that must contain "Income" and may contain "Household" use the following query:
+Income OR Household
Escaping Special Characters
Search supports escaping special characters that are part of the query syntax. The available special characters are as follows:
+ - && || ! ( ) { } [ ] ^ " ~ * ? : \
To escape these characters, use the \ before the character.
"""
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['optionalCountryDataset'] = optionalCountryDataset
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
python
|
def getVariables(self,
sourceCountry,
optionalCountryDataset=None,
searchText=None):
r"""
The GeoEnrichment GetVariables helper method allows you to search
the data collections for variables that contain specific keywords.
To see the comprehensive set of global Esri Demographics data that
are available, use the interactive data browser:
http://resources.arcgis.com/en/help/arcgis-rest-api/02r3/02r300000266000000.htm#GUID-2D66F7F8-83A9-4EAA-B5E2-F09D629939CE
Inputs:
sourceCountry - specify the source country for the search. Use this
parameter to limit the search and query of standard geographic
features to one country. This parameter supports both the
two-digit and three-digit country codes illustrated in the
coverage table.
Examples
Example 1 - Set source country to the United States:
sourceCountry=US
Example 2 - Set source country to the Canada:
sourceCountry=CA
Additional notes
Currently, the service is available for Canada, the
United States and a number of European countries. Other
countries will be added in the near future.
The list of available countries and their associated
IDS are listed in the coverage section.
optionalCountryDataset - Optional parameter to specify a specific
dataset within a defined country. This parameter will not be used
in the Beta release. In the future, some countries may have two or
more datasets that may have different vintages and standard
geography areas. For example, in the United States, there may be
an optional dataset with historic census data from previous years.
Examples
optionalCountryDataset=USA_ESRI_2013
Additional notes
Most countries only have a single dataset.
The United States has multiple datasets.
searchText - Optional parameter to specify the text to query and
search the data collections for the country and datasets
specified. You can use this parameter to query and find specific
keywords that are contained in a data collection.
Default value
(null or empty)
Examples
Example 1 - Return all the data collections and variabels that contain the word furniture:
searchText=furniture
Search terms
A query is broken up into terms and operators. There are two types of terms: Single Terms and Phrases.
A Single Term is a single word such as "Income" or "Households".
A Phrase is a group of words surrounded by double quotes such as "Household Income".
Multiple terms can be combined together with Boolean operators to form a more complex query (see below).
Fields
Geography search supports fielded data. When performing a search, you can either specify a field or use search through all fields.
You can search any field by typing the field name followed by a colon ":" then the term you are looking for.
For example, to search for "Income" in the Alias field:
Alias:Income
The search supports single and multiple character wildcard searches within single terms (not within phrase queries).
To perform a single character wildcard search, use the "?" symbol.
To perform a multiple character wildcard search, use the "*" symbol.
The single character wildcard search looks for terms that match that with the single character replaced. For example, to search for "San" or "Sen" you can use the search:
Fuzzy searches
Fuzzy searches are based on the Levenshtein Distance or Edit Distance algorithm. To perform a fuzzy search, you can explicitly set a fuzzy search by using the tilde symbol "~" at the end of a Single Term.
For example, a term similar in spelling to "Hous" uses the fuzzy search:
Hous~
An additional (optional) numeric parameter can be specified after the tilde symbol ("~") to set the similarity tolerance. The value is between 0 and 1; with a value closer to 1, only terms with a higher similarity will be matched.
For example, if you only want to match terms with a similarity of 0.0 or higher, you can set the fuzzy search as follows:
hous~0.8
The default that is used if the optional similarity number is not provided is 0.5.
Boolean operators
Boolean operators allow terms to be combined through logic operators. The search supports AND, "+", OR, NOT and "-" as Boolean operators. Boolean operators must be ALL CAPS.
In searchText , the AND operator is the default conjunction operator. This means that if there is no Boolean operator between two or more terms, the AND operator is used. The AND operator matches items where both terms exist anywhere in the list of standard geography features. The symbol "&" can be used in place of the word AND.
The OR operator links two terms and finds a matching variable if either of the terms exist. This is equivalent to a union with using sets. The symbol "||" can be used in place of the word OR.
To search for features that contain either "Income" or "Wealth" use the following query:
Income OR Wealth
The "+" or required operator requires that the term after the "+" symbol exist somewhere in the attributes of a variable.
To search for features that must contain "Income" and may contain "Household" use the following query:
+Income OR Household
Escaping Special Characters
Search supports escaping special characters that are part of the query syntax. The available special characters are as follows:
+ - && || ! ( ) { } [ ] ^ " ~ * ? : \
To escape these characters, use the \ before the character.
"""
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['optionalCountryDataset'] = optionalCountryDataset
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
[
"def",
"getVariables",
"(",
"self",
",",
"sourceCountry",
",",
"optionalCountryDataset",
"=",
"None",
",",
"searchText",
"=",
"None",
")",
":",
"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",
"[",
"'optionalCountryDataset'",
"]",
"=",
"optionalCountryDataset",
"return",
"self",
".",
"_post",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] |
r"""
The GeoEnrichment GetVariables helper method allows you to search
the data collections for variables that contain specific keywords.
To see the comprehensive set of global Esri Demographics data that
are available, use the interactive data browser:
http://resources.arcgis.com/en/help/arcgis-rest-api/02r3/02r300000266000000.htm#GUID-2D66F7F8-83A9-4EAA-B5E2-F09D629939CE
Inputs:
sourceCountry - specify the source country for the search. Use this
parameter to limit the search and query of standard geographic
features to one country. This parameter supports both the
two-digit and three-digit country codes illustrated in the
coverage table.
Examples
Example 1 - Set source country to the United States:
sourceCountry=US
Example 2 - Set source country to the Canada:
sourceCountry=CA
Additional notes
Currently, the service is available for Canada, the
United States and a number of European countries. Other
countries will be added in the near future.
The list of available countries and their associated
IDS are listed in the coverage section.
optionalCountryDataset - Optional parameter to specify a specific
dataset within a defined country. This parameter will not be used
in the Beta release. In the future, some countries may have two or
more datasets that may have different vintages and standard
geography areas. For example, in the United States, there may be
an optional dataset with historic census data from previous years.
Examples
optionalCountryDataset=USA_ESRI_2013
Additional notes
Most countries only have a single dataset.
The United States has multiple datasets.
searchText - Optional parameter to specify the text to query and
search the data collections for the country and datasets
specified. You can use this parameter to query and find specific
keywords that are contained in a data collection.
Default value
(null or empty)
Examples
Example 1 - Return all the data collections and variabels that contain the word furniture:
searchText=furniture
Search terms
A query is broken up into terms and operators. There are two types of terms: Single Terms and Phrases.
A Single Term is a single word such as "Income" or "Households".
A Phrase is a group of words surrounded by double quotes such as "Household Income".
Multiple terms can be combined together with Boolean operators to form a more complex query (see below).
Fields
Geography search supports fielded data. When performing a search, you can either specify a field or use search through all fields.
You can search any field by typing the field name followed by a colon ":" then the term you are looking for.
For example, to search for "Income" in the Alias field:
Alias:Income
The search supports single and multiple character wildcard searches within single terms (not within phrase queries).
To perform a single character wildcard search, use the "?" symbol.
To perform a multiple character wildcard search, use the "*" symbol.
The single character wildcard search looks for terms that match that with the single character replaced. For example, to search for "San" or "Sen" you can use the search:
Fuzzy searches
Fuzzy searches are based on the Levenshtein Distance or Edit Distance algorithm. To perform a fuzzy search, you can explicitly set a fuzzy search by using the tilde symbol "~" at the end of a Single Term.
For example, a term similar in spelling to "Hous" uses the fuzzy search:
Hous~
An additional (optional) numeric parameter can be specified after the tilde symbol ("~") to set the similarity tolerance. The value is between 0 and 1; with a value closer to 1, only terms with a higher similarity will be matched.
For example, if you only want to match terms with a similarity of 0.0 or higher, you can set the fuzzy search as follows:
hous~0.8
The default that is used if the optional similarity number is not provided is 0.5.
Boolean operators
Boolean operators allow terms to be combined through logic operators. The search supports AND, "+", OR, NOT and "-" as Boolean operators. Boolean operators must be ALL CAPS.
In searchText , the AND operator is the default conjunction operator. This means that if there is no Boolean operator between two or more terms, the AND operator is used. The AND operator matches items where both terms exist anywhere in the list of standard geography features. The symbol "&" can be used in place of the word AND.
The OR operator links two terms and finds a matching variable if either of the terms exist. This is equivalent to a union with using sets. The symbol "||" can be used in place of the word OR.
To search for features that contain either "Income" or "Wealth" use the following query:
Income OR Wealth
The "+" or required operator requires that the term after the "+" symbol exist somewhere in the attributes of a variable.
To search for features that must contain "Income" and may contain "Household" use the following query:
+Income OR Household
Escaping Special Characters
Search supports escaping special characters that are part of the query syntax. The available special characters are as follows:
+ - && || ! ( ) { } [ ] ^ " ~ * ? : \
To escape these characters, use the \ before the character.
|
[
"r",
"The",
"GeoEnrichment",
"GetVariables",
"helper",
"method",
"allows",
"you",
"to",
"search",
"the",
"data",
"collections",
"for",
"variables",
"that",
"contain",
"specific",
"keywords",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/enrichment/_geoenrichment.py#L445-L546
|
13,129
|
Esri/ArcREST
|
src/arcrest/manageags/_services.py
|
Services.folders
|
def folders(self):
""" returns a list of all folders """
if self._folders is None:
self.__init()
if "/" not in self._folders:
self._folders.append("/")
return self._folders
|
python
|
def folders(self):
""" returns a list of all folders """
if self._folders is None:
self.__init()
if "/" not in self._folders:
self._folders.append("/")
return self._folders
|
[
"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
|
[
"returns",
"a",
"list",
"of",
"all",
"folders"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/_services.py#L109-L115
|
13,130
|
Esri/ArcREST
|
src/arcrest/manageags/_services.py
|
Services.services
|
def services(self):
""" returns the services in the current folder """
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['services']:
uURL = self._currentURL + "/%s.%s" % (s['serviceName'], s['type'])
self._services.append(
AGSService(url=uURL,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
)
return self._services
|
python
|
def services(self):
""" returns the services in the current folder """
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['services']:
uURL = self._currentURL + "/%s.%s" % (s['serviceName'], s['type'])
self._services.append(
AGSService(url=uURL,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
)
return self._services
|
[
"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",
"[",
"'services'",
"]",
":",
"uURL",
"=",
"self",
".",
"_currentURL",
"+",
"\"/%s.%s\"",
"%",
"(",
"s",
"[",
"'serviceName'",
"]",
",",
"s",
"[",
"'type'",
"]",
")",
"self",
".",
"_services",
".",
"append",
"(",
"AGSService",
"(",
"url",
"=",
"uURL",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")",
")",
"return",
"self",
".",
"_services"
] |
returns the services in the current folder
|
[
"returns",
"the",
"services",
"in",
"the",
"current",
"folder"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/_services.py#L139-L159
|
13,131
|
Esri/ArcREST
|
src/arcrest/manageags/_services.py
|
Services.createService
|
def createService(self, service):
"""
Creates a new GIS service in the folder. A service is created by
submitting a JSON representation of the service to this operation.
"""
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,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
python
|
def createService(self, service):
"""
Creates a new GIS service in the folder. A service is created by
submitting a JSON representation of the service to this operation.
"""
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,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
[
"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",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] |
Creates a new GIS service in the folder. A service is created by
submitting a JSON representation of the service to this operation.
|
[
"Creates",
"a",
"new",
"GIS",
"service",
"in",
"the",
"folder",
".",
"A",
"service",
"is",
"created",
"by",
"submitting",
"a",
"JSON",
"representation",
"of",
"the",
"service",
"to",
"this",
"operation",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/_services.py#L401-L418
|
13,132
|
Esri/ArcREST
|
src/arcrest/manageags/_services.py
|
Services.exists
|
def exists(self, folderName, serviceName=None, serviceType=None):
"""
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.
Inputs:
folderName - a folder name
serviceName - a service name
serviceType - a service type. Allowed values:
"GPSERVER", "GLOBESERVER", "MAPSERVER",
"GEOMETRYSERVER", "IMAGESERVER", "SEARCHSERVER",
"GEODATASERVER", "GEOCODESERVER"
"""
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_url=self._proxy_url,
proxy_port=self._proxy_port)
|
python
|
def exists(self, folderName, serviceName=None, serviceType=None):
"""
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.
Inputs:
folderName - a folder name
serviceName - a service name
serviceType - a service type. Allowed values:
"GPSERVER", "GLOBESERVER", "MAPSERVER",
"GEOMETRYSERVER", "IMAGESERVER", "SEARCHSERVER",
"GEODATASERVER", "GEOCODESERVER"
"""
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_url=self._proxy_url,
proxy_port=self._proxy_port)
|
[
"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_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] |
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.
Inputs:
folderName - a folder name
serviceName - a service name
serviceType - a service type. Allowed values:
"GPSERVER", "GLOBESERVER", "MAPSERVER",
"GEOMETRYSERVER", "IMAGESERVER", "SEARCHSERVER",
"GEODATASERVER", "GEOCODESERVER"
|
[
"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",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/_services.py#L524-L552
|
13,133
|
Esri/ArcREST
|
src/arcrest/manageags/_services.py
|
AGSService.__init
|
def __init(self):
""" populates server admin information """
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 = [attr for attr in dir(self)
if not attr.startswith('__') and \
not attr.startswith('_')]
for k,v in json_dict.items():
if k.lower() == "extensions":
self._extensions = []
for ext in v:
self._extensions.append(Extension.fromJSON(ext))
del ext
elif k in attributes:
setattr(self, "_"+ k, json_dict[k])
else:
print( k, " - attribute not implemented in manageags.AGSService.")
del k
del v
|
python
|
def __init(self):
""" populates server admin information """
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 = [attr for attr in dir(self)
if not attr.startswith('__') and \
not attr.startswith('_')]
for k,v in json_dict.items():
if k.lower() == "extensions":
self._extensions = []
for ext in v:
self._extensions.append(Extension.fromJSON(ext))
del ext
elif k in attributes:
setattr(self, "_"+ k, json_dict[k])
else:
print( k, " - attribute not implemented in manageags.AGSService.")
del k
del v
|
[
"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",
"=",
"[",
"attr",
"for",
"attr",
"in",
"dir",
"(",
"self",
")",
"if",
"not",
"attr",
".",
"startswith",
"(",
"'__'",
")",
"and",
"not",
"attr",
".",
"startswith",
"(",
"'_'",
")",
"]",
"for",
"k",
",",
"v",
"in",
"json_dict",
".",
"items",
"(",
")",
":",
"if",
"k",
".",
"lower",
"(",
")",
"==",
"\"extensions\"",
":",
"self",
".",
"_extensions",
"=",
"[",
"]",
"for",
"ext",
"in",
"v",
":",
"self",
".",
"_extensions",
".",
"append",
"(",
"Extension",
".",
"fromJSON",
"(",
"ext",
")",
")",
"del",
"ext",
"elif",
"k",
"in",
"attributes",
":",
"setattr",
"(",
"self",
",",
"\"_\"",
"+",
"k",
",",
"json_dict",
"[",
"k",
"]",
")",
"else",
":",
"print",
"(",
"k",
",",
"\" - attribute not implemented in manageags.AGSService.\"",
")",
"del",
"k",
"del",
"v"
] |
populates server admin information
|
[
"populates",
"server",
"admin",
"information"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/_services.py#L615-L641
|
13,134
|
Esri/ArcREST
|
src/arcrest/manageags/_services.py
|
AGSService.serviceManifest
|
def serviceManifest(self, fileType="json"):
"""
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.
Inputs:
fileType - this can be json or xml. json returns the
manifest.json file. xml returns the manifest.xml file. These
files are stored at \arcgisserver\directories\arcgissystem\
arcgisinput\%servicename%.%servicetype%\extracted folder.
Outputs:
Python dictionary if fileType is json and Python object of
xml.etree.ElementTree.ElementTree type if fileType is xml.
"""
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.gettempdir(),
file_name=os.path.basename(url))
if fileType == 'json':
return f
if fileType == 'xml':
return ET.ElementTree(ET.fromstring(f))
|
python
|
def serviceManifest(self, fileType="json"):
"""
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.
Inputs:
fileType - this can be json or xml. json returns the
manifest.json file. xml returns the manifest.xml file. These
files are stored at \arcgisserver\directories\arcgissystem\
arcgisinput\%servicename%.%servicetype%\extracted folder.
Outputs:
Python dictionary if fileType is json and Python object of
xml.etree.ElementTree.ElementTree type if fileType is xml.
"""
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.gettempdir(),
file_name=os.path.basename(url))
if fileType == 'json':
return f
if fileType == 'xml':
return ET.ElementTree(ET.fromstring(f))
|
[
"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",
".",
"gettempdir",
"(",
")",
",",
"file_name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"url",
")",
")",
"if",
"fileType",
"==",
"'json'",
":",
"return",
"f",
"if",
"fileType",
"==",
"'xml'",
":",
"return",
"ET",
".",
"ElementTree",
"(",
"ET",
".",
"fromstring",
"(",
"f",
")",
")"
] |
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.
Inputs:
fileType - this can be json or xml. json returns the
manifest.json file. xml returns the manifest.xml file. These
files are stored at \arcgisserver\directories\arcgissystem\
arcgisinput\%servicename%.%servicetype%\extracted folder.
Outputs:
Python dictionary if fileType is json and Python object of
xml.etree.ElementTree.ElementTree type if fileType is xml.
|
[
"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",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/_services.py#L1023-L1053
|
13,135
|
Esri/ArcREST
|
src/arcrest/manageags/_data.py
|
Data.startDataStoreMachine
|
def startDataStoreMachine(self, dataStoreItemName, machineName):
"""
Starts the database instance running on the Data Store machine.
Inputs:
dataStoreItemName - name of the item to start
machineName - name of the machine to start on
"""
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=self._proxy_url,
proxy_port=self._proxy_port)
|
python
|
def startDataStoreMachine(self, dataStoreItemName, machineName):
"""
Starts the database instance running on the Data Store machine.
Inputs:
dataStoreItemName - name of the item to start
machineName - name of the machine to start on
"""
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=self._proxy_url,
proxy_port=self._proxy_port)
|
[
"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",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] |
Starts the database instance running on the Data Store machine.
Inputs:
dataStoreItemName - name of the item to start
machineName - name of the machine to start on
|
[
"Starts",
"the",
"database",
"instance",
"running",
"on",
"the",
"Data",
"Store",
"machine",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/_data.py#L236-L251
|
13,136
|
Esri/ArcREST
|
src/arcrest/manageags/_data.py
|
Data.unregisterDataItem
|
def unregisterDataItem(self, path):
"""
Unregisters a data item that has been previously registered with
the server's data store.
Inputs:
path - path to share folder
Example:
path = r"/fileShares/folder_share"
print data.unregisterDataItem(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)
|
python
|
def unregisterDataItem(self, path):
"""
Unregisters a data item that has been previously registered with
the server's data store.
Inputs:
path - path to share folder
Example:
path = r"/fileShares/folder_share"
print data.unregisterDataItem(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)
|
[
"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.
Inputs:
path - path to share folder
Example:
path = r"/fileShares/folder_share"
print data.unregisterDataItem(path)
|
[
"Unregisters",
"a",
"data",
"item",
"that",
"has",
"been",
"previously",
"registered",
"with",
"the",
"server",
"s",
"data",
"store",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/_data.py#L270-L291
|
13,137
|
Esri/ArcREST
|
src/arcrest/manageags/_data.py
|
Data.validateDataStore
|
def validateDataStore(self, dataStoreName, machineName):
"""
Checks the status of ArcGIS Data Store and provides a health check
response.
Inputs:
dataStoreName - name of the datastore
machineName - name of the machine
"""
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._proxy_url,
proxy_port=self._proxy_port)
|
python
|
def validateDataStore(self, dataStoreName, machineName):
"""
Checks the status of ArcGIS Data Store and provides a health check
response.
Inputs:
dataStoreName - name of the datastore
machineName - name of the machine
"""
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._proxy_url,
proxy_port=self._proxy_port)
|
[
"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",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] |
Checks the status of ArcGIS Data Store and provides a health check
response.
Inputs:
dataStoreName - name of the datastore
machineName - name of the machine
|
[
"Checks",
"the",
"status",
"of",
"ArcGIS",
"Data",
"Store",
"and",
"provides",
"a",
"health",
"check",
"response",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/_data.py#L293-L310
|
13,138
|
Esri/ArcREST
|
src/arcrest/ags/_globeservice.py
|
GlobeService.layers
|
def layers(self):
"""gets the globe service layers"""
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)
return lyrs
|
python
|
def layers(self):
"""gets the globe service layers"""
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)
return lyrs
|
[
"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",
")",
"return",
"lyrs"
] |
gets the globe service layers
|
[
"gets",
"the",
"globe",
"service",
"layers"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_globeservice.py#L288-L300
|
13,139
|
Esri/ArcREST
|
src/arcrest/ags/_gpobjects.py
|
GPFeatureRecordSetLayer.loadFeatures
|
def loadFeatures(self, path_to_fc):
"""
loads a feature class features to the object
"""
from ..common.spatial import featureclass_to_json
v = json.loads(featureclass_to_json(path_to_fc))
self.value = v
|
python
|
def loadFeatures(self, path_to_fc):
"""
loads a feature class features to the object
"""
from ..common.spatial import featureclass_to_json
v = json.loads(featureclass_to_json(path_to_fc))
self.value = v
|
[
"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
|
[
"loads",
"a",
"feature",
"class",
"features",
"to",
"the",
"object"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_gpobjects.py#L184-L190
|
13,140
|
Esri/ArcREST
|
src/arcrest/ags/_gpobjects.py
|
GPFeatureRecordSetLayer.fromFeatureClass
|
def fromFeatureClass(fc, paramName):
"""
returns a GPFeatureRecordSetLayer object from a feature class
Input:
fc - path to a feature class
paramName - name of the parameter
"""
from ..common.spatial import featureclass_to_json
val = json.loads(featureclass_to_json(fc))
v = GPFeatureRecordSetLayer()
v.value = val
v.paramName = paramName
return v
|
python
|
def fromFeatureClass(fc, paramName):
"""
returns a GPFeatureRecordSetLayer object from a feature class
Input:
fc - path to a feature class
paramName - name of the parameter
"""
from ..common.spatial import featureclass_to_json
val = json.loads(featureclass_to_json(fc))
v = GPFeatureRecordSetLayer()
v.value = val
v.paramName = paramName
return v
|
[
"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
Input:
fc - path to a feature class
paramName - name of the parameter
|
[
"returns",
"a",
"GPFeatureRecordSetLayer",
"object",
"from",
"a",
"feature",
"class"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_gpobjects.py#L207-L220
|
13,141
|
Esri/ArcREST
|
src/arcrest/webmap/renderer.py
|
SimpleRenderer.asDictionary
|
def asDictionary(self):
""" provides a dictionary representation of the object """
template = {
"type" : "simple",
"symbol" : self._symbol.asDictionary,
"label" : self._label,
"description" : self._description,
"rotationType": self._rotationType,
"rotationExpression": self._rotationExpression
}
return template
|
python
|
def asDictionary(self):
""" provides a dictionary representation of the object """
template = {
"type" : "simple",
"symbol" : self._symbol.asDictionary,
"label" : self._label,
"description" : self._description,
"rotationType": self._rotationType,
"rotationExpression": self._rotationExpression
}
return template
|
[
"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
|
[
"provides",
"a",
"dictionary",
"representation",
"of",
"the",
"object"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/webmap/renderer.py#L32-L42
|
13,142
|
Esri/ArcREST
|
src/arcrest/ags/_schematicsservice.py
|
SchematicsService.searchDiagrams
|
def searchDiagrams(self,whereClause=None,relatedObjects=None,
relatedSchematicObjects=None):
"""
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.
It is used to search diagrams in the schematic service by criteria;
that is, diagrams filtered out via a where clause on any schematic
diagram class table field, diagrams that contain schematic features
associated with a specific set of GIS features/objects, or diagrams
that contain schematic features associated with the same GIS features/
objects related to another set of schematic features.
Inputs:
whereClause - A where clause for the query filter. Any legal SQL
where clause operating on the fields in the schematic
diagram class table is allowed. See the Schematic
diagram class table fields section below to know the
exact list of field names that can be used in this
where clause.
relatedObjects - An array containing the list of the GIS features/
objects IDs per feature class/table name that are in
relation with schematic features in the resulting
queried diagrams. Each GIS feature/object ID
corresponds to a value of the OBJECTID field in the
GIS feature class/table.
relatedSchematicObjects - An array containing the list of the
schematic feature names per schematic
feature class ID that have the same
associated GIS features/objects with
schematic features in the resulting
queried diagrams. Each schematic feature
name corresponds to a value of the
SCHEMATICTID field in the schematic
feature class.
"""
params = {"f" : "json"}
if whereClause:
params["where"] = whereClause
if relatedObjects:
params["relatedObjects"] = relatedObjects
if relatedSchematicObjects:
params["relatedSchematicObjects"] = relatedSchematicObjects
exportURL = self._url + "/searchDiagrams"
return self._get(url=exportURL,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
python
|
def searchDiagrams(self,whereClause=None,relatedObjects=None,
relatedSchematicObjects=None):
"""
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.
It is used to search diagrams in the schematic service by criteria;
that is, diagrams filtered out via a where clause on any schematic
diagram class table field, diagrams that contain schematic features
associated with a specific set of GIS features/objects, or diagrams
that contain schematic features associated with the same GIS features/
objects related to another set of schematic features.
Inputs:
whereClause - A where clause for the query filter. Any legal SQL
where clause operating on the fields in the schematic
diagram class table is allowed. See the Schematic
diagram class table fields section below to know the
exact list of field names that can be used in this
where clause.
relatedObjects - An array containing the list of the GIS features/
objects IDs per feature class/table name that are in
relation with schematic features in the resulting
queried diagrams. Each GIS feature/object ID
corresponds to a value of the OBJECTID field in the
GIS feature class/table.
relatedSchematicObjects - An array containing the list of the
schematic feature names per schematic
feature class ID that have the same
associated GIS features/objects with
schematic features in the resulting
queried diagrams. Each schematic feature
name corresponds to a value of the
SCHEMATICTID field in the schematic
feature class.
"""
params = {"f" : "json"}
if whereClause:
params["where"] = whereClause
if relatedObjects:
params["relatedObjects"] = relatedObjects
if relatedSchematicObjects:
params["relatedSchematicObjects"] = relatedSchematicObjects
exportURL = self._url + "/searchDiagrams"
return self._get(url=exportURL,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
[
"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\"",
"]",
"=",
"relatedSchematicObjects",
"exportURL",
"=",
"self",
".",
"_url",
"+",
"\"/searchDiagrams\"",
"return",
"self",
".",
"_get",
"(",
"url",
"=",
"exportURL",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] |
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.
It is used to search diagrams in the schematic service by criteria;
that is, diagrams filtered out via a where clause on any schematic
diagram class table field, diagrams that contain schematic features
associated with a specific set of GIS features/objects, or diagrams
that contain schematic features associated with the same GIS features/
objects related to another set of schematic features.
Inputs:
whereClause - A where clause for the query filter. Any legal SQL
where clause operating on the fields in the schematic
diagram class table is allowed. See the Schematic
diagram class table fields section below to know the
exact list of field names that can be used in this
where clause.
relatedObjects - An array containing the list of the GIS features/
objects IDs per feature class/table name that are in
relation with schematic features in the resulting
queried diagrams. Each GIS feature/object ID
corresponds to a value of the OBJECTID field in the
GIS feature class/table.
relatedSchematicObjects - An array containing the list of the
schematic feature names per schematic
feature class ID that have the same
associated GIS features/objects with
schematic features in the resulting
queried diagrams. Each schematic feature
name corresponds to a value of the
SCHEMATICTID field in the schematic
feature class.
|
[
"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",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_schematicsservice.py#L166-L216
|
13,143
|
Esri/ArcREST
|
src/arcrest/ags/server.py
|
Server._validateurl
|
def _validateurl(self, url):
"""assembles the server 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() not in "services":
next
path = "/".join(parts)
else:
path = "arcgis"
self._adminUrl = "%s://%s/%s/admin" % (parsed.scheme, parsed.netloc, path)
return "%s://%s/%s/rest/services" % (parsed.scheme, parsed.netloc, path)
|
python
|
def _validateurl(self, url):
"""assembles the server 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() not in "services":
next
path = "/".join(parts)
else:
path = "arcgis"
self._adminUrl = "%s://%s/%s/admin" % (parsed.scheme, parsed.netloc, path)
return "%s://%s/%s/rest/services" % (parsed.scheme, parsed.netloc, path)
|
[
"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",
"(",
")",
"not",
"in",
"\"services\"",
":",
"next",
"path",
"=",
"\"/\"",
".",
"join",
"(",
"parts",
")",
"else",
":",
"path",
"=",
"\"arcgis\"",
"self",
".",
"_adminUrl",
"=",
"\"%s://%s/%s/admin\"",
"%",
"(",
"parsed",
".",
"scheme",
",",
"parsed",
".",
"netloc",
",",
"path",
")",
"return",
"\"%s://%s/%s/rest/services\"",
"%",
"(",
"parsed",
".",
"scheme",
",",
"parsed",
".",
"netloc",
",",
"path",
")"
] |
assembles the server url
|
[
"assembles",
"the",
"server",
"url"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/server.py#L57-L74
|
13,144
|
Esri/ArcREST
|
src/arcrest/ags/server.py
|
Server.admin
|
def admin(self):
"""points to the adminstrative side of ArcGIS Server"""
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_port=self._proxy_port,
initialize=False)
|
python
|
def admin(self):
"""points to the adminstrative side of ArcGIS Server"""
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_port=self._proxy_port,
initialize=False)
|
[
"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_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"False",
")"
] |
points to the adminstrative side of ArcGIS Server
|
[
"points",
"to",
"the",
"adminstrative",
"side",
"of",
"ArcGIS",
"Server"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/server.py#L118-L127
|
13,145
|
Esri/ArcREST
|
src/arcrest/manageorg/_parameters.py
|
InvitationList.addUser
|
def addUser(self, username, password,
firstname, lastname,
email, role):
"""adds a user to the invitation list"""
self._invites.append({
"username":username,
"password":password,
"firstname":firstname,
"lastname":lastname,
"fullname":"%s %s" % (firstname, lastname),
"email":email,
"role":role
})
|
python
|
def addUser(self, username, password,
firstname, lastname,
email, role):
"""adds a user to the invitation list"""
self._invites.append({
"username":username,
"password":password,
"firstname":firstname,
"lastname":lastname,
"fullname":"%s %s" % (firstname, lastname),
"email":email,
"role":role
})
|
[
"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
|
[
"adds",
"a",
"user",
"to",
"the",
"invitation",
"list"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_parameters.py#L17-L29
|
13,146
|
Esri/ArcREST
|
src/arcrest/manageorg/_parameters.py
|
InvitationList.removeByIndex
|
def removeByIndex(self, index):
"""removes a user from the invitation list by position"""
if index < len(self._invites) -1 and \
index >=0:
self._invites.remove(index)
|
python
|
def removeByIndex(self, index):
"""removes a user from the invitation list by position"""
if index < len(self._invites) -1 and \
index >=0:
self._invites.remove(index)
|
[
"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
|
[
"removes",
"a",
"user",
"from",
"the",
"invitation",
"list",
"by",
"position"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_parameters.py#L31-L35
|
13,147
|
Esri/ArcREST
|
src/arcrest/manageorg/_parameters.py
|
PortalParameters.fromDictionary
|
def fromDictionary(value):
"""creates the portal properties object from a dictionary"""
if isinstance(value, dict):
pp = PortalParameters()
for k,v in value.items():
setattr(pp, "_%s" % k, v)
return pp
else:
raise AttributeError("Invalid input.")
|
python
|
def fromDictionary(value):
"""creates the portal properties object from a dictionary"""
if isinstance(value, dict):
pp = PortalParameters()
for k,v in value.items():
setattr(pp, "_%s" % k, v)
return pp
else:
raise AttributeError("Invalid input.")
|
[
"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
|
[
"creates",
"the",
"portal",
"properties",
"object",
"from",
"a",
"dictionary"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_parameters.py#L434-L442
|
13,148
|
Esri/ArcREST
|
src/arcrest/manageorg/_parameters.py
|
PublishCSVParameters.value
|
def value(self):
"""returns the values as a dictionary"""
val = {}
for k in self.__allowed_keys:
value = getattr(self, "_" + k)
if value is not None:
val[k] = value
return val
|
python
|
def value(self):
"""returns the values as a dictionary"""
val = {}
for k in self.__allowed_keys:
value = getattr(self, "_" + k)
if value is not None:
val[k] = value
return val
|
[
"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
|
[
"returns",
"the",
"values",
"as",
"a",
"dictionary"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_parameters.py#L1775-L1782
|
13,149
|
Esri/ArcREST
|
src/arcrest/ags/_vectortile.py
|
VectorTileService.tile_fonts
|
def tile_fonts(self, fontstack, stack_range, out_folder=None):
"""This resource returns glyphs in PBF format. The template url for
this fonts resource is represented in Vector Tile Style resource."""
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=url,
param_dict=params,
out_folder=out_folder,
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_host)
|
python
|
def tile_fonts(self, fontstack, stack_range, out_folder=None):
"""This resource returns glyphs in PBF format. The template url for
this fonts resource is represented in Vector Tile Style resource."""
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=url,
param_dict=params,
out_folder=out_folder,
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_host)
|
[
"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",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"out_folder",
"=",
"out_folder",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_host",
")"
] |
This resource returns glyphs in PBF format. The template url for
this fonts resource is represented in Vector Tile Style resource.
|
[
"This",
"resource",
"returns",
"glyphs",
"in",
"PBF",
"format",
".",
"The",
"template",
"url",
"for",
"this",
"fonts",
"resource",
"is",
"represented",
"in",
"Vector",
"Tile",
"Style",
"resource",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_vectortile.py#L190-L205
|
13,150
|
Esri/ArcREST
|
src/arcrest/ags/_vectortile.py
|
VectorTileService.tile_sprite
|
def tile_sprite(self, out_format="sprite.json", out_folder=None):
"""
This resource returns sprite image and metadata
"""
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=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_host)
|
python
|
def tile_sprite(self, out_format="sprite.json", out_folder=None):
"""
This resource returns sprite image and metadata
"""
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=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_host)
|
[
"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",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_host",
")"
] |
This resource returns sprite image and metadata
|
[
"This",
"resource",
"returns",
"sprite",
"image",
"and",
"metadata"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_vectortile.py#L226-L239
|
13,151
|
Esri/ArcREST
|
src/arcrest/ags/services.py
|
FeatureService.layers
|
def layers(self):
""" gets the layers for the feature service """
if self._layers is None:
self.__init()
self._getLayers()
return self._layers
|
python
|
def layers(self):
""" gets the layers for the feature service """
if self._layers is None:
self.__init()
self._getLayers()
return self._layers
|
[
"def",
"layers",
"(",
"self",
")",
":",
"if",
"self",
".",
"_layers",
"is",
"None",
":",
"self",
".",
"__init",
"(",
")",
"self",
".",
"_getLayers",
"(",
")",
"return",
"self",
".",
"_layers"
] |
gets the layers for the feature service
|
[
"gets",
"the",
"layers",
"for",
"the",
"feature",
"service"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/services.py#L264-L269
|
13,152
|
Esri/ArcREST
|
src/arcrest/ags/services.py
|
FeatureService._getLayers
|
def _getLayers(self):
""" gets layers for the featuer service """
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(
layer.FeatureLayer(url=self._url + "/%s" % l['id'],
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url)
)
|
python
|
def _getLayers(self):
""" gets layers for the featuer service """
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(
layer.FeatureLayer(url=self._url + "/%s" % l['id'],
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url)
)
|
[
"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",
"(",
"layer",
".",
"FeatureLayer",
"(",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/%s\"",
"%",
"l",
"[",
"'id'",
"]",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
")",
")"
] |
gets layers for the featuer service
|
[
"gets",
"layers",
"for",
"the",
"featuer",
"service"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/services.py#L271-L287
|
13,153
|
Esri/ArcREST
|
src/arcrest/ags/services.py
|
FeatureService.query
|
def query(self,
layerDefsFilter=None,
geometryFilter=None,
timeFilter=None,
returnGeometry=True,
returnIdsOnly=False,
returnCountOnly=False,
returnZ=False,
returnM=False,
outSR=None
):
"""
The Query operation is performed on a feature service resource
"""
qurl = self._url + "/query"
params = {"f": "json",
"returnGeometry": returnGeometry,
"returnIdsOnly": returnIdsOnly,
"returnCountOnly": returnCountOnly,
"returnZ": returnZ,
"returnM" : returnM}
if not layerDefsFilter is None and \
isinstance(layerDefsFilter, LayerDefinitionFilter):
params['layerDefs'] = layerDefsFilter.filter
if not geometryFilter is None and \
isinstance(geometryFilter, GeometryFilter):
gf = geometryFilter.filter
params['geometryType'] = gf['geometryType']
params['spatialRel'] = gf['spatialRel']
params['geometry'] = gf['geometry']
params['inSR'] = gf['inSR']
if not outSR is None and \
isinstance(outSR, SpatialReference):
params['outSR'] = outSR.asDictionary
if not timeFilter is None and \
isinstance(timeFilter, TimeFilter):
params['time'] = timeFilter.filter
res = self._post(url=qurl,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
if returnIdsOnly == False and returnCountOnly == False:
if isinstance(res, str):
jd = json.loads(res)
return [FeatureSet.fromJSON(json.dumps(lyr)) for lyr in jd['layers']]
elif isinstance(res, dict):
return [FeatureSet.fromJSON(json.dumps(lyr)) for lyr in res['layers']]
else:
return res
return res
|
python
|
def query(self,
layerDefsFilter=None,
geometryFilter=None,
timeFilter=None,
returnGeometry=True,
returnIdsOnly=False,
returnCountOnly=False,
returnZ=False,
returnM=False,
outSR=None
):
"""
The Query operation is performed on a feature service resource
"""
qurl = self._url + "/query"
params = {"f": "json",
"returnGeometry": returnGeometry,
"returnIdsOnly": returnIdsOnly,
"returnCountOnly": returnCountOnly,
"returnZ": returnZ,
"returnM" : returnM}
if not layerDefsFilter is None and \
isinstance(layerDefsFilter, LayerDefinitionFilter):
params['layerDefs'] = layerDefsFilter.filter
if not geometryFilter is None and \
isinstance(geometryFilter, GeometryFilter):
gf = geometryFilter.filter
params['geometryType'] = gf['geometryType']
params['spatialRel'] = gf['spatialRel']
params['geometry'] = gf['geometry']
params['inSR'] = gf['inSR']
if not outSR is None and \
isinstance(outSR, SpatialReference):
params['outSR'] = outSR.asDictionary
if not timeFilter is None and \
isinstance(timeFilter, TimeFilter):
params['time'] = timeFilter.filter
res = self._post(url=qurl,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
if returnIdsOnly == False and returnCountOnly == False:
if isinstance(res, str):
jd = json.loads(res)
return [FeatureSet.fromJSON(json.dumps(lyr)) for lyr in jd['layers']]
elif isinstance(res, dict):
return [FeatureSet.fromJSON(json.dumps(lyr)) for lyr in res['layers']]
else:
return res
return res
|
[
"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",
",",
"\"returnIdsOnly\"",
":",
"returnIdsOnly",
",",
"\"returnCountOnly\"",
":",
"returnCountOnly",
",",
"\"returnZ\"",
":",
"returnZ",
",",
"\"returnM\"",
":",
"returnM",
"}",
"if",
"not",
"layerDefsFilter",
"is",
"None",
"and",
"isinstance",
"(",
"layerDefsFilter",
",",
"LayerDefinitionFilter",
")",
":",
"params",
"[",
"'layerDefs'",
"]",
"=",
"layerDefsFilter",
".",
"filter",
"if",
"not",
"geometryFilter",
"is",
"None",
"and",
"isinstance",
"(",
"geometryFilter",
",",
"GeometryFilter",
")",
":",
"gf",
"=",
"geometryFilter",
".",
"filter",
"params",
"[",
"'geometryType'",
"]",
"=",
"gf",
"[",
"'geometryType'",
"]",
"params",
"[",
"'spatialRel'",
"]",
"=",
"gf",
"[",
"'spatialRel'",
"]",
"params",
"[",
"'geometry'",
"]",
"=",
"gf",
"[",
"'geometry'",
"]",
"params",
"[",
"'inSR'",
"]",
"=",
"gf",
"[",
"'inSR'",
"]",
"if",
"not",
"outSR",
"is",
"None",
"and",
"isinstance",
"(",
"outSR",
",",
"SpatialReference",
")",
":",
"params",
"[",
"'outSR'",
"]",
"=",
"outSR",
".",
"asDictionary",
"if",
"not",
"timeFilter",
"is",
"None",
"and",
"isinstance",
"(",
"timeFilter",
",",
"TimeFilter",
")",
":",
"params",
"[",
"'time'",
"]",
"=",
"timeFilter",
".",
"filter",
"res",
"=",
"self",
".",
"_post",
"(",
"url",
"=",
"qurl",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")",
"if",
"returnIdsOnly",
"==",
"False",
"and",
"returnCountOnly",
"==",
"False",
":",
"if",
"isinstance",
"(",
"res",
",",
"str",
")",
":",
"jd",
"=",
"json",
".",
"loads",
"(",
"res",
")",
"return",
"[",
"FeatureSet",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"lyr",
")",
")",
"for",
"lyr",
"in",
"jd",
"[",
"'layers'",
"]",
"]",
"elif",
"isinstance",
"(",
"res",
",",
"dict",
")",
":",
"return",
"[",
"FeatureSet",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"lyr",
")",
")",
"for",
"lyr",
"in",
"res",
"[",
"'layers'",
"]",
"]",
"else",
":",
"return",
"res",
"return",
"res"
] |
The Query operation is performed on a feature service resource
|
[
"The",
"Query",
"operation",
"is",
"performed",
"on",
"a",
"feature",
"service",
"resource"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/services.py#L346-L397
|
13,154
|
Esri/ArcREST
|
src/arcrest/common/spatial.py
|
create_feature_layer
|
def create_feature_layer(ds, sql, name="layer"):
""" creates a feature layer object """
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]
|
python
|
def create_feature_layer(ds, sql, name="layer"):
""" creates a feature layer object """
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]
|
[
"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
|
[
"creates",
"a",
"feature",
"layer",
"object"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/spatial.py#L16-L23
|
13,155
|
Esri/ArcREST
|
src/arcrest/common/spatial.py
|
featureclass_to_json
|
def featureclass_to_json(fc):
"""converts a feature class to JSON"""
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
|
python
|
def featureclass_to_json(fc):
"""converts a feature class to JSON"""
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
|
[
"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
|
[
"converts",
"a",
"feature",
"class",
"to",
"JSON"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/spatial.py#L25-L33
|
13,156
|
Esri/ArcREST
|
src/arcrest/common/spatial.py
|
get_attachment_data
|
def get_attachment_data(attachmentTable, sql,
nameField="ATT_NAME", blobField="DATA",
contentTypeField="CONTENT_TYPE",
rel_object_field="REL_OBJECTID"):
""" gets all the data to pass to a feature service """
if arcpyFound == False:
raise Exception("ArcPy is required to use this function")
ret_rows = []
with arcpy.da.SearchCursor(attachmentTable,
[nameField,
blobField,
contentTypeField,
rel_object_field],
where_clause=sql) as rows:
for row in rows:
temp_f = os.environ['temp'] + os.sep + row[0]
writer = open(temp_f,'wb')
writer.write(row[1])
writer.flush()
writer.close()
del writer
ret_rows.append({
"name" : row[0],
"blob" : temp_f,
"content" : row[2],
"rel_oid" : row[3]
})
del row
return ret_rows
|
python
|
def get_attachment_data(attachmentTable, sql,
nameField="ATT_NAME", blobField="DATA",
contentTypeField="CONTENT_TYPE",
rel_object_field="REL_OBJECTID"):
""" gets all the data to pass to a feature service """
if arcpyFound == False:
raise Exception("ArcPy is required to use this function")
ret_rows = []
with arcpy.da.SearchCursor(attachmentTable,
[nameField,
blobField,
contentTypeField,
rel_object_field],
where_clause=sql) as rows:
for row in rows:
temp_f = os.environ['temp'] + os.sep + row[0]
writer = open(temp_f,'wb')
writer.write(row[1])
writer.flush()
writer.close()
del writer
ret_rows.append({
"name" : row[0],
"blob" : temp_f,
"content" : row[2],
"rel_oid" : row[3]
})
del row
return ret_rows
|
[
"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",
",",
"[",
"nameField",
",",
"blobField",
",",
"contentTypeField",
",",
"rel_object_field",
"]",
",",
"where_clause",
"=",
"sql",
")",
"as",
"rows",
":",
"for",
"row",
"in",
"rows",
":",
"temp_f",
"=",
"os",
".",
"environ",
"[",
"'temp'",
"]",
"+",
"os",
".",
"sep",
"+",
"row",
"[",
"0",
"]",
"writer",
"=",
"open",
"(",
"temp_f",
",",
"'wb'",
")",
"writer",
".",
"write",
"(",
"row",
"[",
"1",
"]",
")",
"writer",
".",
"flush",
"(",
")",
"writer",
".",
"close",
"(",
")",
"del",
"writer",
"ret_rows",
".",
"append",
"(",
"{",
"\"name\"",
":",
"row",
"[",
"0",
"]",
",",
"\"blob\"",
":",
"temp_f",
",",
"\"content\"",
":",
"row",
"[",
"2",
"]",
",",
"\"rel_oid\"",
":",
"row",
"[",
"3",
"]",
"}",
")",
"del",
"row",
"return",
"ret_rows"
] |
gets all the data to pass to a feature service
|
[
"gets",
"all",
"the",
"data",
"to",
"pass",
"to",
"a",
"feature",
"service"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/spatial.py#L54-L82
|
13,157
|
Esri/ArcREST
|
src/arcrest/common/spatial.py
|
get_records_with_attachments
|
def get_records_with_attachments(attachment_table, rel_object_field="REL_OBJECTID"):
"""returns a list of ObjectIDs for rows in the attachment table"""
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 OIDs:
OIDs.append("%s" % str(row[0]))
del row
del rows
return OIDs
|
python
|
def get_records_with_attachments(attachment_table, rel_object_field="REL_OBJECTID"):
"""returns a list of ObjectIDs for rows in the attachment table"""
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 OIDs:
OIDs.append("%s" % str(row[0]))
del row
del rows
return OIDs
|
[
"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",
"OIDs",
":",
"OIDs",
".",
"append",
"(",
"\"%s\"",
"%",
"str",
"(",
"row",
"[",
"0",
"]",
")",
")",
"del",
"row",
"del",
"rows",
"return",
"OIDs"
] |
returns a list of ObjectIDs for rows in the attachment table
|
[
"returns",
"a",
"list",
"of",
"ObjectIDs",
"for",
"rows",
"in",
"the",
"attachment",
"table"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/spatial.py#L84-L96
|
13,158
|
Esri/ArcREST
|
src/arcrest/common/spatial.py
|
get_OID_field
|
def get_OID_field(fs):
"""returns a featureset's object id field"""
if arcpyFound == False:
raise Exception("ArcPy is required to use this function")
desc = arcpy.Describe(fs)
if desc.hasOID:
return desc.OIDFieldName
return None
|
python
|
def get_OID_field(fs):
"""returns a featureset's object id field"""
if arcpyFound == False:
raise Exception("ArcPy is required to use this function")
desc = arcpy.Describe(fs)
if desc.hasOID:
return desc.OIDFieldName
return None
|
[
"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
|
[
"returns",
"a",
"featureset",
"s",
"object",
"id",
"field"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/spatial.py#L98-L105
|
13,159
|
Esri/ArcREST
|
src/arcrest/common/spatial.py
|
merge_feature_class
|
def merge_feature_class(merges, out_fc, cleanUp=True):
""" merges featureclass into a single feature class """
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'):
return arcpy.CopyFeatures_management(merges[0], out_fc)[0]
else:
return arcpy.CopyRows_management(merges[0], out_fc)[0]
else:
return arcpy.Merge_management(inputs=merges,
output=out_fc)[0]
else:
if len(merges) == 0:
return None
elif len(merges) == 1:
desc = arcpy.Describe(merges[0])
if hasattr(desc, 'shapeFieldName'):
merged = arcpy.CopyFeatures_management(merges[0], out_fc)[0]
else:
merged = arcpy.CopyRows_management(merges[0], out_fc)[0]
else:
merged = arcpy.Merge_management(inputs=merges,
output=out_fc)[0]
for m in merges:
arcpy.Delete_management(m)
del m
return merged
|
python
|
def merge_feature_class(merges, out_fc, cleanUp=True):
""" merges featureclass into a single feature class """
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'):
return arcpy.CopyFeatures_management(merges[0], out_fc)[0]
else:
return arcpy.CopyRows_management(merges[0], out_fc)[0]
else:
return arcpy.Merge_management(inputs=merges,
output=out_fc)[0]
else:
if len(merges) == 0:
return None
elif len(merges) == 1:
desc = arcpy.Describe(merges[0])
if hasattr(desc, 'shapeFieldName'):
merged = arcpy.CopyFeatures_management(merges[0], out_fc)[0]
else:
merged = arcpy.CopyRows_management(merges[0], out_fc)[0]
else:
merged = arcpy.Merge_management(inputs=merges,
output=out_fc)[0]
for m in merges:
arcpy.Delete_management(m)
del m
return merged
|
[
"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'",
")",
":",
"return",
"arcpy",
".",
"CopyFeatures_management",
"(",
"merges",
"[",
"0",
"]",
",",
"out_fc",
")",
"[",
"0",
"]",
"else",
":",
"return",
"arcpy",
".",
"CopyRows_management",
"(",
"merges",
"[",
"0",
"]",
",",
"out_fc",
")",
"[",
"0",
"]",
"else",
":",
"return",
"arcpy",
".",
"Merge_management",
"(",
"inputs",
"=",
"merges",
",",
"output",
"=",
"out_fc",
")",
"[",
"0",
"]",
"else",
":",
"if",
"len",
"(",
"merges",
")",
"==",
"0",
":",
"return",
"None",
"elif",
"len",
"(",
"merges",
")",
"==",
"1",
":",
"desc",
"=",
"arcpy",
".",
"Describe",
"(",
"merges",
"[",
"0",
"]",
")",
"if",
"hasattr",
"(",
"desc",
",",
"'shapeFieldName'",
")",
":",
"merged",
"=",
"arcpy",
".",
"CopyFeatures_management",
"(",
"merges",
"[",
"0",
"]",
",",
"out_fc",
")",
"[",
"0",
"]",
"else",
":",
"merged",
"=",
"arcpy",
".",
"CopyRows_management",
"(",
"merges",
"[",
"0",
"]",
",",
"out_fc",
")",
"[",
"0",
"]",
"else",
":",
"merged",
"=",
"arcpy",
".",
"Merge_management",
"(",
"inputs",
"=",
"merges",
",",
"output",
"=",
"out_fc",
")",
"[",
"0",
"]",
"for",
"m",
"in",
"merges",
":",
"arcpy",
".",
"Delete_management",
"(",
"m",
")",
"del",
"m",
"return",
"merged"
] |
merges featureclass into a single feature class
|
[
"merges",
"featureclass",
"into",
"a",
"single",
"feature",
"class"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/spatial.py#L107-L138
|
13,160
|
Esri/ArcREST
|
src/arcrest/common/spatial.py
|
insert_rows
|
def insert_rows(fc,
features,
fields,
includeOIDField=False,
oidField=None):
""" inserts rows based on a list features object """
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:
fields.append("SHAPE@")
workspace = os.path.dirname(fc)
with arcpy.da.Editor(workspace) as edit:
date_fields = getDateFields(fc)
icur = arcpy.da.InsertCursor(fc, fields)
for feat in features:
row = [""] * len(fields)
drow = feat.asRow[0]
dfields = feat.fields
for field in fields:
if field in dfields or \
(includeOIDField and field == "FSL_OID"):
if field in date_fields:
row[fields.index(field)] = toDateTime(drow[dfields.index(field)])
elif field == "FSL_OID":
row[fields.index("FSL_OID")] = drow[dfields.index(oidField)]
else:
row[fields.index(field)] = drow[dfields.index(field)]
del field
row[fields.index("SHAPE@")] = feat.geometry
icur.insertRow(row)
del row
del drow
del dfields
del feat
del features
icur = None
del icur
del fields
return fc
else:
return fc
|
python
|
def insert_rows(fc,
features,
fields,
includeOIDField=False,
oidField=None):
""" inserts rows based on a list features object """
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:
fields.append("SHAPE@")
workspace = os.path.dirname(fc)
with arcpy.da.Editor(workspace) as edit:
date_fields = getDateFields(fc)
icur = arcpy.da.InsertCursor(fc, fields)
for feat in features:
row = [""] * len(fields)
drow = feat.asRow[0]
dfields = feat.fields
for field in fields:
if field in dfields or \
(includeOIDField and field == "FSL_OID"):
if field in date_fields:
row[fields.index(field)] = toDateTime(drow[dfields.index(field)])
elif field == "FSL_OID":
row[fields.index("FSL_OID")] = drow[dfields.index(oidField)]
else:
row[fields.index(field)] = drow[dfields.index(field)]
del field
row[fields.index("SHAPE@")] = feat.geometry
icur.insertRow(row)
del row
del drow
del dfields
del feat
del features
icur = None
del icur
del fields
return fc
else:
return fc
|
[
"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",
":",
"fields",
".",
"append",
"(",
"\"SHAPE@\"",
")",
"workspace",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"fc",
")",
"with",
"arcpy",
".",
"da",
".",
"Editor",
"(",
"workspace",
")",
"as",
"edit",
":",
"date_fields",
"=",
"getDateFields",
"(",
"fc",
")",
"icur",
"=",
"arcpy",
".",
"da",
".",
"InsertCursor",
"(",
"fc",
",",
"fields",
")",
"for",
"feat",
"in",
"features",
":",
"row",
"=",
"[",
"\"\"",
"]",
"*",
"len",
"(",
"fields",
")",
"drow",
"=",
"feat",
".",
"asRow",
"[",
"0",
"]",
"dfields",
"=",
"feat",
".",
"fields",
"for",
"field",
"in",
"fields",
":",
"if",
"field",
"in",
"dfields",
"or",
"(",
"includeOIDField",
"and",
"field",
"==",
"\"FSL_OID\"",
")",
":",
"if",
"field",
"in",
"date_fields",
":",
"row",
"[",
"fields",
".",
"index",
"(",
"field",
")",
"]",
"=",
"toDateTime",
"(",
"drow",
"[",
"dfields",
".",
"index",
"(",
"field",
")",
"]",
")",
"elif",
"field",
"==",
"\"FSL_OID\"",
":",
"row",
"[",
"fields",
".",
"index",
"(",
"\"FSL_OID\"",
")",
"]",
"=",
"drow",
"[",
"dfields",
".",
"index",
"(",
"oidField",
")",
"]",
"else",
":",
"row",
"[",
"fields",
".",
"index",
"(",
"field",
")",
"]",
"=",
"drow",
"[",
"dfields",
".",
"index",
"(",
"field",
")",
"]",
"del",
"field",
"row",
"[",
"fields",
".",
"index",
"(",
"\"SHAPE@\"",
")",
"]",
"=",
"feat",
".",
"geometry",
"icur",
".",
"insertRow",
"(",
"row",
")",
"del",
"row",
"del",
"drow",
"del",
"dfields",
"del",
"feat",
"del",
"features",
"icur",
"=",
"None",
"del",
"icur",
"del",
"fields",
"return",
"fc",
"else",
":",
"return",
"fc"
] |
inserts rows based on a list features object
|
[
"inserts",
"rows",
"based",
"on",
"a",
"list",
"features",
"object"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/spatial.py#L164-L208
|
13,161
|
Esri/ArcREST
|
src/arcrest/common/spatial.py
|
create_feature_class
|
def create_feature_class(out_path,
out_name,
geom_type,
wkid,
fields,
objectIdField):
""" creates a feature class in a given gdb or folder """
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_name,
geometry_type=lookUpGeometry(geom_type),
spatial_reference=arcpy.SpatialReference(wkid))[0]
for field in fields:
if field['name'] != objectIdField:
field_names.append(field['name'])
arcpy.AddField_management(out_path + os.sep + out_name,
field['name'],
lookUpFieldType(field['type']))
return fc, field_names
|
python
|
def create_feature_class(out_path,
out_name,
geom_type,
wkid,
fields,
objectIdField):
""" creates a feature class in a given gdb or folder """
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_name,
geometry_type=lookUpGeometry(geom_type),
spatial_reference=arcpy.SpatialReference(wkid))[0]
for field in fields:
if field['name'] != objectIdField:
field_names.append(field['name'])
arcpy.AddField_management(out_path + os.sep + out_name,
field['name'],
lookUpFieldType(field['type']))
return fc, field_names
|
[
"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_name",
",",
"geometry_type",
"=",
"lookUpGeometry",
"(",
"geom_type",
")",
",",
"spatial_reference",
"=",
"arcpy",
".",
"SpatialReference",
"(",
"wkid",
")",
")",
"[",
"0",
"]",
"for",
"field",
"in",
"fields",
":",
"if",
"field",
"[",
"'name'",
"]",
"!=",
"objectIdField",
":",
"field_names",
".",
"append",
"(",
"field",
"[",
"'name'",
"]",
")",
"arcpy",
".",
"AddField_management",
"(",
"out_path",
"+",
"os",
".",
"sep",
"+",
"out_name",
",",
"field",
"[",
"'name'",
"]",
",",
"lookUpFieldType",
"(",
"field",
"[",
"'type'",
"]",
")",
")",
"return",
"fc",
",",
"field_names"
] |
creates a feature class in a given gdb or folder
|
[
"creates",
"a",
"feature",
"class",
"in",
"a",
"given",
"gdb",
"or",
"folder"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/spatial.py#L210-L231
|
13,162
|
Esri/ArcREST
|
ArcGIS Desktop Installer/Install_ArcRest/Tools/Scripts/install_arcrest.py
|
download_arcrest
|
def download_arcrest():
"""downloads arcrest to disk"""
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, "temp34asdf3d")
arcrest_zip = os.path.join(scratch_folder, arcrest_name )
arcresthelper_zip = os.path.join(scratch_folder, arcresthelper_name)
if sys.version_info.major == 3:
import urllib.request
urllib.request.urlretrieve(url, file_name)
else:
import urllib
urllib.urlretrieve(url, file_name)
if os.path.isdir(scratch_folder):
shutil.rmtree(scratch_folder)
os.makedirs(scratch_folder)
zip_obj = zipfile.ZipFile(file_name, 'r')
zip_obj.extractall(scratch_folder)
zip_obj.close()
del zip_obj
zip_obj = zipfile.ZipFile(arcrest_zip, 'w')
zipws(path=os.path.join(scratch_folder, "arcrest-master", "src", "arcrest"), zip=zip_obj, keep=True)
zip_obj.close()
del zip_obj
zip_obj = zipfile.ZipFile(arcresthelper_zip, 'w')
zipws(path=os.path.join(scratch_folder, "arcrest-master", "src", "arcresthelper"), zip=zip_obj, keep=True)
zip_obj.close()
del zip_obj
shutil.rmtree(os.path.join(scratch_folder, "arcrest-master"))
return arcrest_zip, arcresthelper_zip
|
python
|
def download_arcrest():
"""downloads arcrest to disk"""
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, "temp34asdf3d")
arcrest_zip = os.path.join(scratch_folder, arcrest_name )
arcresthelper_zip = os.path.join(scratch_folder, arcresthelper_name)
if sys.version_info.major == 3:
import urllib.request
urllib.request.urlretrieve(url, file_name)
else:
import urllib
urllib.urlretrieve(url, file_name)
if os.path.isdir(scratch_folder):
shutil.rmtree(scratch_folder)
os.makedirs(scratch_folder)
zip_obj = zipfile.ZipFile(file_name, 'r')
zip_obj.extractall(scratch_folder)
zip_obj.close()
del zip_obj
zip_obj = zipfile.ZipFile(arcrest_zip, 'w')
zipws(path=os.path.join(scratch_folder, "arcrest-master", "src", "arcrest"), zip=zip_obj, keep=True)
zip_obj.close()
del zip_obj
zip_obj = zipfile.ZipFile(arcresthelper_zip, 'w')
zipws(path=os.path.join(scratch_folder, "arcrest-master", "src", "arcresthelper"), zip=zip_obj, keep=True)
zip_obj.close()
del zip_obj
shutil.rmtree(os.path.join(scratch_folder, "arcrest-master"))
return arcrest_zip, arcresthelper_zip
|
[
"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",
",",
"\"temp34asdf3d\"",
")",
"arcrest_zip",
"=",
"os",
".",
"path",
".",
"join",
"(",
"scratch_folder",
",",
"arcrest_name",
")",
"arcresthelper_zip",
"=",
"os",
".",
"path",
".",
"join",
"(",
"scratch_folder",
",",
"arcresthelper_name",
")",
"if",
"sys",
".",
"version_info",
".",
"major",
"==",
"3",
":",
"import",
"urllib",
".",
"request",
"urllib",
".",
"request",
".",
"urlretrieve",
"(",
"url",
",",
"file_name",
")",
"else",
":",
"import",
"urllib",
"urllib",
".",
"urlretrieve",
"(",
"url",
",",
"file_name",
")",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"scratch_folder",
")",
":",
"shutil",
".",
"rmtree",
"(",
"scratch_folder",
")",
"os",
".",
"makedirs",
"(",
"scratch_folder",
")",
"zip_obj",
"=",
"zipfile",
".",
"ZipFile",
"(",
"file_name",
",",
"'r'",
")",
"zip_obj",
".",
"extractall",
"(",
"scratch_folder",
")",
"zip_obj",
".",
"close",
"(",
")",
"del",
"zip_obj",
"zip_obj",
"=",
"zipfile",
".",
"ZipFile",
"(",
"arcrest_zip",
",",
"'w'",
")",
"zipws",
"(",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"scratch_folder",
",",
"\"arcrest-master\"",
",",
"\"src\"",
",",
"\"arcrest\"",
")",
",",
"zip",
"=",
"zip_obj",
",",
"keep",
"=",
"True",
")",
"zip_obj",
".",
"close",
"(",
")",
"del",
"zip_obj",
"zip_obj",
"=",
"zipfile",
".",
"ZipFile",
"(",
"arcresthelper_zip",
",",
"'w'",
")",
"zipws",
"(",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"scratch_folder",
",",
"\"arcrest-master\"",
",",
"\"src\"",
",",
"\"arcresthelper\"",
")",
",",
"zip",
"=",
"zip_obj",
",",
"keep",
"=",
"True",
")",
"zip_obj",
".",
"close",
"(",
")",
"del",
"zip_obj",
"shutil",
".",
"rmtree",
"(",
"os",
".",
"path",
".",
"join",
"(",
"scratch_folder",
",",
"\"arcrest-master\"",
")",
")",
"return",
"arcrest_zip",
",",
"arcresthelper_zip"
] |
downloads arcrest to disk
|
[
"downloads",
"arcrest",
"to",
"disk"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/ArcGIS Desktop Installer/Install_ArcRest/Tools/Scripts/install_arcrest.py#L36-L68
|
13,163
|
Esri/ArcREST
|
src/arcrest/security/security.py
|
NTLMSecurityHandler.handler
|
def handler(self):
"""gets the security handler for the class"""
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
else:
raise Exception("Missing Ntlm python package.")
|
python
|
def handler(self):
"""gets the security handler for the class"""
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
else:
raise Exception("Missing Ntlm python package.")
|
[
"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",
"else",
":",
"raise",
"Exception",
"(",
"\"Missing Ntlm python package.\"",
")"
] |
gets the security handler for the class
|
[
"gets",
"the",
"security",
"handler",
"for",
"the",
"class"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/security/security.py#L343-L352
|
13,164
|
Esri/ArcREST
|
src/arcrest/security/security.py
|
PortalServerSecurityHandler.token
|
def token(self):
"""gets the AGS server token"""
return self._portalTokenHandler.servertoken(serverURL=self._serverUrl,
referer=self._referer)
|
python
|
def token(self):
"""gets the AGS server token"""
return self._portalTokenHandler.servertoken(serverURL=self._serverUrl,
referer=self._referer)
|
[
"def",
"token",
"(",
"self",
")",
":",
"return",
"self",
".",
"_portalTokenHandler",
".",
"servertoken",
"(",
"serverURL",
"=",
"self",
".",
"_serverUrl",
",",
"referer",
"=",
"self",
".",
"_referer",
")"
] |
gets the AGS server token
|
[
"gets",
"the",
"AGS",
"server",
"token"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/security/security.py#L598-L601
|
13,165
|
Esri/ArcREST
|
src/arcrest/security/security.py
|
OAuthSecurityHandler.token
|
def token(self):
""" obtains a token from the site """
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
|
python
|
def token(self):
""" obtains a token from the site """
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
|
[
"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
|
[
"obtains",
"a",
"token",
"from",
"the",
"site"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/security/security.py#L790-L797
|
13,166
|
Esri/ArcREST
|
src/arcrest/security/security.py
|
OAuthSecurityHandler._generateForOAuthSecurity
|
def _generateForOAuthSecurity(self, client_id,
secret_id, token_url=None):
""" generates a token based on the OAuth security model """
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 = self._post(url=token_url,
param_dict=params,
securityHandler=None,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url)
if 'access_token' in token:
self._token = token['access_token']
self._expires_in = token['expires_in']
self._token_created_on = datetime.datetime.now()
self._token_expires_on = self._token_created_on + datetime.timedelta(seconds=int(token['expires_in']))
self._valid = True
self._message = "Token Generated"
else:
self._token = None
self._expires_in = None
self._token_created_on = None
self._token_expires_on = None
self._valid = False
self._message = token
|
python
|
def _generateForOAuthSecurity(self, client_id,
secret_id, token_url=None):
""" generates a token based on the OAuth security model """
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 = self._post(url=token_url,
param_dict=params,
securityHandler=None,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url)
if 'access_token' in token:
self._token = token['access_token']
self._expires_in = token['expires_in']
self._token_created_on = datetime.datetime.now()
self._token_expires_on = self._token_created_on + datetime.timedelta(seconds=int(token['expires_in']))
self._valid = True
self._message = "Token Generated"
else:
self._token = None
self._expires_in = None
self._token_created_on = None
self._token_expires_on = None
self._valid = False
self._message = token
|
[
"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",
"=",
"self",
".",
"_post",
"(",
"url",
"=",
"token_url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"None",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
")",
"if",
"'access_token'",
"in",
"token",
":",
"self",
".",
"_token",
"=",
"token",
"[",
"'access_token'",
"]",
"self",
".",
"_expires_in",
"=",
"token",
"[",
"'expires_in'",
"]",
"self",
".",
"_token_created_on",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"self",
".",
"_token_expires_on",
"=",
"self",
".",
"_token_created_on",
"+",
"datetime",
".",
"timedelta",
"(",
"seconds",
"=",
"int",
"(",
"token",
"[",
"'expires_in'",
"]",
")",
")",
"self",
".",
"_valid",
"=",
"True",
"self",
".",
"_message",
"=",
"\"Token Generated\"",
"else",
":",
"self",
".",
"_token",
"=",
"None",
"self",
".",
"_expires_in",
"=",
"None",
"self",
".",
"_token_created_on",
"=",
"None",
"self",
".",
"_token_expires_on",
"=",
"None",
"self",
".",
"_valid",
"=",
"False",
"self",
".",
"_message",
"=",
"token"
] |
generates a token based on the OAuth security model
|
[
"generates",
"a",
"token",
"based",
"on",
"the",
"OAuth",
"security",
"model"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/security/security.py#L847-L877
|
13,167
|
Esri/ArcREST
|
src/arcrest/security/security.py
|
ArcGISTokenSecurityHandler.referer_url
|
def referer_url(self, value):
"""sets the referer url"""
if self._referer_url != value:
self._token = None
self._referer_url = value
|
python
|
def referer_url(self, value):
"""sets the referer url"""
if self._referer_url != value:
self._token = None
self._referer_url = value
|
[
"def",
"referer_url",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"_referer_url",
"!=",
"value",
":",
"self",
".",
"_token",
"=",
"None",
"self",
".",
"_referer_url",
"=",
"value"
] |
sets the referer url
|
[
"sets",
"the",
"referer",
"url"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/security/security.py#L1026-L1030
|
13,168
|
Esri/ArcREST
|
src/arcrest/security/security.py
|
AGOLTokenSecurityHandler.__getRefererUrl
|
def __getRefererUrl(self, url=None):
"""
gets the referer url for the token handler
"""
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.com"#"http://%s.%s" % (val['urlKey'], val['customBaseUrl'])
self._token = None
return self._referer_url
|
python
|
def __getRefererUrl(self, url=None):
"""
gets the referer url for the token handler
"""
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.com"#"http://%s.%s" % (val['urlKey'], val['customBaseUrl'])
self._token = None
return self._referer_url
|
[
"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.com\"",
"#\"http://%s.%s\" % (val['urlKey'], val['customBaseUrl'])",
"self",
".",
"_token",
"=",
"None",
"return",
"self",
".",
"_referer_url"
] |
gets the referer url for the token handler
|
[
"gets",
"the",
"referer",
"url",
"for",
"the",
"token",
"handler"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/security/security.py#L1236-L1251
|
13,169
|
Esri/ArcREST
|
src/arcrest/security/security.py
|
PortalTokenSecurityHandler.servertoken
|
def servertoken(self,serverURL,referer):
""" returns the server token for the server """
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=serverURL,
token=self.token,
tokenUrl=self._token_url,
referer=referer)
if 'error' in result:
self._valid = False
self._message = result
else:
self._valid = True
self._message = "Server Token Generated"
return self._server_token
|
python
|
def servertoken(self,serverURL,referer):
""" returns the server token for the server """
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=serverURL,
token=self.token,
tokenUrl=self._token_url,
referer=referer)
if 'error' in result:
self._valid = False
self._message = result
else:
self._valid = True
self._message = "Server Token Generated"
return self._server_token
|
[
"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",
"=",
"serverURL",
",",
"token",
"=",
"self",
".",
"token",
",",
"tokenUrl",
"=",
"self",
".",
"_token_url",
",",
"referer",
"=",
"referer",
")",
"if",
"'error'",
"in",
"result",
":",
"self",
".",
"_valid",
"=",
"False",
"self",
".",
"_message",
"=",
"result",
"else",
":",
"self",
".",
"_valid",
"=",
"True",
"self",
".",
"_message",
"=",
"\"Server Token Generated\"",
"return",
"self",
".",
"_server_token"
] |
returns the server token for the server
|
[
"returns",
"the",
"server",
"token",
"for",
"the",
"server"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/security/security.py#L1856-L1872
|
13,170
|
Esri/ArcREST
|
src/arcrest/manageags/_machines.py
|
Machine.exportCertificate
|
def exportCertificate(self, certificate, folder):
"""gets the SSL Certificates for a given machine"""
url = self._url + "/sslcertificates/%s/export" % certificate
params = {
"f" : "json",
}
return self._get(url=url,
param_dict=params,
out_folder=folder)
|
python
|
def exportCertificate(self, certificate, folder):
"""gets the SSL Certificates for a given machine"""
url = self._url + "/sslcertificates/%s/export" % certificate
params = {
"f" : "json",
}
return self._get(url=url,
param_dict=params,
out_folder=folder)
|
[
"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
|
[
"gets",
"the",
"SSL",
"Certificates",
"for",
"a",
"given",
"machine"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/_machines.py#L277-L285
|
13,171
|
Esri/ArcREST
|
src/arcrest/manageorg/administration.py
|
Administration.currentVersion
|
def currentVersion(self):
""" returns the current version of the site """
if self._currentVersion is None:
self.__init(self._url)
return self._currentVersion
|
python
|
def currentVersion(self):
""" returns the current version of the site """
if self._currentVersion is None:
self.__init(self._url)
return self._currentVersion
|
[
"def",
"currentVersion",
"(",
"self",
")",
":",
"if",
"self",
".",
"_currentVersion",
"is",
"None",
":",
"self",
".",
"__init",
"(",
"self",
".",
"_url",
")",
"return",
"self",
".",
"_currentVersion"
] |
returns the current version of the site
|
[
"returns",
"the",
"current",
"version",
"of",
"the",
"site"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/administration.py#L118-L122
|
13,172
|
Esri/ArcREST
|
src/arcrest/manageorg/administration.py
|
Administration.portals
|
def portals(self):
"""returns the Portals class that provides administration access
into a given organization"""
url = "%s/portals" % self.root
return _portals.Portals(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
python
|
def portals(self):
"""returns the Portals class that provides administration access
into a given organization"""
url = "%s/portals" % self.root
return _portals.Portals(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
[
"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
|
[
"returns",
"the",
"Portals",
"class",
"that",
"provides",
"administration",
"access",
"into",
"a",
"given",
"organization"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/administration.py#L125-L132
|
13,173
|
Esri/ArcREST
|
src/arcrest/manageorg/administration.py
|
Administration.oauth2
|
def oauth2(self):
"""
returns the oauth2 class
"""
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)
|
python
|
def oauth2(self):
"""
returns the oauth2 class
"""
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)
|
[
"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
|
[
"returns",
"the",
"oauth2",
"class"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/administration.py#L135-L146
|
13,174
|
Esri/ArcREST
|
src/arcrest/manageorg/administration.py
|
Administration.community
|
def community(self):
"""The portal community root covers user and group resources and
operations.
"""
return _community.Community(url=self._url + "/community",
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
python
|
def community(self):
"""The portal community root covers user and group resources and
operations.
"""
return _community.Community(url=self._url + "/community",
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
[
"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.
|
[
"The",
"portal",
"community",
"root",
"covers",
"user",
"and",
"group",
"resources",
"and",
"operations",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/administration.py#L149-L156
|
13,175
|
Esri/ArcREST
|
src/arcrest/manageorg/administration.py
|
Administration.content
|
def content(self):
"""returns access into the site's content"""
return _content.Content(url=self._url + "/content",
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
python
|
def content(self):
"""returns access into the site's content"""
return _content.Content(url=self._url + "/content",
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
[
"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
|
[
"returns",
"access",
"into",
"the",
"site",
"s",
"content"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/administration.py#L159-L164
|
13,176
|
Esri/ArcREST
|
src/arcrest/manageorg/administration.py
|
Administration.search
|
def search(self,
q,
t=None,
focus=None,
bbox=None,
start=1,
num=10,
sortField=None,
sortOrder="asc",
useSecurity=True):
"""
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 delete
content. There can be a lag between the time that the content is
updated and the time when it's reflected in the search results.
The results of a search only contain items that the user has
permission to access.
Inputs:
q - The query string used to search
t - type of content to search for.
focus - another content filter. Ex: files
bbox - The bounding box for a spatial search defined as minx,
miny, maxx, or maxy. Search requires q, bbox, or both.
Spatial search is an overlaps/intersects function of the
query bbox and the extent of the document.
Documents that have no extent (e.g., mxds, 3dds, lyr)
will not be found when doing a bbox search.
Document extent is assumed to be in the WGS84 geographic
coordinate system.
start - The number of the first entry in the result set
response. The index number is 1-based.
The default value of start is 1 (that is, the first
search result).
The start parameter, along with the num parameter, can
be used to paginate the search results.
num - The maximum number of results to be included in the result
set response.
The default value is 10, and the maximum allowed value is
100.
The start parameter, along with the num parameter, can be
used to paginate the search results.
sortField - Field to sort by. You can also sort by multiple
fields (comma separated) for an item.
The allowed sort field names are title, created,
type, owner, modified, avgRating, numRatings,
numComments, and numViews.
sortOrder - Describes whether the results return in ascending or
descending order. Default is ascending.
Values: asc | desc
useSecurity - boolean value that determines if the security
handler object's token will be appended on the
search call. If the value is set to False, then
the search will be performed without
authentication. This means only items that have
been shared with everyone on AGOL or portal site
will be found. If it is set to True, then all
items the user has permission to see based on the
query passed will be returned.
Output:
returns a list of dictionary
"""
if self._url.endswith("/rest"):
url = self._url + "/search"
else:
url = self._url + "/rest/search"
params = {
"f" : "json",
"q" : q,
"sortOrder" : sortOrder,
"num" : num,
"start" : start,
'restrict' : useSecurity
}
if not focus is None:
params['focus'] = focus
if not t is None:
params['t'] = t
if useSecurity and \
self._securityHandler is not None and \
self._securityHandler.method == "token":
params["token"] = self._securityHandler.token
if sortField is not None:
params['sortField'] = sortField
if bbox is not None:
params['bbox'] = bbox
return self._get(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
python
|
def search(self,
q,
t=None,
focus=None,
bbox=None,
start=1,
num=10,
sortField=None,
sortOrder="asc",
useSecurity=True):
"""
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 delete
content. There can be a lag between the time that the content is
updated and the time when it's reflected in the search results.
The results of a search only contain items that the user has
permission to access.
Inputs:
q - The query string used to search
t - type of content to search for.
focus - another content filter. Ex: files
bbox - The bounding box for a spatial search defined as minx,
miny, maxx, or maxy. Search requires q, bbox, or both.
Spatial search is an overlaps/intersects function of the
query bbox and the extent of the document.
Documents that have no extent (e.g., mxds, 3dds, lyr)
will not be found when doing a bbox search.
Document extent is assumed to be in the WGS84 geographic
coordinate system.
start - The number of the first entry in the result set
response. The index number is 1-based.
The default value of start is 1 (that is, the first
search result).
The start parameter, along with the num parameter, can
be used to paginate the search results.
num - The maximum number of results to be included in the result
set response.
The default value is 10, and the maximum allowed value is
100.
The start parameter, along with the num parameter, can be
used to paginate the search results.
sortField - Field to sort by. You can also sort by multiple
fields (comma separated) for an item.
The allowed sort field names are title, created,
type, owner, modified, avgRating, numRatings,
numComments, and numViews.
sortOrder - Describes whether the results return in ascending or
descending order. Default is ascending.
Values: asc | desc
useSecurity - boolean value that determines if the security
handler object's token will be appended on the
search call. If the value is set to False, then
the search will be performed without
authentication. This means only items that have
been shared with everyone on AGOL or portal site
will be found. If it is set to True, then all
items the user has permission to see based on the
query passed will be returned.
Output:
returns a list of dictionary
"""
if self._url.endswith("/rest"):
url = self._url + "/search"
else:
url = self._url + "/rest/search"
params = {
"f" : "json",
"q" : q,
"sortOrder" : sortOrder,
"num" : num,
"start" : start,
'restrict' : useSecurity
}
if not focus is None:
params['focus'] = focus
if not t is None:
params['t'] = t
if useSecurity and \
self._securityHandler is not None and \
self._securityHandler.method == "token":
params["token"] = self._securityHandler.token
if sortField is not None:
params['sortField'] = sortField
if bbox is not None:
params['bbox'] = bbox
return self._get(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
[
"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",
",",
"\"num\"",
":",
"num",
",",
"\"start\"",
":",
"start",
",",
"'restrict'",
":",
"useSecurity",
"}",
"if",
"not",
"focus",
"is",
"None",
":",
"params",
"[",
"'focus'",
"]",
"=",
"focus",
"if",
"not",
"t",
"is",
"None",
":",
"params",
"[",
"'t'",
"]",
"=",
"t",
"if",
"useSecurity",
"and",
"self",
".",
"_securityHandler",
"is",
"not",
"None",
"and",
"self",
".",
"_securityHandler",
".",
"method",
"==",
"\"token\"",
":",
"params",
"[",
"\"token\"",
"]",
"=",
"self",
".",
"_securityHandler",
".",
"token",
"if",
"sortField",
"is",
"not",
"None",
":",
"params",
"[",
"'sortField'",
"]",
"=",
"sortField",
"if",
"bbox",
"is",
"not",
"None",
":",
"params",
"[",
"'bbox'",
"]",
"=",
"bbox",
"return",
"self",
".",
"_get",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] |
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 delete
content. There can be a lag between the time that the content is
updated and the time when it's reflected in the search results.
The results of a search only contain items that the user has
permission to access.
Inputs:
q - The query string used to search
t - type of content to search for.
focus - another content filter. Ex: files
bbox - The bounding box for a spatial search defined as minx,
miny, maxx, or maxy. Search requires q, bbox, or both.
Spatial search is an overlaps/intersects function of the
query bbox and the extent of the document.
Documents that have no extent (e.g., mxds, 3dds, lyr)
will not be found when doing a bbox search.
Document extent is assumed to be in the WGS84 geographic
coordinate system.
start - The number of the first entry in the result set
response. The index number is 1-based.
The default value of start is 1 (that is, the first
search result).
The start parameter, along with the num parameter, can
be used to paginate the search results.
num - The maximum number of results to be included in the result
set response.
The default value is 10, and the maximum allowed value is
100.
The start parameter, along with the num parameter, can be
used to paginate the search results.
sortField - Field to sort by. You can also sort by multiple
fields (comma separated) for an item.
The allowed sort field names are title, created,
type, owner, modified, avgRating, numRatings,
numComments, and numViews.
sortOrder - Describes whether the results return in ascending or
descending order. Default is ascending.
Values: asc | desc
useSecurity - boolean value that determines if the security
handler object's token will be appended on the
search call. If the value is set to False, then
the search will be performed without
authentication. This means only items that have
been shared with everyone on AGOL or portal site
will be found. If it is set to True, then all
items the user has permission to see based on the
query passed will be returned.
Output:
returns a list of dictionary
|
[
"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",
"delete",
"content",
".",
"There",
"can",
"be",
"a",
"lag",
"between",
"the",
"time",
"that",
"the",
"content",
"is",
"updated",
"and",
"the",
"time",
"when",
"it",
"s",
"reflected",
"in",
"the",
"search",
"results",
".",
"The",
"results",
"of",
"a",
"search",
"only",
"contain",
"items",
"that",
"the",
"user",
"has",
"permission",
"to",
"access",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/administration.py#L167-L263
|
13,177
|
Esri/ArcREST
|
src/arcrest/manageorg/administration.py
|
Administration.hostingServers
|
def hostingServers(self):
"""
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.
"""
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']['features']['https']:
if portal.isPortal == True:
url = "%s/admin" % https
#url = https
services.append(AGSAdministration(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port))
else:
url = "https://%s/%s/ArcGIS/rest/admin" % (https, portal.portalId)
services.append(Services(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port))
elif 'http' in urls['urls']['features']:
for http in urls['urls']['features']['http']:
if (portal.isPortal == True):
url = "%s/admin" % http
services.append(AGSAdministration(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True))
else:
url = "http://%s/%s/ArcGIS/rest/admin" % (http, portal.portalId)
services.append(Services(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port))
else:
print( "Publishing servers not found")
else:
print ("Publishing servers not found")
else:
print( "Publishing servers not found")
return services
else:
for server in portal.servers['servers']:
url = server['adminUrl'] + "/admin"
sh = PortalServerSecurityHandler(tokenHandler=self._securityHandler,
serverUrl=url,
referer=server['name'].replace(":6080", ":6443")
)
services.append(
AGSAdministration(url=url,
securityHandler=sh,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=False)
)
return services
|
python
|
def hostingServers(self):
"""
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.
"""
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']['features']['https']:
if portal.isPortal == True:
url = "%s/admin" % https
#url = https
services.append(AGSAdministration(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port))
else:
url = "https://%s/%s/ArcGIS/rest/admin" % (https, portal.portalId)
services.append(Services(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port))
elif 'http' in urls['urls']['features']:
for http in urls['urls']['features']['http']:
if (portal.isPortal == True):
url = "%s/admin" % http
services.append(AGSAdministration(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True))
else:
url = "http://%s/%s/ArcGIS/rest/admin" % (http, portal.portalId)
services.append(Services(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port))
else:
print( "Publishing servers not found")
else:
print ("Publishing servers not found")
else:
print( "Publishing servers not found")
return services
else:
for server in portal.servers['servers']:
url = server['adminUrl'] + "/admin"
sh = PortalServerSecurityHandler(tokenHandler=self._securityHandler,
serverUrl=url,
referer=server['name'].replace(":6080", ":6443")
)
services.append(
AGSAdministration(url=url,
securityHandler=sh,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=False)
)
return services
|
[
"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'",
"]",
"[",
"'features'",
"]",
"[",
"'https'",
"]",
":",
"if",
"portal",
".",
"isPortal",
"==",
"True",
":",
"url",
"=",
"\"%s/admin\"",
"%",
"https",
"#url = https",
"services",
".",
"append",
"(",
"AGSAdministration",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")",
")",
"else",
":",
"url",
"=",
"\"https://%s/%s/ArcGIS/rest/admin\"",
"%",
"(",
"https",
",",
"portal",
".",
"portalId",
")",
"services",
".",
"append",
"(",
"Services",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")",
")",
"elif",
"'http'",
"in",
"urls",
"[",
"'urls'",
"]",
"[",
"'features'",
"]",
":",
"for",
"http",
"in",
"urls",
"[",
"'urls'",
"]",
"[",
"'features'",
"]",
"[",
"'http'",
"]",
":",
"if",
"(",
"portal",
".",
"isPortal",
"==",
"True",
")",
":",
"url",
"=",
"\"%s/admin\"",
"%",
"http",
"services",
".",
"append",
"(",
"AGSAdministration",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"True",
")",
")",
"else",
":",
"url",
"=",
"\"http://%s/%s/ArcGIS/rest/admin\"",
"%",
"(",
"http",
",",
"portal",
".",
"portalId",
")",
"services",
".",
"append",
"(",
"Services",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")",
")",
"else",
":",
"print",
"(",
"\"Publishing servers not found\"",
")",
"else",
":",
"print",
"(",
"\"Publishing servers not found\"",
")",
"else",
":",
"print",
"(",
"\"Publishing servers not found\"",
")",
"return",
"services",
"else",
":",
"for",
"server",
"in",
"portal",
".",
"servers",
"[",
"'servers'",
"]",
":",
"url",
"=",
"server",
"[",
"'adminUrl'",
"]",
"+",
"\"/admin\"",
"sh",
"=",
"PortalServerSecurityHandler",
"(",
"tokenHandler",
"=",
"self",
".",
"_securityHandler",
",",
"serverUrl",
"=",
"url",
",",
"referer",
"=",
"server",
"[",
"'name'",
"]",
".",
"replace",
"(",
"\":6080\"",
",",
"\":6443\"",
")",
")",
"services",
".",
"append",
"(",
"AGSAdministration",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"sh",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"False",
")",
")",
"return",
"services"
] |
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.
|
[
"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",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/administration.py#L267-L341
|
13,178
|
Esri/ArcREST
|
src/arcrest/webmap/domain.py
|
CodedValueDomain.add_codedValue
|
def add_codedValue(self, name, code):
""" adds a value to the coded value list """
if self._codedValues is None:
self._codedValues = []
self._codedValues.append(
{"name": name, "code": code}
)
|
python
|
def add_codedValue(self, name, code):
""" adds a value to the coded value list """
if self._codedValues is None:
self._codedValues = []
self._codedValues.append(
{"name": name, "code": code}
)
|
[
"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
|
[
"adds",
"a",
"value",
"to",
"the",
"coded",
"value",
"list"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/webmap/domain.py#L96-L102
|
13,179
|
Esri/ArcREST
|
src/arcrest/geometryservice/geometryservice.py
|
GeometryService.__init
|
def __init(self):
"""loads the json values"""
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.items():
setattr(self, k, v)
|
python
|
def __init(self):
"""loads the json values"""
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.items():
setattr(self, k, v)
|
[
"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",
".",
"items",
"(",
")",
":",
"setattr",
"(",
"self",
",",
"k",
",",
"v",
")"
] |
loads the json values
|
[
"loads",
"the",
"json",
"values"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/geometryservice/geometryservice.py#L33-L43
|
13,180
|
Esri/ArcREST
|
src/arcrest/geometryservice/geometryservice.py
|
GeometryService.areasAndLengths
|
def areasAndLengths(self,
polygons,
lengthUnit,
areaUnit,
calculationType,
):
"""
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.
Inputs:
polygons - The array of polygons whose areas and lengths are
to be computed.
lengthUnit - The length unit in which the perimeters of
polygons will be calculated. If calculationType
is planar, then lengthUnit can be any esriUnits
constant. If lengthUnit is not specified, the
units are derived from sr. If calculationType is
not planar, then lengthUnit must be a linear
esriUnits constant, such as esriSRUnit_Meter or
esriSRUnit_SurveyMile. If lengthUnit is not
specified, the units are meters. For a list of
valid units, see esriSRUnitType Constants and
esriSRUnit2Type Constant.
areaUnit - The area unit in which areas of polygons will be
calculated. If calculationType is planar, then
areaUnit can be any esriUnits constant. If
areaUnit is not specified, the units are derived
from sr. If calculationType is not planar, then
areaUnit must be a linear esriUnits constant such
as esriSRUnit_Meter or esriSRUnit_SurveyMile. If
areaUnit is not specified, then the units are
meters. For a list of valid units, see
esriSRUnitType Constants and esriSRUnit2Type
constant.
The list of valid esriAreaUnits constants include,
esriSquareInches | esriSquareFeet |
esriSquareYards | esriAcres | esriSquareMiles |
esriSquareMillimeters | esriSquareCentimeters |
esriSquareDecimeters | esriSquareMeters | esriAres
| esriHectares | esriSquareKilometers.
calculationType - The type defined for the area and length
calculation of the input geometries. The
type can be one of the following values:
planar - Planar measurements use 2D
Euclidean distance to calculate
area and length. Th- should
only be used if the area or
length needs to be calculated in
the given spatial reference.
Otherwise, use preserveShape.
geodesic - Use this type if you want to
calculate an area or length using
only the vertices of the polygon
and define the lines between the
points as geodesic segments
independent of the actual shape
of the polygon. A geodesic
segment is the shortest path
between two points on an ellipsoid.
preserveShape - This type calculates the
area or length of the geometry on
the surface of the Earth
ellipsoid. The shape of the
geometry in its coordinate system
is preserved.
Output:
JSON as dictionary
"""
url = self._url + "/areasAndLengths"
params = {
"f" : "json",
"lengthUnit" : lengthUnit,
"areaUnit" : {"areaUnit" : areaUnit},
"calculationType" : calculationType
}
if isinstance(polygons, list) and len(polygons) > 0:
p = polygons[0]
if isinstance(p, Polygon):
params['sr'] = p.spatialReference['wkid']
params['polygons'] = [poly.asDictionary for poly in polygons]
del p
else:
return "No polygons provided, please submit a list of polygon geometries"
return self._get(url=url, param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
python
|
def areasAndLengths(self,
polygons,
lengthUnit,
areaUnit,
calculationType,
):
"""
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.
Inputs:
polygons - The array of polygons whose areas and lengths are
to be computed.
lengthUnit - The length unit in which the perimeters of
polygons will be calculated. If calculationType
is planar, then lengthUnit can be any esriUnits
constant. If lengthUnit is not specified, the
units are derived from sr. If calculationType is
not planar, then lengthUnit must be a linear
esriUnits constant, such as esriSRUnit_Meter or
esriSRUnit_SurveyMile. If lengthUnit is not
specified, the units are meters. For a list of
valid units, see esriSRUnitType Constants and
esriSRUnit2Type Constant.
areaUnit - The area unit in which areas of polygons will be
calculated. If calculationType is planar, then
areaUnit can be any esriUnits constant. If
areaUnit is not specified, the units are derived
from sr. If calculationType is not planar, then
areaUnit must be a linear esriUnits constant such
as esriSRUnit_Meter or esriSRUnit_SurveyMile. If
areaUnit is not specified, then the units are
meters. For a list of valid units, see
esriSRUnitType Constants and esriSRUnit2Type
constant.
The list of valid esriAreaUnits constants include,
esriSquareInches | esriSquareFeet |
esriSquareYards | esriAcres | esriSquareMiles |
esriSquareMillimeters | esriSquareCentimeters |
esriSquareDecimeters | esriSquareMeters | esriAres
| esriHectares | esriSquareKilometers.
calculationType - The type defined for the area and length
calculation of the input geometries. The
type can be one of the following values:
planar - Planar measurements use 2D
Euclidean distance to calculate
area and length. Th- should
only be used if the area or
length needs to be calculated in
the given spatial reference.
Otherwise, use preserveShape.
geodesic - Use this type if you want to
calculate an area or length using
only the vertices of the polygon
and define the lines between the
points as geodesic segments
independent of the actual shape
of the polygon. A geodesic
segment is the shortest path
between two points on an ellipsoid.
preserveShape - This type calculates the
area or length of the geometry on
the surface of the Earth
ellipsoid. The shape of the
geometry in its coordinate system
is preserved.
Output:
JSON as dictionary
"""
url = self._url + "/areasAndLengths"
params = {
"f" : "json",
"lengthUnit" : lengthUnit,
"areaUnit" : {"areaUnit" : areaUnit},
"calculationType" : calculationType
}
if isinstance(polygons, list) and len(polygons) > 0:
p = polygons[0]
if isinstance(p, Polygon):
params['sr'] = p.spatialReference['wkid']
params['polygons'] = [poly.asDictionary for poly in polygons]
del p
else:
return "No polygons provided, please submit a list of polygon geometries"
return self._get(url=url, param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
[
"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",
"=",
"polygons",
"[",
"0",
"]",
"if",
"isinstance",
"(",
"p",
",",
"Polygon",
")",
":",
"params",
"[",
"'sr'",
"]",
"=",
"p",
".",
"spatialReference",
"[",
"'wkid'",
"]",
"params",
"[",
"'polygons'",
"]",
"=",
"[",
"poly",
".",
"asDictionary",
"for",
"poly",
"in",
"polygons",
"]",
"del",
"p",
"else",
":",
"return",
"\"No polygons provided, please submit a list of polygon geometries\"",
"return",
"self",
".",
"_get",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] |
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.
Inputs:
polygons - The array of polygons whose areas and lengths are
to be computed.
lengthUnit - The length unit in which the perimeters of
polygons will be calculated. If calculationType
is planar, then lengthUnit can be any esriUnits
constant. If lengthUnit is not specified, the
units are derived from sr. If calculationType is
not planar, then lengthUnit must be a linear
esriUnits constant, such as esriSRUnit_Meter or
esriSRUnit_SurveyMile. If lengthUnit is not
specified, the units are meters. For a list of
valid units, see esriSRUnitType Constants and
esriSRUnit2Type Constant.
areaUnit - The area unit in which areas of polygons will be
calculated. If calculationType is planar, then
areaUnit can be any esriUnits constant. If
areaUnit is not specified, the units are derived
from sr. If calculationType is not planar, then
areaUnit must be a linear esriUnits constant such
as esriSRUnit_Meter or esriSRUnit_SurveyMile. If
areaUnit is not specified, then the units are
meters. For a list of valid units, see
esriSRUnitType Constants and esriSRUnit2Type
constant.
The list of valid esriAreaUnits constants include,
esriSquareInches | esriSquareFeet |
esriSquareYards | esriAcres | esriSquareMiles |
esriSquareMillimeters | esriSquareCentimeters |
esriSquareDecimeters | esriSquareMeters | esriAres
| esriHectares | esriSquareKilometers.
calculationType - The type defined for the area and length
calculation of the input geometries. The
type can be one of the following values:
planar - Planar measurements use 2D
Euclidean distance to calculate
area and length. Th- should
only be used if the area or
length needs to be calculated in
the given spatial reference.
Otherwise, use preserveShape.
geodesic - Use this type if you want to
calculate an area or length using
only the vertices of the polygon
and define the lines between the
points as geodesic segments
independent of the actual shape
of the polygon. A geodesic
segment is the shortest path
between two points on an ellipsoid.
preserveShape - This type calculates the
area or length of the geometry on
the surface of the Earth
ellipsoid. The shape of the
geometry in its coordinate system
is preserved.
Output:
JSON as dictionary
|
[
"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",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/geometryservice/geometryservice.py#L58-L146
|
13,181
|
Esri/ArcREST
|
src/arcrest/geometryservice/geometryservice.py
|
GeometryService.__geometryToGeomTemplate
|
def __geometryToGeomTemplate(self, geometry):
"""
Converts a single geometry object to a geometry service geometry
template value.
Input:
geometry - ArcREST geometry object
Output:
python dictionary of geometry template
"""
template = {"geometryType": None,
"geometry" : None}
if isinstance(geometry, Polyline):
template['geometryType'] = "esriGeometryPolyline"
elif isinstance(geometry, Polygon):
template['geometryType'] = "esriGeometryPolygon"
elif isinstance(geometry, Point):
template['geometryType'] = "esriGeometryPoint"
elif isinstance(geometry, MultiPoint):
template['geometryType'] = "esriGeometryMultipoint"
elif isinstance(geometry, Envelope):
template['geometryType'] = "esriGeometryEnvelope"
else:
raise AttributeError("Invalid geometry type")
template['geometry'] = geometry.asDictionary
return template
|
python
|
def __geometryToGeomTemplate(self, geometry):
"""
Converts a single geometry object to a geometry service geometry
template value.
Input:
geometry - ArcREST geometry object
Output:
python dictionary of geometry template
"""
template = {"geometryType": None,
"geometry" : None}
if isinstance(geometry, Polyline):
template['geometryType'] = "esriGeometryPolyline"
elif isinstance(geometry, Polygon):
template['geometryType'] = "esriGeometryPolygon"
elif isinstance(geometry, Point):
template['geometryType'] = "esriGeometryPoint"
elif isinstance(geometry, MultiPoint):
template['geometryType'] = "esriGeometryMultipoint"
elif isinstance(geometry, Envelope):
template['geometryType'] = "esriGeometryEnvelope"
else:
raise AttributeError("Invalid geometry type")
template['geometry'] = geometry.asDictionary
return template
|
[
"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",
",",
"Point",
")",
":",
"template",
"[",
"'geometryType'",
"]",
"=",
"\"esriGeometryPoint\"",
"elif",
"isinstance",
"(",
"geometry",
",",
"MultiPoint",
")",
":",
"template",
"[",
"'geometryType'",
"]",
"=",
"\"esriGeometryMultipoint\"",
"elif",
"isinstance",
"(",
"geometry",
",",
"Envelope",
")",
":",
"template",
"[",
"'geometryType'",
"]",
"=",
"\"esriGeometryEnvelope\"",
"else",
":",
"raise",
"AttributeError",
"(",
"\"Invalid geometry type\"",
")",
"template",
"[",
"'geometry'",
"]",
"=",
"geometry",
".",
"asDictionary",
"return",
"template"
] |
Converts a single geometry object to a geometry service geometry
template value.
Input:
geometry - ArcREST geometry object
Output:
python dictionary of geometry template
|
[
"Converts",
"a",
"single",
"geometry",
"object",
"to",
"a",
"geometry",
"service",
"geometry",
"template",
"value",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/geometryservice/geometryservice.py#L178-L203
|
13,182
|
Esri/ArcREST
|
src/arcrest/geometryservice/geometryservice.py
|
GeometryService.__geomToStringArray
|
def __geomToStringArray(self, geometries, returnType="str"):
""" function to convert the geomtries to strings """
listGeoms = []
for g in geometries:
if isinstance(g, Point):
listGeoms.append(g.asDictionary)
elif isinstance(g, Polygon):
listGeoms.append(g.asDictionary) #json.dumps(
elif isinstance(g, Polyline):
listGeoms.append({'paths' : g.asDictionary['paths']})
if returnType == "str":
return json.dumps(listGeoms)
elif returnType == "list":
return listGeoms
else:
return json.dumps(listGeoms)
|
python
|
def __geomToStringArray(self, geometries, returnType="str"):
""" function to convert the geomtries to strings """
listGeoms = []
for g in geometries:
if isinstance(g, Point):
listGeoms.append(g.asDictionary)
elif isinstance(g, Polygon):
listGeoms.append(g.asDictionary) #json.dumps(
elif isinstance(g, Polyline):
listGeoms.append({'paths' : g.asDictionary['paths']})
if returnType == "str":
return json.dumps(listGeoms)
elif returnType == "list":
return listGeoms
else:
return json.dumps(listGeoms)
|
[
"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",
")",
"#json.dumps(",
"elif",
"isinstance",
"(",
"g",
",",
"Polyline",
")",
":",
"listGeoms",
".",
"append",
"(",
"{",
"'paths'",
":",
"g",
".",
"asDictionary",
"[",
"'paths'",
"]",
"}",
")",
"if",
"returnType",
"==",
"\"str\"",
":",
"return",
"json",
".",
"dumps",
"(",
"listGeoms",
")",
"elif",
"returnType",
"==",
"\"list\"",
":",
"return",
"listGeoms",
"else",
":",
"return",
"json",
".",
"dumps",
"(",
"listGeoms",
")"
] |
function to convert the geomtries to strings
|
[
"function",
"to",
"convert",
"the",
"geomtries",
"to",
"strings"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/geometryservice/geometryservice.py#L205-L220
|
13,183
|
Esri/ArcREST
|
src/arcrest/geometryservice/geometryservice.py
|
GeometryService.autoComplete
|
def autoComplete(self,
polygons=[],
polylines=[],
sr=None
):
"""
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.
Inputs:
polygons - array of Polygon objects.
polylines - list of Polyline objects.
sr - spatial reference of the input geometries WKID.
"""
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._get(url, param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
python
|
def autoComplete(self,
polygons=[],
polylines=[],
sr=None
):
"""
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.
Inputs:
polygons - array of Polygon objects.
polylines - list of Polyline objects.
sr - spatial reference of the input geometries WKID.
"""
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._get(url, param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
[
"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",
".",
"_get",
"(",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] |
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.
Inputs:
polygons - array of Polygon objects.
polylines - list of Polyline objects.
sr - spatial reference of the input geometries WKID.
|
[
"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",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/geometryservice/geometryservice.py#L222-L247
|
13,184
|
Esri/ArcREST
|
src/arcrest/geometryservice/geometryservice.py
|
GeometryService.buffer
|
def buffer(self,
geometries,
inSR,
distances,
units,
outSR=None,
bufferSR=None,
unionResults=True,
geodesic=True
):
"""
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.
Inputs:
geometries - array of geometries (structured as JSON geometry
objects returned by the ArcGIS REST API).
inSR - spatial reference of the input geometries WKID.
outSR - spatial reference for the returned geometries.
bufferSR - WKID or a spatial reference JSON object in
which the geometries are buffered.
distances - distances that each of the input geometries is buffered
unit - units for calculating each buffer distance.
unionResults - if true, all geometries buffered at a given distance
are unioned into a single (possibly multipart) polygon,
and the unioned geometry is placed in the output array.
geodesic - set geodesic to true to buffer the using geodesic distance.
"""
url = self._url + "/buffer"
params = {
"f" : "json",
"inSR" : inSR,
"geodesic" : geodesic,
"unionResults" : unionResults
}
if isinstance(geometries, list) and len(geometries) > 0:
g = geometries[0]
if isinstance(g, Polygon):
params['geometries'] = {"geometryType": "esriGeometryPolygon",
"geometries" : self.__geomToStringArray(geometries, "list")}
elif isinstance(g, Point):
params['geometries'] = {"geometryType": "esriGeometryPoint",
"geometries" : self.__geomToStringArray(geometries, "list")}
elif isinstance(g, Polyline):
params['geometries'] = {"geometryType": "esriGeometryPolyline",
"geometries" : self.__geomToStringArray(geometries, "list")}
else:
return None
if isinstance(distances, list):
distances = [str(d) for d in distances]
params['distances'] = ",".join(distances)
else:
params['distances'] = str(distances)
params['units'] = units
if bufferSR is not None:
params['bufferSR'] = bufferSR
if outSR is not None:
params['outSR'] = outSR
return self._get(url, param_dict=params,
proxy_port=self._proxy_port,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url)
|
python
|
def buffer(self,
geometries,
inSR,
distances,
units,
outSR=None,
bufferSR=None,
unionResults=True,
geodesic=True
):
"""
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.
Inputs:
geometries - array of geometries (structured as JSON geometry
objects returned by the ArcGIS REST API).
inSR - spatial reference of the input geometries WKID.
outSR - spatial reference for the returned geometries.
bufferSR - WKID or a spatial reference JSON object in
which the geometries are buffered.
distances - distances that each of the input geometries is buffered
unit - units for calculating each buffer distance.
unionResults - if true, all geometries buffered at a given distance
are unioned into a single (possibly multipart) polygon,
and the unioned geometry is placed in the output array.
geodesic - set geodesic to true to buffer the using geodesic distance.
"""
url = self._url + "/buffer"
params = {
"f" : "json",
"inSR" : inSR,
"geodesic" : geodesic,
"unionResults" : unionResults
}
if isinstance(geometries, list) and len(geometries) > 0:
g = geometries[0]
if isinstance(g, Polygon):
params['geometries'] = {"geometryType": "esriGeometryPolygon",
"geometries" : self.__geomToStringArray(geometries, "list")}
elif isinstance(g, Point):
params['geometries'] = {"geometryType": "esriGeometryPoint",
"geometries" : self.__geomToStringArray(geometries, "list")}
elif isinstance(g, Polyline):
params['geometries'] = {"geometryType": "esriGeometryPolyline",
"geometries" : self.__geomToStringArray(geometries, "list")}
else:
return None
if isinstance(distances, list):
distances = [str(d) for d in distances]
params['distances'] = ",".join(distances)
else:
params['distances'] = str(distances)
params['units'] = units
if bufferSR is not None:
params['bufferSR'] = bufferSR
if outSR is not None:
params['outSR'] = outSR
return self._get(url, param_dict=params,
proxy_port=self._proxy_port,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url)
|
[
"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",
")",
">",
"0",
":",
"g",
"=",
"geometries",
"[",
"0",
"]",
"if",
"isinstance",
"(",
"g",
",",
"Polygon",
")",
":",
"params",
"[",
"'geometries'",
"]",
"=",
"{",
"\"geometryType\"",
":",
"\"esriGeometryPolygon\"",
",",
"\"geometries\"",
":",
"self",
".",
"__geomToStringArray",
"(",
"geometries",
",",
"\"list\"",
")",
"}",
"elif",
"isinstance",
"(",
"g",
",",
"Point",
")",
":",
"params",
"[",
"'geometries'",
"]",
"=",
"{",
"\"geometryType\"",
":",
"\"esriGeometryPoint\"",
",",
"\"geometries\"",
":",
"self",
".",
"__geomToStringArray",
"(",
"geometries",
",",
"\"list\"",
")",
"}",
"elif",
"isinstance",
"(",
"g",
",",
"Polyline",
")",
":",
"params",
"[",
"'geometries'",
"]",
"=",
"{",
"\"geometryType\"",
":",
"\"esriGeometryPolyline\"",
",",
"\"geometries\"",
":",
"self",
".",
"__geomToStringArray",
"(",
"geometries",
",",
"\"list\"",
")",
"}",
"else",
":",
"return",
"None",
"if",
"isinstance",
"(",
"distances",
",",
"list",
")",
":",
"distances",
"=",
"[",
"str",
"(",
"d",
")",
"for",
"d",
"in",
"distances",
"]",
"params",
"[",
"'distances'",
"]",
"=",
"\",\"",
".",
"join",
"(",
"distances",
")",
"else",
":",
"params",
"[",
"'distances'",
"]",
"=",
"str",
"(",
"distances",
")",
"params",
"[",
"'units'",
"]",
"=",
"units",
"if",
"bufferSR",
"is",
"not",
"None",
":",
"params",
"[",
"'bufferSR'",
"]",
"=",
"bufferSR",
"if",
"outSR",
"is",
"not",
"None",
":",
"params",
"[",
"'outSR'",
"]",
"=",
"outSR",
"return",
"self",
".",
"_get",
"(",
"url",
",",
"param_dict",
"=",
"params",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
")"
] |
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.
Inputs:
geometries - array of geometries (structured as JSON geometry
objects returned by the ArcGIS REST API).
inSR - spatial reference of the input geometries WKID.
outSR - spatial reference for the returned geometries.
bufferSR - WKID or a spatial reference JSON object in
which the geometries are buffered.
distances - distances that each of the input geometries is buffered
unit - units for calculating each buffer distance.
unionResults - if true, all geometries buffered at a given distance
are unioned into a single (possibly multipart) polygon,
and the unioned geometry is placed in the output array.
geodesic - set geodesic to true to buffer the using geodesic distance.
|
[
"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",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/geometryservice/geometryservice.py#L249-L313
|
13,185
|
Esri/ArcREST
|
src/arcrest/geometryservice/geometryservice.py
|
GeometryService.findTransformation
|
def findTransformation(self, inSR, outSR, extentOfInterest=None, numOfResults=1):
"""
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 order of most applicable to least applicable. Recall that a
geographic transformation is not needed when the input and output
spatial references have the same underlying geographic coordinate
systems. In this case, findTransformations returns an empty list.
Every returned geographic transformation is a forward
transformation meaning that it can be used as-is to project from
the input spatial reference to the output spatial reference. In the
case where a predefined transformation needs to be applied in the
reverse direction, it is returned as a forward composite
transformation containing one transformation and a transformForward
element with a value of false.
Inputs:
inSR - The well-known ID (WKID) of the spatial reference or a
spatial reference JSON object for the input geometries
outSR - The well-known ID (WKID) of the spatial reference or a
spatial reference JSON object for the input geometries
extentOfInterest - The bounding box of the area of interest
specified as a JSON envelope. If provided, the extent of
interest is used to return the most applicable geographic
transformations for the area. If a spatial reference is not
included in the JSON envelope, the inSR is used for the
envelope.
numOfResults - The number of geographic transformations to
return. The default value is 1. If numOfResults has a value of
-1, all applicable transformations are returned.
"""
params = {
"f" : "json",
"inSR" : inSR,
"outSR" : outSR
}
url = self._url + "/findTransformations"
if isinstance(numOfResults, int):
params['numOfResults'] = numOfResults
if isinstance(extentOfInterest, Envelope):
params['extentOfInterest'] = extentOfInterest.asDictionary
return self._post(url=url, param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
python
|
def findTransformation(self, inSR, outSR, extentOfInterest=None, numOfResults=1):
"""
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 order of most applicable to least applicable. Recall that a
geographic transformation is not needed when the input and output
spatial references have the same underlying geographic coordinate
systems. In this case, findTransformations returns an empty list.
Every returned geographic transformation is a forward
transformation meaning that it can be used as-is to project from
the input spatial reference to the output spatial reference. In the
case where a predefined transformation needs to be applied in the
reverse direction, it is returned as a forward composite
transformation containing one transformation and a transformForward
element with a value of false.
Inputs:
inSR - The well-known ID (WKID) of the spatial reference or a
spatial reference JSON object for the input geometries
outSR - The well-known ID (WKID) of the spatial reference or a
spatial reference JSON object for the input geometries
extentOfInterest - The bounding box of the area of interest
specified as a JSON envelope. If provided, the extent of
interest is used to return the most applicable geographic
transformations for the area. If a spatial reference is not
included in the JSON envelope, the inSR is used for the
envelope.
numOfResults - The number of geographic transformations to
return. The default value is 1. If numOfResults has a value of
-1, all applicable transformations are returned.
"""
params = {
"f" : "json",
"inSR" : inSR,
"outSR" : outSR
}
url = self._url + "/findTransformations"
if isinstance(numOfResults, int):
params['numOfResults'] = numOfResults
if isinstance(extentOfInterest, Envelope):
params['extentOfInterest'] = extentOfInterest.asDictionary
return self._post(url=url, param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
[
"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",
")",
":",
"params",
"[",
"'extentOfInterest'",
"]",
"=",
"extentOfInterest",
".",
"asDictionary",
"return",
"self",
".",
"_post",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] |
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 order of most applicable to least applicable. Recall that a
geographic transformation is not needed when the input and output
spatial references have the same underlying geographic coordinate
systems. In this case, findTransformations returns an empty list.
Every returned geographic transformation is a forward
transformation meaning that it can be used as-is to project from
the input spatial reference to the output spatial reference. In the
case where a predefined transformation needs to be applied in the
reverse direction, it is returned as a forward composite
transformation containing one transformation and a transformForward
element with a value of false.
Inputs:
inSR - The well-known ID (WKID) of the spatial reference or a
spatial reference JSON object for the input geometries
outSR - The well-known ID (WKID) of the spatial reference or a
spatial reference JSON object for the input geometries
extentOfInterest - The bounding box of the area of interest
specified as a JSON envelope. If provided, the extent of
interest is used to return the most applicable geographic
transformations for the area. If a spatial reference is not
included in the JSON envelope, the inSR is used for the
envelope.
numOfResults - The number of geographic transformations to
return. The default value is 1. If numOfResults has a value of
-1, all applicable transformations are returned.
|
[
"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",
"order",
"of",
"most",
"applicable",
"to",
"least",
"applicable",
".",
"Recall",
"that",
"a",
"geographic",
"transformation",
"is",
"not",
"needed",
"when",
"the",
"input",
"and",
"output",
"spatial",
"references",
"have",
"the",
"same",
"underlying",
"geographic",
"coordinate",
"systems",
".",
"In",
"this",
"case",
"findTransformations",
"returns",
"an",
"empty",
"list",
".",
"Every",
"returned",
"geographic",
"transformation",
"is",
"a",
"forward",
"transformation",
"meaning",
"that",
"it",
"can",
"be",
"used",
"as",
"-",
"is",
"to",
"project",
"from",
"the",
"input",
"spatial",
"reference",
"to",
"the",
"output",
"spatial",
"reference",
".",
"In",
"the",
"case",
"where",
"a",
"predefined",
"transformation",
"needs",
"to",
"be",
"applied",
"in",
"the",
"reverse",
"direction",
"it",
"is",
"returned",
"as",
"a",
"forward",
"composite",
"transformation",
"containing",
"one",
"transformation",
"and",
"a",
"transformForward",
"element",
"with",
"a",
"value",
"of",
"false",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/geometryservice/geometryservice.py#L551-L598
|
13,186
|
Esri/ArcREST
|
src/arcrest/geometryservice/geometryservice.py
|
GeometryService.fromGeoCoordinateString
|
def fromGeoCoordinateString(self, sr, strings,
conversionType, conversionMode=None):
"""
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.
Inputs:
sr - The well-known ID of the spatial reference or a spatial
reference json object.
strings - An array of strings formatted as specified by
conversionType.
Syntax: [<string1>,...,<stringN>]
Example: ["01N AA 66021 00000","11S NT 00000 62155",
"31U BT 94071 65288"]
conversionType - The conversion type of the input strings.
Valid conversion types are:
MGRS - Military Grid Reference System
USNG - United States National Grid
UTM - Universal Transverse Mercator
GeoRef - World Geographic Reference System
GARS - Global Area Reference System
DMS - Degree Minute Second
DDM - Degree Decimal Minute
DD - Decimal Degree
conversionMode - Conversion options for MGRS, UTM and GARS
conversion types.
Conversion options for MGRS and UTM conversion types.
Valid conversion modes for MGRS are:
mgrsDefault - Default. Uses the spheroid from the given spatial
reference.
mgrsNewStyle - Treats all spheroids as new, like WGS 1984. The
180 degree longitude falls into Zone 60.
mgrsOldStyle - Treats all spheroids as old, like Bessel 1841.
The 180 degree longitude falls into Zone 60.
mgrsNewWith180InZone01 - Same as mgrsNewStyle except the 180
degree longitude falls into Zone 01.
mgrsOldWith180InZone01 - Same as mgrsOldStyle except the 180
degree longitude falls into Zone 01.
Valid conversion modes for UTM are:
utmDefault - Default. No options.
utmNorthSouth - Uses north/south latitude indicators instead of
zone numbers. Non-standard. Default is recommended
"""
url = self._url + "/fromGeoCoordinateString"
params = {
"f" : "json",
"sr" : sr,
"strings" : strings,
"conversionType" : conversionType
}
if not conversionMode is None:
params['conversionMode'] = conversionMode
return self._post(url=url, param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
python
|
def fromGeoCoordinateString(self, sr, strings,
conversionType, conversionMode=None):
"""
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.
Inputs:
sr - The well-known ID of the spatial reference or a spatial
reference json object.
strings - An array of strings formatted as specified by
conversionType.
Syntax: [<string1>,...,<stringN>]
Example: ["01N AA 66021 00000","11S NT 00000 62155",
"31U BT 94071 65288"]
conversionType - The conversion type of the input strings.
Valid conversion types are:
MGRS - Military Grid Reference System
USNG - United States National Grid
UTM - Universal Transverse Mercator
GeoRef - World Geographic Reference System
GARS - Global Area Reference System
DMS - Degree Minute Second
DDM - Degree Decimal Minute
DD - Decimal Degree
conversionMode - Conversion options for MGRS, UTM and GARS
conversion types.
Conversion options for MGRS and UTM conversion types.
Valid conversion modes for MGRS are:
mgrsDefault - Default. Uses the spheroid from the given spatial
reference.
mgrsNewStyle - Treats all spheroids as new, like WGS 1984. The
180 degree longitude falls into Zone 60.
mgrsOldStyle - Treats all spheroids as old, like Bessel 1841.
The 180 degree longitude falls into Zone 60.
mgrsNewWith180InZone01 - Same as mgrsNewStyle except the 180
degree longitude falls into Zone 01.
mgrsOldWith180InZone01 - Same as mgrsOldStyle except the 180
degree longitude falls into Zone 01.
Valid conversion modes for UTM are:
utmDefault - Default. No options.
utmNorthSouth - Uses north/south latitude indicators instead of
zone numbers. Non-standard. Default is recommended
"""
url = self._url + "/fromGeoCoordinateString"
params = {
"f" : "json",
"sr" : sr,
"strings" : strings,
"conversionType" : conversionType
}
if not conversionMode is None:
params['conversionMode'] = conversionMode
return self._post(url=url, param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
|
[
"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",
"return",
"self",
".",
"_post",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] |
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.
Inputs:
sr - The well-known ID of the spatial reference or a spatial
reference json object.
strings - An array of strings formatted as specified by
conversionType.
Syntax: [<string1>,...,<stringN>]
Example: ["01N AA 66021 00000","11S NT 00000 62155",
"31U BT 94071 65288"]
conversionType - The conversion type of the input strings.
Valid conversion types are:
MGRS - Military Grid Reference System
USNG - United States National Grid
UTM - Universal Transverse Mercator
GeoRef - World Geographic Reference System
GARS - Global Area Reference System
DMS - Degree Minute Second
DDM - Degree Decimal Minute
DD - Decimal Degree
conversionMode - Conversion options for MGRS, UTM and GARS
conversion types.
Conversion options for MGRS and UTM conversion types.
Valid conversion modes for MGRS are:
mgrsDefault - Default. Uses the spheroid from the given spatial
reference.
mgrsNewStyle - Treats all spheroids as new, like WGS 1984. The
180 degree longitude falls into Zone 60.
mgrsOldStyle - Treats all spheroids as old, like Bessel 1841.
The 180 degree longitude falls into Zone 60.
mgrsNewWith180InZone01 - Same as mgrsNewStyle except the 180
degree longitude falls into Zone 01.
mgrsOldWith180InZone01 - Same as mgrsOldStyle except the 180
degree longitude falls into Zone 01.
Valid conversion modes for UTM are:
utmDefault - Default. No options.
utmNorthSouth - Uses north/south latitude indicators instead of
zone numbers. Non-standard. Default is recommended
|
[
"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",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/geometryservice/geometryservice.py#L600-L658
|
13,187
|
Esri/ArcREST
|
src/arcrest/geometryservice/geometryservice.py
|
GeometryService.toGeoCoordinateString
|
def toGeoCoordinateString(self,
sr,
coordinates,
conversionType,
conversionMode="mgrsDefault",
numOfDigits=None,
rounding=True,
addSpaces=True
):
"""
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
parameter is not applicable for a particular conversion type, but a
value is supplied for that parameter, the value will be ignored.
Inputs:
sr - The well-known ID of the spatial reference or a spatial
reference json object.
coordinates - An array of xy-coordinates in JSON format to be
converted. Syntax: [[x1,y2],...[xN,yN]]
conversionType - The conversion type of the input strings.
Allowed Values:
MGRS - Military Grid Reference System
USNG - United States National Grid
UTM - Universal Transverse Mercator
GeoRef - World Geographic Reference System
GARS - Global Area Reference System
DMS - Degree Minute Second
DDM - Degree Decimal Minute
DD - Decimal Degree
conversionMode - Conversion options for MGRS and UTM conversion
types.
Valid conversion modes for MGRS are:
mgrsDefault - Default. Uses the spheroid from the given spatial
reference.
mgrsNewStyle - Treats all spheroids as new, like WGS 1984. The
180 degree longitude falls into Zone 60.
mgrsOldStyle - Treats all spheroids as old, like Bessel 1841.
The 180 degree longitude falls into Zone 60.
mgrsNewWith180InZone01 - Same as mgrsNewStyle except the 180
degree longitude falls into Zone 01.
mgrsOldWith180InZone01 - Same as mgrsOldStyle except the 180
degree longitude falls into Zone 01.
Valid conversion modes for UTM are:
utmDefault - Default. No options.
utmNorthSouth - Uses north/south latitude indicators instead of
zone numbers. Non-standard. Default is recommended.
numOfDigits - The number of digits to output for each of the
numerical portions in the string. The default value for
numOfDigits varies depending on conversionType.
rounding - If true, then numeric portions of the string are
rounded to the nearest whole magnitude as specified by
numOfDigits. Otherwise, numeric portions of the string are
truncated. The rounding parameter applies only to conversion
types MGRS, USNG and GeoRef. The default value is true.
addSpaces - If true, then spaces are added between components of
the string. The addSpaces parameter applies only to conversion
types MGRS, USNG and UTM. The default value for MGRS is false,
while the default value for both USNG and UTM is true.
"""
params = {
"f": "json",
"sr" : sr,
"coordinates" : coordinates,
"conversionType": conversionType
}
url = self._url + "/toGeoCoordinateString"
if not conversionMode is None:
params['conversionMode'] = conversionMode
if isinstance(numOfDigits, int):
params['numOfDigits'] = numOfDigits
if isinstance(rounding, int):
params['rounding'] = rounding
if isinstance(addSpaces, bool):
params['addSpaces'] = addSpaces
return self._post(url=url,
param_dict=params,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
securityHandler=self._securityHandler)
|
python
|
def toGeoCoordinateString(self,
sr,
coordinates,
conversionType,
conversionMode="mgrsDefault",
numOfDigits=None,
rounding=True,
addSpaces=True
):
"""
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
parameter is not applicable for a particular conversion type, but a
value is supplied for that parameter, the value will be ignored.
Inputs:
sr - The well-known ID of the spatial reference or a spatial
reference json object.
coordinates - An array of xy-coordinates in JSON format to be
converted. Syntax: [[x1,y2],...[xN,yN]]
conversionType - The conversion type of the input strings.
Allowed Values:
MGRS - Military Grid Reference System
USNG - United States National Grid
UTM - Universal Transverse Mercator
GeoRef - World Geographic Reference System
GARS - Global Area Reference System
DMS - Degree Minute Second
DDM - Degree Decimal Minute
DD - Decimal Degree
conversionMode - Conversion options for MGRS and UTM conversion
types.
Valid conversion modes for MGRS are:
mgrsDefault - Default. Uses the spheroid from the given spatial
reference.
mgrsNewStyle - Treats all spheroids as new, like WGS 1984. The
180 degree longitude falls into Zone 60.
mgrsOldStyle - Treats all spheroids as old, like Bessel 1841.
The 180 degree longitude falls into Zone 60.
mgrsNewWith180InZone01 - Same as mgrsNewStyle except the 180
degree longitude falls into Zone 01.
mgrsOldWith180InZone01 - Same as mgrsOldStyle except the 180
degree longitude falls into Zone 01.
Valid conversion modes for UTM are:
utmDefault - Default. No options.
utmNorthSouth - Uses north/south latitude indicators instead of
zone numbers. Non-standard. Default is recommended.
numOfDigits - The number of digits to output for each of the
numerical portions in the string. The default value for
numOfDigits varies depending on conversionType.
rounding - If true, then numeric portions of the string are
rounded to the nearest whole magnitude as specified by
numOfDigits. Otherwise, numeric portions of the string are
truncated. The rounding parameter applies only to conversion
types MGRS, USNG and GeoRef. The default value is true.
addSpaces - If true, then spaces are added between components of
the string. The addSpaces parameter applies only to conversion
types MGRS, USNG and UTM. The default value for MGRS is false,
while the default value for both USNG and UTM is true.
"""
params = {
"f": "json",
"sr" : sr,
"coordinates" : coordinates,
"conversionType": conversionType
}
url = self._url + "/toGeoCoordinateString"
if not conversionMode is None:
params['conversionMode'] = conversionMode
if isinstance(numOfDigits, int):
params['numOfDigits'] = numOfDigits
if isinstance(rounding, int):
params['rounding'] = rounding
if isinstance(addSpaces, bool):
params['addSpaces'] = addSpaces
return self._post(url=url,
param_dict=params,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
securityHandler=self._securityHandler)
|
[
"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",
"conversionMode",
"is",
"None",
":",
"params",
"[",
"'conversionMode'",
"]",
"=",
"conversionMode",
"if",
"isinstance",
"(",
"numOfDigits",
",",
"int",
")",
":",
"params",
"[",
"'numOfDigits'",
"]",
"=",
"numOfDigits",
"if",
"isinstance",
"(",
"rounding",
",",
"int",
")",
":",
"params",
"[",
"'rounding'",
"]",
"=",
"rounding",
"if",
"isinstance",
"(",
"addSpaces",
",",
"bool",
")",
":",
"params",
"[",
"'addSpaces'",
"]",
"=",
"addSpaces",
"return",
"self",
".",
"_post",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
")"
] |
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
parameter is not applicable for a particular conversion type, but a
value is supplied for that parameter, the value will be ignored.
Inputs:
sr - The well-known ID of the spatial reference or a spatial
reference json object.
coordinates - An array of xy-coordinates in JSON format to be
converted. Syntax: [[x1,y2],...[xN,yN]]
conversionType - The conversion type of the input strings.
Allowed Values:
MGRS - Military Grid Reference System
USNG - United States National Grid
UTM - Universal Transverse Mercator
GeoRef - World Geographic Reference System
GARS - Global Area Reference System
DMS - Degree Minute Second
DDM - Degree Decimal Minute
DD - Decimal Degree
conversionMode - Conversion options for MGRS and UTM conversion
types.
Valid conversion modes for MGRS are:
mgrsDefault - Default. Uses the spheroid from the given spatial
reference.
mgrsNewStyle - Treats all spheroids as new, like WGS 1984. The
180 degree longitude falls into Zone 60.
mgrsOldStyle - Treats all spheroids as old, like Bessel 1841.
The 180 degree longitude falls into Zone 60.
mgrsNewWith180InZone01 - Same as mgrsNewStyle except the 180
degree longitude falls into Zone 01.
mgrsOldWith180InZone01 - Same as mgrsOldStyle except the 180
degree longitude falls into Zone 01.
Valid conversion modes for UTM are:
utmDefault - Default. No options.
utmNorthSouth - Uses north/south latitude indicators instead of
zone numbers. Non-standard. Default is recommended.
numOfDigits - The number of digits to output for each of the
numerical portions in the string. The default value for
numOfDigits varies depending on conversionType.
rounding - If true, then numeric portions of the string are
rounded to the nearest whole magnitude as specified by
numOfDigits. Otherwise, numeric portions of the string are
truncated. The rounding parameter applies only to conversion
types MGRS, USNG and GeoRef. The default value is true.
addSpaces - If true, then spaces are added between components of
the string. The addSpaces parameter applies only to conversion
types MGRS, USNG and UTM. The default value for MGRS is false,
while the default value for both USNG and UTM is true.
|
[
"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",
"parameter",
"is",
"not",
"applicable",
"for",
"a",
"particular",
"conversion",
"type",
"but",
"a",
"value",
"is",
"supplied",
"for",
"that",
"parameter",
"the",
"value",
"will",
"be",
"ignored",
"."
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/geometryservice/geometryservice.py#L985-L1067
|
13,188
|
Esri/ArcREST
|
src/arcrest/agol/helperservices/hydrology.py
|
hydrology.__init_url
|
def __init_url(self):
"""loads the information into the class"""
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,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
if "helperServices" in res:
helper_services = res.get("helperServices")
if "hydrology" in helper_services:
analysis_service = helper_services.get("elevation")
if "url" in analysis_service:
self._analysis_url = analysis_service.get("url")
self._gpService = GPService(url=self._analysis_url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=False)
|
python
|
def __init_url(self):
"""loads the information into the class"""
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,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
if "helperServices" in res:
helper_services = res.get("helperServices")
if "hydrology" in helper_services:
analysis_service = helper_services.get("elevation")
if "url" in analysis_service:
self._analysis_url = analysis_service.get("url")
self._gpService = GPService(url=self._analysis_url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=False)
|
[
"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",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")",
"if",
"\"helperServices\"",
"in",
"res",
":",
"helper_services",
"=",
"res",
".",
"get",
"(",
"\"helperServices\"",
")",
"if",
"\"hydrology\"",
"in",
"helper_services",
":",
"analysis_service",
"=",
"helper_services",
".",
"get",
"(",
"\"elevation\"",
")",
"if",
"\"url\"",
"in",
"analysis_service",
":",
"self",
".",
"_analysis_url",
"=",
"analysis_service",
".",
"get",
"(",
"\"url\"",
")",
"self",
".",
"_gpService",
"=",
"GPService",
"(",
"url",
"=",
"self",
".",
"_analysis_url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"False",
")"
] |
loads the information into the class
|
[
"loads",
"the",
"information",
"into",
"the",
"class"
] |
ab240fde2b0200f61d4a5f6df033516e53f2f416
|
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/agol/helperservices/hydrology.py#L51-L74
|
13,189
|
bw2/ConfigArgParse
|
configargparse.py
|
get_argument_parser
|
def get_argument_parser(name=None, **kwargs):
"""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.
"""
if name is None:
name = "default"
if len(kwargs) > 0 or name not in _parsers:
init_argument_parser(name, **kwargs)
return _parsers[name]
|
python
|
def get_argument_parser(name=None, **kwargs):
"""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.
"""
if name is None:
name = "default"
if len(kwargs) > 0 or name not in _parsers:
init_argument_parser(name, **kwargs)
return _parsers[name]
|
[
"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.
|
[
"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",
"."
] |
8bbc7de67f884184068d62af7f78e723d01c0081
|
https://github.com/bw2/ConfigArgParse/blob/8bbc7de67f884184068d62af7f78e723d01c0081/configargparse.py#L46-L58
|
13,190
|
bw2/ConfigArgParse
|
configargparse.py
|
DefaultConfigFileParser.parse
|
def parse(self, stream):
"""Parses the keys + values from a config file."""
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>.+?)"
comment = white_space+"(?P<comment>\\s[;#].*)?"
key_only_match = re.match("^" + key + comment + "$", line)
if key_only_match:
key = key_only_match.group("key")
items[key] = "true"
continue
key_value_match = re.match("^"+key+value+comment+"$", line)
if key_value_match:
key = key_value_match.group("key")
value = key_value_match.group("value")
if value.startswith("[") and value.endswith("]"):
# handle special case of lists
value = [elem.strip() for elem in value[1:-1].split(",")]
items[key] = value
continue
raise ConfigFileParserException("Unexpected line %s in %s: %s" % (i,
getattr(stream, 'name', 'stream'), line))
return items
|
python
|
def parse(self, stream):
"""Parses the keys + values from a config file."""
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>.+?)"
comment = white_space+"(?P<comment>\\s[;#].*)?"
key_only_match = re.match("^" + key + comment + "$", line)
if key_only_match:
key = key_only_match.group("key")
items[key] = "true"
continue
key_value_match = re.match("^"+key+value+comment+"$", line)
if key_value_match:
key = key_value_match.group("key")
value = key_value_match.group("value")
if value.startswith("[") and value.endswith("]"):
# handle special case of lists
value = [elem.strip() for elem in value[1:-1].split(",")]
items[key] = value
continue
raise ConfigFileParserException("Unexpected line %s in %s: %s" % (i,
getattr(stream, 'name', 'stream'), line))
return items
|
[
"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>.+?)\"",
"comment",
"=",
"white_space",
"+",
"\"(?P<comment>\\\\s[;#].*)?\"",
"key_only_match",
"=",
"re",
".",
"match",
"(",
"\"^\"",
"+",
"key",
"+",
"comment",
"+",
"\"$\"",
",",
"line",
")",
"if",
"key_only_match",
":",
"key",
"=",
"key_only_match",
".",
"group",
"(",
"\"key\"",
")",
"items",
"[",
"key",
"]",
"=",
"\"true\"",
"continue",
"key_value_match",
"=",
"re",
".",
"match",
"(",
"\"^\"",
"+",
"key",
"+",
"value",
"+",
"comment",
"+",
"\"$\"",
",",
"line",
")",
"if",
"key_value_match",
":",
"key",
"=",
"key_value_match",
".",
"group",
"(",
"\"key\"",
")",
"value",
"=",
"key_value_match",
".",
"group",
"(",
"\"value\"",
")",
"if",
"value",
".",
"startswith",
"(",
"\"[\"",
")",
"and",
"value",
".",
"endswith",
"(",
"\"]\"",
")",
":",
"# handle special case of lists",
"value",
"=",
"[",
"elem",
".",
"strip",
"(",
")",
"for",
"elem",
"in",
"value",
"[",
"1",
":",
"-",
"1",
"]",
".",
"split",
"(",
"\",\"",
")",
"]",
"items",
"[",
"key",
"]",
"=",
"value",
"continue",
"raise",
"ConfigFileParserException",
"(",
"\"Unexpected line %s in %s: %s\"",
"%",
"(",
"i",
",",
"getattr",
"(",
"stream",
",",
"'name'",
",",
"'stream'",
")",
",",
"line",
")",
")",
"return",
"items"
] |
Parses the keys + values from a config file.
|
[
"Parses",
"the",
"keys",
"+",
"values",
"from",
"a",
"config",
"file",
"."
] |
8bbc7de67f884184068d62af7f78e723d01c0081
|
https://github.com/bw2/ConfigArgParse/blob/8bbc7de67f884184068d62af7f78e723d01c0081/configargparse.py#L146-L179
|
13,191
|
bw2/ConfigArgParse
|
configargparse.py
|
YAMLConfigFileParser.parse
|
def parse(self, stream):
"""Parses the keys and values from a config file."""
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 "
"contain 'key: value' pairs (aka. a YAML mapping). "
"yaml.load('%s') returned type '%s' instead of 'dict'." % (
getattr(stream, 'name', 'stream'), type(parsed_obj).__name__))
result = OrderedDict()
for key, value in parsed_obj.items():
if isinstance(value, list):
result[key] = value
else:
result[key] = str(value)
return result
|
python
|
def parse(self, stream):
"""Parses the keys and values from a config file."""
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 "
"contain 'key: value' pairs (aka. a YAML mapping). "
"yaml.load('%s') returned type '%s' instead of 'dict'." % (
getattr(stream, 'name', 'stream'), type(parsed_obj).__name__))
result = OrderedDict()
for key, value in parsed_obj.items():
if isinstance(value, list):
result[key] = value
else:
result[key] = str(value)
return result
|
[
"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 \"",
"\"contain 'key: value' pairs (aka. a YAML mapping). \"",
"\"yaml.load('%s') returned type '%s' instead of 'dict'.\"",
"%",
"(",
"getattr",
"(",
"stream",
",",
"'name'",
",",
"'stream'",
")",
",",
"type",
"(",
"parsed_obj",
")",
".",
"__name__",
")",
")",
"result",
"=",
"OrderedDict",
"(",
")",
"for",
"key",
",",
"value",
"in",
"parsed_obj",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"list",
")",
":",
"result",
"[",
"key",
"]",
"=",
"value",
"else",
":",
"result",
"[",
"key",
"]",
"=",
"str",
"(",
"value",
")",
"return",
"result"
] |
Parses the keys and values from a config file.
|
[
"Parses",
"the",
"keys",
"and",
"values",
"from",
"a",
"config",
"file",
"."
] |
8bbc7de67f884184068d62af7f78e723d01c0081
|
https://github.com/bw2/ConfigArgParse/blob/8bbc7de67f884184068d62af7f78e723d01c0081/configargparse.py#L215-L237
|
13,192
|
bw2/ConfigArgParse
|
configargparse.py
|
ArgumentParser.write_config_file
|
def write_config_file(self, parsed_namespace, output_file_paths, exit_after=False):
"""Write the given settings to output files.
Args:
parsed_namespace: namespace object created within parse_known_args()
output_file_paths: any number of file paths to write the config to
exit_after: whether to exit the program after writing the config files
"""
for output_file_path in output_file_paths:
# validate the output file path
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_file_paths:
# generate the config file contents
config_items = self.get_items_for_config_file_output(
self._source_to_settings, parsed_namespace)
file_contents = self._config_file_parser.serialize(config_items)
for output_file_path in output_file_paths:
with open(output_file_path, "w") as output_file:
output_file.write(file_contents)
message = "Wrote config file to " + ", ".join(output_file_paths)
if exit_after:
self.exit(0, message)
else:
print(message)
|
python
|
def write_config_file(self, parsed_namespace, output_file_paths, exit_after=False):
"""Write the given settings to output files.
Args:
parsed_namespace: namespace object created within parse_known_args()
output_file_paths: any number of file paths to write the config to
exit_after: whether to exit the program after writing the config files
"""
for output_file_path in output_file_paths:
# validate the output file path
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_file_paths:
# generate the config file contents
config_items = self.get_items_for_config_file_output(
self._source_to_settings, parsed_namespace)
file_contents = self._config_file_parser.serialize(config_items)
for output_file_path in output_file_paths:
with open(output_file_path, "w") as output_file:
output_file.write(file_contents)
message = "Wrote config file to " + ", ".join(output_file_paths)
if exit_after:
self.exit(0, message)
else:
print(message)
|
[
"def",
"write_config_file",
"(",
"self",
",",
"parsed_namespace",
",",
"output_file_paths",
",",
"exit_after",
"=",
"False",
")",
":",
"for",
"output_file_path",
"in",
"output_file_paths",
":",
"# validate the output file path",
"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_file_paths",
":",
"# generate the config file contents",
"config_items",
"=",
"self",
".",
"get_items_for_config_file_output",
"(",
"self",
".",
"_source_to_settings",
",",
"parsed_namespace",
")",
"file_contents",
"=",
"self",
".",
"_config_file_parser",
".",
"serialize",
"(",
"config_items",
")",
"for",
"output_file_path",
"in",
"output_file_paths",
":",
"with",
"open",
"(",
"output_file_path",
",",
"\"w\"",
")",
"as",
"output_file",
":",
"output_file",
".",
"write",
"(",
"file_contents",
")",
"message",
"=",
"\"Wrote config file to \"",
"+",
"\", \"",
".",
"join",
"(",
"output_file_paths",
")",
"if",
"exit_after",
":",
"self",
".",
"exit",
"(",
"0",
",",
"message",
")",
"else",
":",
"print",
"(",
"message",
")"
] |
Write the given settings to output files.
Args:
parsed_namespace: namespace object created within parse_known_args()
output_file_paths: any number of file paths to write the config to
exit_after: whether to exit the program after writing the config files
|
[
"Write",
"the",
"given",
"settings",
"to",
"output",
"files",
"."
] |
8bbc7de67f884184068d62af7f78e723d01c0081
|
https://github.com/bw2/ConfigArgParse/blob/8bbc7de67f884184068d62af7f78e723d01c0081/configargparse.py#L542-L570
|
13,193
|
bw2/ConfigArgParse
|
configargparse.py
|
ArgumentParser.convert_item_to_command_line_arg
|
def convert_item_to_command_line_arg(self, action, key, value):
"""Converts a config file or env var key + value to a list of
commandline args to append to the commandline.
Args:
action: The argparse Action object for this setting, or None if this
config file setting doesn't correspond to any defined
configargparse arg.
key: string (config file key or env var name)
value: parsed value of type string or list
"""
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]
# handle boolean value
if action is not None and isinstance(action, ACTION_TYPES_THAT_DONT_NEED_A_VALUE):
if value.lower() in ("true", "yes", "1"):
args.append( command_line_key )
elif value.lower() in ("false", "no", "0"):
# don't append when set to "false" / "no"
pass
else:
self.error("Unexpected value for %s: '%s'. Expecting 'true', "
"'false', 'yes', 'no', '1' or '0'" % (key, value))
elif isinstance(value, list):
if action is None or isinstance(action, argparse._AppendAction):
for list_elem in value:
args.append( command_line_key )
args.append( str(list_elem) )
elif (isinstance(action, argparse._StoreAction) and action.nargs in ('+', '*')) or (
isinstance(action.nargs, int) and action.nargs > 1):
args.append( command_line_key )
for list_elem in value:
args.append( str(list_elem) )
else:
self.error(("%s can't be set to a list '%s' unless its action type is changed "
"to 'append' or nargs is set to '*', '+', or > 1") % (key, value))
elif isinstance(value, str):
args.append( command_line_key )
args.append( value )
else:
raise ValueError("Unexpected value type %s for value: %s" % (
type(value), value))
return args
|
python
|
def convert_item_to_command_line_arg(self, action, key, value):
"""Converts a config file or env var key + value to a list of
commandline args to append to the commandline.
Args:
action: The argparse Action object for this setting, or None if this
config file setting doesn't correspond to any defined
configargparse arg.
key: string (config file key or env var name)
value: parsed value of type string or list
"""
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]
# handle boolean value
if action is not None and isinstance(action, ACTION_TYPES_THAT_DONT_NEED_A_VALUE):
if value.lower() in ("true", "yes", "1"):
args.append( command_line_key )
elif value.lower() in ("false", "no", "0"):
# don't append when set to "false" / "no"
pass
else:
self.error("Unexpected value for %s: '%s'. Expecting 'true', "
"'false', 'yes', 'no', '1' or '0'" % (key, value))
elif isinstance(value, list):
if action is None or isinstance(action, argparse._AppendAction):
for list_elem in value:
args.append( command_line_key )
args.append( str(list_elem) )
elif (isinstance(action, argparse._StoreAction) and action.nargs in ('+', '*')) or (
isinstance(action.nargs, int) and action.nargs > 1):
args.append( command_line_key )
for list_elem in value:
args.append( str(list_elem) )
else:
self.error(("%s can't be set to a list '%s' unless its action type is changed "
"to 'append' or nargs is set to '*', '+', or > 1") % (key, value))
elif isinstance(value, str):
args.append( command_line_key )
args.append( value )
else:
raise ValueError("Unexpected value type %s for value: %s" % (
type(value), value))
return args
|
[
"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",
"]",
"# handle boolean value",
"if",
"action",
"is",
"not",
"None",
"and",
"isinstance",
"(",
"action",
",",
"ACTION_TYPES_THAT_DONT_NEED_A_VALUE",
")",
":",
"if",
"value",
".",
"lower",
"(",
")",
"in",
"(",
"\"true\"",
",",
"\"yes\"",
",",
"\"1\"",
")",
":",
"args",
".",
"append",
"(",
"command_line_key",
")",
"elif",
"value",
".",
"lower",
"(",
")",
"in",
"(",
"\"false\"",
",",
"\"no\"",
",",
"\"0\"",
")",
":",
"# don't append when set to \"false\" / \"no\"",
"pass",
"else",
":",
"self",
".",
"error",
"(",
"\"Unexpected value for %s: '%s'. Expecting 'true', \"",
"\"'false', 'yes', 'no', '1' or '0'\"",
"%",
"(",
"key",
",",
"value",
")",
")",
"elif",
"isinstance",
"(",
"value",
",",
"list",
")",
":",
"if",
"action",
"is",
"None",
"or",
"isinstance",
"(",
"action",
",",
"argparse",
".",
"_AppendAction",
")",
":",
"for",
"list_elem",
"in",
"value",
":",
"args",
".",
"append",
"(",
"command_line_key",
")",
"args",
".",
"append",
"(",
"str",
"(",
"list_elem",
")",
")",
"elif",
"(",
"isinstance",
"(",
"action",
",",
"argparse",
".",
"_StoreAction",
")",
"and",
"action",
".",
"nargs",
"in",
"(",
"'+'",
",",
"'*'",
")",
")",
"or",
"(",
"isinstance",
"(",
"action",
".",
"nargs",
",",
"int",
")",
"and",
"action",
".",
"nargs",
">",
"1",
")",
":",
"args",
".",
"append",
"(",
"command_line_key",
")",
"for",
"list_elem",
"in",
"value",
":",
"args",
".",
"append",
"(",
"str",
"(",
"list_elem",
")",
")",
"else",
":",
"self",
".",
"error",
"(",
"(",
"\"%s can't be set to a list '%s' unless its action type is changed \"",
"\"to 'append' or nargs is set to '*', '+', or > 1\"",
")",
"%",
"(",
"key",
",",
"value",
")",
")",
"elif",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"args",
".",
"append",
"(",
"command_line_key",
")",
"args",
".",
"append",
"(",
"value",
")",
"else",
":",
"raise",
"ValueError",
"(",
"\"Unexpected value type %s for value: %s\"",
"%",
"(",
"type",
"(",
"value",
")",
",",
"value",
")",
")",
"return",
"args"
] |
Converts a config file or env var key + value to a list of
commandline args to append to the commandline.
Args:
action: The argparse Action object for this setting, or None if this
config file setting doesn't correspond to any defined
configargparse arg.
key: string (config file key or env var name)
value: parsed value of type string or list
|
[
"Converts",
"a",
"config",
"file",
"or",
"env",
"var",
"key",
"+",
"value",
"to",
"a",
"list",
"of",
"commandline",
"args",
"to",
"append",
"to",
"the",
"commandline",
"."
] |
8bbc7de67f884184068d62af7f78e723d01c0081
|
https://github.com/bw2/ConfigArgParse/blob/8bbc7de67f884184068d62af7f78e723d01c0081/configargparse.py#L632-L681
|
13,194
|
bw2/ConfigArgParse
|
configargparse.py
|
ArgumentParser.get_possible_config_keys
|
def get_possible_config_keys(self, action):
"""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.
"""
keys = []
# Do not write out the config options for writing out a config file
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] # eg. for '--bla' return ['bla', '--bla']
return keys
|
python
|
def get_possible_config_keys(self, action):
"""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.
"""
keys = []
# Do not write out the config options for writing out a config file
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] # eg. for '--bla' return ['bla', '--bla']
return keys
|
[
"def",
"get_possible_config_keys",
"(",
"self",
",",
"action",
")",
":",
"keys",
"=",
"[",
"]",
"# Do not write out the config options for writing out a config file",
"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",
"]",
"# eg. for '--bla' return ['bla', '--bla']",
"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.
|
[
"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",
"."
] |
8bbc7de67f884184068d62af7f78e723d01c0081
|
https://github.com/bw2/ConfigArgParse/blob/8bbc7de67f884184068d62af7f78e723d01c0081/configargparse.py#L683-L698
|
13,195
|
ihucos/plash
|
opt/plash/lib/py/plash/eval.py
|
eval
|
def eval(lisp):
'''
plash lisp is one dimensional 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 list of list of strings. not a list of strings: {}'
.format(item))
name = item[0]
args = item[1:]
try:
macro = state['macros'][name]
except KeyError:
raise MacroNotFoundError("macro {} not found".format(repr(name)))
try:
res = macro(*args)
except Exception as exc:
if os.getenv('PLASH_DEBUG', '').lower() in ('1', 'yes', 'true'):
raise
if isinstance(exc, MacroError):
# only raise that one time and don't have multiple wrapped MacroError
raise
raise MacroError(macro, name, sys.exc_info())
if not isinstance(res, str) and res is not None:
raise EvalError(
'eval macro must return string or None ({} returned {})'.
format(name, type(res)))
if res is not None:
macro_values.append(res)
return '\n'.join(macro_values)
|
python
|
def eval(lisp):
'''
plash lisp is one dimensional 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 list of list of strings. not a list of strings: {}'
.format(item))
name = item[0]
args = item[1:]
try:
macro = state['macros'][name]
except KeyError:
raise MacroNotFoundError("macro {} not found".format(repr(name)))
try:
res = macro(*args)
except Exception as exc:
if os.getenv('PLASH_DEBUG', '').lower() in ('1', 'yes', 'true'):
raise
if isinstance(exc, MacroError):
# only raise that one time and don't have multiple wrapped MacroError
raise
raise MacroError(macro, name, sys.exc_info())
if not isinstance(res, str) and res is not None:
raise EvalError(
'eval macro must return string or None ({} returned {})'.
format(name, type(res)))
if res is not None:
macro_values.append(res)
return '\n'.join(macro_values)
|
[
"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 list of list of strings. not a list of strings: {}'",
".",
"format",
"(",
"item",
")",
")",
"name",
"=",
"item",
"[",
"0",
"]",
"args",
"=",
"item",
"[",
"1",
":",
"]",
"try",
":",
"macro",
"=",
"state",
"[",
"'macros'",
"]",
"[",
"name",
"]",
"except",
"KeyError",
":",
"raise",
"MacroNotFoundError",
"(",
"\"macro {} not found\"",
".",
"format",
"(",
"repr",
"(",
"name",
")",
")",
")",
"try",
":",
"res",
"=",
"macro",
"(",
"*",
"args",
")",
"except",
"Exception",
"as",
"exc",
":",
"if",
"os",
".",
"getenv",
"(",
"'PLASH_DEBUG'",
",",
"''",
")",
".",
"lower",
"(",
")",
"in",
"(",
"'1'",
",",
"'yes'",
",",
"'true'",
")",
":",
"raise",
"if",
"isinstance",
"(",
"exc",
",",
"MacroError",
")",
":",
"# only raise that one time and don't have multiple wrapped MacroError",
"raise",
"raise",
"MacroError",
"(",
"macro",
",",
"name",
",",
"sys",
".",
"exc_info",
"(",
")",
")",
"if",
"not",
"isinstance",
"(",
"res",
",",
"str",
")",
"and",
"res",
"is",
"not",
"None",
":",
"raise",
"EvalError",
"(",
"'eval macro must return string or None ({} returned {})'",
".",
"format",
"(",
"name",
",",
"type",
"(",
"res",
")",
")",
")",
"if",
"res",
"is",
"not",
"None",
":",
"macro_values",
".",
"append",
"(",
"res",
")",
"return",
"'\\n'",
".",
"join",
"(",
"macro_values",
")"
] |
plash lisp is one dimensional lisp.
|
[
"plash",
"lisp",
"is",
"one",
"dimensional",
"lisp",
"."
] |
2ab2bc956e309d5aa6414c80983bfbf29b0ce572
|
https://github.com/ihucos/plash/blob/2ab2bc956e309d5aa6414c80983bfbf29b0ce572/opt/plash/lib/py/plash/eval.py#L62-L97
|
13,196
|
ihucos/plash
|
opt/plash/lib/py/plash/utils.py
|
plash_map
|
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')
|
python
|
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')
|
[
"def",
"plash_map",
"(",
"*",
"args",
")",
":",
"from",
"subprocess",
"import",
"check_output",
"out",
"=",
"check_output",
"(",
"[",
"'plash'",
",",
"'map'",
"]",
"+",
"list",
"(",
"args",
")",
")",
"if",
"out",
"==",
"''",
":",
"return",
"None",
"return",
"out",
".",
"decode",
"(",
")",
".",
"strip",
"(",
"'\\n'",
")"
] |
thin wrapper around plash map
|
[
"thin",
"wrapper",
"around",
"plash",
"map"
] |
2ab2bc956e309d5aa6414c80983bfbf29b0ce572
|
https://github.com/ihucos/plash/blob/2ab2bc956e309d5aa6414c80983bfbf29b0ce572/opt/plash/lib/py/plash/utils.py#L96-L102
|
13,197
|
ihucos/plash
|
opt/plash/lib/py/plash/macros/packagemanagers.py
|
defpm
|
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]
return eval([['run'] + expanded_lines])
package_manager.__doc__ = "install packages with {}".format(name)
|
python
|
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]
return eval([['run'] + expanded_lines])
package_manager.__doc__ = "install packages with {}".format(name)
|
[
"def",
"defpm",
"(",
"name",
",",
"*",
"lines",
")",
":",
"@",
"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",
"]",
"return",
"eval",
"(",
"[",
"[",
"'run'",
"]",
"+",
"expanded_lines",
"]",
")",
"package_manager",
".",
"__doc__",
"=",
"\"install packages with {}\"",
".",
"format",
"(",
"name",
")"
] |
define a new package manager
|
[
"define",
"a",
"new",
"package",
"manager"
] |
2ab2bc956e309d5aa6414c80983bfbf29b0ce572
|
https://github.com/ihucos/plash/blob/2ab2bc956e309d5aa6414c80983bfbf29b0ce572/opt/plash/lib/py/plash/macros/packagemanagers.py#L5-L17
|
13,198
|
ihucos/plash
|
opt/plash/lib/py/plash/macros/common.py
|
layer
|
def layer(command=None, *args):
'hints the start of a new layer'
if not command:
return eval([['hint', 'layer']]) # fall back to buildin layer macro
else:
lst = [['layer']]
for arg in args:
lst.append([command, arg])
lst.append(['layer'])
return eval(lst)
|
python
|
def layer(command=None, *args):
'hints the start of a new layer'
if not command:
return eval([['hint', 'layer']]) # fall back to buildin layer macro
else:
lst = [['layer']]
for arg in args:
lst.append([command, arg])
lst.append(['layer'])
return eval(lst)
|
[
"def",
"layer",
"(",
"command",
"=",
"None",
",",
"*",
"args",
")",
":",
"if",
"not",
"command",
":",
"return",
"eval",
"(",
"[",
"[",
"'hint'",
",",
"'layer'",
"]",
"]",
")",
"# fall back to buildin layer macro",
"else",
":",
"lst",
"=",
"[",
"[",
"'layer'",
"]",
"]",
"for",
"arg",
"in",
"args",
":",
"lst",
".",
"append",
"(",
"[",
"command",
",",
"arg",
"]",
")",
"lst",
".",
"append",
"(",
"[",
"'layer'",
"]",
")",
"return",
"eval",
"(",
"lst",
")"
] |
hints the start of a new layer
|
[
"hints",
"the",
"start",
"of",
"a",
"new",
"layer"
] |
2ab2bc956e309d5aa6414c80983bfbf29b0ce572
|
https://github.com/ihucos/plash/blob/2ab2bc956e309d5aa6414c80983bfbf29b0ce572/opt/plash/lib/py/plash/macros/common.py#L15-L24
|
13,199
|
ihucos/plash
|
opt/plash/lib/py/plash/macros/common.py
|
import_env
|
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))
|
python
|
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))
|
[
"def",
"import_env",
"(",
"*",
"envs",
")",
":",
"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
|
[
"import",
"environment",
"variables",
"from",
"host"
] |
2ab2bc956e309d5aa6414c80983bfbf29b0ce572
|
https://github.com/ihucos/plash/blob/2ab2bc956e309d5aa6414c80983bfbf29b0ce572/opt/plash/lib/py/plash/macros/common.py#L40-L50
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.