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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
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... | 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... | [
"def",
"searchDiagrams",
"(",
"self",
",",
"whereClause",
"=",
"None",
",",
"relatedObjects",
"=",
"None",
",",
"relatedSchematicObjects",
"=",
"None",
")",
":",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
"}",
"if",
"whereClause",
":",
"params",
"[",
"\... | 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... | [
"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 | train |
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 part... | 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 part... | [
"def",
"_validateurl",
"(",
"self",
",",
"url",
")",
":",
"parsed",
"=",
"urlparse",
"(",
"url",
")",
"path",
"=",
"parsed",
".",
"path",
".",
"strip",
"(",
"\"/\"",
")",
"if",
"path",
":",
"parts",
"=",
"path",
".",
"split",
"(",
"\"/\"",
")",
"... | assembles the server url | [
"assembles",
"the",
"server",
"url"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/server.py#L57-L74 | train |
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,
... | 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,
... | [
"def",
"admin",
"(",
"self",
")",
":",
"if",
"self",
".",
"_securityHandler",
"is",
"None",
":",
"raise",
"Exception",
"(",
"\"Cannot connect to adminstrative server without authentication\"",
")",
"from",
".",
".",
"manageags",
"import",
"AGSAdministration",
"return"... | 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 | train |
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,
... | 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,
... | [
"def",
"addUser",
"(",
"self",
",",
"username",
",",
"password",
",",
"firstname",
",",
"lastname",
",",
"email",
",",
"role",
")",
":",
"self",
".",
"_invites",
".",
"append",
"(",
"{",
"\"username\"",
":",
"username",
",",
"\"password\"",
":",
"passwor... | 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 | train |
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 | train |
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("In... | 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("In... | [
"def",
"fromDictionary",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"pp",
"=",
"PortalParameters",
"(",
")",
"for",
"k",
",",
"v",
"in",
"value",
".",
"items",
"(",
")",
":",
"setattr",
"(",
"pp",
",",
"\"_%s\"... | 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 | train |
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",
"]",... | 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 | train |
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,
... | 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,
... | [
"def",
"tile_fonts",
"(",
"self",
",",
"fontstack",
",",
"stack_range",
",",
"out_folder",
"=",
"None",
")",
":",
"url",
"=",
"\"{url}/resources/fonts/{fontstack}/{stack_range}.pbf\"",
".",
"format",
"(",
"url",
"=",
"self",
".",
"_url",
",",
"fontstack",
"=",
... | 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 | train |
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:
... | 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:
... | [
"def",
"tile_sprite",
"(",
"self",
",",
"out_format",
"=",
"\"sprite.json\"",
",",
"out_folder",
"=",
"None",
")",
":",
"url",
"=",
"\"{url}/resources/sprites/{f}\"",
".",
"format",
"(",
"url",
"=",
"self",
".",
"_url",
",",
"f",
"=",
"out_format",
")",
"i... | 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 | train |
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 | train |
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,
... | 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,
... | [
"def",
"_getLayers",
"(",
"self",
")",
":",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
"}",
"json_dict",
"=",
"self",
".",
"_get",
"(",
"self",
".",
"_url",
",",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"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 | train |
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
... | python | def query(self,
layerDefsFilter=None,
geometryFilter=None,
timeFilter=None,
returnGeometry=True,
returnIdsOnly=False,
returnCountOnly=False,
returnZ=False,
returnM=False,
outSR=None
... | [
"def",
"query",
"(",
"self",
",",
"layerDefsFilter",
"=",
"None",
",",
"geometryFilter",
"=",
"None",
",",
"timeFilter",
"=",
"None",
",",
"returnGeometry",
"=",
"True",
",",
"returnIdsOnly",
"=",
"False",
",",
"returnCountOnly",
"=",
"False",
",",
"returnZ"... | 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 | train |
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,
... | 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,
... | [
"def",
"create_feature_layer",
"(",
"ds",
",",
"sql",
",",
"name",
"=",
"\"layer\"",
")",
":",
"if",
"arcpyFound",
"==",
"False",
":",
"raise",
"Exception",
"(",
"\"ArcPy is required to use this function\"",
")",
"result",
"=",
"arcpy",
".",
"MakeFeatureLayer_mana... | 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 | train |
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:
... | 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:
... | [
"def",
"featureclass_to_json",
"(",
"fc",
")",
":",
"if",
"arcpyFound",
"==",
"False",
":",
"raise",
"Exception",
"(",
"\"ArcPy is required to use this function\"",
")",
"desc",
"=",
"arcpy",
".",
"Describe",
"(",
"fc",
")",
"if",
"desc",
".",
"dataType",
"=="... | 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 | train |
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:
... | 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:
... | [
"def",
"get_attachment_data",
"(",
"attachmentTable",
",",
"sql",
",",
"nameField",
"=",
"\"ATT_NAME\"",
",",
"blobField",
"=",
"\"DATA\"",
",",
"contentTypeField",
"=",
"\"CONTENT_TYPE\"",
",",
"rel_object_field",
"=",
"\"REL_OBJECTID\"",
")",
":",
"if",
"arcpyFoun... | 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 | train |
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,
... | 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,
... | [
"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",
"=",
"[",
"]",
"wi... | 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 | train |
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",
":",
"retur... | 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 | train |
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:
... | 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:
... | [
"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",
... | 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 | train |
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 inclu... | 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 inclu... | [
"def",
"insert_rows",
"(",
"fc",
",",
"features",
",",
"fields",
",",
"includeOIDField",
"=",
"False",
",",
"oidField",
"=",
"None",
")",
":",
"if",
"arcpyFound",
"==",
"False",
":",
"raise",
"Exception",
"(",
"\"ArcPy is required to use this function\"",
")",
... | 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 | train |
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 Except... | 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 Except... | [
"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\"",
")",
"ar... | 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 | train |
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.e... | 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.e... | [
"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",
".... | 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 | train |
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)
se... | 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)
se... | [
"def",
"handler",
"(",
"self",
")",
":",
"if",
"hasNTLM",
":",
"if",
"self",
".",
"_handler",
"is",
"None",
":",
"passman",
"=",
"request",
".",
"HTTPPasswordMgrWithDefaultRealm",
"(",
")",
"passman",
".",
"add_password",
"(",
"None",
",",
"self",
".",
"... | 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 | train |
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 | train |
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,
... | 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,
... | [
"def",
"token",
"(",
"self",
")",
":",
"if",
"self",
".",
"_token",
"is",
"None",
"or",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
">=",
"self",
".",
"_token_expires_on",
":",
"self",
".",
"_generateForOAuthSecurity",
"(",
"self",
".",
"_client_i... | 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 | train |
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... | 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... | [
"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/oa... | 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 | train |
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 | train |
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=... | 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=... | [
"def",
"__getRefererUrl",
"(",
"self",
",",
"url",
"=",
"None",
")",
":",
"if",
"url",
"is",
"None",
":",
"url",
"=",
"\"http://www.arcgis.com/sharing/rest/portals/self\"",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
",",
"\"token\"",
":",
"self",
".",
"to... | 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 | train |
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... | 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... | [
"def",
"servertoken",
"(",
"self",
",",
"serverURL",
",",
"referer",
")",
":",
"if",
"self",
".",
"_server_token",
"is",
"None",
"or",
"self",
".",
"_server_token_expires_on",
"is",
"None",
"or",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
">=",
"... | 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 | train |
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,
... | 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,
... | [
"def",
"exportCertificate",
"(",
"self",
",",
"certificate",
",",
"folder",
")",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/sslcertificates/%s/export\"",
"%",
"certificate",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
",",
"}",
"return",
"self",
".",
... | 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 | train |
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 | train |
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_ur... | 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_ur... | [
"def",
"portals",
"(",
"self",
")",
":",
"url",
"=",
"\"%s/portals\"",
"%",
"self",
".",
"root",
"return",
"_portals",
".",
"Portals",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".... | 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 | train |
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,
... | 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,
... | [
"def",
"oauth2",
"(",
"self",
")",
":",
"if",
"self",
".",
"_url",
".",
"endswith",
"(",
"\"/oauth2\"",
")",
":",
"url",
"=",
"self",
".",
"_url",
"else",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/oauth2\"",
"return",
"_oauth2",
".",
"oauth2",
... | returns the oauth2 class | [
"returns",
"the",
"oauth2",
"class"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/administration.py#L135-L146 | train |
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._p... | 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._p... | [
"def",
"community",
"(",
"self",
")",
":",
"return",
"_community",
".",
"Community",
"(",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/community\"",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
... | 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 | train |
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_por... | 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_por... | [
"def",
"content",
"(",
"self",
")",
":",
"return",
"_content",
".",
"Content",
"(",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/content\"",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
... | 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 | train |
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 porta... | 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 porta... | [
"def",
"search",
"(",
"self",
",",
"q",
",",
"t",
"=",
"None",
",",
"focus",
"=",
"None",
",",
"bbox",
"=",
"None",
",",
"start",
"=",
"1",
",",
"num",
"=",
"10",
",",
"sortField",
"=",
"None",
",",
"sortOrder",
"=",
"\"asc\"",
",",
"useSecurity"... | 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 updat... | [
"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",
".",
"Se... | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/administration.py#L167-L263 | train |
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.portalSel... | 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.portalSel... | [
"def",
"hostingServers",
"(",
"self",
")",
":",
"portals",
"=",
"self",
".",
"portals",
"portal",
"=",
"portals",
".",
"portalSelf",
"urls",
"=",
"portal",
".",
"urls",
"if",
"'error'",
"in",
"urls",
":",
"print",
"(",
"urls",
")",
"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... | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/administration.py#L267-L341 | train |
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",
... | 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 | train |
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... | 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... | [
"def",
"__init",
"(",
"self",
")",
":",
"res",
"=",
"self",
".",
"_get",
"(",
"url",
"=",
"self",
".",
"_url",
",",
"param_dict",
"=",
"{",
"\"f\"",
":",
"\"json\"",
"}",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
... | loads the json values | [
"loads",
"the",
"json",
"values"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/geometryservice/geometryservice.py#L33-L43 | train |
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 operatio... | python | def areasAndLengths(self,
polygons,
lengthUnit,
areaUnit,
calculationType,
):
"""
The areasAndLengths operation is performed on a geometry service
resource. This operatio... | [
"def",
"areasAndLengths",
"(",
"self",
",",
"polygons",
",",
"lengthUnit",
",",
"areaUnit",
",",
"calculationType",
",",
")",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/areasAndLengths\"",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
",",
"\"lengthUnit\... | 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... | [
"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 | train |
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
"""
... | 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
"""
... | [
"def",
"__geometryToGeomTemplate",
"(",
"self",
",",
"geometry",
")",
":",
"template",
"=",
"{",
"\"geometryType\"",
":",
"None",
",",
"\"geometry\"",
":",
"None",
"}",
"if",
"isinstance",
"(",
"geometry",
",",
"Polyline",
")",
":",
"template",
"[",
"'geomet... | 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 | train |
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):
lis... | 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):
lis... | [
"def",
"__geomToStringArray",
"(",
"self",
",",
"geometries",
",",
"returnType",
"=",
"\"str\"",
")",
":",
"listGeoms",
"=",
"[",
"]",
"for",
"g",
"in",
"geometries",
":",
"if",
"isinstance",
"(",
"g",
",",
"Point",
")",
":",
"listGeoms",
".",
"append",
... | 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 | train |
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 ... | 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 ... | [
"def",
"autoComplete",
"(",
"self",
",",
"polygons",
"=",
"[",
"]",
",",
"polylines",
"=",
"[",
"]",
",",
"sr",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/autoComplete\"",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
"}",
"if... | 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.
... | [
"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",
"p... | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/geometryservice/geometryservice.py#L222-L247 | train |
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 geometr... | python | def buffer(self,
geometries,
inSR,
distances,
units,
outSR=None,
bufferSR=None,
unionResults=True,
geodesic=True
):
"""
The buffer operation is performed on a geometr... | [
"def",
"buffer",
"(",
"self",
",",
"geometries",
",",
"inSR",
",",
"distances",
",",
"units",
",",
"outSR",
"=",
"None",
",",
"bufferSR",
"=",
"None",
",",
"unionResults",
"=",
"True",
",",
"geodesic",
"=",
"True",
")",
":",
"url",
"=",
"self",
".",
... | 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 - ... | [
"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",
".",
"Op... | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/geometryservice/geometryservice.py#L249-L313 | train |
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 fr... | 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 fr... | [
"def",
"findTransformation",
"(",
"self",
",",
"inSR",
",",
"outSR",
",",
"extentOfInterest",
"=",
"None",
",",
"numOfResults",
"=",
"1",
")",
":",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
",",
"\"inSR\"",
":",
"inSR",
",",
"\"outSR\"",
":",
"outSR"... | 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 JSO... | [
"The",
"findTransformations",
"operation",
"is",
"performed",
"on",
"a",
"geometry",
"service",
"resource",
".",
"This",
"operation",
"returns",
"a",
"list",
"of",
"applicable",
"geographic",
"transformations",
"you",
"should",
"use",
"when",
"projecting",
"geometri... | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/geometryservice/geometryservice.py#L551-L598 | train |
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 t... | 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 t... | [
"def",
"fromGeoCoordinateString",
"(",
"self",
",",
"sr",
",",
"strings",
",",
"conversionType",
",",
"conversionMode",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/fromGeoCoordinateString\"",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
... | 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 som... | [
"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",
"... | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/geometryservice/geometryservice.py#L600-L658 | train |
Esri/ArcREST | src/arcrest/geometryservice/geometryservice.py | GeometryService.toGeoCoordinateString | def toGeoCoordinateString(self,
sr,
coordinates,
conversionType,
conversionMode="mgrsDefault",
numOfDigits=None,
rounding=True,
... | python | def toGeoCoordinateString(self,
sr,
coordinates,
conversionType,
conversionMode="mgrsDefault",
numOfDigits=None,
rounding=True,
... | [
"def",
"toGeoCoordinateString",
"(",
"self",
",",
"sr",
",",
"coordinates",
",",
"conversionType",
",",
"conversionMode",
"=",
"\"mgrsDefault\"",
",",
"numOfDigits",
"=",
"None",
",",
"rounding",
"=",
"True",
",",
"addSpaces",
"=",
"True",
")",
":",
"params",
... | 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.... | [
"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",
"co... | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/geometryservice/geometryservice.py#L985-L1067 | train |
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... | 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... | [
"def",
"__init_url",
"(",
"self",
")",
":",
"portals_self_url",
"=",
"\"{}/portals/self\"",
".",
"format",
"(",
"self",
".",
"_url",
")",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
"}",
"if",
"not",
"self",
".",
"_securityHandler",
"is",
"None",
":",
... | 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 | train |
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.
... | 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.
... | [
"def",
"get_argument_parser",
"(",
"name",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"\"default\"",
"if",
"len",
"(",
"kwargs",
")",
">",
"0",
"or",
"name",
"not",
"in",
"_parsers",
":",
"init_argum... | 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",
... | 8bbc7de67f884184068d62af7f78e723d01c0081 | https://github.com/bw2/ConfigArgParse/blob/8bbc7de67f884184068d62af7f78e723d01c0081/configargparse.py#L46-L58 | train |
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 =... | 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 =... | [
"def",
"parse",
"(",
"self",
",",
"stream",
")",
":",
"items",
"=",
"OrderedDict",
"(",
")",
"for",
"i",
",",
"line",
"in",
"enumerate",
"(",
"stream",
")",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"if",
"not",
"line",
"or",
"line",
"[",... | 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 | train |
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... | 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... | [
"def",
"parse",
"(",
"self",
",",
"stream",
")",
":",
"yaml",
"=",
"self",
".",
"_load_yaml",
"(",
")",
"try",
":",
"parsed_obj",
"=",
"yaml",
".",
"safe_load",
"(",
"stream",
")",
"except",
"Exception",
"as",
"e",
":",
"raise",
"ConfigFileParserExceptio... | 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 | train |
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
... | 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
... | [
"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",
"(",
"out... | 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 | train |
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... | 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... | [
"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",
"(",
... | 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.
... | [
"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 | train |
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 ... | 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 ... | [
"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",... | 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",
... | 8bbc7de67f884184068d62af7f78e723d01c0081 | https://github.com/bw2/ConfigArgParse/blob/8bbc7de67f884184068d62af7f78e723d01c0081/configargparse.py#L683-L698 | train |
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 n... | 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 n... | [
"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",
"isin... | 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 | train |
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",
"r... | 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 | train |
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_package... | 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_package... | [
"def",
"defpm",
"(",
"name",
",",
"*",
"lines",
")",
":",
"@",
"register_macro",
"(",
"name",
",",
"group",
"=",
"'package managers'",
")",
"@",
"shell_escape_args",
"def",
"package_manager",
"(",
"*",
"packages",
")",
":",
"if",
"not",
"packages",
":",
... | 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 | train |
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(... | 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(... | [
"def",
"layer",
"(",
"command",
"=",
"None",
",",
"*",
"args",
")",
":",
"if",
"not",
"command",
":",
"return",
"eval",
"(",
"[",
"[",
"'hint'",
",",
"'layer'",
"]",
"]",
")",
"# fall back to buildin layer macro",
"else",
":",
"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 | train |
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 '{}=... | 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 '{}=... | [
"def",
"import_env",
"(",
"*",
"envs",
")",
":",
"for",
"env",
"in",
"envs",
":",
"parts",
"=",
"env",
".",
"split",
"(",
"':'",
",",
"1",
")",
"if",
"len",
"(",
"parts",
")",
"==",
"1",
":",
"export_as",
"=",
"env",
"else",
":",
"env",
",",
... | 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 | train |
ihucos/plash | opt/plash/lib/py/plash/macros/common.py | write_file | def write_file(fname, *lines):
'write lines to a file'
yield 'touch {}'.format(fname)
for line in lines:
yield "echo {} >> {}".format(line, fname) | python | def write_file(fname, *lines):
'write lines to a file'
yield 'touch {}'.format(fname)
for line in lines:
yield "echo {} >> {}".format(line, fname) | [
"def",
"write_file",
"(",
"fname",
",",
"*",
"lines",
")",
":",
"yield",
"'touch {}'",
".",
"format",
"(",
"fname",
")",
"for",
"line",
"in",
"lines",
":",
"yield",
"\"echo {} >> {}\"",
".",
"format",
"(",
"line",
",",
"fname",
")"
] | write lines to a file | [
"write",
"lines",
"to",
"a",
"file"
] | 2ab2bc956e309d5aa6414c80983bfbf29b0ce572 | https://github.com/ihucos/plash/blob/2ab2bc956e309d5aa6414c80983bfbf29b0ce572/opt/plash/lib/py/plash/macros/common.py#L62-L66 | train |
ihucos/plash | opt/plash/lib/py/plash/macros/common.py | eval_file | def eval_file(file):
'evaluate file content as expressions'
fname = os.path.realpath(os.path.expanduser(file))
with open(fname) as f:
inscript = f.read()
sh = run_write_read(['plash', 'eval'], inscript.encode()).decode()
# we remove an possibly existing newline
# because else this mac... | python | def eval_file(file):
'evaluate file content as expressions'
fname = os.path.realpath(os.path.expanduser(file))
with open(fname) as f:
inscript = f.read()
sh = run_write_read(['plash', 'eval'], inscript.encode()).decode()
# we remove an possibly existing newline
# because else this mac... | [
"def",
"eval_file",
"(",
"file",
")",
":",
"fname",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"file",
")",
")",
"with",
"open",
"(",
"fname",
")",
"as",
"f",
":",
"inscript",
"=",
"f",
".",
"read",
... | evaluate file content as expressions | [
"evaluate",
"file",
"content",
"as",
"expressions"
] | 2ab2bc956e309d5aa6414c80983bfbf29b0ce572 | https://github.com/ihucos/plash/blob/2ab2bc956e309d5aa6414c80983bfbf29b0ce572/opt/plash/lib/py/plash/macros/common.py#L78-L92 | train |
ihucos/plash | opt/plash/lib/py/plash/macros/common.py | eval_string | def eval_string(stri):
'evaluate expressions passed as string'
tokens = shlex.split(stri)
return run_write_read(['plash', 'eval'], '\n'.join(tokens).encode()).decode() | python | def eval_string(stri):
'evaluate expressions passed as string'
tokens = shlex.split(stri)
return run_write_read(['plash', 'eval'], '\n'.join(tokens).encode()).decode() | [
"def",
"eval_string",
"(",
"stri",
")",
":",
"tokens",
"=",
"shlex",
".",
"split",
"(",
"stri",
")",
"return",
"run_write_read",
"(",
"[",
"'plash'",
",",
"'eval'",
"]",
",",
"'\\n'",
".",
"join",
"(",
"tokens",
")",
".",
"encode",
"(",
")",
")",
"... | evaluate expressions passed as string | [
"evaluate",
"expressions",
"passed",
"as",
"string"
] | 2ab2bc956e309d5aa6414c80983bfbf29b0ce572 | https://github.com/ihucos/plash/blob/2ab2bc956e309d5aa6414c80983bfbf29b0ce572/opt/plash/lib/py/plash/macros/common.py#L96-L100 | train |
ihucos/plash | opt/plash/lib/py/plash/macros/common.py | eval_stdin | def eval_stdin():
'evaluate expressions read from stdin'
cmd = ['plash', 'eval']
p = subprocess.Popen(cmd, stdin=sys.stdin, stdout=sys.stdout)
exit = p.wait()
if exit:
raise subprocess.CalledProcessError(exit, cmd) | python | def eval_stdin():
'evaluate expressions read from stdin'
cmd = ['plash', 'eval']
p = subprocess.Popen(cmd, stdin=sys.stdin, stdout=sys.stdout)
exit = p.wait()
if exit:
raise subprocess.CalledProcessError(exit, cmd) | [
"def",
"eval_stdin",
"(",
")",
":",
"cmd",
"=",
"[",
"'plash'",
",",
"'eval'",
"]",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"cmd",
",",
"stdin",
"=",
"sys",
".",
"stdin",
",",
"stdout",
"=",
"sys",
".",
"stdout",
")",
"exit",
"=",
"p",
".",
... | evaluate expressions read from stdin | [
"evaluate",
"expressions",
"read",
"from",
"stdin"
] | 2ab2bc956e309d5aa6414c80983bfbf29b0ce572 | https://github.com/ihucos/plash/blob/2ab2bc956e309d5aa6414c80983bfbf29b0ce572/opt/plash/lib/py/plash/macros/common.py#L104-L110 | train |
ihucos/plash | opt/plash/lib/py/plash/macros/froms.py | from_map | def from_map(map_key):
'use resolved map as image'
image_id = subprocess.check_output(['plash', 'map',
map_key]).decode().strip('\n')
if not image_id:
raise MapDoesNotExist('map {} not found'.format(repr(map_key)))
return hint('image', image_id) | python | def from_map(map_key):
'use resolved map as image'
image_id = subprocess.check_output(['plash', 'map',
map_key]).decode().strip('\n')
if not image_id:
raise MapDoesNotExist('map {} not found'.format(repr(map_key)))
return hint('image', image_id) | [
"def",
"from_map",
"(",
"map_key",
")",
":",
"image_id",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"'plash'",
",",
"'map'",
",",
"map_key",
"]",
")",
".",
"decode",
"(",
")",
".",
"strip",
"(",
"'\\n'",
")",
"if",
"not",
"image_id",
":",
"rai... | use resolved map as image | [
"use",
"resolved",
"map",
"as",
"image"
] | 2ab2bc956e309d5aa6414c80983bfbf29b0ce572 | https://github.com/ihucos/plash/blob/2ab2bc956e309d5aa6414c80983bfbf29b0ce572/opt/plash/lib/py/plash/macros/froms.py#L61-L67 | train |
dbrgn/drf-dynamic-fields | drf_dynamic_fields/__init__.py | DynamicFieldsMixin.fields | def fields(self):
"""
Filters the fields according to the `fields` query parameter.
A blank `fields` parameter (?fields) will remove all fields. Not
passing `fields` will pass all fields individual fields are comma
separated (?fields=id,name,url,email).
"""
fiel... | python | def fields(self):
"""
Filters the fields according to the `fields` query parameter.
A blank `fields` parameter (?fields) will remove all fields. Not
passing `fields` will pass all fields individual fields are comma
separated (?fields=id,name,url,email).
"""
fiel... | [
"def",
"fields",
"(",
"self",
")",
":",
"fields",
"=",
"super",
"(",
"DynamicFieldsMixin",
",",
"self",
")",
".",
"fields",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_context'",
")",
":",
"# We are being called before a request cycle",
"return",
"fields",
"#... | Filters the fields according to the `fields` query parameter.
A blank `fields` parameter (?fields) will remove all fields. Not
passing `fields` will pass all fields individual fields are comma
separated (?fields=id,name,url,email). | [
"Filters",
"the",
"fields",
"according",
"to",
"the",
"fields",
"query",
"parameter",
"."
] | d24da8bc321462ea6231821d6c3d210b76d4785b | https://github.com/dbrgn/drf-dynamic-fields/blob/d24da8bc321462ea6231821d6c3d210b76d4785b/drf_dynamic_fields/__init__.py#L16-L84 | train |
aio-libs/aiohttp_admin | aiohttp_admin/admin.py | setup_admin_on_rest_handlers | def setup_admin_on_rest_handlers(admin, admin_handler):
"""
Initialize routes.
"""
add_route = admin.router.add_route
add_static = admin.router.add_static
static_folder = str(PROJ_ROOT / 'static')
a = admin_handler
add_route('GET', '', a.index_page, name='admin.index')
add_route('PO... | python | def setup_admin_on_rest_handlers(admin, admin_handler):
"""
Initialize routes.
"""
add_route = admin.router.add_route
add_static = admin.router.add_static
static_folder = str(PROJ_ROOT / 'static')
a = admin_handler
add_route('GET', '', a.index_page, name='admin.index')
add_route('PO... | [
"def",
"setup_admin_on_rest_handlers",
"(",
"admin",
",",
"admin_handler",
")",
":",
"add_route",
"=",
"admin",
".",
"router",
".",
"add_route",
"add_static",
"=",
"admin",
".",
"router",
".",
"add_static",
"static_folder",
"=",
"str",
"(",
"PROJ_ROOT",
"/",
"... | Initialize routes. | [
"Initialize",
"routes",
"."
] | 82e5032ef14ae8cc3c594fdd45d6c977aab1baad | https://github.com/aio-libs/aiohttp_admin/blob/82e5032ef14ae8cc3c594fdd45d6c977aab1baad/aiohttp_admin/admin.py#L148-L160 | train |
aio-libs/aiohttp_admin | aiohttp_admin/admin.py | AdminOnRestHandler.index_page | async def index_page(self, request):
"""
Return index page with initial state for admin
"""
context = {"initial_state": self.schema.to_json()}
return render_template(
self.template,
request,
context,
app_key=TEMPLATE_APP_KEY,
... | python | async def index_page(self, request):
"""
Return index page with initial state for admin
"""
context = {"initial_state": self.schema.to_json()}
return render_template(
self.template,
request,
context,
app_key=TEMPLATE_APP_KEY,
... | [
"async",
"def",
"index_page",
"(",
"self",
",",
"request",
")",
":",
"context",
"=",
"{",
"\"initial_state\"",
":",
"self",
".",
"schema",
".",
"to_json",
"(",
")",
"}",
"return",
"render_template",
"(",
"self",
".",
"template",
",",
"request",
",",
"con... | Return index page with initial state for admin | [
"Return",
"index",
"page",
"with",
"initial",
"state",
"for",
"admin"
] | 82e5032ef14ae8cc3c594fdd45d6c977aab1baad | https://github.com/aio-libs/aiohttp_admin/blob/82e5032ef14ae8cc3c594fdd45d6c977aab1baad/aiohttp_admin/admin.py#L105-L116 | train |
aio-libs/aiohttp_admin | aiohttp_admin/admin.py | AdminOnRestHandler.logout | async def logout(self, request):
"""
Simple handler for logout
"""
if "Authorization" not in request.headers:
msg = "Auth header is not present, can not destroy token"
raise JsonValidaitonError(msg)
response = json_response()
await forget(request,... | python | async def logout(self, request):
"""
Simple handler for logout
"""
if "Authorization" not in request.headers:
msg = "Auth header is not present, can not destroy token"
raise JsonValidaitonError(msg)
response = json_response()
await forget(request,... | [
"async",
"def",
"logout",
"(",
"self",
",",
"request",
")",
":",
"if",
"\"Authorization\"",
"not",
"in",
"request",
".",
"headers",
":",
"msg",
"=",
"\"Auth header is not present, can not destroy token\"",
"raise",
"JsonValidaitonError",
"(",
"msg",
")",
"response",... | Simple handler for logout | [
"Simple",
"handler",
"for",
"logout"
] | 82e5032ef14ae8cc3c594fdd45d6c977aab1baad | https://github.com/aio-libs/aiohttp_admin/blob/82e5032ef14ae8cc3c594fdd45d6c977aab1baad/aiohttp_admin/admin.py#L134-L145 | train |
aio-libs/aiohttp_admin | aiohttp_admin/utils.py | validate_query_structure | def validate_query_structure(query):
"""Validate query arguments in list request.
:param query: mapping with pagination and filtering information
"""
query_dict = dict(query)
filters = query_dict.pop('_filters', None)
if filters:
try:
f = json.loads(filters)
except V... | python | def validate_query_structure(query):
"""Validate query arguments in list request.
:param query: mapping with pagination and filtering information
"""
query_dict = dict(query)
filters = query_dict.pop('_filters', None)
if filters:
try:
f = json.loads(filters)
except V... | [
"def",
"validate_query_structure",
"(",
"query",
")",
":",
"query_dict",
"=",
"dict",
"(",
"query",
")",
"filters",
"=",
"query_dict",
".",
"pop",
"(",
"'_filters'",
",",
"None",
")",
"if",
"filters",
":",
"try",
":",
"f",
"=",
"json",
".",
"loads",
"(... | Validate query arguments in list request.
:param query: mapping with pagination and filtering information | [
"Validate",
"query",
"arguments",
"in",
"list",
"request",
"."
] | 82e5032ef14ae8cc3c594fdd45d6c977aab1baad | https://github.com/aio-libs/aiohttp_admin/blob/82e5032ef14ae8cc3c594fdd45d6c977aab1baad/aiohttp_admin/utils.py#L82-L103 | train |
aio-libs/aiohttp_admin | aiohttp_admin/contrib/admin.py | Schema.to_json | def to_json(self):
"""
Prepare data for the initial state of the admin-on-rest
"""
endpoints = []
for endpoint in self.endpoints:
list_fields = endpoint.fields
resource_type = endpoint.Meta.resource_type
table = endpoint.Meta.table
... | python | def to_json(self):
"""
Prepare data for the initial state of the admin-on-rest
"""
endpoints = []
for endpoint in self.endpoints:
list_fields = endpoint.fields
resource_type = endpoint.Meta.resource_type
table = endpoint.Meta.table
... | [
"def",
"to_json",
"(",
"self",
")",
":",
"endpoints",
"=",
"[",
"]",
"for",
"endpoint",
"in",
"self",
".",
"endpoints",
":",
"list_fields",
"=",
"endpoint",
".",
"fields",
"resource_type",
"=",
"endpoint",
".",
"Meta",
".",
"resource_type",
"table",
"=",
... | Prepare data for the initial state of the admin-on-rest | [
"Prepare",
"data",
"for",
"the",
"initial",
"state",
"of",
"the",
"admin",
"-",
"on",
"-",
"rest"
] | 82e5032ef14ae8cc3c594fdd45d6c977aab1baad | https://github.com/aio-libs/aiohttp_admin/blob/82e5032ef14ae8cc3c594fdd45d6c977aab1baad/aiohttp_admin/contrib/admin.py#L30-L52 | train |
aio-libs/aiohttp_admin | aiohttp_admin/contrib/admin.py | Schema.resources | def resources(self):
"""
Return list of all registered resources.
"""
resources = []
for endpoint in self.endpoints:
resource_type = endpoint.Meta.resource_type
table = endpoint.Meta.table
url = endpoint.name
resources.append((res... | python | def resources(self):
"""
Return list of all registered resources.
"""
resources = []
for endpoint in self.endpoints:
resource_type = endpoint.Meta.resource_type
table = endpoint.Meta.table
url = endpoint.name
resources.append((res... | [
"def",
"resources",
"(",
"self",
")",
":",
"resources",
"=",
"[",
"]",
"for",
"endpoint",
"in",
"self",
".",
"endpoints",
":",
"resource_type",
"=",
"endpoint",
".",
"Meta",
".",
"resource_type",
"table",
"=",
"endpoint",
".",
"Meta",
".",
"table",
"url"... | Return list of all registered resources. | [
"Return",
"list",
"of",
"all",
"registered",
"resources",
"."
] | 82e5032ef14ae8cc3c594fdd45d6c977aab1baad | https://github.com/aio-libs/aiohttp_admin/blob/82e5032ef14ae8cc3c594fdd45d6c977aab1baad/aiohttp_admin/contrib/admin.py#L55-L68 | train |
aio-libs/aiohttp_admin | aiohttp_admin/backends/sa.py | PGResource.get_type_of_fields | def get_type_of_fields(fields, table):
"""
Return data types of `fields` that are in `table`. If a given
parameter is empty return primary key.
:param fields: list - list of fields that need to be returned
:param table: sa.Table - the current table
:return: list - list o... | python | def get_type_of_fields(fields, table):
"""
Return data types of `fields` that are in `table`. If a given
parameter is empty return primary key.
:param fields: list - list of fields that need to be returned
:param table: sa.Table - the current table
:return: list - list o... | [
"def",
"get_type_of_fields",
"(",
"fields",
",",
"table",
")",
":",
"if",
"not",
"fields",
":",
"fields",
"=",
"table",
".",
"primary_key",
"actual_fields",
"=",
"[",
"field",
"for",
"field",
"in",
"table",
".",
"c",
".",
"items",
"(",
")",
"if",
"fiel... | Return data types of `fields` that are in `table`. If a given
parameter is empty return primary key.
:param fields: list - list of fields that need to be returned
:param table: sa.Table - the current table
:return: list - list of the tuples `(field_name, fields_type)` | [
"Return",
"data",
"types",
"of",
"fields",
"that",
"are",
"in",
"table",
".",
"If",
"a",
"given",
"parameter",
"is",
"empty",
"return",
"primary",
"key",
"."
] | 82e5032ef14ae8cc3c594fdd45d6c977aab1baad | https://github.com/aio-libs/aiohttp_admin/blob/82e5032ef14ae8cc3c594fdd45d6c977aab1baad/aiohttp_admin/backends/sa.py#L58-L80 | train |
aio-libs/aiohttp_admin | aiohttp_admin/backends/sa.py | PGResource.get_type_for_inputs | def get_type_for_inputs(table):
"""
Return information about table's fields in dictionary type.
:param table: sa.Table - the current table
:return: list - list of the dictionaries
"""
return [
dict(
type=INPUT_TYPES.get(
ty... | python | def get_type_for_inputs(table):
"""
Return information about table's fields in dictionary type.
:param table: sa.Table - the current table
:return: list - list of the dictionaries
"""
return [
dict(
type=INPUT_TYPES.get(
ty... | [
"def",
"get_type_for_inputs",
"(",
"table",
")",
":",
"return",
"[",
"dict",
"(",
"type",
"=",
"INPUT_TYPES",
".",
"get",
"(",
"type",
"(",
"field_type",
".",
"type",
")",
",",
"rc",
".",
"TEXT_INPUT",
".",
"value",
")",
",",
"name",
"=",
"name",
","... | Return information about table's fields in dictionary type.
:param table: sa.Table - the current table
:return: list - list of the dictionaries | [
"Return",
"information",
"about",
"table",
"s",
"fields",
"in",
"dictionary",
"type",
"."
] | 82e5032ef14ae8cc3c594fdd45d6c977aab1baad | https://github.com/aio-libs/aiohttp_admin/blob/82e5032ef14ae8cc3c594fdd45d6c977aab1baad/aiohttp_admin/backends/sa.py#L83-L99 | train |
aio-libs/aiohttp_admin | aiohttp_admin/__init__.py | _setup | def _setup(app, *, schema, title=None, app_key=APP_KEY, db=None):
"""Initialize the admin-on-rest admin"""
admin = web.Application(loop=app.loop)
app[app_key] = admin
loader = jinja2.FileSystemLoader([TEMPLATES_ROOT, ])
aiohttp_jinja2.setup(admin, loader=loader, app_key=TEMPLATE_APP_KEY)
if t... | python | def _setup(app, *, schema, title=None, app_key=APP_KEY, db=None):
"""Initialize the admin-on-rest admin"""
admin = web.Application(loop=app.loop)
app[app_key] = admin
loader = jinja2.FileSystemLoader([TEMPLATES_ROOT, ])
aiohttp_jinja2.setup(admin, loader=loader, app_key=TEMPLATE_APP_KEY)
if t... | [
"def",
"_setup",
"(",
"app",
",",
"*",
",",
"schema",
",",
"title",
"=",
"None",
",",
"app_key",
"=",
"APP_KEY",
",",
"db",
"=",
"None",
")",
":",
"admin",
"=",
"web",
".",
"Application",
"(",
"loop",
"=",
"app",
".",
"loop",
")",
"app",
"[",
"... | Initialize the admin-on-rest admin | [
"Initialize",
"the",
"admin",
"-",
"on",
"-",
"rest",
"admin"
] | 82e5032ef14ae8cc3c594fdd45d6c977aab1baad | https://github.com/aio-libs/aiohttp_admin/blob/82e5032ef14ae8cc3c594fdd45d6c977aab1baad/aiohttp_admin/__init__.py#L44-L70 | train |
aio-libs/aiohttp_admin | aiohttp_admin/contrib/models.py | ModelAdmin.to_dict | def to_dict(self):
"""
Return dict with the all base information about the instance.
"""
data = {
"name": self.name,
"canEdit": self.can_edit,
"canCreate": self.can_create,
"canDelete": self.can_delete,
"perPage": self.per_page,... | python | def to_dict(self):
"""
Return dict with the all base information about the instance.
"""
data = {
"name": self.name,
"canEdit": self.can_edit,
"canCreate": self.can_create,
"canDelete": self.can_delete,
"perPage": self.per_page,... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"data",
"=",
"{",
"\"name\"",
":",
"self",
".",
"name",
",",
"\"canEdit\"",
":",
"self",
".",
"can_edit",
",",
"\"canCreate\"",
":",
"self",
".",
"can_create",
",",
"\"canDelete\"",
":",
"self",
".",
"can_delete",... | Return dict with the all base information about the instance. | [
"Return",
"dict",
"with",
"the",
"all",
"base",
"information",
"about",
"the",
"instance",
"."
] | 82e5032ef14ae8cc3c594fdd45d6c977aab1baad | https://github.com/aio-libs/aiohttp_admin/blob/82e5032ef14ae8cc3c594fdd45d6c977aab1baad/aiohttp_admin/contrib/models.py#L30-L45 | train |
aio-libs/aiohttp_admin | aiohttp_admin/contrib/models.py | ModelAdmin.generate_data_for_edit_page | def generate_data_for_edit_page(self):
"""
Generate a custom representation of table's fields in dictionary type
if exist edit form else use default representation.
:return: dict
"""
if not self.can_edit:
return {}
if self.edit_form:
ret... | python | def generate_data_for_edit_page(self):
"""
Generate a custom representation of table's fields in dictionary type
if exist edit form else use default representation.
:return: dict
"""
if not self.can_edit:
return {}
if self.edit_form:
ret... | [
"def",
"generate_data_for_edit_page",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"can_edit",
":",
"return",
"{",
"}",
"if",
"self",
".",
"edit_form",
":",
"return",
"self",
".",
"edit_form",
".",
"to_dict",
"(",
")",
"return",
"self",
".",
"generat... | Generate a custom representation of table's fields in dictionary type
if exist edit form else use default representation.
:return: dict | [
"Generate",
"a",
"custom",
"representation",
"of",
"table",
"s",
"fields",
"in",
"dictionary",
"type",
"if",
"exist",
"edit",
"form",
"else",
"use",
"default",
"representation",
"."
] | 82e5032ef14ae8cc3c594fdd45d6c977aab1baad | https://github.com/aio-libs/aiohttp_admin/blob/82e5032ef14ae8cc3c594fdd45d6c977aab1baad/aiohttp_admin/contrib/models.py#L55-L69 | train |
aio-libs/aiohttp_admin | aiohttp_admin/contrib/models.py | ModelAdmin.generate_data_for_create_page | def generate_data_for_create_page(self):
"""
Generate a custom representation of table's fields in dictionary type
if exist create form else use default representation.
:return: dict
"""
if not self.can_create:
return {}
if self.create_form:
... | python | def generate_data_for_create_page(self):
"""
Generate a custom representation of table's fields in dictionary type
if exist create form else use default representation.
:return: dict
"""
if not self.can_create:
return {}
if self.create_form:
... | [
"def",
"generate_data_for_create_page",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"can_create",
":",
"return",
"{",
"}",
"if",
"self",
".",
"create_form",
":",
"return",
"self",
".",
"create_form",
".",
"to_dict",
"(",
")",
"return",
"self",
".",
... | Generate a custom representation of table's fields in dictionary type
if exist create form else use default representation.
:return: dict | [
"Generate",
"a",
"custom",
"representation",
"of",
"table",
"s",
"fields",
"in",
"dictionary",
"type",
"if",
"exist",
"create",
"form",
"else",
"use",
"default",
"representation",
"."
] | 82e5032ef14ae8cc3c594fdd45d6c977aab1baad | https://github.com/aio-libs/aiohttp_admin/blob/82e5032ef14ae8cc3c594fdd45d6c977aab1baad/aiohttp_admin/contrib/models.py#L83-L96 | train |
aio-libs/aiohttp_admin | demos/motortwit/motortwit/views.py | SiteHandler.register | async def register(self, request):
"""Registers the user."""
session = await get_session(request)
user_id = session.get('user_id')
if user_id:
return redirect(request, 'timeline')
error = None
form = None
if request.method == 'POST':
form ... | python | async def register(self, request):
"""Registers the user."""
session = await get_session(request)
user_id = session.get('user_id')
if user_id:
return redirect(request, 'timeline')
error = None
form = None
if request.method == 'POST':
form ... | [
"async",
"def",
"register",
"(",
"self",
",",
"request",
")",
":",
"session",
"=",
"await",
"get_session",
"(",
"request",
")",
"user_id",
"=",
"session",
".",
"get",
"(",
"'user_id'",
")",
"if",
"user_id",
":",
"return",
"redirect",
"(",
"request",
",",... | Registers the user. | [
"Registers",
"the",
"user",
"."
] | 82e5032ef14ae8cc3c594fdd45d6c977aab1baad | https://github.com/aio-libs/aiohttp_admin/blob/82e5032ef14ae8cc3c594fdd45d6c977aab1baad/demos/motortwit/motortwit/views.py#L116-L145 | train |
aio-libs/aiohttp_admin | demos/motortwit/motortwit/views.py | SiteHandler.follow_user | async def follow_user(self, request):
"""Adds the current user as follower of the given user."""
username = request.match_info['username']
session = await get_session(request)
user_id = session.get('user_id')
if not user_id:
raise web.HTTPNotAuthorized()
who... | python | async def follow_user(self, request):
"""Adds the current user as follower of the given user."""
username = request.match_info['username']
session = await get_session(request)
user_id = session.get('user_id')
if not user_id:
raise web.HTTPNotAuthorized()
who... | [
"async",
"def",
"follow_user",
"(",
"self",
",",
"request",
")",
":",
"username",
"=",
"request",
".",
"match_info",
"[",
"'username'",
"]",
"session",
"=",
"await",
"get_session",
"(",
"request",
")",
"user_id",
"=",
"session",
".",
"get",
"(",
"'user_id'... | Adds the current user as follower of the given user. | [
"Adds",
"the",
"current",
"user",
"as",
"follower",
"of",
"the",
"given",
"user",
"."
] | 82e5032ef14ae8cc3c594fdd45d6c977aab1baad | https://github.com/aio-libs/aiohttp_admin/blob/82e5032ef14ae8cc3c594fdd45d6c977aab1baad/demos/motortwit/motortwit/views.py#L147-L165 | train |
aio-libs/aiohttp_admin | demos/motortwit/motortwit/views.py | SiteHandler.add_message | async def add_message(self, request):
"""Registers a new message for the user."""
session = await get_session(request)
user_id = session.get('user_id')
if not user_id:
raise web.HTTPNotAuthorized()
form = await request.post()
if form.get('text'):
... | python | async def add_message(self, request):
"""Registers a new message for the user."""
session = await get_session(request)
user_id = session.get('user_id')
if not user_id:
raise web.HTTPNotAuthorized()
form = await request.post()
if form.get('text'):
... | [
"async",
"def",
"add_message",
"(",
"self",
",",
"request",
")",
":",
"session",
"=",
"await",
"get_session",
"(",
"request",
")",
"user_id",
"=",
"session",
".",
"get",
"(",
"'user_id'",
")",
"if",
"not",
"user_id",
":",
"raise",
"web",
".",
"HTTPNotAut... | Registers a new message for the user. | [
"Registers",
"a",
"new",
"message",
"for",
"the",
"user",
"."
] | 82e5032ef14ae8cc3c594fdd45d6c977aab1baad | https://github.com/aio-libs/aiohttp_admin/blob/82e5032ef14ae8cc3c594fdd45d6c977aab1baad/demos/motortwit/motortwit/views.py#L184-L203 | train |
aio-libs/aiohttp_admin | demos/motortwit/motortwit/utils.py | robo_avatar_url | def robo_avatar_url(user_data, size=80):
"""Return the gravatar image for the given email address."""
hash = md5(str(user_data).strip().lower().encode('utf-8')).hexdigest()
url = "https://robohash.org/{hash}.png?size={size}x{size}".format(
hash=hash, size=size)
return url | python | def robo_avatar_url(user_data, size=80):
"""Return the gravatar image for the given email address."""
hash = md5(str(user_data).strip().lower().encode('utf-8')).hexdigest()
url = "https://robohash.org/{hash}.png?size={size}x{size}".format(
hash=hash, size=size)
return url | [
"def",
"robo_avatar_url",
"(",
"user_data",
",",
"size",
"=",
"80",
")",
":",
"hash",
"=",
"md5",
"(",
"str",
"(",
"user_data",
")",
".",
"strip",
"(",
")",
".",
"lower",
"(",
")",
".",
"encode",
"(",
"'utf-8'",
")",
")",
".",
"hexdigest",
"(",
"... | Return the gravatar image for the given email address. | [
"Return",
"the",
"gravatar",
"image",
"for",
"the",
"given",
"email",
"address",
"."
] | 82e5032ef14ae8cc3c594fdd45d6c977aab1baad | https://github.com/aio-libs/aiohttp_admin/blob/82e5032ef14ae8cc3c594fdd45d6c977aab1baad/demos/motortwit/motortwit/utils.py#L27-L32 | train |
ponty/PyVirtualDisplay | pyvirtualdisplay/smartdisplay.py | SmartDisplay.waitgrab | def waitgrab(self, timeout=60, autocrop=True, cb_imgcheck=None):
'''start process and create screenshot.
Repeat screenshot until it is not empty and
cb_imgcheck callback function returns True
for current screenshot.
:param autocrop: True -> crop screenshot
:param timeout... | python | def waitgrab(self, timeout=60, autocrop=True, cb_imgcheck=None):
'''start process and create screenshot.
Repeat screenshot until it is not empty and
cb_imgcheck callback function returns True
for current screenshot.
:param autocrop: True -> crop screenshot
:param timeout... | [
"def",
"waitgrab",
"(",
"self",
",",
"timeout",
"=",
"60",
",",
"autocrop",
"=",
"True",
",",
"cb_imgcheck",
"=",
"None",
")",
":",
"t",
"=",
"0",
"sleep_time",
"=",
"0.3",
"# for fast windows",
"repeat_time",
"=",
"1",
"while",
"1",
":",
"log",
".",
... | start process and create screenshot.
Repeat screenshot until it is not empty and
cb_imgcheck callback function returns True
for current screenshot.
:param autocrop: True -> crop screenshot
:param timeout: int
:param cb_imgcheck: None or callback for testing img,
... | [
"start",
"process",
"and",
"create",
"screenshot",
".",
"Repeat",
"screenshot",
"until",
"it",
"is",
"not",
"empty",
"and",
"cb_imgcheck",
"callback",
"function",
"returns",
"True",
"for",
"current",
"screenshot",
"."
] | 903841f5ef13bf162be6fdd22daa5c349af45d67 | https://github.com/ponty/PyVirtualDisplay/blob/903841f5ef13bf162be6fdd22daa5c349af45d67/pyvirtualdisplay/smartdisplay.py#L54-L90 | train |
ponty/PyVirtualDisplay | pyvirtualdisplay/abstractdisplay.py | AbstractDisplay._setup_xauth | def _setup_xauth(self):
'''
Set up the Xauthority file and the XAUTHORITY environment variable.
'''
handle, filename = tempfile.mkstemp(prefix='PyVirtualDisplay.',
suffix='.Xauthority')
self._xauth_filename = filename
os.close(h... | python | def _setup_xauth(self):
'''
Set up the Xauthority file and the XAUTHORITY environment variable.
'''
handle, filename = tempfile.mkstemp(prefix='PyVirtualDisplay.',
suffix='.Xauthority')
self._xauth_filename = filename
os.close(h... | [
"def",
"_setup_xauth",
"(",
"self",
")",
":",
"handle",
",",
"filename",
"=",
"tempfile",
".",
"mkstemp",
"(",
"prefix",
"=",
"'PyVirtualDisplay.'",
",",
"suffix",
"=",
"'.Xauthority'",
")",
"self",
".",
"_xauth_filename",
"=",
"filename",
"os",
".",
"close"... | Set up the Xauthority file and the XAUTHORITY environment variable. | [
"Set",
"up",
"the",
"Xauthority",
"file",
"and",
"the",
"XAUTHORITY",
"environment",
"variable",
"."
] | 903841f5ef13bf162be6fdd22daa5c349af45d67 | https://github.com/ponty/PyVirtualDisplay/blob/903841f5ef13bf162be6fdd22daa5c349af45d67/pyvirtualdisplay/abstractdisplay.py#L154-L169 | train |
ponty/PyVirtualDisplay | pyvirtualdisplay/abstractdisplay.py | AbstractDisplay._clear_xauth | def _clear_xauth(self):
'''
Clear the Xauthority file and restore the environment variables.
'''
os.remove(self._xauth_filename)
for varname in ['AUTHFILE', 'XAUTHORITY']:
if self._old_xauth[varname] is None:
del os.environ[varname]
else:
... | python | def _clear_xauth(self):
'''
Clear the Xauthority file and restore the environment variables.
'''
os.remove(self._xauth_filename)
for varname in ['AUTHFILE', 'XAUTHORITY']:
if self._old_xauth[varname] is None:
del os.environ[varname]
else:
... | [
"def",
"_clear_xauth",
"(",
"self",
")",
":",
"os",
".",
"remove",
"(",
"self",
".",
"_xauth_filename",
")",
"for",
"varname",
"in",
"[",
"'AUTHFILE'",
",",
"'XAUTHORITY'",
"]",
":",
"if",
"self",
".",
"_old_xauth",
"[",
"varname",
"]",
"is",
"None",
"... | Clear the Xauthority file and restore the environment variables. | [
"Clear",
"the",
"Xauthority",
"file",
"and",
"restore",
"the",
"environment",
"variables",
"."
] | 903841f5ef13bf162be6fdd22daa5c349af45d67 | https://github.com/ponty/PyVirtualDisplay/blob/903841f5ef13bf162be6fdd22daa5c349af45d67/pyvirtualdisplay/abstractdisplay.py#L171-L181 | train |
jasonrollins/shareplum | shareplum/shareplum.py | Office365.GetCookies | def GetCookies(self):
"""
Grabs the cookies form your Office Sharepoint site
and uses it as Authentication for the rest of the calls
"""
sectoken = self.GetSecurityToken(self.Username, self.Password)
url = self.share_point_site+ '/_forms/default.aspx?wa=wsignin1.0'
... | python | def GetCookies(self):
"""
Grabs the cookies form your Office Sharepoint site
and uses it as Authentication for the rest of the calls
"""
sectoken = self.GetSecurityToken(self.Username, self.Password)
url = self.share_point_site+ '/_forms/default.aspx?wa=wsignin1.0'
... | [
"def",
"GetCookies",
"(",
"self",
")",
":",
"sectoken",
"=",
"self",
".",
"GetSecurityToken",
"(",
"self",
".",
"Username",
",",
"self",
".",
"Password",
")",
"url",
"=",
"self",
".",
"share_point_site",
"+",
"'/_forms/default.aspx?wa=wsignin1.0'",
"response",
... | Grabs the cookies form your Office Sharepoint site
and uses it as Authentication for the rest of the calls | [
"Grabs",
"the",
"cookies",
"form",
"your",
"Office",
"Sharepoint",
"site",
"and",
"uses",
"it",
"as",
"Authentication",
"for",
"the",
"rest",
"of",
"the",
"calls"
] | 404f320808912619920e2d787f2c4387225a14e0 | https://github.com/jasonrollins/shareplum/blob/404f320808912619920e2d787f2c4387225a14e0/shareplum/shareplum.py#L70-L78 | train |
jasonrollins/shareplum | shareplum/shareplum.py | Site.DeleteList | def DeleteList(self, listName):
"""Delete a List with given name"""
# Build Request
soap_request = soap('DeleteList')
soap_request.add_parameter('listName', listName)
self.last_request = str(soap_request)
# Send Request
response = self._session.post(url=self._ur... | python | def DeleteList(self, listName):
"""Delete a List with given name"""
# Build Request
soap_request = soap('DeleteList')
soap_request.add_parameter('listName', listName)
self.last_request = str(soap_request)
# Send Request
response = self._session.post(url=self._ur... | [
"def",
"DeleteList",
"(",
"self",
",",
"listName",
")",
":",
"# Build Request",
"soap_request",
"=",
"soap",
"(",
"'DeleteList'",
")",
"soap_request",
".",
"add_parameter",
"(",
"'listName'",
",",
"listName",
")",
"self",
".",
"last_request",
"=",
"str",
"(",
... | Delete a List with given name | [
"Delete",
"a",
"List",
"with",
"given",
"name"
] | 404f320808912619920e2d787f2c4387225a14e0 | https://github.com/jasonrollins/shareplum/blob/404f320808912619920e2d787f2c4387225a14e0/shareplum/shareplum.py#L207-L226 | train |
jasonrollins/shareplum | shareplum/shareplum.py | Site.GetListCollection | def GetListCollection(self):
"""Returns List information for current Site"""
# Build Request
soap_request = soap('GetListCollection')
self.last_request = str(soap_request)
# Send Request
response = self._session.post(url=self._url('SiteData'),
... | python | def GetListCollection(self):
"""Returns List information for current Site"""
# Build Request
soap_request = soap('GetListCollection')
self.last_request = str(soap_request)
# Send Request
response = self._session.post(url=self._url('SiteData'),
... | [
"def",
"GetListCollection",
"(",
"self",
")",
":",
"# Build Request",
"soap_request",
"=",
"soap",
"(",
"'GetListCollection'",
")",
"self",
".",
"last_request",
"=",
"str",
"(",
"soap_request",
")",
"# Send Request",
"response",
"=",
"self",
".",
"_session",
"."... | Returns List information for current Site | [
"Returns",
"List",
"information",
"for",
"current",
"Site"
] | 404f320808912619920e2d787f2c4387225a14e0 | https://github.com/jasonrollins/shareplum/blob/404f320808912619920e2d787f2c4387225a14e0/shareplum/shareplum.py#L228-L257 | train |
jasonrollins/shareplum | shareplum/shareplum.py | _List._convert_to_internal | def _convert_to_internal(self, data):
"""From 'Column Title' to 'Column_x0020_Title'"""
for _dict in data:
keys = list(_dict.keys())[:]
for key in keys:
if key not in self._disp_cols:
raise Exception(key + ' not a column in current List.')
... | python | def _convert_to_internal(self, data):
"""From 'Column Title' to 'Column_x0020_Title'"""
for _dict in data:
keys = list(_dict.keys())[:]
for key in keys:
if key not in self._disp_cols:
raise Exception(key + ' not a column in current List.')
... | [
"def",
"_convert_to_internal",
"(",
"self",
",",
"data",
")",
":",
"for",
"_dict",
"in",
"data",
":",
"keys",
"=",
"list",
"(",
"_dict",
".",
"keys",
"(",
")",
")",
"[",
":",
"]",
"for",
"key",
"in",
"keys",
":",
"if",
"key",
"not",
"in",
"self",... | From 'Column Title' to 'Column_x0020_Title | [
"From",
"Column",
"Title",
"to",
"Column_x0020_Title"
] | 404f320808912619920e2d787f2c4387225a14e0 | https://github.com/jasonrollins/shareplum/blob/404f320808912619920e2d787f2c4387225a14e0/shareplum/shareplum.py#L358-L365 | train |
jasonrollins/shareplum | shareplum/shareplum.py | _List._convert_to_display | def _convert_to_display(self, data):
"""From 'Column_x0020_Title' to 'Column Title'"""
for _dict in data:
keys = list(_dict.keys())[:]
for key in keys:
if key not in self._sp_cols:
raise Exception(key + ' not a column in current List.')
... | python | def _convert_to_display(self, data):
"""From 'Column_x0020_Title' to 'Column Title'"""
for _dict in data:
keys = list(_dict.keys())[:]
for key in keys:
if key not in self._sp_cols:
raise Exception(key + ' not a column in current List.')
... | [
"def",
"_convert_to_display",
"(",
"self",
",",
"data",
")",
":",
"for",
"_dict",
"in",
"data",
":",
"keys",
"=",
"list",
"(",
"_dict",
".",
"keys",
"(",
")",
")",
"[",
":",
"]",
"for",
"key",
"in",
"keys",
":",
"if",
"key",
"not",
"in",
"self",
... | From 'Column_x0020_Title' to 'Column Title | [
"From",
"Column_x0020_Title",
"to",
"Column",
"Title"
] | 404f320808912619920e2d787f2c4387225a14e0 | https://github.com/jasonrollins/shareplum/blob/404f320808912619920e2d787f2c4387225a14e0/shareplum/shareplum.py#L367-L374 | train |
jasonrollins/shareplum | shareplum/shareplum.py | _List.GetView | def GetView(self, viewname):
"""Get Info on View Name
"""
# Build Request
soap_request = soap('GetView')
soap_request.add_parameter('listName', self.listName)
if viewname == None:
views = self.GetViewCollection()
for view in views:
... | python | def GetView(self, viewname):
"""Get Info on View Name
"""
# Build Request
soap_request = soap('GetView')
soap_request.add_parameter('listName', self.listName)
if viewname == None:
views = self.GetViewCollection()
for view in views:
... | [
"def",
"GetView",
"(",
"self",
",",
"viewname",
")",
":",
"# Build Request",
"soap_request",
"=",
"soap",
"(",
"'GetView'",
")",
"soap_request",
".",
"add_parameter",
"(",
"'listName'",
",",
"self",
".",
"listName",
")",
"if",
"viewname",
"==",
"None",
":",
... | Get Info on View Name | [
"Get",
"Info",
"on",
"View",
"Name"
] | 404f320808912619920e2d787f2c4387225a14e0 | https://github.com/jasonrollins/shareplum/blob/404f320808912619920e2d787f2c4387225a14e0/shareplum/shareplum.py#L562-L600 | train |
jasonrollins/shareplum | shareplum/shareplum.py | _List.UpdateListItems | def UpdateListItems(self, data, kind):
"""Update List Items
kind = 'New', 'Update', or 'Delete'
New:
Provide data like so:
data = [{'Title': 'New Title', 'Col1': 'New Value'}]
Update:
Provide data like so:
data = [{'ID': 23, ... | python | def UpdateListItems(self, data, kind):
"""Update List Items
kind = 'New', 'Update', or 'Delete'
New:
Provide data like so:
data = [{'Title': 'New Title', 'Col1': 'New Value'}]
Update:
Provide data like so:
data = [{'ID': 23, ... | [
"def",
"UpdateListItems",
"(",
"self",
",",
"data",
",",
"kind",
")",
":",
"if",
"type",
"(",
"data",
")",
"!=",
"list",
":",
"raise",
"Exception",
"(",
"'data must be a list of dictionaries'",
")",
"# Build Request",
"soap_request",
"=",
"soap",
"(",
"'Update... | Update List Items
kind = 'New', 'Update', or 'Delete'
New:
Provide data like so:
data = [{'Title': 'New Title', 'Col1': 'New Value'}]
Update:
Provide data like so:
data = [{'ID': 23, 'Title': 'Updated Title'},
... | [
"Update",
"List",
"Items",
"kind",
"=",
"New",
"Update",
"or",
"Delete"
] | 404f320808912619920e2d787f2c4387225a14e0 | https://github.com/jasonrollins/shareplum/blob/404f320808912619920e2d787f2c4387225a14e0/shareplum/shareplum.py#L658-L704 | train |
jasonrollins/shareplum | shareplum/shareplum.py | _List.GetAttachmentCollection | def GetAttachmentCollection(self, _id):
"""Get Attachments for given List Item ID"""
# Build Request
soap_request = soap('GetAttachmentCollection')
soap_request.add_parameter('listName', self.listName)
soap_request.add_parameter('listItemID', _id)
self.last_request = str... | python | def GetAttachmentCollection(self, _id):
"""Get Attachments for given List Item ID"""
# Build Request
soap_request = soap('GetAttachmentCollection')
soap_request.add_parameter('listName', self.listName)
soap_request.add_parameter('listItemID', _id)
self.last_request = str... | [
"def",
"GetAttachmentCollection",
"(",
"self",
",",
"_id",
")",
":",
"# Build Request",
"soap_request",
"=",
"soap",
"(",
"'GetAttachmentCollection'",
")",
"soap_request",
".",
"add_parameter",
"(",
"'listName'",
",",
"self",
".",
"listName",
")",
"soap_request",
... | Get Attachments for given List Item ID | [
"Get",
"Attachments",
"for",
"given",
"List",
"Item",
"ID"
] | 404f320808912619920e2d787f2c4387225a14e0 | https://github.com/jasonrollins/shareplum/blob/404f320808912619920e2d787f2c4387225a14e0/shareplum/shareplum.py#L706-L731 | train |
jasonrollins/shareplum | shareplum/ListDict.py | changes | def changes(new_cmp_dict, old_cmp_dict, id_column, columns):
"""Return a list dict of the changes of the
rows that exist in both dictionaries
User must provide an ID column for old_cmp_dict
"""
update_ldict = []
same_keys = set(new_cmp_dict).intersection(set(old_cmp_dict))
for same_ke... | python | def changes(new_cmp_dict, old_cmp_dict, id_column, columns):
"""Return a list dict of the changes of the
rows that exist in both dictionaries
User must provide an ID column for old_cmp_dict
"""
update_ldict = []
same_keys = set(new_cmp_dict).intersection(set(old_cmp_dict))
for same_ke... | [
"def",
"changes",
"(",
"new_cmp_dict",
",",
"old_cmp_dict",
",",
"id_column",
",",
"columns",
")",
":",
"update_ldict",
"=",
"[",
"]",
"same_keys",
"=",
"set",
"(",
"new_cmp_dict",
")",
".",
"intersection",
"(",
"set",
"(",
"old_cmp_dict",
")",
")",
"for",... | Return a list dict of the changes of the
rows that exist in both dictionaries
User must provide an ID column for old_cmp_dict | [
"Return",
"a",
"list",
"dict",
"of",
"the",
"changes",
"of",
"the",
"rows",
"that",
"exist",
"in",
"both",
"dictionaries",
"User",
"must",
"provide",
"an",
"ID",
"column",
"for",
"old_cmp_dict"
] | 404f320808912619920e2d787f2c4387225a14e0 | https://github.com/jasonrollins/shareplum/blob/404f320808912619920e2d787f2c4387225a14e0/shareplum/ListDict.py#L4-L33 | train |
jasonrollins/shareplum | shareplum/ListDict.py | unique | def unique(new_cmp_dict, old_cmp_dict):
"""Return a list dict of
the unique keys in new_cmp_dict
"""
newkeys = set(new_cmp_dict)
oldkeys = set(old_cmp_dict)
unique = newkeys - oldkeys
unique_ldict = []
for key in unique:
unique_ldict.append(new_cmp_dict[key])
return unique... | python | def unique(new_cmp_dict, old_cmp_dict):
"""Return a list dict of
the unique keys in new_cmp_dict
"""
newkeys = set(new_cmp_dict)
oldkeys = set(old_cmp_dict)
unique = newkeys - oldkeys
unique_ldict = []
for key in unique:
unique_ldict.append(new_cmp_dict[key])
return unique... | [
"def",
"unique",
"(",
"new_cmp_dict",
",",
"old_cmp_dict",
")",
":",
"newkeys",
"=",
"set",
"(",
"new_cmp_dict",
")",
"oldkeys",
"=",
"set",
"(",
"old_cmp_dict",
")",
"unique",
"=",
"newkeys",
"-",
"oldkeys",
"unique_ldict",
"=",
"[",
"]",
"for",
"key",
... | Return a list dict of
the unique keys in new_cmp_dict | [
"Return",
"a",
"list",
"dict",
"of",
"the",
"unique",
"keys",
"in",
"new_cmp_dict"
] | 404f320808912619920e2d787f2c4387225a14e0 | https://github.com/jasonrollins/shareplum/blob/404f320808912619920e2d787f2c4387225a14e0/shareplum/ListDict.py#L35-L45 | train |
improbable-research/keanu | keanu-python/keanu/plots/traceplot.py | traceplot | def traceplot(trace: sample_types, labels: List[Union[str, Tuple[str, str]]] = None, ax: Any = None,
x0: int = 0) -> Any:
"""
Plot samples values.
:param trace: result of MCMC run
:param labels: labels of vertices to be plotted. if None, all vertices are plotted.
:param ax: Matplotli... | python | def traceplot(trace: sample_types, labels: List[Union[str, Tuple[str, str]]] = None, ax: Any = None,
x0: int = 0) -> Any:
"""
Plot samples values.
:param trace: result of MCMC run
:param labels: labels of vertices to be plotted. if None, all vertices are plotted.
:param ax: Matplotli... | [
"def",
"traceplot",
"(",
"trace",
":",
"sample_types",
",",
"labels",
":",
"List",
"[",
"Union",
"[",
"str",
",",
"Tuple",
"[",
"str",
",",
"str",
"]",
"]",
"]",
"=",
"None",
",",
"ax",
":",
"Any",
"=",
"None",
",",
"x0",
":",
"int",
"=",
"0",
... | Plot samples values.
:param trace: result of MCMC run
:param labels: labels of vertices to be plotted. if None, all vertices are plotted.
:param ax: Matplotlib axes
:param x0: index of first data point, used for sample stream plots | [
"Plot",
"samples",
"values",
"."
] | 73189a8f569078e156168e795f82c7366c59574b | https://github.com/improbable-research/keanu/blob/73189a8f569078e156168e795f82c7366c59574b/keanu-python/keanu/plots/traceplot.py#L12-L37 | train |
improbable-research/keanu | docs/bin/snippet_writer.py | read_file_snippets | def read_file_snippets(file, snippet_store):
"""Parse a file and add all snippets to the snippet_store dictionary"""
start_reg = re.compile("(.*%%SNIPPET_START%% )([a-zA-Z0-9]+)")
end_reg = re.compile("(.*%%SNIPPET_END%% )([a-zA-Z0-9]+)")
open_snippets = {}
with open(file, encoding="utf-8") as w:
... | python | def read_file_snippets(file, snippet_store):
"""Parse a file and add all snippets to the snippet_store dictionary"""
start_reg = re.compile("(.*%%SNIPPET_START%% )([a-zA-Z0-9]+)")
end_reg = re.compile("(.*%%SNIPPET_END%% )([a-zA-Z0-9]+)")
open_snippets = {}
with open(file, encoding="utf-8") as w:
... | [
"def",
"read_file_snippets",
"(",
"file",
",",
"snippet_store",
")",
":",
"start_reg",
"=",
"re",
".",
"compile",
"(",
"\"(.*%%SNIPPET_START%% )([a-zA-Z0-9]+)\"",
")",
"end_reg",
"=",
"re",
".",
"compile",
"(",
"\"(.*%%SNIPPET_END%% )([a-zA-Z0-9]+)\"",
")",
"open_snip... | Parse a file and add all snippets to the snippet_store dictionary | [
"Parse",
"a",
"file",
"and",
"add",
"all",
"snippets",
"to",
"the",
"snippet_store",
"dictionary"
] | 73189a8f569078e156168e795f82c7366c59574b | https://github.com/improbable-research/keanu/blob/73189a8f569078e156168e795f82c7366c59574b/docs/bin/snippet_writer.py#L31-L73 | train |
improbable-research/keanu | docs/bin/snippet_writer.py | strip_block_whitespace | def strip_block_whitespace(string_list):
"""Treats a list of strings as a code block and strips
whitespace so that the min whitespace line sits at char 0 of line."""
min_ws = min([(len(x) - len(x.lstrip())) for x in string_list if x != '\n'])
return [x[min_ws:] if x != '\n' else x for x in string_li... | python | def strip_block_whitespace(string_list):
"""Treats a list of strings as a code block and strips
whitespace so that the min whitespace line sits at char 0 of line."""
min_ws = min([(len(x) - len(x.lstrip())) for x in string_list if x != '\n'])
return [x[min_ws:] if x != '\n' else x for x in string_li... | [
"def",
"strip_block_whitespace",
"(",
"string_list",
")",
":",
"min_ws",
"=",
"min",
"(",
"[",
"(",
"len",
"(",
"x",
")",
"-",
"len",
"(",
"x",
".",
"lstrip",
"(",
")",
")",
")",
"for",
"x",
"in",
"string_list",
"if",
"x",
"!=",
"'\\n'",
"]",
")"... | Treats a list of strings as a code block and strips
whitespace so that the min whitespace line sits at char 0 of line. | [
"Treats",
"a",
"list",
"of",
"strings",
"as",
"a",
"code",
"block",
"and",
"strips",
"whitespace",
"so",
"that",
"the",
"min",
"whitespace",
"line",
"sits",
"at",
"char",
"0",
"of",
"line",
"."
] | 73189a8f569078e156168e795f82c7366c59574b | https://github.com/improbable-research/keanu/blob/73189a8f569078e156168e795f82c7366c59574b/docs/bin/snippet_writer.py#L126-L130 | train |
aio-libs/aiohttp-sse | aiohttp_sse/__init__.py | EventSourceResponse.prepare | async def prepare(self, request):
"""Prepare for streaming and send HTTP headers.
:param request: regular aiohttp.web.Request.
"""
if request.method != 'GET':
raise HTTPMethodNotAllowed(request.method, ['GET'])
if not self.prepared:
writer = await super(... | python | async def prepare(self, request):
"""Prepare for streaming and send HTTP headers.
:param request: regular aiohttp.web.Request.
"""
if request.method != 'GET':
raise HTTPMethodNotAllowed(request.method, ['GET'])
if not self.prepared:
writer = await super(... | [
"async",
"def",
"prepare",
"(",
"self",
",",
"request",
")",
":",
"if",
"request",
".",
"method",
"!=",
"'GET'",
":",
"raise",
"HTTPMethodNotAllowed",
"(",
"request",
".",
"method",
",",
"[",
"'GET'",
"]",
")",
"if",
"not",
"self",
".",
"prepared",
":"... | Prepare for streaming and send HTTP headers.
:param request: regular aiohttp.web.Request. | [
"Prepare",
"for",
"streaming",
"and",
"send",
"HTTP",
"headers",
"."
] | 5148d087f9df75ecea61f574d3c768506680e5dc | https://github.com/aio-libs/aiohttp-sse/blob/5148d087f9df75ecea61f574d3c768506680e5dc/aiohttp_sse/__init__.py#L52-L74 | train |
aio-libs/aiohttp-sse | aiohttp_sse/__init__.py | EventSourceResponse.send | async def send(self, data, id=None, event=None, retry=None):
"""Send data using EventSource protocol
:param str data: The data field for the message.
:param str id: The event ID to set the EventSource object's last
event ID value to.
:param str event: The event's type. If th... | python | async def send(self, data, id=None, event=None, retry=None):
"""Send data using EventSource protocol
:param str data: The data field for the message.
:param str id: The event ID to set the EventSource object's last
event ID value to.
:param str event: The event's type. If th... | [
"async",
"def",
"send",
"(",
"self",
",",
"data",
",",
"id",
"=",
"None",
",",
"event",
"=",
"None",
",",
"retry",
"=",
"None",
")",
":",
"buffer",
"=",
"io",
".",
"StringIO",
"(",
")",
"if",
"id",
"is",
"not",
"None",
":",
"buffer",
".",
"writ... | Send data using EventSource protocol
:param str data: The data field for the message.
:param str id: The event ID to set the EventSource object's last
event ID value to.
:param str event: The event's type. If this is specified, an event will
be dispatched on the browser ... | [
"Send",
"data",
"using",
"EventSource",
"protocol"
] | 5148d087f9df75ecea61f574d3c768506680e5dc | https://github.com/aio-libs/aiohttp-sse/blob/5148d087f9df75ecea61f574d3c768506680e5dc/aiohttp_sse/__init__.py#L76-L111 | train |
aio-libs/aiohttp-sse | aiohttp_sse/__init__.py | EventSourceResponse.wait | async def wait(self):
"""EventSourceResponse object is used for streaming data to the client,
this method returns future, so we can wain until connection will
be closed or other task explicitly call ``stop_streaming`` method.
"""
if self._ping_task is None:
raise Runt... | python | async def wait(self):
"""EventSourceResponse object is used for streaming data to the client,
this method returns future, so we can wain until connection will
be closed or other task explicitly call ``stop_streaming`` method.
"""
if self._ping_task is None:
raise Runt... | [
"async",
"def",
"wait",
"(",
"self",
")",
":",
"if",
"self",
".",
"_ping_task",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"'Response is not started'",
")",
"with",
"contextlib",
".",
"suppress",
"(",
"asyncio",
".",
"CancelledError",
")",
":",
"await"... | EventSourceResponse object is used for streaming data to the client,
this method returns future, so we can wain until connection will
be closed or other task explicitly call ``stop_streaming`` method. | [
"EventSourceResponse",
"object",
"is",
"used",
"for",
"streaming",
"data",
"to",
"the",
"client",
"this",
"method",
"returns",
"future",
"so",
"we",
"can",
"wain",
"until",
"connection",
"will",
"be",
"closed",
"or",
"other",
"task",
"explicitly",
"call",
"sto... | 5148d087f9df75ecea61f574d3c768506680e5dc | https://github.com/aio-libs/aiohttp-sse/blob/5148d087f9df75ecea61f574d3c768506680e5dc/aiohttp_sse/__init__.py#L113-L121 | train |
aio-libs/aiohttp-sse | aiohttp_sse/__init__.py | EventSourceResponse.ping_interval | def ping_interval(self, value):
"""Setter for ping_interval property.
:param int value: interval in sec between two ping values.
"""
if not isinstance(value, int):
raise TypeError("ping interval must be int")
if value < 0:
raise ValueError("ping interval... | python | def ping_interval(self, value):
"""Setter for ping_interval property.
:param int value: interval in sec between two ping values.
"""
if not isinstance(value, int):
raise TypeError("ping interval must be int")
if value < 0:
raise ValueError("ping interval... | [
"def",
"ping_interval",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"int",
")",
":",
"raise",
"TypeError",
"(",
"\"ping interval must be int\"",
")",
"if",
"value",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"ping i... | Setter for ping_interval property.
:param int value: interval in sec between two ping values. | [
"Setter",
"for",
"ping_interval",
"property",
"."
] | 5148d087f9df75ecea61f574d3c768506680e5dc | https://github.com/aio-libs/aiohttp-sse/blob/5148d087f9df75ecea61f574d3c768506680e5dc/aiohttp_sse/__init__.py#L140-L151 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.