partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | Community.add_record | Add a record to the community.
:param record: Record object.
:type record: `invenio_records.api.Record` | invenio_communities/models.py | def add_record(self, record):
"""Add a record to the community.
:param record: Record object.
:type record: `invenio_records.api.Record`
"""
key = current_app.config['COMMUNITIES_RECORD_KEY']
record.setdefault(key, [])
if self.has_record(record):
cur... | def add_record(self, record):
"""Add a record to the community.
:param record: Record object.
:type record: `invenio_records.api.Record`
"""
key = current_app.config['COMMUNITIES_RECORD_KEY']
record.setdefault(key, [])
if self.has_record(record):
cur... | [
"Add",
"a",
"record",
"to",
"the",
"community",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/models.py#L286-L304 | [
"def",
"add_record",
"(",
"self",
",",
"record",
")",
":",
"key",
"=",
"current_app",
".",
"config",
"[",
"'COMMUNITIES_RECORD_KEY'",
"]",
"record",
".",
"setdefault",
"(",
"key",
",",
"[",
"]",
")",
"if",
"self",
".",
"has_record",
"(",
"record",
")",
... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | Community.remove_record | Remove an already accepted record from the community.
:param record: Record object.
:type record: `invenio_records.api.Record` | invenio_communities/models.py | def remove_record(self, record):
"""Remove an already accepted record from the community.
:param record: Record object.
:type record: `invenio_records.api.Record`
"""
if not self.has_record(record):
current_app.logger.warning(
'Community removal: reco... | def remove_record(self, record):
"""Remove an already accepted record from the community.
:param record: Record object.
:type record: `invenio_records.api.Record`
"""
if not self.has_record(record):
current_app.logger.warning(
'Community removal: reco... | [
"Remove",
"an",
"already",
"accepted",
"record",
"from",
"the",
"community",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/models.py#L306-L322 | [
"def",
"remove_record",
"(",
"self",
",",
"record",
")",
":",
"if",
"not",
"self",
".",
"has_record",
"(",
"record",
")",
":",
"current_app",
".",
"logger",
".",
"warning",
"(",
"'Community removal: record {uuid} was not in community '",
"'\"{comm}\"'",
".",
"form... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | Community.accept_record | Accept a record for inclusion in the community.
:param record: Record object. | invenio_communities/models.py | def accept_record(self, record):
"""Accept a record for inclusion in the community.
:param record: Record object.
"""
with db.session.begin_nested():
req = InclusionRequest.get(self.id, record.id)
if req is None:
raise InclusionRequestMissingError... | def accept_record(self, record):
"""Accept a record for inclusion in the community.
:param record: Record object.
"""
with db.session.begin_nested():
req = InclusionRequest.get(self.id, record.id)
if req is None:
raise InclusionRequestMissingError... | [
"Accept",
"a",
"record",
"for",
"inclusion",
"in",
"the",
"community",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/models.py#L329-L341 | [
"def",
"accept_record",
"(",
"self",
",",
"record",
")",
":",
"with",
"db",
".",
"session",
".",
"begin_nested",
"(",
")",
":",
"req",
"=",
"InclusionRequest",
".",
"get",
"(",
"self",
".",
"id",
",",
"record",
".",
"id",
")",
"if",
"req",
"is",
"N... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | Community.reject_record | Reject a record for inclusion in the community.
:param record: Record object. | invenio_communities/models.py | def reject_record(self, record):
"""Reject a record for inclusion in the community.
:param record: Record object.
"""
with db.session.begin_nested():
req = InclusionRequest.get(self.id, record.id)
if req is None:
raise InclusionRequestMissingError... | def reject_record(self, record):
"""Reject a record for inclusion in the community.
:param record: Record object.
"""
with db.session.begin_nested():
req = InclusionRequest.get(self.id, record.id)
if req is None:
raise InclusionRequestMissingError... | [
"Reject",
"a",
"record",
"for",
"inclusion",
"in",
"the",
"community",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/models.py#L343-L353 | [
"def",
"reject_record",
"(",
"self",
",",
"record",
")",
":",
"with",
"db",
".",
"session",
".",
"begin_nested",
"(",
")",
":",
"req",
"=",
"InclusionRequest",
".",
"get",
"(",
"self",
".",
"id",
",",
"record",
".",
"id",
")",
"if",
"req",
"is",
"N... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | Community.delete | Mark the community for deletion.
:param delete_time: DateTime after which to delete the community.
:type delete_time: datetime.datetime
:raises: CommunitiesError | invenio_communities/models.py | def delete(self):
"""Mark the community for deletion.
:param delete_time: DateTime after which to delete the community.
:type delete_time: datetime.datetime
:raises: CommunitiesError
"""
if self.deleted_at is not None:
raise CommunitiesError(community=self)
... | def delete(self):
"""Mark the community for deletion.
:param delete_time: DateTime after which to delete the community.
:type delete_time: datetime.datetime
:raises: CommunitiesError
"""
if self.deleted_at is not None:
raise CommunitiesError(community=self)
... | [
"Mark",
"the",
"community",
"for",
"deletion",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/models.py#L355-L365 | [
"def",
"delete",
"(",
"self",
")",
":",
"if",
"self",
".",
"deleted_at",
"is",
"not",
"None",
":",
"raise",
"CommunitiesError",
"(",
"community",
"=",
"self",
")",
"else",
":",
"self",
".",
"deleted_at",
"=",
"datetime",
".",
"utcnow",
"(",
")"
] | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | Community.logo_url | Get URL to collection logo.
:returns: Path to community logo.
:rtype: str | invenio_communities/models.py | def logo_url(self):
"""Get URL to collection logo.
:returns: Path to community logo.
:rtype: str
"""
if self.logo_ext:
return '/api/files/{bucket}/{key}'.format(
bucket=current_app.config['COMMUNITIES_BUCKET_UUID'],
key='{0}/logo.{1}'.... | def logo_url(self):
"""Get URL to collection logo.
:returns: Path to community logo.
:rtype: str
"""
if self.logo_ext:
return '/api/files/{bucket}/{key}'.format(
bucket=current_app.config['COMMUNITIES_BUCKET_UUID'],
key='{0}/logo.{1}'.... | [
"Get",
"URL",
"to",
"collection",
"logo",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/models.py#L380-L391 | [
"def",
"logo_url",
"(",
"self",
")",
":",
"if",
"self",
".",
"logo_ext",
":",
"return",
"'/api/files/{bucket}/{key}'",
".",
"format",
"(",
"bucket",
"=",
"current_app",
".",
"config",
"[",
"'COMMUNITIES_BUCKET_UUID'",
"]",
",",
"key",
"=",
"'{0}/logo.{1}'",
".... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | Community.oaiset | Return the corresponding OAISet for given community.
If OAIServer is not installed this property will return None.
:returns: returns OAISet object corresponding to this community.
:rtype: `invenio_oaiserver.models.OAISet` or None | invenio_communities/models.py | def oaiset(self):
"""Return the corresponding OAISet for given community.
If OAIServer is not installed this property will return None.
:returns: returns OAISet object corresponding to this community.
:rtype: `invenio_oaiserver.models.OAISet` or None
"""
if current_app.... | def oaiset(self):
"""Return the corresponding OAISet for given community.
If OAIServer is not installed this property will return None.
:returns: returns OAISet object corresponding to this community.
:rtype: `invenio_oaiserver.models.OAISet` or None
"""
if current_app.... | [
"Return",
"the",
"corresponding",
"OAISet",
"for",
"given",
"community",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/models.py#L421-L433 | [
"def",
"oaiset",
"(",
"self",
")",
":",
"if",
"current_app",
".",
"config",
"[",
"'COMMUNITIES_OAI_ENABLED'",
"]",
":",
"from",
"invenio_oaiserver",
".",
"models",
"import",
"OAISet",
"return",
"OAISet",
".",
"query",
".",
"filter_by",
"(",
"spec",
"=",
"sel... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | Community.oaiset_url | Return the OAISet URL for given community.
:returns: URL of corresponding OAISet.
:rtype: str | invenio_communities/models.py | def oaiset_url(self):
"""Return the OAISet URL for given community.
:returns: URL of corresponding OAISet.
:rtype: str
"""
return url_for(
'invenio_oaiserver.response',
verb='ListRecords',
metadataPrefix='oai_dc', set=self.oaiset_spec, _extern... | def oaiset_url(self):
"""Return the OAISet URL for given community.
:returns: URL of corresponding OAISet.
:rtype: str
"""
return url_for(
'invenio_oaiserver.response',
verb='ListRecords',
metadataPrefix='oai_dc', set=self.oaiset_spec, _extern... | [
"Return",
"the",
"OAISet",
"URL",
"for",
"given",
"community",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/models.py#L436-L445 | [
"def",
"oaiset_url",
"(",
"self",
")",
":",
"return",
"url_for",
"(",
"'invenio_oaiserver.response'",
",",
"verb",
"=",
"'ListRecords'",
",",
"metadataPrefix",
"=",
"'oai_dc'",
",",
"set",
"=",
"self",
".",
"oaiset_spec",
",",
"_external",
"=",
"True",
")"
] | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | Community.version_id | Return the version of the community.
:returns: hash which encodes the community id and its las update.
:rtype: str | invenio_communities/models.py | def version_id(self):
"""Return the version of the community.
:returns: hash which encodes the community id and its las update.
:rtype: str
"""
return hashlib.sha1('{0}__{1}'.format(
self.id, self.updated).encode('utf-8')).hexdigest() | def version_id(self):
"""Return the version of the community.
:returns: hash which encodes the community id and its las update.
:rtype: str
"""
return hashlib.sha1('{0}__{1}'.format(
self.id, self.updated).encode('utf-8')).hexdigest() | [
"Return",
"the",
"version",
"of",
"the",
"community",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/models.py#L448-L455 | [
"def",
"version_id",
"(",
"self",
")",
":",
"return",
"hashlib",
".",
"sha1",
"(",
"'{0}__{1}'",
".",
"format",
"(",
"self",
".",
"id",
",",
"self",
".",
"updated",
")",
".",
"encode",
"(",
"'utf-8'",
")",
")",
".",
"hexdigest",
"(",
")"
] | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | FeaturedCommunity.get_featured_or_none | Get the latest featured community.
:param start_date: Date after which the featuring starts
:returns: Community object or None
:rtype: `invenio_communities.models.Community` or None | invenio_communities/models.py | def get_featured_or_none(cls, start_date=None):
"""Get the latest featured community.
:param start_date: Date after which the featuring starts
:returns: Community object or None
:rtype: `invenio_communities.models.Community` or None
"""
start_date = start_date or datetim... | def get_featured_or_none(cls, start_date=None):
"""Get the latest featured community.
:param start_date: Date after which the featuring starts
:returns: Community object or None
:rtype: `invenio_communities.models.Community` or None
"""
start_date = start_date or datetim... | [
"Get",
"the",
"latest",
"featured",
"community",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/models.py#L486-L500 | [
"def",
"get_featured_or_none",
"(",
"cls",
",",
"start_date",
"=",
"None",
")",
":",
"start_date",
"=",
"start_date",
"or",
"datetime",
".",
"utcnow",
"(",
")",
"comm",
"=",
"cls",
".",
"query",
".",
"filter",
"(",
"FeaturedCommunity",
".",
"start_date",
"... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | connector.getConnectorVersion | GET the current Connector version.
:returns: asyncResult object, populates error and result fields
:rtype: asyncResult | mbed_connector_api/mbed_connector_api.py | def getConnectorVersion(self):
"""
GET the current Connector version.
:returns: asyncResult object, populates error and result fields
:rtype: asyncResult
"""
result = asyncResult()
data = self._getURL("/",versioned=False)
result.fill(data)
if data.status_code == 200:
result.error = False
else:
... | def getConnectorVersion(self):
"""
GET the current Connector version.
:returns: asyncResult object, populates error and result fields
:rtype: asyncResult
"""
result = asyncResult()
data = self._getURL("/",versioned=False)
result.fill(data)
if data.status_code == 200:
result.error = False
else:
... | [
"GET",
"the",
"current",
"Connector",
"version",
"."
] | ARMmbed/mbed-connector-api-python | python | https://github.com/ARMmbed/mbed-connector-api-python/blob/a5024a01dc67cc192c8bf7a70b251fcf0a3f279b/mbed_connector_api/mbed_connector_api.py#L72-L87 | [
"def",
"getConnectorVersion",
"(",
"self",
")",
":",
"result",
"=",
"asyncResult",
"(",
")",
"data",
"=",
"self",
".",
"_getURL",
"(",
"\"/\"",
",",
"versioned",
"=",
"False",
")",
"result",
".",
"fill",
"(",
"data",
")",
"if",
"data",
".",
"status_cod... | a5024a01dc67cc192c8bf7a70b251fcf0a3f279b |
train | connector.getEndpoints | Get list of all endpoints on the domain.
:param str typeOfEndpoint: Optional filter endpoints returned by type
:return: list of all endpoints
:rtype: asyncResult | mbed_connector_api/mbed_connector_api.py | def getEndpoints(self,typeOfEndpoint=""):
"""
Get list of all endpoints on the domain.
:param str typeOfEndpoint: Optional filter endpoints returned by type
:return: list of all endpoints
:rtype: asyncResult
"""
q = {}
result = asyncResult()
if typeOfEndpoint:
q['type'] = typeOfEndpoint
resul... | def getEndpoints(self,typeOfEndpoint=""):
"""
Get list of all endpoints on the domain.
:param str typeOfEndpoint: Optional filter endpoints returned by type
:return: list of all endpoints
:rtype: asyncResult
"""
q = {}
result = asyncResult()
if typeOfEndpoint:
q['type'] = typeOfEndpoint
resul... | [
"Get",
"list",
"of",
"all",
"endpoints",
"on",
"the",
"domain",
".",
":",
"param",
"str",
"typeOfEndpoint",
":",
"Optional",
"filter",
"endpoints",
"returned",
"by",
"type",
":",
"return",
":",
"list",
"of",
"all",
"endpoints",
":",
"rtype",
":",
"asyncRes... | ARMmbed/mbed-connector-api-python | python | https://github.com/ARMmbed/mbed-connector-api-python/blob/a5024a01dc67cc192c8bf7a70b251fcf0a3f279b/mbed_connector_api/mbed_connector_api.py#L126-L146 | [
"def",
"getEndpoints",
"(",
"self",
",",
"typeOfEndpoint",
"=",
"\"\"",
")",
":",
"q",
"=",
"{",
"}",
"result",
"=",
"asyncResult",
"(",
")",
"if",
"typeOfEndpoint",
":",
"q",
"[",
"'type'",
"]",
"=",
"typeOfEndpoint",
"result",
".",
"extra",
"[",
"'ty... | a5024a01dc67cc192c8bf7a70b251fcf0a3f279b |
train | connector.getResources | Get list of resources on an endpoint.
:param str ep: Endpoint to get the resources of
:param bool noResp: Optional - specify no response necessary from endpoint
:param bool cacheOnly: Optional - get results from cache on connector, do not wake up endpoint
:return: list of resources
:rtype: asyncResult | mbed_connector_api/mbed_connector_api.py | def getResources(self,ep,noResp=False,cacheOnly=False):
"""
Get list of resources on an endpoint.
:param str ep: Endpoint to get the resources of
:param bool noResp: Optional - specify no response necessary from endpoint
:param bool cacheOnly: Optional - get results from cache on connector, do not wake up ... | def getResources(self,ep,noResp=False,cacheOnly=False):
"""
Get list of resources on an endpoint.
:param str ep: Endpoint to get the resources of
:param bool noResp: Optional - specify no response necessary from endpoint
:param bool cacheOnly: Optional - get results from cache on connector, do not wake up ... | [
"Get",
"list",
"of",
"resources",
"on",
"an",
"endpoint",
".",
":",
"param",
"str",
"ep",
":",
"Endpoint",
"to",
"get",
"the",
"resources",
"of",
":",
"param",
"bool",
"noResp",
":",
"Optional",
"-",
"specify",
"no",
"response",
"necessary",
"from",
"end... | ARMmbed/mbed-connector-api-python | python | https://github.com/ARMmbed/mbed-connector-api-python/blob/a5024a01dc67cc192c8bf7a70b251fcf0a3f279b/mbed_connector_api/mbed_connector_api.py#L149-L178 | [
"def",
"getResources",
"(",
"self",
",",
"ep",
",",
"noResp",
"=",
"False",
",",
"cacheOnly",
"=",
"False",
")",
":",
"# load query params if set to other than defaults",
"q",
"=",
"{",
"}",
"result",
"=",
"asyncResult",
"(",
")",
"result",
".",
"endpoint",
... | a5024a01dc67cc192c8bf7a70b251fcf0a3f279b |
train | connector.getResourceValue | Get value of a specific resource on a specific endpoint.
:param str ep: name of endpoint
:param str res: name of resource
:param fnptr cbfn: Optional - callback function to be called on completion
:param bool noResp: Optional - specify no response necessary from endpoint
:param bool cacheOnly: Optional - g... | mbed_connector_api/mbed_connector_api.py | def getResourceValue(self,ep,res,cbfn="",noResp=False,cacheOnly=False):
"""
Get value of a specific resource on a specific endpoint.
:param str ep: name of endpoint
:param str res: name of resource
:param fnptr cbfn: Optional - callback function to be called on completion
:param bool noResp: Optional - s... | def getResourceValue(self,ep,res,cbfn="",noResp=False,cacheOnly=False):
"""
Get value of a specific resource on a specific endpoint.
:param str ep: name of endpoint
:param str res: name of resource
:param fnptr cbfn: Optional - callback function to be called on completion
:param bool noResp: Optional - s... | [
"Get",
"value",
"of",
"a",
"specific",
"resource",
"on",
"a",
"specific",
"endpoint",
".",
":",
"param",
"str",
"ep",
":",
"name",
"of",
"endpoint",
":",
"param",
"str",
"res",
":",
"name",
"of",
"resource",
":",
"param",
"fnptr",
"cbfn",
":",
"Optiona... | ARMmbed/mbed-connector-api-python | python | https://github.com/ARMmbed/mbed-connector-api-python/blob/a5024a01dc67cc192c8bf7a70b251fcf0a3f279b/mbed_connector_api/mbed_connector_api.py#L182-L217 | [
"def",
"getResourceValue",
"(",
"self",
",",
"ep",
",",
"res",
",",
"cbfn",
"=",
"\"\"",
",",
"noResp",
"=",
"False",
",",
"cacheOnly",
"=",
"False",
")",
":",
"q",
"=",
"{",
"}",
"result",
"=",
"asyncResult",
"(",
"callback",
"=",
"cbfn",
")",
"#s... | a5024a01dc67cc192c8bf7a70b251fcf0a3f279b |
train | connector.putResourceValue | Put a value to a resource on an endpoint
:param str ep: name of endpoint
:param str res: name of resource
:param str data: data to send via PUT
:param fnptr cbfn: Optional - callback funtion to call when operation is completed
:return: successful ``.status_code`` / ``.is_done``. Check the ``.error``
:rty... | mbed_connector_api/mbed_connector_api.py | def putResourceValue(self,ep,res,data,cbfn=""):
"""
Put a value to a resource on an endpoint
:param str ep: name of endpoint
:param str res: name of resource
:param str data: data to send via PUT
:param fnptr cbfn: Optional - callback funtion to call when operation is completed
:return: successful ``.s... | def putResourceValue(self,ep,res,data,cbfn=""):
"""
Put a value to a resource on an endpoint
:param str ep: name of endpoint
:param str res: name of resource
:param str data: data to send via PUT
:param fnptr cbfn: Optional - callback funtion to call when operation is completed
:return: successful ``.s... | [
"Put",
"a",
"value",
"to",
"a",
"resource",
"on",
"an",
"endpoint",
":",
"param",
"str",
"ep",
":",
"name",
"of",
"endpoint",
":",
"param",
"str",
"res",
":",
"name",
"of",
"resource",
":",
"param",
"str",
"data",
":",
"data",
"to",
"send",
"via",
... | ARMmbed/mbed-connector-api-python | python | https://github.com/ARMmbed/mbed-connector-api-python/blob/a5024a01dc67cc192c8bf7a70b251fcf0a3f279b/mbed_connector_api/mbed_connector_api.py#L220-L245 | [
"def",
"putResourceValue",
"(",
"self",
",",
"ep",
",",
"res",
",",
"data",
",",
"cbfn",
"=",
"\"\"",
")",
":",
"result",
"=",
"asyncResult",
"(",
"callback",
"=",
"cbfn",
")",
"result",
".",
"endpoint",
"=",
"ep",
"result",
".",
"resource",
"=",
"re... | a5024a01dc67cc192c8bf7a70b251fcf0a3f279b |
train | connector.deleteEndpoint | Send DELETE message to an endpoint.
:param str ep: name of endpoint
:param fnptr cbfn: Optional - callback funtion to call when operation is completed
:return: successful ``.status_code`` / ``.is_done``. Check the ``.error``
:rtype: asyncResult | mbed_connector_api/mbed_connector_api.py | def deleteEndpoint(self,ep,cbfn=""):
'''
Send DELETE message to an endpoint.
:param str ep: name of endpoint
:param fnptr cbfn: Optional - callback funtion to call when operation is completed
:return: successful ``.status_code`` / ``.is_done``. Check the ``.error``
:rtype: asyncResult
'''
result = as... | def deleteEndpoint(self,ep,cbfn=""):
'''
Send DELETE message to an endpoint.
:param str ep: name of endpoint
:param fnptr cbfn: Optional - callback funtion to call when operation is completed
:return: successful ``.status_code`` / ``.is_done``. Check the ``.error``
:rtype: asyncResult
'''
result = as... | [
"Send",
"DELETE",
"message",
"to",
"an",
"endpoint",
".",
":",
"param",
"str",
"ep",
":",
"name",
"of",
"endpoint",
":",
"param",
"fnptr",
"cbfn",
":",
"Optional",
"-",
"callback",
"funtion",
"to",
"call",
"when",
"operation",
"is",
"completed",
":",
"re... | ARMmbed/mbed-connector-api-python | python | https://github.com/ARMmbed/mbed-connector-api-python/blob/a5024a01dc67cc192c8bf7a70b251fcf0a3f279b/mbed_connector_api/mbed_connector_api.py#L276-L298 | [
"def",
"deleteEndpoint",
"(",
"self",
",",
"ep",
",",
"cbfn",
"=",
"\"\"",
")",
":",
"result",
"=",
"asyncResult",
"(",
"callback",
"=",
"cbfn",
")",
"result",
".",
"endpoint",
"=",
"ep",
"data",
"=",
"self",
".",
"_deleteURL",
"(",
"\"/endpoints/\"",
... | a5024a01dc67cc192c8bf7a70b251fcf0a3f279b |
train | connector.deleteEndpointSubscriptions | Delete all subscriptions on specified endpoint ``ep``
:param str ep: name of endpoint
:return: successful ``.status_code`` / ``.is_done``. Check the ``.error``
:rtype: asyncResult | mbed_connector_api/mbed_connector_api.py | def deleteEndpointSubscriptions(self,ep):
'''
Delete all subscriptions on specified endpoint ``ep``
:param str ep: name of endpoint
:return: successful ``.status_code`` / ``.is_done``. Check the ``.error``
:rtype: asyncResult
'''
result = asyncResult()
result.endpoint = ep
data = self._deleteURL("... | def deleteEndpointSubscriptions(self,ep):
'''
Delete all subscriptions on specified endpoint ``ep``
:param str ep: name of endpoint
:return: successful ``.status_code`` / ``.is_done``. Check the ``.error``
:rtype: asyncResult
'''
result = asyncResult()
result.endpoint = ep
data = self._deleteURL("... | [
"Delete",
"all",
"subscriptions",
"on",
"specified",
"endpoint",
"ep",
":",
"param",
"str",
"ep",
":",
"name",
"of",
"endpoint",
":",
"return",
":",
"successful",
".",
"status_code",
"/",
".",
"is_done",
".",
"Check",
"the",
".",
"error",
":",
"rtype",
"... | ARMmbed/mbed-connector-api-python | python | https://github.com/ARMmbed/mbed-connector-api-python/blob/a5024a01dc67cc192c8bf7a70b251fcf0a3f279b/mbed_connector_api/mbed_connector_api.py#L329-L348 | [
"def",
"deleteEndpointSubscriptions",
"(",
"self",
",",
"ep",
")",
":",
"result",
"=",
"asyncResult",
"(",
")",
"result",
".",
"endpoint",
"=",
"ep",
"data",
"=",
"self",
".",
"_deleteURL",
"(",
"\"/subscriptions/\"",
"+",
"ep",
")",
"if",
"data",
".",
"... | a5024a01dc67cc192c8bf7a70b251fcf0a3f279b |
train | connector.deleteAllSubscriptions | Delete all subscriptions on the domain (all endpoints, all resources)
:return: successful ``.status_code`` / ``.is_done``. Check the ``.error``
:rtype: asyncResult | mbed_connector_api/mbed_connector_api.py | def deleteAllSubscriptions(self):
'''
Delete all subscriptions on the domain (all endpoints, all resources)
:return: successful ``.status_code`` / ``.is_done``. Check the ``.error``
:rtype: asyncResult
'''
result = asyncResult()
data = self._deleteURL("/subscriptions/")
if data.status_code == 204: #i... | def deleteAllSubscriptions(self):
'''
Delete all subscriptions on the domain (all endpoints, all resources)
:return: successful ``.status_code`` / ``.is_done``. Check the ``.error``
:rtype: asyncResult
'''
result = asyncResult()
data = self._deleteURL("/subscriptions/")
if data.status_code == 204: #i... | [
"Delete",
"all",
"subscriptions",
"on",
"the",
"domain",
"(",
"all",
"endpoints",
"all",
"resources",
")",
":",
"return",
":",
"successful",
".",
"status_code",
"/",
".",
"is_done",
".",
"Check",
"the",
".",
"error",
":",
"rtype",
":",
"asyncResult"
] | ARMmbed/mbed-connector-api-python | python | https://github.com/ARMmbed/mbed-connector-api-python/blob/a5024a01dc67cc192c8bf7a70b251fcf0a3f279b/mbed_connector_api/mbed_connector_api.py#L373-L390 | [
"def",
"deleteAllSubscriptions",
"(",
"self",
")",
":",
"result",
"=",
"asyncResult",
"(",
")",
"data",
"=",
"self",
".",
"_deleteURL",
"(",
"\"/subscriptions/\"",
")",
"if",
"data",
".",
"status_code",
"==",
"204",
":",
"#immediate success",
"result",
".",
... | a5024a01dc67cc192c8bf7a70b251fcf0a3f279b |
train | connector.getEndpointSubscriptions | Get list of all subscriptions on a given endpoint ``ep``
:param str ep: name of endpoint
:return: successful ``.status_code`` / ``.is_done``. Check the ``.error``
:rtype: asyncResult | mbed_connector_api/mbed_connector_api.py | def getEndpointSubscriptions(self,ep):
'''
Get list of all subscriptions on a given endpoint ``ep``
:param str ep: name of endpoint
:return: successful ``.status_code`` / ``.is_done``. Check the ``.error``
:rtype: asyncResult
'''
result = asyncResult()
result.endpoint = ep
data = self._getURL("/sub... | def getEndpointSubscriptions(self,ep):
'''
Get list of all subscriptions on a given endpoint ``ep``
:param str ep: name of endpoint
:return: successful ``.status_code`` / ``.is_done``. Check the ``.error``
:rtype: asyncResult
'''
result = asyncResult()
result.endpoint = ep
data = self._getURL("/sub... | [
"Get",
"list",
"of",
"all",
"subscriptions",
"on",
"a",
"given",
"endpoint",
"ep",
":",
"param",
"str",
"ep",
":",
"name",
"of",
"endpoint",
":",
"return",
":",
"successful",
".",
"status_code",
"/",
".",
"is_done",
".",
"Check",
"the",
".",
"error",
"... | ARMmbed/mbed-connector-api-python | python | https://github.com/ARMmbed/mbed-connector-api-python/blob/a5024a01dc67cc192c8bf7a70b251fcf0a3f279b/mbed_connector_api/mbed_connector_api.py#L394-L414 | [
"def",
"getEndpointSubscriptions",
"(",
"self",
",",
"ep",
")",
":",
"result",
"=",
"asyncResult",
"(",
")",
"result",
".",
"endpoint",
"=",
"ep",
"data",
"=",
"self",
".",
"_getURL",
"(",
"\"/subscriptions/\"",
"+",
"ep",
")",
"if",
"data",
".",
"status... | a5024a01dc67cc192c8bf7a70b251fcf0a3f279b |
train | connector.getResourceSubscription | Get list of all subscriptions for a resource ``res`` on an endpoint ``ep``
:param str ep: name of endpoint
:param str res: name of resource
:return: successful ``.status_code`` / ``.is_done``. Check the ``.error``
:rtype: asyncResult | mbed_connector_api/mbed_connector_api.py | def getResourceSubscription(self,ep,res):
'''
Get list of all subscriptions for a resource ``res`` on an endpoint ``ep``
:param str ep: name of endpoint
:param str res: name of resource
:return: successful ``.status_code`` / ``.is_done``. Check the ``.error``
:rtype: asyncResult
'''
result = asyncRes... | def getResourceSubscription(self,ep,res):
'''
Get list of all subscriptions for a resource ``res`` on an endpoint ``ep``
:param str ep: name of endpoint
:param str res: name of resource
:return: successful ``.status_code`` / ``.is_done``. Check the ``.error``
:rtype: asyncResult
'''
result = asyncRes... | [
"Get",
"list",
"of",
"all",
"subscriptions",
"for",
"a",
"resource",
"res",
"on",
"an",
"endpoint",
"ep",
":",
"param",
"str",
"ep",
":",
"name",
"of",
"endpoint",
":",
"param",
"str",
"res",
":",
"name",
"of",
"resource",
":",
"return",
":",
"successf... | ARMmbed/mbed-connector-api-python | python | https://github.com/ARMmbed/mbed-connector-api-python/blob/a5024a01dc67cc192c8bf7a70b251fcf0a3f279b/mbed_connector_api/mbed_connector_api.py#L418-L440 | [
"def",
"getResourceSubscription",
"(",
"self",
",",
"ep",
",",
"res",
")",
":",
"result",
"=",
"asyncResult",
"(",
")",
"result",
".",
"endpoint",
"=",
"ep",
"result",
".",
"resource",
"=",
"res",
"data",
"=",
"self",
".",
"_getURL",
"(",
"\"/subscriptio... | a5024a01dc67cc192c8bf7a70b251fcf0a3f279b |
train | connector.putPreSubscription | Set pre-subscription rules for all endpoints / resources on the domain.
This can be useful for all current and future endpoints/resources.
:param json JSONdata: data to use as pre-subscription data. Wildcards are permitted
:return: successful ``.status_code`` / ``.is_done``. Check the ``.error``
:rtype: asyn... | mbed_connector_api/mbed_connector_api.py | def putPreSubscription(self,JSONdata):
'''
Set pre-subscription rules for all endpoints / resources on the domain.
This can be useful for all current and future endpoints/resources.
:param json JSONdata: data to use as pre-subscription data. Wildcards are permitted
:return: successful ``.status_code`` / ``... | def putPreSubscription(self,JSONdata):
'''
Set pre-subscription rules for all endpoints / resources on the domain.
This can be useful for all current and future endpoints/resources.
:param json JSONdata: data to use as pre-subscription data. Wildcards are permitted
:return: successful ``.status_code`` / ``... | [
"Set",
"pre",
"-",
"subscription",
"rules",
"for",
"all",
"endpoints",
"/",
"resources",
"on",
"the",
"domain",
".",
"This",
"can",
"be",
"useful",
"for",
"all",
"current",
"and",
"future",
"endpoints",
"/",
"resources",
".",
":",
"param",
"json",
"JSONdat... | ARMmbed/mbed-connector-api-python | python | https://github.com/ARMmbed/mbed-connector-api-python/blob/a5024a01dc67cc192c8bf7a70b251fcf0a3f279b/mbed_connector_api/mbed_connector_api.py#L442-L467 | [
"def",
"putPreSubscription",
"(",
"self",
",",
"JSONdata",
")",
":",
"if",
"isinstance",
"(",
"JSONdata",
",",
"str",
")",
"and",
"self",
".",
"_isJSON",
"(",
"JSONdata",
")",
":",
"self",
".",
"log",
".",
"warn",
"(",
"\"pre-subscription data was a string, ... | a5024a01dc67cc192c8bf7a70b251fcf0a3f279b |
train | connector.getPreSubscription | Get the current pre-subscription data from connector
:return: JSON that represents the pre-subscription data in the ``.result`` field
:rtype: asyncResult | mbed_connector_api/mbed_connector_api.py | def getPreSubscription(self):
'''
Get the current pre-subscription data from connector
:return: JSON that represents the pre-subscription data in the ``.result`` field
:rtype: asyncResult
'''
result = asyncResult()
data = self._getURL("/subscriptions")
if data.status_code == 200: #immediate success
... | def getPreSubscription(self):
'''
Get the current pre-subscription data from connector
:return: JSON that represents the pre-subscription data in the ``.result`` field
:rtype: asyncResult
'''
result = asyncResult()
data = self._getURL("/subscriptions")
if data.status_code == 200: #immediate success
... | [
"Get",
"the",
"current",
"pre",
"-",
"subscription",
"data",
"from",
"connector",
":",
"return",
":",
"JSON",
"that",
"represents",
"the",
"pre",
"-",
"subscription",
"data",
"in",
"the",
".",
"result",
"field",
":",
"rtype",
":",
"asyncResult"
] | ARMmbed/mbed-connector-api-python | python | https://github.com/ARMmbed/mbed-connector-api-python/blob/a5024a01dc67cc192c8bf7a70b251fcf0a3f279b/mbed_connector_api/mbed_connector_api.py#L469-L487 | [
"def",
"getPreSubscription",
"(",
"self",
")",
":",
"result",
"=",
"asyncResult",
"(",
")",
"data",
"=",
"self",
".",
"_getURL",
"(",
"\"/subscriptions\"",
")",
"if",
"data",
".",
"status_code",
"==",
"200",
":",
"#immediate success",
"result",
".",
"error",... | a5024a01dc67cc192c8bf7a70b251fcf0a3f279b |
train | connector.putCallback | Set the callback URL. To be used in place of LongPolling when deploying a webapp.
**note**: make sure you set up a callback URL in your web app
:param str url: complete url, including port, where the callback url is located
:param str headers: Optional - Headers to have Connector send back with all calls
... | mbed_connector_api/mbed_connector_api.py | def putCallback(self,url,headers=""):
'''
Set the callback URL. To be used in place of LongPolling when deploying a webapp.
**note**: make sure you set up a callback URL in your web app
:param str url: complete url, including port, where the callback url is located
:param str headers: Optional - Headers... | def putCallback(self,url,headers=""):
'''
Set the callback URL. To be used in place of LongPolling when deploying a webapp.
**note**: make sure you set up a callback URL in your web app
:param str url: complete url, including port, where the callback url is located
:param str headers: Optional - Headers... | [
"Set",
"the",
"callback",
"URL",
".",
"To",
"be",
"used",
"in",
"place",
"of",
"LongPolling",
"when",
"deploying",
"a",
"webapp",
".",
"**",
"note",
"**",
":",
"make",
"sure",
"you",
"set",
"up",
"a",
"callback",
"URL",
"in",
"your",
"web",
"app",
":... | ARMmbed/mbed-connector-api-python | python | https://github.com/ARMmbed/mbed-connector-api-python/blob/a5024a01dc67cc192c8bf7a70b251fcf0a3f279b/mbed_connector_api/mbed_connector_api.py#L489-L513 | [
"def",
"putCallback",
"(",
"self",
",",
"url",
",",
"headers",
"=",
"\"\"",
")",
":",
"result",
"=",
"asyncResult",
"(",
")",
"payloadToSend",
"=",
"{",
"\"url\"",
":",
"url",
"}",
"if",
"headers",
":",
"payload",
"[",
"'headers'",
":",
"headers",
"]",... | a5024a01dc67cc192c8bf7a70b251fcf0a3f279b |
train | connector.setHandler | Register a handler for a particular notification type.
These are the types of notifications that are acceptable.
| 'async-responses'
| 'registrations-expired'
| 'de-registrations'
| 'reg-updates'
| 'registrations'
| 'notifications'
:param str handler: name of the notification type
:param fnptr cb... | mbed_connector_api/mbed_connector_api.py | def setHandler(self,handler,cbfn):
'''
Register a handler for a particular notification type.
These are the types of notifications that are acceptable.
| 'async-responses'
| 'registrations-expired'
| 'de-registrations'
| 'reg-updates'
| 'registrations'
| 'notifications'
:param str handler: name... | def setHandler(self,handler,cbfn):
'''
Register a handler for a particular notification type.
These are the types of notifications that are acceptable.
| 'async-responses'
| 'registrations-expired'
| 'de-registrations'
| 'reg-updates'
| 'registrations'
| 'notifications'
:param str handler: name... | [
"Register",
"a",
"handler",
"for",
"a",
"particular",
"notification",
"type",
".",
"These",
"are",
"the",
"types",
"of",
"notifications",
"that",
"are",
"acceptable",
".",
"|",
"async",
"-",
"responses",
"|",
"registrations",
"-",
"expired",
"|",
"de",
"-",
... | ARMmbed/mbed-connector-api-python | python | https://github.com/ARMmbed/mbed-connector-api-python/blob/a5024a01dc67cc192c8bf7a70b251fcf0a3f279b/mbed_connector_api/mbed_connector_api.py#L554-L583 | [
"def",
"setHandler",
"(",
"self",
",",
"handler",
",",
"cbfn",
")",
":",
"if",
"handler",
"==",
"\"async-responses\"",
":",
"self",
".",
"async_responses_callback",
"=",
"cbfn",
"elif",
"handler",
"==",
"\"registrations-expired\"",
":",
"self",
".",
"registratio... | a5024a01dc67cc192c8bf7a70b251fcf0a3f279b |
train | connector.startLongPolling | Start LongPolling Connector for notifications.
:param bool noWait: Optional - use the cached values in connector, do not wait for the device to respond
:return: Thread of constantly running LongPoll. To be used to kill the thred if necessary.
:rtype: pythonThread | mbed_connector_api/mbed_connector_api.py | def startLongPolling(self, noWait=False):
'''
Start LongPolling Connector for notifications.
:param bool noWait: Optional - use the cached values in connector, do not wait for the device to respond
:return: Thread of constantly running LongPoll. To be used to kill the thred if necessary.
:rtype: pythonThre... | def startLongPolling(self, noWait=False):
'''
Start LongPolling Connector for notifications.
:param bool noWait: Optional - use the cached values in connector, do not wait for the device to respond
:return: Thread of constantly running LongPoll. To be used to kill the thred if necessary.
:rtype: pythonThre... | [
"Start",
"LongPolling",
"Connector",
"for",
"notifications",
".",
":",
"param",
"bool",
"noWait",
":",
"Optional",
"-",
"use",
"the",
"cached",
"values",
"in",
"connector",
"do",
"not",
"wait",
"for",
"the",
"device",
"to",
"respond",
":",
"return",
":",
"... | ARMmbed/mbed-connector-api-python | python | https://github.com/ARMmbed/mbed-connector-api-python/blob/a5024a01dc67cc192c8bf7a70b251fcf0a3f279b/mbed_connector_api/mbed_connector_api.py#L587-L608 | [
"def",
"startLongPolling",
"(",
"self",
",",
"noWait",
"=",
"False",
")",
":",
"# check Asynch ID's against insternal database of ID's",
"# Call return function with the value given, maybe decode from base64?",
"wait",
"=",
"''",
"if",
"(",
"noWait",
"==",
"True",
")",
":",... | a5024a01dc67cc192c8bf7a70b251fcf0a3f279b |
train | connector.stopLongPolling | Stop LongPolling thread
:return: none | mbed_connector_api/mbed_connector_api.py | def stopLongPolling(self):
'''
Stop LongPolling thread
:return: none
'''
if(self.longPollThread.isAlive()):
self._stopLongPolling.set()
self.log.debug("set stop longpolling flag")
else:
self.log.warn("LongPolling thread already stopped")
return | def stopLongPolling(self):
'''
Stop LongPolling thread
:return: none
'''
if(self.longPollThread.isAlive()):
self._stopLongPolling.set()
self.log.debug("set stop longpolling flag")
else:
self.log.warn("LongPolling thread already stopped")
return | [
"Stop",
"LongPolling",
"thread",
":",
"return",
":",
"none"
] | ARMmbed/mbed-connector-api-python | python | https://github.com/ARMmbed/mbed-connector-api-python/blob/a5024a01dc67cc192c8bf7a70b251fcf0a3f279b/mbed_connector_api/mbed_connector_api.py#L611-L622 | [
"def",
"stopLongPolling",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"longPollThread",
".",
"isAlive",
"(",
")",
")",
":",
"self",
".",
"_stopLongPolling",
".",
"set",
"(",
")",
"self",
".",
"log",
".",
"debug",
"(",
"\"set stop longpolling flag\"",
... | a5024a01dc67cc192c8bf7a70b251fcf0a3f279b |
train | connector.handler | Function to handle notification data as part of Callback URL handler.
:param str data: data posted to Callback URL by connector.
:return: nothing | mbed_connector_api/mbed_connector_api.py | def handler(self,data):
'''
Function to handle notification data as part of Callback URL handler.
:param str data: data posted to Callback URL by connector.
:return: nothing
'''
if isinstance(data,r.models.Response):
self.log.debug("data is request object = %s", str(data.content))
data = data.con... | def handler(self,data):
'''
Function to handle notification data as part of Callback URL handler.
:param str data: data posted to Callback URL by connector.
:return: nothing
'''
if isinstance(data,r.models.Response):
self.log.debug("data is request object = %s", str(data.content))
data = data.con... | [
"Function",
"to",
"handle",
"notification",
"data",
"as",
"part",
"of",
"Callback",
"URL",
"handler",
".",
":",
"param",
"str",
"data",
":",
"data",
"posted",
"to",
"Callback",
"URL",
"by",
"connector",
".",
":",
"return",
":",
"nothing"
] | ARMmbed/mbed-connector-api-python | python | https://github.com/ARMmbed/mbed-connector-api-python/blob/a5024a01dc67cc192c8bf7a70b251fcf0a3f279b/mbed_connector_api/mbed_connector_api.py#L648-L685 | [
"def",
"handler",
"(",
"self",
",",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"r",
".",
"models",
".",
"Response",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"data is request object = %s\"",
",",
"str",
"(",
"data",
".",
"content... | a5024a01dc67cc192c8bf7a70b251fcf0a3f279b |
train | connector.debug | Enable / Disable debugging
:param bool onOff: turn debugging on / off
:return: none | mbed_connector_api/mbed_connector_api.py | def debug(self,onOff,level='DEBUG'):
'''
Enable / Disable debugging
:param bool onOff: turn debugging on / off
:return: none
'''
if onOff:
if level == 'DEBUG':
self.log.setLevel(logging.DEBUG)
self._ch.setLevel(logging.DEBUG)
self.log.debug("Debugging level DEBUG enabled")
elif level =... | def debug(self,onOff,level='DEBUG'):
'''
Enable / Disable debugging
:param bool onOff: turn debugging on / off
:return: none
'''
if onOff:
if level == 'DEBUG':
self.log.setLevel(logging.DEBUG)
self._ch.setLevel(logging.DEBUG)
self.log.debug("Debugging level DEBUG enabled")
elif level =... | [
"Enable",
"/",
"Disable",
"debugging",
":",
"param",
"bool",
"onOff",
":",
"turn",
"debugging",
"on",
"/",
"off",
":",
"return",
":",
"none"
] | ARMmbed/mbed-connector-api-python | python | https://github.com/ARMmbed/mbed-connector-api-python/blob/a5024a01dc67cc192c8bf7a70b251fcf0a3f279b/mbed_connector_api/mbed_connector_api.py#L688-L715 | [
"def",
"debug",
"(",
"self",
",",
"onOff",
",",
"level",
"=",
"'DEBUG'",
")",
":",
"if",
"onOff",
":",
"if",
"level",
"==",
"'DEBUG'",
":",
"self",
".",
"log",
".",
"setLevel",
"(",
"logging",
".",
"DEBUG",
")",
"self",
".",
"_ch",
".",
"setLevel",... | a5024a01dc67cc192c8bf7a70b251fcf0a3f279b |
train | JSGEbnf.python_cardinality | Add the appropriate python typing to subject (e.g. Optional, List, ...)
:param subject: Subject to be decorated
:param all_are_optional: Force everything to be optional
:return: Typed subject | pyjsg/parser_impl/jsg_ebnf_parser.py | def python_cardinality(self, subject: str, all_are_optional: bool = False) -> str:
"""Add the appropriate python typing to subject (e.g. Optional, List, ...)
:param subject: Subject to be decorated
:param all_are_optional: Force everything to be optional
:return: Typed subject
"... | def python_cardinality(self, subject: str, all_are_optional: bool = False) -> str:
"""Add the appropriate python typing to subject (e.g. Optional, List, ...)
:param subject: Subject to be decorated
:param all_are_optional: Force everything to be optional
:return: Typed subject
"... | [
"Add",
"the",
"appropriate",
"python",
"typing",
"to",
"subject",
"(",
"e",
".",
"g",
".",
"Optional",
"List",
"...",
")"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_ebnf_parser.py#L36-L53 | [
"def",
"python_cardinality",
"(",
"self",
",",
"subject",
":",
"str",
",",
"all_are_optional",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"if",
"self",
".",
"multiple_elements",
":",
"rval",
"=",
"f\"typing.List[{subject}]\"",
"elif",
"self",
".",
"on... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | JSGEbnf.signature_cardinality | Add the appropriate python typing to subject (e.g. Optional, List, ...)
:param subject: Subject to be decorated
:param all_are_optional: Force everything to be optional
:return: Typed subject | pyjsg/parser_impl/jsg_ebnf_parser.py | def signature_cardinality(self, subject: str, all_are_optional: bool = False) -> str:
"""Add the appropriate python typing to subject (e.g. Optional, List, ...)
:param subject: Subject to be decorated
:param all_are_optional: Force everything to be optional
:return: Typed subject
... | def signature_cardinality(self, subject: str, all_are_optional: bool = False) -> str:
"""Add the appropriate python typing to subject (e.g. Optional, List, ...)
:param subject: Subject to be decorated
:param all_are_optional: Force everything to be optional
:return: Typed subject
... | [
"Add",
"the",
"appropriate",
"python",
"typing",
"to",
"subject",
"(",
"e",
".",
"g",
".",
"Optional",
"List",
"...",
")"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_ebnf_parser.py#L55-L72 | [
"def",
"signature_cardinality",
"(",
"self",
",",
"subject",
":",
"str",
",",
"all_are_optional",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"if",
"self",
".",
"multiple_elements",
":",
"rval",
"=",
"f\"jsg.ArrayFactory('{{name}}', _CONTEXT, {subject}, {self.... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | JSGEbnf.visitEbnfSuffix | ebnfSuffix: QMARK | STAR | PLUS | OBRACE INT (COMMA (INT|STAR)?)? CBRACE | pyjsg/parser_impl/jsg_ebnf_parser.py | def visitEbnfSuffix(self, ctx: jsgParser.EbnfSuffixContext):
""" ebnfSuffix: QMARK | STAR | PLUS | OBRACE INT (COMMA (INT|STAR)?)? CBRACE """
self._ebnftext = ctx.getText()
if ctx.INT():
self.min = int(ctx.INT(0).getText())
if ctx.COMMA():
if len(ctx.INT()... | def visitEbnfSuffix(self, ctx: jsgParser.EbnfSuffixContext):
""" ebnfSuffix: QMARK | STAR | PLUS | OBRACE INT (COMMA (INT|STAR)?)? CBRACE """
self._ebnftext = ctx.getText()
if ctx.INT():
self.min = int(ctx.INT(0).getText())
if ctx.COMMA():
if len(ctx.INT()... | [
"ebnfSuffix",
":",
"QMARK",
"|",
"STAR",
"|",
"PLUS",
"|",
"OBRACE",
"INT",
"(",
"COMMA",
"(",
"INT|STAR",
")",
"?",
")",
"?",
"CBRACE"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_ebnf_parser.py#L80-L102 | [
"def",
"visitEbnfSuffix",
"(",
"self",
",",
"ctx",
":",
"jsgParser",
".",
"EbnfSuffixContext",
")",
":",
"self",
".",
"_ebnftext",
"=",
"ctx",
".",
"getText",
"(",
")",
"if",
"ctx",
".",
"INT",
"(",
")",
":",
"self",
".",
"min",
"=",
"int",
"(",
"c... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | JSGDocParser.as_python | Return the python representation of the document | pyjsg/parser_impl/jsg_doc_parser.py | def as_python(self, infile, include_original_shex: bool=False):
""" Return the python representation of the document """
self._context.resolve_circular_references() # add forwards for any circular entries
body = ''
for k in self._context.ordered_elements():
v = sel... | def as_python(self, infile, include_original_shex: bool=False):
""" Return the python representation of the document """
self._context.resolve_circular_references() # add forwards for any circular entries
body = ''
for k in self._context.ordered_elements():
v = sel... | [
"Return",
"the",
"python",
"representation",
"of",
"the",
"document"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_doc_parser.py#L36-L59 | [
"def",
"as_python",
"(",
"self",
",",
"infile",
",",
"include_original_shex",
":",
"bool",
"=",
"False",
")",
":",
"self",
".",
"_context",
".",
"resolve_circular_references",
"(",
")",
"# add forwards for any circular entries",
"body",
"=",
"''",
"for",
"k",
"i... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | JSGDocParser.visitTypeDirective | directive: '.TYPE' name typeExceptions? SEMI | pyjsg/parser_impl/jsg_doc_parser.py | def visitTypeDirective(self, ctx: jsgParser.TypeDirectiveContext):
""" directive: '.TYPE' name typeExceptions? SEMI """
self._context.directives.append('_CONTEXT.TYPE = "{}"'.format(as_token(ctx.name())))
self._context.has_typeid = True
self.visitChildren(ctx) | def visitTypeDirective(self, ctx: jsgParser.TypeDirectiveContext):
""" directive: '.TYPE' name typeExceptions? SEMI """
self._context.directives.append('_CONTEXT.TYPE = "{}"'.format(as_token(ctx.name())))
self._context.has_typeid = True
self.visitChildren(ctx) | [
"directive",
":",
".",
"TYPE",
"name",
"typeExceptions?",
"SEMI"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_doc_parser.py#L75-L79 | [
"def",
"visitTypeDirective",
"(",
"self",
",",
"ctx",
":",
"jsgParser",
".",
"TypeDirectiveContext",
")",
":",
"self",
".",
"_context",
".",
"directives",
".",
"append",
"(",
"'_CONTEXT.TYPE = \"{}\"'",
".",
"format",
"(",
"as_token",
"(",
"ctx",
".",
"name",
... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | JSGDocParser.visitTypeExceptions | typeExceptions: DASH idref+ | pyjsg/parser_impl/jsg_doc_parser.py | def visitTypeExceptions(self, ctx: jsgParser.TypeExceptionsContext):
""" typeExceptions: DASH idref+ """
for tkn in as_tokens(ctx.idref()):
self._context.directives.append('_CONTEXT.TYPE_EXCEPTIONS.append("{}")'.format(tkn)) | def visitTypeExceptions(self, ctx: jsgParser.TypeExceptionsContext):
""" typeExceptions: DASH idref+ """
for tkn in as_tokens(ctx.idref()):
self._context.directives.append('_CONTEXT.TYPE_EXCEPTIONS.append("{}")'.format(tkn)) | [
"typeExceptions",
":",
"DASH",
"idref",
"+"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_doc_parser.py#L81-L84 | [
"def",
"visitTypeExceptions",
"(",
"self",
",",
"ctx",
":",
"jsgParser",
".",
"TypeExceptionsContext",
")",
":",
"for",
"tkn",
"in",
"as_tokens",
"(",
"ctx",
".",
"idref",
"(",
")",
")",
":",
"self",
".",
"_context",
".",
"directives",
".",
"append",
"("... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | JSGDocParser.visitIgnoreDirective | directive: '.IGNORE' name* SEMI | pyjsg/parser_impl/jsg_doc_parser.py | def visitIgnoreDirective(self, ctx: jsgParser.IgnoreDirectiveContext):
""" directive: '.IGNORE' name* SEMI """
for name in as_tokens(ctx.name()):
self._context.directives.append('_CONTEXT.IGNORE.append("{}")'.format(name)) | def visitIgnoreDirective(self, ctx: jsgParser.IgnoreDirectiveContext):
""" directive: '.IGNORE' name* SEMI """
for name in as_tokens(ctx.name()):
self._context.directives.append('_CONTEXT.IGNORE.append("{}")'.format(name)) | [
"directive",
":",
".",
"IGNORE",
"name",
"*",
"SEMI"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_doc_parser.py#L86-L89 | [
"def",
"visitIgnoreDirective",
"(",
"self",
",",
"ctx",
":",
"jsgParser",
".",
"IgnoreDirectiveContext",
")",
":",
"for",
"name",
"in",
"as_tokens",
"(",
"ctx",
".",
"name",
"(",
")",
")",
":",
"self",
".",
"_context",
".",
"directives",
".",
"append",
"... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | JSGDocParser.visitObjectDef | objectDef: ID objectExpr | pyjsg/parser_impl/jsg_doc_parser.py | def visitObjectDef(self, ctx: jsgParser.ObjectDefContext):
""" objectDef: ID objectExpr """
name = as_token(ctx)
self._context.grammarelts[name] = JSGObjectExpr(self._context, ctx.objectExpr(), name) | def visitObjectDef(self, ctx: jsgParser.ObjectDefContext):
""" objectDef: ID objectExpr """
name = as_token(ctx)
self._context.grammarelts[name] = JSGObjectExpr(self._context, ctx.objectExpr(), name) | [
"objectDef",
":",
"ID",
"objectExpr"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_doc_parser.py#L94-L97 | [
"def",
"visitObjectDef",
"(",
"self",
",",
"ctx",
":",
"jsgParser",
".",
"ObjectDefContext",
")",
":",
"name",
"=",
"as_token",
"(",
"ctx",
")",
"self",
".",
"_context",
".",
"grammarelts",
"[",
"name",
"]",
"=",
"JSGObjectExpr",
"(",
"self",
".",
"_cont... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | JSGDocParser.visitArrayDef | arrayDef : ID arrayExpr | pyjsg/parser_impl/jsg_doc_parser.py | def visitArrayDef(self, ctx: jsgParser.ArrayDefContext):
""" arrayDef : ID arrayExpr """
self._context.grammarelts[as_token(ctx)] = JSGArrayExpr(self._context, ctx.arrayExpr()) | def visitArrayDef(self, ctx: jsgParser.ArrayDefContext):
""" arrayDef : ID arrayExpr """
self._context.grammarelts[as_token(ctx)] = JSGArrayExpr(self._context, ctx.arrayExpr()) | [
"arrayDef",
":",
"ID",
"arrayExpr"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_doc_parser.py#L102-L104 | [
"def",
"visitArrayDef",
"(",
"self",
",",
"ctx",
":",
"jsgParser",
".",
"ArrayDefContext",
")",
":",
"self",
".",
"_context",
".",
"grammarelts",
"[",
"as_token",
"(",
"ctx",
")",
"]",
"=",
"JSGArrayExpr",
"(",
"self",
".",
"_context",
",",
"ctx",
".",
... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | JSGDocParser.visitObjectMacro | objectMacro : ID EQUALS membersDef SEMI | pyjsg/parser_impl/jsg_doc_parser.py | def visitObjectMacro(self, ctx: jsgParser.ObjectExprContext):
""" objectMacro : ID EQUALS membersDef SEMI """
name = as_token(ctx)
self._context.grammarelts[name] = JSGObjectExpr(self._context, ctx.membersDef(), name) | def visitObjectMacro(self, ctx: jsgParser.ObjectExprContext):
""" objectMacro : ID EQUALS membersDef SEMI """
name = as_token(ctx)
self._context.grammarelts[name] = JSGObjectExpr(self._context, ctx.membersDef(), name) | [
"objectMacro",
":",
"ID",
"EQUALS",
"membersDef",
"SEMI"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_doc_parser.py#L109-L112 | [
"def",
"visitObjectMacro",
"(",
"self",
",",
"ctx",
":",
"jsgParser",
".",
"ObjectExprContext",
")",
":",
"name",
"=",
"as_token",
"(",
"ctx",
")",
"self",
".",
"_context",
".",
"grammarelts",
"[",
"name",
"]",
"=",
"JSGObjectExpr",
"(",
"self",
".",
"_c... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | JSGDocParser.visitValueTypeMacro | valueTypeMacro : ID EQUALS nonRefValueType (BAR nonRefValueType)* SEMI | pyjsg/parser_impl/jsg_doc_parser.py | def visitValueTypeMacro(self, ctx: jsgParser.ValueTypeMacroContext):
""" valueTypeMacro : ID EQUALS nonRefValueType (BAR nonRefValueType)* SEMI """
self._context.grammarelts[as_token(ctx)] = JSGValueType(self._context, ctx) | def visitValueTypeMacro(self, ctx: jsgParser.ValueTypeMacroContext):
""" valueTypeMacro : ID EQUALS nonRefValueType (BAR nonRefValueType)* SEMI """
self._context.grammarelts[as_token(ctx)] = JSGValueType(self._context, ctx) | [
"valueTypeMacro",
":",
"ID",
"EQUALS",
"nonRefValueType",
"(",
"BAR",
"nonRefValueType",
")",
"*",
"SEMI"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_doc_parser.py#L117-L119 | [
"def",
"visitValueTypeMacro",
"(",
"self",
",",
"ctx",
":",
"jsgParser",
".",
"ValueTypeMacroContext",
")",
":",
"self",
".",
"_context",
".",
"grammarelts",
"[",
"as_token",
"(",
"ctx",
")",
"]",
"=",
"JSGValueType",
"(",
"self",
".",
"_context",
",",
"ct... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | JSGDocParser.visitLexerRuleSpec | lexerRuleSpec: LEXER_ID COLON lexerRuleBlock SEMI | pyjsg/parser_impl/jsg_doc_parser.py | def visitLexerRuleSpec(self, ctx: jsgParser.LexerRuleSpecContext):
""" lexerRuleSpec: LEXER_ID COLON lexerRuleBlock SEMI """
self._context.grammarelts[as_token(ctx)] = JSGLexerRuleBlock(self._context, ctx.lexerRuleBlock()) | def visitLexerRuleSpec(self, ctx: jsgParser.LexerRuleSpecContext):
""" lexerRuleSpec: LEXER_ID COLON lexerRuleBlock SEMI """
self._context.grammarelts[as_token(ctx)] = JSGLexerRuleBlock(self._context, ctx.lexerRuleBlock()) | [
"lexerRuleSpec",
":",
"LEXER_ID",
"COLON",
"lexerRuleBlock",
"SEMI"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_doc_parser.py#L124-L126 | [
"def",
"visitLexerRuleSpec",
"(",
"self",
",",
"ctx",
":",
"jsgParser",
".",
"LexerRuleSpecContext",
")",
":",
"self",
".",
"_context",
".",
"grammarelts",
"[",
"as_token",
"(",
"ctx",
")",
"]",
"=",
"JSGLexerRuleBlock",
"(",
"self",
".",
"_context",
",",
... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | create_id2amendment_info | Searches for JSON files in this repo and returns
a map of amendment id ==> (`tag`, dir, amendment filepath)
where `tag` is typically the shard name | peyotl/amendments/amendments_shard.py | def create_id2amendment_info(path, tag):
"""Searches for JSON files in this repo and returns
a map of amendment id ==> (`tag`, dir, amendment filepath)
where `tag` is typically the shard name
"""
d = {}
for triple in os.walk(path):
root, files = triple[0], triple[2]
for filename ... | def create_id2amendment_info(path, tag):
"""Searches for JSON files in this repo and returns
a map of amendment id ==> (`tag`, dir, amendment filepath)
where `tag` is typically the shard name
"""
d = {}
for triple in os.walk(path):
root, files = triple[0], triple[2]
for filename ... | [
"Searches",
"for",
"JSON",
"files",
"in",
"this",
"repo",
"and",
"returns",
"a",
"map",
"of",
"amendment",
"id",
"==",
">",
"(",
"tag",
"dir",
"amendment",
"filepath",
")",
"where",
"tag",
"is",
"typically",
"the",
"shard",
"name"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/amendments/amendments_shard.py#L41-L54 | [
"def",
"create_id2amendment_info",
"(",
"path",
",",
"tag",
")",
":",
"d",
"=",
"{",
"}",
"for",
"triple",
"in",
"os",
".",
"walk",
"(",
"path",
")",
":",
"root",
",",
"files",
"=",
"triple",
"[",
"0",
"]",
",",
"triple",
"[",
"2",
"]",
"for",
... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | TaxonomicAmendmentsShard.get_configuration_dict | Overrides superclass method and renames some properties | peyotl/amendments/amendments_shard.py | def get_configuration_dict(self, secret_attrs=False):
"""Overrides superclass method and renames some properties"""
cd = super(TaxonomicAmendmentsShard, self).get_configuration_dict(secret_attrs=secret_attrs)
# "rename" some keys in the dict provided
cd['number of amendments'] = cd.pop('... | def get_configuration_dict(self, secret_attrs=False):
"""Overrides superclass method and renames some properties"""
cd = super(TaxonomicAmendmentsShard, self).get_configuration_dict(secret_attrs=secret_attrs)
# "rename" some keys in the dict provided
cd['number of amendments'] = cd.pop('... | [
"Overrides",
"superclass",
"method",
"and",
"renames",
"some",
"properties"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/amendments/amendments_shard.py#L128-L137 | [
"def",
"get_configuration_dict",
"(",
"self",
",",
"secret_attrs",
"=",
"False",
")",
":",
"cd",
"=",
"super",
"(",
"TaxonomicAmendmentsShard",
",",
"self",
")",
".",
"get_configuration_dict",
"(",
"secret_attrs",
"=",
"secret_attrs",
")",
"# \"rename\" some keys in... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | TaxonomicAmendmentsShard._determine_next_ott_id | Read an initial value (int) from our stored counter (file)
Checks out master branch as a side effect! | peyotl/amendments/amendments_shard.py | def _determine_next_ott_id(self):
"""Read an initial value (int) from our stored counter (file)
Checks out master branch as a side effect!
"""
if self._doc_counter_lock is None:
self._doc_counter_lock = Lock()
with self._doc_counter_lock:
_LOG.debug('Read... | def _determine_next_ott_id(self):
"""Read an initial value (int) from our stored counter (file)
Checks out master branch as a side effect!
"""
if self._doc_counter_lock is None:
self._doc_counter_lock = Lock()
with self._doc_counter_lock:
_LOG.debug('Read... | [
"Read",
"an",
"initial",
"value",
"(",
"int",
")",
"from",
"our",
"stored",
"counter",
"(",
"file",
")"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/amendments/amendments_shard.py#L139-L152 | [
"def",
"_determine_next_ott_id",
"(",
"self",
")",
":",
"if",
"self",
".",
"_doc_counter_lock",
"is",
"None",
":",
"self",
".",
"_doc_counter_lock",
"=",
"Lock",
"(",
")",
"with",
"self",
".",
"_doc_counter_lock",
":",
"_LOG",
".",
"debug",
"(",
"'Reading \"... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | TaxonomicAmendmentsShard._mint_new_ott_ids | ASSUMES the caller holds the _doc_counter_lock !
Checks the current int value of the next ottid, reserves a block of
{how_many} ids, advances the counter to the next available value,
stores the counter in a file in case the server is restarted.
Checks out master branch as a side effect. | peyotl/amendments/amendments_shard.py | def _mint_new_ott_ids(self, how_many=1):
""" ASSUMES the caller holds the _doc_counter_lock !
Checks the current int value of the next ottid, reserves a block of
{how_many} ids, advances the counter to the next available value,
stores the counter in a file in case the server is restarted... | def _mint_new_ott_ids(self, how_many=1):
""" ASSUMES the caller holds the _doc_counter_lock !
Checks the current int value of the next ottid, reserves a block of
{how_many} ids, advances the counter to the next available value,
stores the counter in a file in case the server is restarted... | [
"ASSUMES",
"the",
"caller",
"holds",
"the",
"_doc_counter_lock",
"!",
"Checks",
"the",
"current",
"int",
"value",
"of",
"the",
"next",
"ottid",
"reserves",
"a",
"block",
"of",
"{",
"how_many",
"}",
"ids",
"advances",
"the",
"counter",
"to",
"the",
"next",
... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/amendments/amendments_shard.py#L161-L177 | [
"def",
"_mint_new_ott_ids",
"(",
"self",
",",
"how_many",
"=",
"1",
")",
":",
"first_minted_id",
"=",
"self",
".",
"_next_ott_id",
"self",
".",
"_next_ott_id",
"=",
"first_minted_id",
"+",
"how_many",
"content",
"=",
"u'{\"next_ott_id\": %d}\\n'",
"%",
"self",
"... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | TaxonomicAmendmentsShard.create_git_action_for_new_amendment | Checks out master branch as a side effect | peyotl/amendments/amendments_shard.py | def create_git_action_for_new_amendment(self, new_amendment_id=None):
"""Checks out master branch as a side effect"""
ga = self.create_git_action()
assert new_amendment_id is not None
# id should have been sorted out by the caller
self.register_doc_id(ga, new_amendment_id)
... | def create_git_action_for_new_amendment(self, new_amendment_id=None):
"""Checks out master branch as a side effect"""
ga = self.create_git_action()
assert new_amendment_id is not None
# id should have been sorted out by the caller
self.register_doc_id(ga, new_amendment_id)
... | [
"Checks",
"out",
"master",
"branch",
"as",
"a",
"side",
"effect"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/amendments/amendments_shard.py#L179-L185 | [
"def",
"create_git_action_for_new_amendment",
"(",
"self",
",",
"new_amendment_id",
"=",
"None",
")",
":",
"ga",
"=",
"self",
".",
"create_git_action",
"(",
")",
"assert",
"new_amendment_id",
"is",
"not",
"None",
"# id should have been sorted out by the caller",
"self",... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | __getDummyDateList | Generate a dummy date list for testing without
hitting the server | bowshock/modis.py | def __getDummyDateList():
"""
Generate a dummy date list for testing without
hitting the server
"""
D = []
for y in xrange(2001, 2010):
for d in xrange(1, 365, 1):
D.append('A%04d%03d' % (y, d))
return D | def __getDummyDateList():
"""
Generate a dummy date list for testing without
hitting the server
"""
D = []
for y in xrange(2001, 2010):
for d in xrange(1, 365, 1):
D.append('A%04d%03d' % (y, d))
return D | [
"Generate",
"a",
"dummy",
"date",
"list",
"for",
"testing",
"without",
"hitting",
"the",
"server"
] | emirozer/bowshock | python | https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/modis.py#L92-L103 | [
"def",
"__getDummyDateList",
"(",
")",
":",
"D",
"=",
"[",
"]",
"for",
"y",
"in",
"xrange",
"(",
"2001",
",",
"2010",
")",
":",
"for",
"d",
"in",
"xrange",
"(",
"1",
",",
"365",
",",
"1",
")",
":",
"D",
".",
"append",
"(",
"'A%04d%03d'",
"%",
... | 9f5e053f1d54995b833b83616f37c67178c3e840 |
train | mkIntDate | Convert the webserver formatted dates
to an integer format by stripping the
leading char and casting | bowshock/modis.py | def mkIntDate(s):
"""
Convert the webserver formatted dates
to an integer format by stripping the
leading char and casting
"""
n = s.__len__()
d = int(s[-(n - 1):n])
return d | def mkIntDate(s):
"""
Convert the webserver formatted dates
to an integer format by stripping the
leading char and casting
"""
n = s.__len__()
d = int(s[-(n - 1):n])
return d | [
"Convert",
"the",
"webserver",
"formatted",
"dates",
"to",
"an",
"integer",
"format",
"by",
"stripping",
"the",
"leading",
"char",
"and",
"casting"
] | emirozer/bowshock | python | https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/modis.py#L118-L127 | [
"def",
"mkIntDate",
"(",
"s",
")",
":",
"n",
"=",
"s",
".",
"__len__",
"(",
")",
"d",
"=",
"int",
"(",
"s",
"[",
"-",
"(",
"n",
"-",
"1",
")",
":",
"n",
"]",
")",
"return",
"d"
] | 9f5e053f1d54995b833b83616f37c67178c3e840 |
train | modisClient | modisClient: function for building a modisData object | bowshock/modis.py | def modisClient(client=None,
product=None,
band=None,
lat=None,
lon=None,
startDate=None,
endDate=None,
chunkSize=8,
kmAboveBelow=0,
kmLeftRight=0):
"""
modisClient: funct... | def modisClient(client=None,
product=None,
band=None,
lat=None,
lon=None,
startDate=None,
endDate=None,
chunkSize=8,
kmAboveBelow=0,
kmLeftRight=0):
"""
modisClient: funct... | [
"modisClient",
":",
"function",
"for",
"building",
"a",
"modisData",
"object"
] | emirozer/bowshock | python | https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/modis.py#L185-L306 | [
"def",
"modisClient",
"(",
"client",
"=",
"None",
",",
"product",
"=",
"None",
",",
"band",
"=",
"None",
",",
"lat",
"=",
"None",
",",
"lon",
"=",
"None",
",",
"startDate",
"=",
"None",
",",
"endDate",
"=",
"None",
",",
"chunkSize",
"=",
"8",
",",
... | 9f5e053f1d54995b833b83616f37c67178c3e840 |
train | AgentRegistrar.send_nym | Send input agent's cryptonym (including DID, verification key, plus optional alias and role)
to the distributed ledger.
Raise BadLedgerTxn on failure.
:param did: agent DID to send to ledger
:param verkey: agent verification key
:param alias: optional alias
:param role:... | von_agent/agent/registrar.py | async def send_nym(self, did: str, verkey: str, alias: str = None, role: str = None) -> None:
"""
Send input agent's cryptonym (including DID, verification key, plus optional alias and role)
to the distributed ledger.
Raise BadLedgerTxn on failure.
:param did: agent DID to send... | async def send_nym(self, did: str, verkey: str, alias: str = None, role: str = None) -> None:
"""
Send input agent's cryptonym (including DID, verification key, plus optional alias and role)
to the distributed ledger.
Raise BadLedgerTxn on failure.
:param did: agent DID to send... | [
"Send",
"input",
"agent",
"s",
"cryptonym",
"(",
"including",
"DID",
"verification",
"key",
"plus",
"optional",
"alias",
"and",
"role",
")",
"to",
"the",
"distributed",
"ledger",
"."
] | PSPC-SPAC-buyandsell/von_agent | python | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/registrar.py#L47-L67 | [
"async",
"def",
"send_nym",
"(",
"self",
",",
"did",
":",
"str",
",",
"verkey",
":",
"str",
",",
"alias",
":",
"str",
"=",
"None",
",",
"role",
":",
"str",
"=",
"None",
")",
"->",
"None",
":",
"LOGGER",
".",
"debug",
"(",
"'AgentRegistrar.send_nym >>... | 0b1c17cca3bd178b6e6974af84dbac1dfce5cf45 |
train | IDGenerator.create_id | Create an ID.
Note that if `prefix` is not provided, it will be `guid`, even if the
`method` is `METHOD_INT`. | mixbox/idgen.py | def create_id(self, prefix="guid"):
"""Create an ID.
Note that if `prefix` is not provided, it will be `guid`, even if the
`method` is `METHOD_INT`.
"""
if self.method == IDGenerator.METHOD_UUID:
id_ = str(uuid.uuid4())
elif self.method == IDGenerator.METHOD_... | def create_id(self, prefix="guid"):
"""Create an ID.
Note that if `prefix` is not provided, it will be `guid`, even if the
`method` is `METHOD_INT`.
"""
if self.method == IDGenerator.METHOD_UUID:
id_ = str(uuid.uuid4())
elif self.method == IDGenerator.METHOD_... | [
"Create",
"an",
"ID",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/idgen.py#L61-L75 | [
"def",
"create_id",
"(",
"self",
",",
"prefix",
"=",
"\"guid\"",
")",
":",
"if",
"self",
".",
"method",
"==",
"IDGenerator",
".",
"METHOD_UUID",
":",
"id_",
"=",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
"elif",
"self",
".",
"method",
"==",
... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | imagery | # ----------QUERY PARAMETERS----------
# Parameter Type Default Description
# lat float n/a Latitude
# lon float n/a Longitude
# dim float 0.025 width and height of image in degrees
# date YYYY-MM-DD today date of image ----if not supplied, then the most recent image (i.e., closest to today) is re... | bowshock/earth.py | def imagery(lon=None, lat=None, dim=None, date=None, cloud_score=None):
'''
# ----------QUERY PARAMETERS----------
# Parameter Type Default Description
# lat float n/a Latitude
# lon float n/a Longitude
# dim float 0.025 width and height of image in degrees
# date YYYY-MM-DD today date of ... | def imagery(lon=None, lat=None, dim=None, date=None, cloud_score=None):
'''
# ----------QUERY PARAMETERS----------
# Parameter Type Default Description
# lat float n/a Latitude
# lon float n/a Longitude
# dim float 0.025 width and height of image in degrees
# date YYYY-MM-DD today date of ... | [
"#",
"----------",
"QUERY",
"PARAMETERS",
"----------"
] | emirozer/bowshock | python | https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/earth.py#L16-L77 | [
"def",
"imagery",
"(",
"lon",
"=",
"None",
",",
"lat",
"=",
"None",
",",
"dim",
"=",
"None",
",",
"date",
"=",
"None",
",",
"cloud_score",
"=",
"None",
")",
":",
"base_url",
"=",
"\"https://api.nasa.gov/planetary/earth/imagery?\"",
"if",
"not",
"lon",
"or"... | 9f5e053f1d54995b833b83616f37c67178c3e840 |
train | assets | HTTP REQUEST
GET https://api.nasa.gov/planetary/earth/assets
QUERY PARAMETERS
Parameter Type Default Description
lat float n/a Latitude
lon float n/a Longitude
begin YYYY-MM-DD n/a beginning of date range
end YYYY-MM-DD today end of date range
api_key string DEMO_KEY api.nasa.... | bowshock/earth.py | def assets(lon=None, lat=None, begin=None, end=None):
'''
HTTP REQUEST
GET https://api.nasa.gov/planetary/earth/assets
QUERY PARAMETERS
Parameter Type Default Description
lat float n/a Latitude
lon float n/a Longitude
begin YYYY-MM-DD n/a beginning of date range
end YYYY-M... | def assets(lon=None, lat=None, begin=None, end=None):
'''
HTTP REQUEST
GET https://api.nasa.gov/planetary/earth/assets
QUERY PARAMETERS
Parameter Type Default Description
lat float n/a Latitude
lon float n/a Longitude
begin YYYY-MM-DD n/a beginning of date range
end YYYY-M... | [
"HTTP",
"REQUEST"
] | emirozer/bowshock | python | https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/earth.py#L85-L145 | [
"def",
"assets",
"(",
"lon",
"=",
"None",
",",
"lat",
"=",
"None",
",",
"begin",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"base_url",
"=",
"\"https://api.nasa.gov/planetary/earth/assets?\"",
"if",
"not",
"lon",
"or",
"not",
"lat",
":",
"raise",
"V... | 9f5e053f1d54995b833b83616f37c67178c3e840 |
train | aggregate | Aggregate a ndarray with structured dtype (or recarray) on columns for
given functions.
Aggregate a numpy recarray (or tabular tabarray) on a set of specified
factors, using specified aggregation functions.
Intuitively, this function will aggregate the dataset `X` on a set of
columns, whose nam... | tabular/spreadsheet.py | def aggregate(X, On=None, AggFuncDict=None, AggFunc=None,
AggList=None, returnsort=False, KeepOthers=True,
keyfuncdict=None):
"""
Aggregate a ndarray with structured dtype (or recarray) on columns for
given functions.
Aggregate a numpy recarray (or tabular tabarray) on a se... | def aggregate(X, On=None, AggFuncDict=None, AggFunc=None,
AggList=None, returnsort=False, KeepOthers=True,
keyfuncdict=None):
"""
Aggregate a ndarray with structured dtype (or recarray) on columns for
given functions.
Aggregate a numpy recarray (or tabular tabarray) on a se... | [
"Aggregate",
"a",
"ndarray",
"with",
"structured",
"dtype",
"(",
"or",
"recarray",
")",
"on",
"columns",
"for",
"given",
"functions",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/spreadsheet.py#L35-L240 | [
"def",
"aggregate",
"(",
"X",
",",
"On",
"=",
"None",
",",
"AggFuncDict",
"=",
"None",
",",
"AggFunc",
"=",
"None",
",",
"AggList",
"=",
"None",
",",
"returnsort",
"=",
"False",
",",
"KeepOthers",
"=",
"True",
",",
"keyfuncdict",
"=",
"None",
")",
":... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | aggregate_in | Aggregate a ndarray with structured dtype or recarray
and include original data in the result.
Take aggregate of data set on specified columns, then add the resulting
rows back into data set to make a composite object containing both original
non-aggregate data rows as well as the aggregate rows.
... | tabular/spreadsheet.py | def aggregate_in(Data, On=None, AggFuncDict=None, AggFunc=None, AggList=None,
interspersed=True):
"""
Aggregate a ndarray with structured dtype or recarray
and include original data in the result.
Take aggregate of data set on specified columns, then add the resulting
rows back i... | def aggregate_in(Data, On=None, AggFuncDict=None, AggFunc=None, AggList=None,
interspersed=True):
"""
Aggregate a ndarray with structured dtype or recarray
and include original data in the result.
Take aggregate of data set on specified columns, then add the resulting
rows back i... | [
"Aggregate",
"a",
"ndarray",
"with",
"structured",
"dtype",
"or",
"recarray",
"and",
"include",
"original",
"data",
"in",
"the",
"result",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/spreadsheet.py#L308-L474 | [
"def",
"aggregate_in",
"(",
"Data",
",",
"On",
"=",
"None",
",",
"AggFuncDict",
"=",
"None",
",",
"AggFunc",
"=",
"None",
",",
"AggList",
"=",
"None",
",",
"interspersed",
"=",
"True",
")",
":",
"# See if there's an '__aggregates__ column'. ",
"# If so, strip o... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | grayspec | List of gray-scale colors in HSV space as web hex triplets.
For integer argument k, returns list of `k` gray-scale colors, increasingly
light, linearly in the HSV color space, as web hex triplets.
Technical dependency of :func:`tabular.spreadsheet.aggregate_in`.
**Parameters**
**k** : ... | tabular/spreadsheet.py | def grayspec(k):
"""
List of gray-scale colors in HSV space as web hex triplets.
For integer argument k, returns list of `k` gray-scale colors, increasingly
light, linearly in the HSV color space, as web hex triplets.
Technical dependency of :func:`tabular.spreadsheet.aggregate_in`.
**Parame... | def grayspec(k):
"""
List of gray-scale colors in HSV space as web hex triplets.
For integer argument k, returns list of `k` gray-scale colors, increasingly
light, linearly in the HSV color space, as web hex triplets.
Technical dependency of :func:`tabular.spreadsheet.aggregate_in`.
**Parame... | [
"List",
"of",
"gray",
"-",
"scale",
"colors",
"in",
"HSV",
"space",
"as",
"web",
"hex",
"triplets",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/spreadsheet.py#L477-L502 | [
"def",
"grayspec",
"(",
"k",
")",
":",
"ll",
"=",
".5",
"ul",
"=",
".8",
"delta",
"=",
"(",
"ul",
"-",
"ll",
")",
"/",
"k",
"return",
"[",
"GrayScale",
"(",
"t",
")",
"for",
"t",
"in",
"np",
".",
"arange",
"(",
"ll",
",",
"ul",
",",
"delta"... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | pivot | Implements pivoting on numpy ndarrays (with structured dtype) or recarrays.
See http://en.wikipedia.org/wiki/Pivot_table for information about pivot
tables.
Returns `X` pivoted on (a,b) with `a` as the row axis and `b` values as the
column axis.
So-called "nontrivial columns relative to `b`" in... | tabular/spreadsheet.py | def pivot(X, a, b, Keep=None, NullVals=None, order = None, prefix='_'):
'''
Implements pivoting on numpy ndarrays (with structured dtype) or recarrays.
See http://en.wikipedia.org/wiki/Pivot_table for information about pivot
tables.
Returns `X` pivoted on (a,b) with `a` as the row axis and `b` va... | def pivot(X, a, b, Keep=None, NullVals=None, order = None, prefix='_'):
'''
Implements pivoting on numpy ndarrays (with structured dtype) or recarrays.
See http://en.wikipedia.org/wiki/Pivot_table for information about pivot
tables.
Returns `X` pivoted on (a,b) with `a` as the row axis and `b` va... | [
"Implements",
"pivoting",
"on",
"numpy",
"ndarrays",
"(",
"with",
"structured",
"dtype",
")",
"or",
"recarrays",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/spreadsheet.py#L505-L702 | [
"def",
"pivot",
"(",
"X",
",",
"a",
",",
"b",
",",
"Keep",
"=",
"None",
",",
"NullVals",
"=",
"None",
",",
"order",
"=",
"None",
",",
"prefix",
"=",
"'_'",
")",
":",
"othernames",
"=",
"[",
"o",
"for",
"o",
"in",
"X",
".",
"dtype",
".",
"name... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | addrecords | Append one or more records to the end of a numpy recarray or ndarray .
Can take a single record, void or tuple, or a list of records, voids or
tuples.
Implemented by the tabarray method
:func:`tabular.tab.tabarray.addrecords`.
**Parameters**
**X** : numpy ndarray with structured d... | tabular/spreadsheet.py | def addrecords(X, new):
"""
Append one or more records to the end of a numpy recarray or ndarray .
Can take a single record, void or tuple, or a list of records, voids or
tuples.
Implemented by the tabarray method
:func:`tabular.tab.tabarray.addrecords`.
**Parameters**
**X*... | def addrecords(X, new):
"""
Append one or more records to the end of a numpy recarray or ndarray .
Can take a single record, void or tuple, or a list of records, voids or
tuples.
Implemented by the tabarray method
:func:`tabular.tab.tabarray.addrecords`.
**Parameters**
**X*... | [
"Append",
"one",
"or",
"more",
"records",
"to",
"the",
"end",
"of",
"a",
"numpy",
"recarray",
"or",
"ndarray",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/spreadsheet.py#L704-L737 | [
"def",
"addrecords",
"(",
"X",
",",
"new",
")",
":",
"if",
"isinstance",
"(",
"new",
",",
"np",
".",
"record",
")",
"or",
"isinstance",
"(",
"new",
",",
"np",
".",
"void",
")",
"or",
"isinstance",
"(",
"new",
",",
"tuple",
")",
":",
"new",
"=",
... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | addcols | Add one or more columns to a numpy ndarray.
Technical dependency of :func:`tabular.spreadsheet.aggregate_in`.
Implemented by the tabarray method
:func:`tabular.tab.tabarray.addcols`.
**Parameters**
**X** : numpy ndarray with structured dtype or recarray
The recarra... | tabular/spreadsheet.py | def addcols(X, cols, names=None):
"""
Add one or more columns to a numpy ndarray.
Technical dependency of :func:`tabular.spreadsheet.aggregate_in`.
Implemented by the tabarray method
:func:`tabular.tab.tabarray.addcols`.
**Parameters**
**X** : numpy ndarray with structured dtyp... | def addcols(X, cols, names=None):
"""
Add one or more columns to a numpy ndarray.
Technical dependency of :func:`tabular.spreadsheet.aggregate_in`.
Implemented by the tabarray method
:func:`tabular.tab.tabarray.addcols`.
**Parameters**
**X** : numpy ndarray with structured dtyp... | [
"Add",
"one",
"or",
"more",
"columns",
"to",
"a",
"numpy",
"ndarray",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/spreadsheet.py#L740-L803 | [
"def",
"addcols",
"(",
"X",
",",
"cols",
",",
"names",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"names",
",",
"str",
")",
":",
"names",
"=",
"[",
"n",
".",
"strip",
"(",
")",
"for",
"n",
"in",
"names",
".",
"split",
"(",
"','",
")",
"]... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | deletecols | Delete columns from a numpy ndarry or recarray.
Can take a string giving a column name or comma-separated list of column
names, or a list of string column names.
Implemented by the tabarray method
:func:`tabular.tab.tabarray.deletecols`.
**Parameters**
**X** : numpy recarray or nd... | tabular/spreadsheet.py | def deletecols(X, cols):
"""
Delete columns from a numpy ndarry or recarray.
Can take a string giving a column name or comma-separated list of column
names, or a list of string column names.
Implemented by the tabarray method
:func:`tabular.tab.tabarray.deletecols`.
**Parameters**
... | def deletecols(X, cols):
"""
Delete columns from a numpy ndarry or recarray.
Can take a string giving a column name or comma-separated list of column
names, or a list of string column names.
Implemented by the tabarray method
:func:`tabular.tab.tabarray.deletecols`.
**Parameters**
... | [
"Delete",
"columns",
"from",
"a",
"numpy",
"ndarry",
"or",
"recarray",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/spreadsheet.py#L806-L842 | [
"def",
"deletecols",
"(",
"X",
",",
"cols",
")",
":",
"if",
"isinstance",
"(",
"cols",
",",
"str",
")",
":",
"cols",
"=",
"cols",
".",
"split",
"(",
"','",
")",
"retain",
"=",
"[",
"n",
"for",
"n",
"in",
"X",
".",
"dtype",
".",
"names",
"if",
... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | renamecol | Rename column of a numpy ndarray with structured dtype, in-place.
Implemented by the tabarray method
:func:`tabular.tab.tabarray.renamecol`.
**Parameters**
**X** : numpy ndarray with structured dtype
The numpy array for which a column is to be renamed.
**ol... | tabular/spreadsheet.py | def renamecol(X, old, new):
"""
Rename column of a numpy ndarray with structured dtype, in-place.
Implemented by the tabarray method
:func:`tabular.tab.tabarray.renamecol`.
**Parameters**
**X** : numpy ndarray with structured dtype
The numpy array for which a co... | def renamecol(X, old, new):
"""
Rename column of a numpy ndarray with structured dtype, in-place.
Implemented by the tabarray method
:func:`tabular.tab.tabarray.renamecol`.
**Parameters**
**X** : numpy ndarray with structured dtype
The numpy array for which a co... | [
"Rename",
"column",
"of",
"a",
"numpy",
"ndarray",
"with",
"structured",
"dtype",
"in",
"-",
"place",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/spreadsheet.py#L845-L868 | [
"def",
"renamecol",
"(",
"X",
",",
"old",
",",
"new",
")",
":",
"NewNames",
"=",
"tuple",
"(",
"[",
"n",
"if",
"n",
"!=",
"old",
"else",
"new",
"for",
"n",
"in",
"X",
".",
"dtype",
".",
"names",
"]",
")",
"X",
".",
"dtype",
".",
"names",
"=",... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | replace | Replace value `old` with `new` everywhere it appears in-place.
Implemented by the tabarray method
:func:`tabular.tab.tabarray.replace`.
**Parameters**
**X** : numpy ndarray with structured dtype
Numpy array for which in-place replacement of `old` with
... | tabular/spreadsheet.py | def replace(X, old, new, strict=True, cols=None, rows=None):
"""
Replace value `old` with `new` everywhere it appears in-place.
Implemented by the tabarray method
:func:`tabular.tab.tabarray.replace`.
**Parameters**
**X** : numpy ndarray with structured dtype
Nu... | def replace(X, old, new, strict=True, cols=None, rows=None):
"""
Replace value `old` with `new` everywhere it appears in-place.
Implemented by the tabarray method
:func:`tabular.tab.tabarray.replace`.
**Parameters**
**X** : numpy ndarray with structured dtype
Nu... | [
"Replace",
"value",
"old",
"with",
"new",
"everywhere",
"it",
"appears",
"in",
"-",
"place",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/spreadsheet.py#L871-L964 | [
"def",
"replace",
"(",
"X",
",",
"old",
",",
"new",
",",
"strict",
"=",
"True",
",",
"cols",
"=",
"None",
",",
"rows",
"=",
"None",
")",
":",
"if",
"cols",
"==",
"None",
":",
"cols",
"=",
"X",
".",
"dtype",
".",
"names",
"elif",
"isinstance",
"... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | rowstack | Vertically stack a sequence of numpy ndarrays with structured dtype
Analog of numpy.vstack
Implemented by the tabarray method
:func:`tabular.tab.tabarray.rowstack` which uses
:func:`tabular.tabarray.tab_rowstack`.
**Parameters**
**seq** : sequence of numpy recarrays
... | tabular/spreadsheet.py | def rowstack(seq, mode='nulls', nullvals=None):
'''
Vertically stack a sequence of numpy ndarrays with structured dtype
Analog of numpy.vstack
Implemented by the tabarray method
:func:`tabular.tab.tabarray.rowstack` which uses
:func:`tabular.tabarray.tab_rowstack`.
**Parameters**
... | def rowstack(seq, mode='nulls', nullvals=None):
'''
Vertically stack a sequence of numpy ndarrays with structured dtype
Analog of numpy.vstack
Implemented by the tabarray method
:func:`tabular.tab.tabarray.rowstack` which uses
:func:`tabular.tabarray.tab_rowstack`.
**Parameters**
... | [
"Vertically",
"stack",
"a",
"sequence",
"of",
"numpy",
"ndarrays",
"with",
"structured",
"dtype"
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/spreadsheet.py#L967-L1044 | [
"def",
"rowstack",
"(",
"seq",
",",
"mode",
"=",
"'nulls'",
",",
"nullvals",
"=",
"None",
")",
":",
"if",
"nullvals",
"==",
"None",
":",
"nullvals",
"=",
"utils",
".",
"DEFAULT_NULLVALUEFORMAT",
"#newseq = [ss for ss in seq if len(ss) > 0]",
"if",
"len",
"(",
... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | colstack | Horizontally stack a sequence of numpy ndarrays with structured dtypes
Analog of numpy.hstack for recarrays.
Implemented by the tabarray method
:func:`tabular.tab.tabarray.colstack` which uses
:func:`tabular.tabarray.tab_colstack`.
**Parameters**
**seq** : sequence of numpy ndarra... | tabular/spreadsheet.py | def colstack(seq, mode='abort',returnnaming=False):
"""
Horizontally stack a sequence of numpy ndarrays with structured dtypes
Analog of numpy.hstack for recarrays.
Implemented by the tabarray method
:func:`tabular.tab.tabarray.colstack` which uses
:func:`tabular.tabarray.tab_colstack`.
... | def colstack(seq, mode='abort',returnnaming=False):
"""
Horizontally stack a sequence of numpy ndarrays with structured dtypes
Analog of numpy.hstack for recarrays.
Implemented by the tabarray method
:func:`tabular.tab.tabarray.colstack` which uses
:func:`tabular.tabarray.tab_colstack`.
... | [
"Horizontally",
"stack",
"a",
"sequence",
"of",
"numpy",
"ndarrays",
"with",
"structured",
"dtypes"
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/spreadsheet.py#L1047-L1123 | [
"def",
"colstack",
"(",
"seq",
",",
"mode",
"=",
"'abort'",
",",
"returnnaming",
"=",
"False",
")",
":",
"assert",
"mode",
"in",
"[",
"'first'",
",",
"'drop'",
",",
"'abort'",
",",
"'rename'",
"]",
",",
"'mode argument must take on value \"first\",\"drop\", \"re... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | join | Combine two or more numpy ndarray with structured dtype on common key
column(s).
Merge a list (or dictionary) of numpy ndarray with structured dtype, given
by `L`, on key columns listed in `keycols`.
This function is actually a wrapper for
:func:`tabular.spreadsheet.strictjoin`.
The ``stric... | tabular/spreadsheet.py | def join(L, keycols=None, nullvals=None, renamer=None,
returnrenaming=False, Names=None):
"""
Combine two or more numpy ndarray with structured dtype on common key
column(s).
Merge a list (or dictionary) of numpy ndarray with structured dtype, given
by `L`, on key columns listed in `keyc... | def join(L, keycols=None, nullvals=None, renamer=None,
returnrenaming=False, Names=None):
"""
Combine two or more numpy ndarray with structured dtype on common key
column(s).
Merge a list (or dictionary) of numpy ndarray with structured dtype, given
by `L`, on key columns listed in `keyc... | [
"Combine",
"two",
"or",
"more",
"numpy",
"ndarray",
"with",
"structured",
"dtype",
"on",
"common",
"key",
"column",
"(",
"s",
")",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/spreadsheet.py#L1126-L1316 | [
"def",
"join",
"(",
"L",
",",
"keycols",
"=",
"None",
",",
"nullvals",
"=",
"None",
",",
"renamer",
"=",
"None",
",",
"returnrenaming",
"=",
"False",
",",
"Names",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"L",
",",
"dict",
")",
":",
"Names",... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | strictjoin | Combine two or more numpy ndarray with structured dtypes on common key
column(s).
Merge a list (or dictionary) of numpy arrays, given by `L`, on key
columns listed in `keycols`.
The ``strictjoin`` assumes the following restrictions:
* each element of `keycol` must be a valid column name in `X`... | tabular/spreadsheet.py | def strictjoin(L, keycols, nullvals=None, renaming=None, Names=None):
"""
Combine two or more numpy ndarray with structured dtypes on common key
column(s).
Merge a list (or dictionary) of numpy arrays, given by `L`, on key
columns listed in `keycols`.
The ``strictjoin`` assumes the following ... | def strictjoin(L, keycols, nullvals=None, renaming=None, Names=None):
"""
Combine two or more numpy ndarray with structured dtypes on common key
column(s).
Merge a list (or dictionary) of numpy arrays, given by `L`, on key
columns listed in `keycols`.
The ``strictjoin`` assumes the following ... | [
"Combine",
"two",
"or",
"more",
"numpy",
"ndarray",
"with",
"structured",
"dtypes",
"on",
"common",
"key",
"column",
"(",
"s",
")",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/spreadsheet.py#L1319-L1499 | [
"def",
"strictjoin",
"(",
"L",
",",
"keycols",
",",
"nullvals",
"=",
"None",
",",
"renaming",
"=",
"None",
",",
"Names",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"L",
",",
"dict",
")",
":",
"Names",
"=",
"L",
".",
"keys",
"(",
")",
"LL",
... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | DEFAULT_RENAMER | Renames overlapping column names of numpy ndarrays with structured dtypes
Rename the columns by using a simple convention:
* If `L` is a list, it will append the number in the list to the key
associated with the array.
* If `L` is a dictionary, the algorithm will append the string
r... | tabular/spreadsheet.py | def DEFAULT_RENAMER(L, Names=None):
"""
Renames overlapping column names of numpy ndarrays with structured dtypes
Rename the columns by using a simple convention:
* If `L` is a list, it will append the number in the list to the key
associated with the array.
* If `L` is a dictionary,... | def DEFAULT_RENAMER(L, Names=None):
"""
Renames overlapping column names of numpy ndarrays with structured dtypes
Rename the columns by using a simple convention:
* If `L` is a list, it will append the number in the list to the key
associated with the array.
* If `L` is a dictionary,... | [
"Renames",
"overlapping",
"column",
"names",
"of",
"numpy",
"ndarrays",
"with",
"structured",
"dtypes"
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/spreadsheet.py#L1520-L1571 | [
"def",
"DEFAULT_RENAMER",
"(",
"L",
",",
"Names",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"L",
",",
"dict",
")",
":",
"Names",
"=",
"L",
".",
"keys",
"(",
")",
"LL",
"=",
"L",
".",
"values",
"(",
")",
"else",
":",
"if",
"Names",
"==",
... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | getjp2image | Helioviewer.org and JHelioviewer operate off of JPEG2000 formatted image data generated from science-quality FITS files. Use the APIs below to interact directly with these intermediary JPEG2000 files.
Download a JP2 image for the specified datasource that is the closest match in time to the `date` requested.
... | bowshock/helioviewer.py | def getjp2image(date,
sourceId=None,
observatory=None,
instrument=None,
detector=None,
measurement=None):
'''
Helioviewer.org and JHelioviewer operate off of JPEG2000 formatted image data generated from science-quality FITS files. U... | def getjp2image(date,
sourceId=None,
observatory=None,
instrument=None,
detector=None,
measurement=None):
'''
Helioviewer.org and JHelioviewer operate off of JPEG2000 formatted image data generated from science-quality FITS files. U... | [
"Helioviewer",
".",
"org",
"and",
"JHelioviewer",
"operate",
"off",
"of",
"JPEG2000",
"formatted",
"image",
"data",
"generated",
"from",
"science",
"-",
"quality",
"FITS",
"files",
".",
"Use",
"the",
"APIs",
"below",
"to",
"interact",
"directly",
"with",
"thes... | emirozer/bowshock | python | https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/helioviewer.py#L10-L85 | [
"def",
"getjp2image",
"(",
"date",
",",
"sourceId",
"=",
"None",
",",
"observatory",
"=",
"None",
",",
"instrument",
"=",
"None",
",",
"detector",
"=",
"None",
",",
"measurement",
"=",
"None",
")",
":",
"base_url",
"=",
"'http://helioviewer.org/api/v1/getJP2Im... | 9f5e053f1d54995b833b83616f37c67178c3e840 |
train | getjp2header | GET /api/v1/getJP2Header/
Get the XML header embedded in a JPEG2000 image. Includes the FITS header as well as a section of Helioviewer-specific metadata.
Request Parameters:
Parameter Required Type Example Description
id Required number 7654321 Unique JP2 image identifier.
callback Optional str... | bowshock/helioviewer.py | def getjp2header(Id):
'''
GET /api/v1/getJP2Header/
Get the XML header embedded in a JPEG2000 image. Includes the FITS header as well as a section of Helioviewer-specific metadata.
Request Parameters:
Parameter Required Type Example Description
id Required number 7654321 Unique JP2 image ide... | def getjp2header(Id):
'''
GET /api/v1/getJP2Header/
Get the XML header embedded in a JPEG2000 image. Includes the FITS header as well as a section of Helioviewer-specific metadata.
Request Parameters:
Parameter Required Type Example Description
id Required number 7654321 Unique JP2 image ide... | [
"GET",
"/",
"api",
"/",
"v1",
"/",
"getJP2Header",
"/"
] | emirozer/bowshock | python | https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/helioviewer.py#L88-L116 | [
"def",
"getjp2header",
"(",
"Id",
")",
":",
"base_url",
"=",
"'http://helioviewer.org/api/v1/getJP2Header/?'",
"if",
"not",
"isinstance",
"(",
"Id",
",",
"int",
")",
":",
"raise",
"ValueError",
"(",
"\"The Id argument should be an int, ignoring it\"",
")",
"else",
":"... | 9f5e053f1d54995b833b83616f37c67178c3e840 |
train | loads_loader | json loader objecthook
:param load_module: Module that contains the various types
:param pairs: key/value tuples (In our case, they are str/str)
:return: | pyjsg/jsglib/loader.py | def loads_loader(load_module: types.ModuleType, pairs: Dict[str, str]) -> Optional[JSGValidateable]:
"""json loader objecthook
:param load_module: Module that contains the various types
:param pairs: key/value tuples (In our case, they are str/str)
:return:
"""
cntxt = load_module._CONTEXT
... | def loads_loader(load_module: types.ModuleType, pairs: Dict[str, str]) -> Optional[JSGValidateable]:
"""json loader objecthook
:param load_module: Module that contains the various types
:param pairs: key/value tuples (In our case, they are str/str)
:return:
"""
cntxt = load_module._CONTEXT
... | [
"json",
"loader",
"objecthook"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/jsglib/loader.py#L17-L54 | [
"def",
"loads_loader",
"(",
"load_module",
":",
"types",
".",
"ModuleType",
",",
"pairs",
":",
"Dict",
"[",
"str",
",",
"str",
"]",
")",
"->",
"Optional",
"[",
"JSGValidateable",
"]",
":",
"cntxt",
"=",
"load_module",
".",
"_CONTEXT",
"# If the type element ... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | loads | Convert a JSON string into a JSGObject
:param s: string representation of JSON document
:param load_module: module that contains declarations for types
:param kwargs: arguments see: json.load for details
:return: JSGObject representing the json string | pyjsg/jsglib/loader.py | def loads(s: str, load_module: types.ModuleType, **kwargs):
""" Convert a JSON string into a JSGObject
:param s: string representation of JSON document
:param load_module: module that contains declarations for types
:param kwargs: arguments see: json.load for details
:return: JSGObject representing... | def loads(s: str, load_module: types.ModuleType, **kwargs):
""" Convert a JSON string into a JSGObject
:param s: string representation of JSON document
:param load_module: module that contains declarations for types
:param kwargs: arguments see: json.load for details
:return: JSGObject representing... | [
"Convert",
"a",
"JSON",
"string",
"into",
"a",
"JSGObject"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/jsglib/loader.py#L57-L65 | [
"def",
"loads",
"(",
"s",
":",
"str",
",",
"load_module",
":",
"types",
".",
"ModuleType",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"json",
".",
"loads",
"(",
"s",
",",
"object_hook",
"=",
"lambda",
"pairs",
":",
"loads_loader",
"(",
"load_module",... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | load | Convert a file name or file-like object containing stringified JSON into a JSGObject
:param fp: file-like object to deserialize
:param load_module: module that contains declarations for types
:param kwargs: arguments see: json.load for details
:return: JSGObject representing the json string | pyjsg/jsglib/loader.py | def load(fp: Union[TextIO, str], load_module: types.ModuleType, **kwargs):
""" Convert a file name or file-like object containing stringified JSON into a JSGObject
:param fp: file-like object to deserialize
:param load_module: module that contains declarations for types
:param kwargs: arguments see: js... | def load(fp: Union[TextIO, str], load_module: types.ModuleType, **kwargs):
""" Convert a file name or file-like object containing stringified JSON into a JSGObject
:param fp: file-like object to deserialize
:param load_module: module that contains declarations for types
:param kwargs: arguments see: js... | [
"Convert",
"a",
"file",
"name",
"or",
"file",
"-",
"like",
"object",
"containing",
"stringified",
"JSON",
"into",
"a",
"JSGObject"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/jsglib/loader.py#L68-L80 | [
"def",
"load",
"(",
"fp",
":",
"Union",
"[",
"TextIO",
",",
"str",
"]",
",",
"load_module",
":",
"types",
".",
"ModuleType",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"fp",
",",
"str",
")",
":",
"with",
"open",
"(",
"fp",
")",
... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | isinstance_ | native isinstance_ with the test for typing.Union overridden | pyjsg/jsglib/loader.py | def isinstance_(x, A_tuple):
""" native isinstance_ with the test for typing.Union overridden """
if is_union(A_tuple):
return any(isinstance_(x, t) for t in A_tuple.__args__)
elif getattr(A_tuple, '__origin__', None) is not None:
return isinstance(x, A_tuple.__origin__)
else:
re... | def isinstance_(x, A_tuple):
""" native isinstance_ with the test for typing.Union overridden """
if is_union(A_tuple):
return any(isinstance_(x, t) for t in A_tuple.__args__)
elif getattr(A_tuple, '__origin__', None) is not None:
return isinstance(x, A_tuple.__origin__)
else:
re... | [
"native",
"isinstance_",
"with",
"the",
"test",
"for",
"typing",
".",
"Union",
"overridden"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/jsglib/loader.py#L83-L90 | [
"def",
"isinstance_",
"(",
"x",
",",
"A_tuple",
")",
":",
"if",
"is_union",
"(",
"A_tuple",
")",
":",
"return",
"any",
"(",
"isinstance_",
"(",
"x",
",",
"t",
")",
"for",
"t",
"in",
"A_tuple",
".",
"__args__",
")",
"elif",
"getattr",
"(",
"A_tuple",
... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | is_valid | Determine whether obj is valid
:param obj: Object to validate
:param log: Logger to record validation failures. If absent, no information is recorded | pyjsg/jsglib/loader.py | def is_valid(obj: JSGValidateable, log: Optional[Union[TextIO, Logger]] = None) -> bool:
""" Determine whether obj is valid
:param obj: Object to validate
:param log: Logger to record validation failures. If absent, no information is recorded
"""
return obj._is_valid(log) | def is_valid(obj: JSGValidateable, log: Optional[Union[TextIO, Logger]] = None) -> bool:
""" Determine whether obj is valid
:param obj: Object to validate
:param log: Logger to record validation failures. If absent, no information is recorded
"""
return obj._is_valid(log) | [
"Determine",
"whether",
"obj",
"is",
"valid"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/jsglib/loader.py#L93-L99 | [
"def",
"is_valid",
"(",
"obj",
":",
"JSGValidateable",
",",
"log",
":",
"Optional",
"[",
"Union",
"[",
"TextIO",
",",
"Logger",
"]",
"]",
"=",
"None",
")",
"->",
"bool",
":",
"return",
"obj",
".",
"_is_valid",
"(",
"log",
")"
] | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | write_newick_ott | `out` is an output stream
`ott` is an OTT instance used for translating labels
`ott_id2children` is a dict mapping an OTT ID to the IDs of its children
`root_ott_id` is the root of the subtree to write.
`label_style` is a facet of OTULabelStyleEnum
`prune_flags` is a set strings (flags) or OTTFlagUn... | peyotl/ott/__init__.py | def write_newick_ott(out,
ott,
ott_id2children,
root_ott_id,
label_style,
prune_flags,
create_log_dict=False):
"""`out` is an output stream
`ott` is an OTT instance used for translating ... | def write_newick_ott(out,
ott,
ott_id2children,
root_ott_id,
label_style,
prune_flags,
create_log_dict=False):
"""`out` is an output stream
`ott` is an OTT instance used for translating ... | [
"out",
"is",
"an",
"output",
"stream",
"ott",
"is",
"an",
"OTT",
"instance",
"used",
"for",
"translating",
"labels",
"ott_id2children",
"is",
"a",
"dict",
"mapping",
"an",
"OTT",
"ID",
"to",
"the",
"IDs",
"of",
"its",
"children",
"root_ott_id",
"is",
"the"... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/ott/__init__.py#L34-L149 | [
"def",
"write_newick_ott",
"(",
"out",
",",
"ott",
",",
"ott_id2children",
",",
"root_ott_id",
",",
"label_style",
",",
"prune_flags",
",",
"create_log_dict",
"=",
"False",
")",
":",
"# create to_prune_fsi_set a set of flag set indices to prune...",
"if",
"prune_flags",
... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | create_pruned_and_taxonomy_for_tip_ott_ids | returns a pair of trees:
the first is that is a pruned version of tree_proxy created by pruning
any leaf that has no ott_id and every internal that does not have
any descendant with an ott_id. Nodes of out-degree 1 are suppressed
as part of the TreeWithPathsInEdges-style.
... | peyotl/ott/__init__.py | def create_pruned_and_taxonomy_for_tip_ott_ids(tree_proxy, ott, create_monotypic_nodes=False):
"""returns a pair of trees:
the first is that is a pruned version of tree_proxy created by pruning
any leaf that has no ott_id and every internal that does not have
any descendant with an o... | def create_pruned_and_taxonomy_for_tip_ott_ids(tree_proxy, ott, create_monotypic_nodes=False):
"""returns a pair of trees:
the first is that is a pruned version of tree_proxy created by pruning
any leaf that has no ott_id and every internal that does not have
any descendant with an o... | [
"returns",
"a",
"pair",
"of",
"trees",
":",
"the",
"first",
"is",
"that",
"is",
"a",
"pruned",
"version",
"of",
"tree_proxy",
"created",
"by",
"pruning",
"any",
"leaf",
"that",
"has",
"no",
"ott_id",
"and",
"every",
"internal",
"that",
"does",
"not",
"ha... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/ott/__init__.py#L945-L977 | [
"def",
"create_pruned_and_taxonomy_for_tip_ott_ids",
"(",
"tree_proxy",
",",
"ott",
",",
"create_monotypic_nodes",
"=",
"False",
")",
":",
"# create and id2par that has ott IDs only at the tips (we are",
"# ignoring mappings at internal nodes.",
"# OTT IDs are integers, and the nodeIDs... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | main | fstrs = ['{k:d}: {v}'.format(k=k, v=v) for k, v in o.flag_set_id_to_flag_set.items()]
print('flag_set_id_to_flag_set =\n {}'.format('\n '.join(fstrs)))
for ott_id, info in o.ott_id_to_sources.items():
if 'ncbi' in info:
print('OTT {o:d} => NCBI {n:d}'.format(o=ott_id, n=info['ncbi']))
... | peyotl/ott/__init__.py | def main():
import sys
cout = codecs.getwriter('utf-8')(sys.stdout)
o = OTT()
# print('taxonomic sources = "{}"'.format('", "'.join([iii for iii in o.taxonomic_sources])))
# print(o.ncbi(1115784))
o.write_newick(cout, label_style=OTULabelStyleEnum.CURRENT_LABEL_OTT_ID, prune_flags=_TREEMACHINE_P... | def main():
import sys
cout = codecs.getwriter('utf-8')(sys.stdout)
o = OTT()
# print('taxonomic sources = "{}"'.format('", "'.join([iii for iii in o.taxonomic_sources])))
# print(o.ncbi(1115784))
o.write_newick(cout, label_style=OTULabelStyleEnum.CURRENT_LABEL_OTT_ID, prune_flags=_TREEMACHINE_P... | [
"fstrs",
"=",
"[",
"{",
"k",
":",
"d",
"}",
":",
"{",
"v",
"}",
".",
"format",
"(",
"k",
"=",
"k",
"v",
"=",
"v",
")",
"for",
"k",
"v",
"in",
"o",
".",
"flag_set_id_to_flag_set",
".",
"items",
"()",
"]",
"print",
"(",
"flag_set_id_to_flag_set",
... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/ott/__init__.py#L980-L998 | [
"def",
"main",
"(",
")",
":",
"import",
"sys",
"cout",
"=",
"codecs",
".",
"getwriter",
"(",
"'utf-8'",
")",
"(",
"sys",
".",
"stdout",
")",
"o",
"=",
"OTT",
"(",
")",
"# print('taxonomic sources = \"{}\"'.format('\", \"'.join([iii for iii in o.taxonomic_sources])))... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | OTT._create_pickle_files | preorder2tuple maps a preorder number to a node definition.
ottID2preorder maps every OTT ID in taxonomy.tsv to a preorder #
'ottID2preorder'
'ottID2preorder'
'preorder2ottID'
'ottID2uniq'
'uniq2ottID'
'name2ottID'
'ottID2names'
'ottID2ranks'
... | peyotl/ott/__init__.py | def _create_pickle_files(self, out_dir=None): # pylint: disable=R0914,R0915
"""
preorder2tuple maps a preorder number to a node definition.
ottID2preorder maps every OTT ID in taxonomy.tsv to a preorder #
'ottID2preorder'
'ottID2preorder'
'preorder2ottID'
'ottID2un... | def _create_pickle_files(self, out_dir=None): # pylint: disable=R0914,R0915
"""
preorder2tuple maps a preorder number to a node definition.
ottID2preorder maps every OTT ID in taxonomy.tsv to a preorder #
'ottID2preorder'
'ottID2preorder'
'preorder2ottID'
'ottID2un... | [
"preorder2tuple",
"maps",
"a",
"preorder",
"number",
"to",
"a",
"node",
"definition",
".",
"ottID2preorder",
"maps",
"every",
"OTT",
"ID",
"in",
"taxonomy",
".",
"tsv",
"to",
"a",
"preorder",
"#",
"ottID2preorder",
"ottID2preorder",
"preorder2ottID",
"ottID2uniq",... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/ott/__init__.py#L492-L704 | [
"def",
"_create_pickle_files",
"(",
"self",
",",
"out_dir",
"=",
"None",
")",
":",
"# pylint: disable=R0914,R0915",
"if",
"out_dir",
"is",
"None",
":",
"out_dir",
"=",
"self",
".",
"ott_dir",
"taxonomy_file",
"=",
"self",
".",
"taxonomy_filepath",
"if",
"not",
... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | OTT.map_ott_ids | returns:
- a list of recognized ott_ids.
- a list of unrecognized ott_ids
- a list of ott_ids that forward to unrecognized ott_ids
- a list of ott_ids that do not appear in the tree because they are flagged to be pruned.
- a list of ott_ids that do not appear in the tre... | peyotl/ott/__init__.py | def map_ott_ids(self, ott_id_list, to_prune_fsi_set, root_ott_id):
"""returns:
- a list of recognized ott_ids.
- a list of unrecognized ott_ids
- a list of ott_ids that forward to unrecognized ott_ids
- a list of ott_ids that do not appear in the tree because they are fla... | def map_ott_ids(self, ott_id_list, to_prune_fsi_set, root_ott_id):
"""returns:
- a list of recognized ott_ids.
- a list of unrecognized ott_ids
- a list of ott_ids that forward to unrecognized ott_ids
- a list of ott_ids that do not appear in the tree because they are fla... | [
"returns",
":",
"-",
"a",
"list",
"of",
"recognized",
"ott_ids",
".",
"-",
"a",
"list",
"of",
"unrecognized",
"ott_ids",
"-",
"a",
"list",
"of",
"ott_ids",
"that",
"forward",
"to",
"unrecognized",
"ott_ids",
"-",
"a",
"list",
"of",
"ott_ids",
"that",
"do... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/ott/__init__.py#L827-L866 | [
"def",
"map_ott_ids",
"(",
"self",
",",
"ott_id_list",
",",
"to_prune_fsi_set",
",",
"root_ott_id",
")",
":",
"mapped",
",",
"unrecog",
",",
"forward2unrecog",
",",
"pruned",
",",
"above_root",
",",
"old2new",
"=",
"[",
"]",
",",
"[",
"]",
",",
"[",
"]",... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | arg_tup_to_dict | Given a set of argument tuples, set their value in a data dictionary if not blank | pifx/util.py | def arg_tup_to_dict(argument_tuples):
"""Given a set of argument tuples, set their value in a data dictionary if not blank"""
data = dict()
for arg_name, arg_val in argument_tuples:
if arg_val is not None:
if arg_val is True:
arg_val = 'true'
elif arg_val is F... | def arg_tup_to_dict(argument_tuples):
"""Given a set of argument tuples, set their value in a data dictionary if not blank"""
data = dict()
for arg_name, arg_val in argument_tuples:
if arg_val is not None:
if arg_val is True:
arg_val = 'true'
elif arg_val is F... | [
"Given",
"a",
"set",
"of",
"argument",
"tuples",
"set",
"their",
"value",
"in",
"a",
"data",
"dictionary",
"if",
"not",
"blank"
] | cydrobolt/pifx | python | https://github.com/cydrobolt/pifx/blob/c9de9c2695c3e6e72de4aa0de47b78fc13c457c3/pifx/util.py#L32-L43 | [
"def",
"arg_tup_to_dict",
"(",
"argument_tuples",
")",
":",
"data",
"=",
"dict",
"(",
")",
"for",
"arg_name",
",",
"arg_val",
"in",
"argument_tuples",
":",
"if",
"arg_val",
"is",
"not",
"None",
":",
"if",
"arg_val",
"is",
"True",
":",
"arg_val",
"=",
"'t... | c9de9c2695c3e6e72de4aa0de47b78fc13c457c3 |
train | handle_error | Raise appropriate exceptions if necessary. | pifx/util.py | def handle_error(response):
"""Raise appropriate exceptions if necessary."""
status_code = response.status_code
if status_code not in A_OK_HTTP_CODES:
error_explanation = A_ERROR_HTTP_CODES.get(status_code)
raise_error = "{}: {}".format(status_code, error_explanation)
raise Exceptio... | def handle_error(response):
"""Raise appropriate exceptions if necessary."""
status_code = response.status_code
if status_code not in A_OK_HTTP_CODES:
error_explanation = A_ERROR_HTTP_CODES.get(status_code)
raise_error = "{}: {}".format(status_code, error_explanation)
raise Exceptio... | [
"Raise",
"appropriate",
"exceptions",
"if",
"necessary",
"."
] | cydrobolt/pifx | python | https://github.com/cydrobolt/pifx/blob/c9de9c2695c3e6e72de4aa0de47b78fc13c457c3/pifx/util.py#L54-L63 | [
"def",
"handle_error",
"(",
"response",
")",
":",
"status_code",
"=",
"response",
".",
"status_code",
"if",
"status_code",
"not",
"in",
"A_OK_HTTP_CODES",
":",
"error_explanation",
"=",
"A_ERROR_HTTP_CODES",
".",
"get",
"(",
"status_code",
")",
"raise_error",
"=",... | c9de9c2695c3e6e72de4aa0de47b78fc13c457c3 |
train | NexsonAnnotationAdder.add_or_replace_annotation | Takes an `annotation` dictionary which is
expected to have a string as the value of annotation['author']['name']
This function will remove all annotations from obj that:
1. have the same author/name, and
2. have no messages that are flagged as messages to be preserved (values for... | peyotl/nexson_validation/_validation_base.py | def add_or_replace_annotation(self, # pylint: disable=R0201
obj,
annotation,
agent,
add_agent_only=False):
"""Takes an `annotation` dictionary which is
expected to hav... | def add_or_replace_annotation(self, # pylint: disable=R0201
obj,
annotation,
agent,
add_agent_only=False):
"""Takes an `annotation` dictionary which is
expected to hav... | [
"Takes",
"an",
"annotation",
"dictionary",
"which",
"is",
"expected",
"to",
"have",
"a",
"string",
"as",
"the",
"value",
"of",
"annotation",
"[",
"author",
"]",
"[",
"name",
"]",
"This",
"function",
"will",
"remove",
"all",
"annotations",
"from",
"obj",
"t... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_validation/_validation_base.py#L263-L293 | [
"def",
"add_or_replace_annotation",
"(",
"self",
",",
"# pylint: disable=R0201",
"obj",
",",
"annotation",
",",
"agent",
",",
"add_agent_only",
"=",
"False",
")",
":",
"nex",
"=",
"get_nexml_el",
"(",
"obj",
")",
"nvers",
"=",
"detect_nexson_version",
"(",
"obj"... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | NexsonValidationAdaptor._get_list_key | Either:
* Returns a list, or
* Generates a MissingExpectedListWarning and returns None (if
the value is not a dict or list) | peyotl/nexson_validation/_validation_base.py | def _get_list_key(self, obj, key, vc, obj_nex_id=None):
"""Either:
* Returns a list, or
* Generates a MissingExpectedListWarning and returns None (if
the value is not a dict or list)
"""
k = obj.get(key)
if k is None:
return None
... | def _get_list_key(self, obj, key, vc, obj_nex_id=None):
"""Either:
* Returns a list, or
* Generates a MissingExpectedListWarning and returns None (if
the value is not a dict or list)
"""
k = obj.get(key)
if k is None:
return None
... | [
"Either",
":",
"*",
"Returns",
"a",
"list",
"or",
"*",
"Generates",
"a",
"MissingExpectedListWarning",
"and",
"returns",
"None",
"(",
"if",
"the",
"value",
"is",
"not",
"a",
"dict",
"or",
"list",
")"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_validation/_validation_base.py#L524-L543 | [
"def",
"_get_list_key",
"(",
"self",
",",
"obj",
",",
"key",
",",
"vc",
",",
"obj_nex_id",
"=",
"None",
")",
":",
"k",
"=",
"obj",
".",
"get",
"(",
"key",
")",
"if",
"k",
"is",
"None",
":",
"return",
"None",
"if",
"isinstance",
"(",
"k",
",",
"... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | NexsonValidationAdaptor._validate_obj_by_schema | Creates:
errors if `obj` does not contain keys in the schema.ALLOWED_KEY_SET,
warnings if `obj` lacks keys listed in schema.EXPECETED_KEY_SET,
or if `obj` contains keys not listed in schema.ALLOWED_KEY_SET. | peyotl/nexson_validation/_validation_base.py | def _validate_obj_by_schema(self, obj, obj_nex_id, vc):
"""Creates:
errors if `obj` does not contain keys in the schema.ALLOWED_KEY_SET,
warnings if `obj` lacks keys listed in schema.EXPECETED_KEY_SET,
or if `obj` contains keys not listed in schema.ALLOWED_KEY_SET.
... | def _validate_obj_by_schema(self, obj, obj_nex_id, vc):
"""Creates:
errors if `obj` does not contain keys in the schema.ALLOWED_KEY_SET,
warnings if `obj` lacks keys listed in schema.EXPECETED_KEY_SET,
or if `obj` contains keys not listed in schema.ALLOWED_KEY_SET.
... | [
"Creates",
":",
"errors",
"if",
"obj",
"does",
"not",
"contain",
"keys",
"in",
"the",
"schema",
".",
"ALLOWED_KEY_SET",
"warnings",
"if",
"obj",
"lacks",
"keys",
"listed",
"in",
"schema",
".",
"EXPECETED_KEY_SET",
"or",
"if",
"obj",
"contains",
"keys",
"not"... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_validation/_validation_base.py#L575-L581 | [
"def",
"_validate_obj_by_schema",
"(",
"self",
",",
"obj",
",",
"obj_nex_id",
",",
"vc",
")",
":",
"return",
"self",
".",
"_validate_id_obj_list_by_schema",
"(",
"[",
"(",
"obj_nex_id",
",",
"obj",
")",
"]",
",",
"vc",
",",
"group_by_warning",
"=",
"False",
... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | add_schema_attributes | Adds several attributes to `container`:
_using_hbf_meta - boolean. True for HoneyBadgerFish v1-style meta elements ('^prop': value
rather than 'meta': {'$':value})
and the following _SchemaFragment instances:
_NexmlEl_Schema | peyotl/nexson_validation/schema.py | def add_schema_attributes(container, nexson_version):
"""Adds several attributes to `container`:
_using_hbf_meta - boolean. True for HoneyBadgerFish v1-style meta elements ('^prop': value
rather than 'meta': {'$':value})
and the following _SchemaFragment instances:
_NexmlEl_Schema
"... | def add_schema_attributes(container, nexson_version):
"""Adds several attributes to `container`:
_using_hbf_meta - boolean. True for HoneyBadgerFish v1-style meta elements ('^prop': value
rather than 'meta': {'$':value})
and the following _SchemaFragment instances:
_NexmlEl_Schema
"... | [
"Adds",
"several",
"attributes",
"to",
"container",
":",
"_using_hbf_meta",
"-",
"boolean",
".",
"True",
"for",
"HoneyBadgerFish",
"v1",
"-",
"style",
"meta",
"elements",
"(",
"^prop",
":",
"value",
"rather",
"than",
"meta",
":",
"{",
"$",
":",
"value",
"}... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_validation/schema.py#L13-L27 | [
"def",
"add_schema_attributes",
"(",
"container",
",",
"nexson_version",
")",
":",
"if",
"_is_by_id_hbf",
"(",
"nexson_version",
")",
":",
"_add_by_id_nexson_schema_attributes",
"(",
"container",
")",
"elif",
"_is_badgerfish_version",
"(",
"nexson_version",
")",
":",
... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | _BaseAgent.open | Context manager entry; open wallet.
For use when keeping agent open across multiple calls.
:return: current object | von_agent/agent/base.py | async def open(self) -> '_BaseAgent':
"""
Context manager entry; open wallet.
For use when keeping agent open across multiple calls.
:return: current object
"""
LOGGER.debug('_BaseAgent.open >>>')
# Do not open pool independently: let relying party decide when ... | async def open(self) -> '_BaseAgent':
"""
Context manager entry; open wallet.
For use when keeping agent open across multiple calls.
:return: current object
"""
LOGGER.debug('_BaseAgent.open >>>')
# Do not open pool independently: let relying party decide when ... | [
"Context",
"manager",
"entry",
";",
"open",
"wallet",
".",
"For",
"use",
"when",
"keeping",
"agent",
"open",
"across",
"multiple",
"calls",
"."
] | PSPC-SPAC-buyandsell/von_agent | python | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/base.py#L129-L143 | [
"async",
"def",
"open",
"(",
"self",
")",
"->",
"'_BaseAgent'",
":",
"LOGGER",
".",
"debug",
"(",
"'_BaseAgent.open >>>'",
")",
"# Do not open pool independently: let relying party decide when to go on-line and off-line",
"await",
"self",
".",
"wallet",
".",
"open",
"(",
... | 0b1c17cca3bd178b6e6974af84dbac1dfce5cf45 |
train | _BaseAgent.get_nym | Get json cryptonym (including current verification key) for input (agent) DID from ledger.
Raise BadLedgerTxn on failure.
:param did: DID of cryptonym to fetch
:return: cryptonym json | von_agent/agent/base.py | async def get_nym(self, did: str) -> str:
"""
Get json cryptonym (including current verification key) for input (agent) DID from ledger.
Raise BadLedgerTxn on failure.
:param did: DID of cryptonym to fetch
:return: cryptonym json
"""
LOGGER.debug('_BaseAgent.ge... | async def get_nym(self, did: str) -> str:
"""
Get json cryptonym (including current verification key) for input (agent) DID from ledger.
Raise BadLedgerTxn on failure.
:param did: DID of cryptonym to fetch
:return: cryptonym json
"""
LOGGER.debug('_BaseAgent.ge... | [
"Get",
"json",
"cryptonym",
"(",
"including",
"current",
"verification",
"key",
")",
"for",
"input",
"(",
"agent",
")",
"DID",
"from",
"ledger",
"."
] | PSPC-SPAC-buyandsell/von_agent | python | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/base.py#L173-L194 | [
"async",
"def",
"get_nym",
"(",
"self",
",",
"did",
":",
"str",
")",
"->",
"str",
":",
"LOGGER",
".",
"debug",
"(",
"'_BaseAgent.get_nym >>> did: %s'",
",",
"did",
")",
"rv",
"=",
"json",
".",
"dumps",
"(",
"{",
"}",
")",
"get_nym_req",
"=",
"await",
... | 0b1c17cca3bd178b6e6974af84dbac1dfce5cf45 |
train | _BaseAgent._sign_submit | Sign and submit (json) request to ledger; return (json) result.
Raise ClosedPool if pool is not yet open, CorruptWallet if existing wallet's
pool is no longer extant, or BadLedgerTxn on any other failure.
:param req_json: json of request to sign and submit
:return: json response | von_agent/agent/base.py | async def _sign_submit(self, req_json: str) -> str:
"""
Sign and submit (json) request to ledger; return (json) result.
Raise ClosedPool if pool is not yet open, CorruptWallet if existing wallet's
pool is no longer extant, or BadLedgerTxn on any other failure.
:param req_json: ... | async def _sign_submit(self, req_json: str) -> str:
"""
Sign and submit (json) request to ledger; return (json) result.
Raise ClosedPool if pool is not yet open, CorruptWallet if existing wallet's
pool is no longer extant, or BadLedgerTxn on any other failure.
:param req_json: ... | [
"Sign",
"and",
"submit",
"(",
"json",
")",
"request",
"to",
"ledger",
";",
"return",
"(",
"json",
")",
"result",
"."
] | PSPC-SPAC-buyandsell/von_agent | python | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/base.py#L242-L287 | [
"async",
"def",
"_sign_submit",
"(",
"self",
",",
"req_json",
":",
"str",
")",
"->",
"str",
":",
"LOGGER",
".",
"debug",
"(",
"'_BaseAgent._sign_submit >>> json: %s'",
",",
"req_json",
")",
"if",
"not",
"self",
".",
"pool",
".",
"handle",
":",
"LOGGER",
".... | 0b1c17cca3bd178b6e6974af84dbac1dfce5cf45 |
train | _BaseAgent._get_rev_reg_def | Get revocation registry definition from ledger by its identifier. Raise AbsentRevReg
for no such revocation registry, logging any error condition and raising BadLedgerTxn
on bad request.
Retrieve the revocation registry definition from the agent's revocation cache if it has it;
cache it... | von_agent/agent/base.py | async def _get_rev_reg_def(self, rr_id: str) -> str:
"""
Get revocation registry definition from ledger by its identifier. Raise AbsentRevReg
for no such revocation registry, logging any error condition and raising BadLedgerTxn
on bad request.
Retrieve the revocation registry de... | async def _get_rev_reg_def(self, rr_id: str) -> str:
"""
Get revocation registry definition from ledger by its identifier. Raise AbsentRevReg
for no such revocation registry, logging any error condition and raising BadLedgerTxn
on bad request.
Retrieve the revocation registry de... | [
"Get",
"revocation",
"registry",
"definition",
"from",
"ledger",
"by",
"its",
"identifier",
".",
"Raise",
"AbsentRevReg",
"for",
"no",
"such",
"revocation",
"registry",
"logging",
"any",
"error",
"condition",
"and",
"raising",
"BadLedgerTxn",
"on",
"bad",
"request... | PSPC-SPAC-buyandsell/von_agent | python | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/base.py#L289-L329 | [
"async",
"def",
"_get_rev_reg_def",
"(",
"self",
",",
"rr_id",
":",
"str",
")",
"->",
"str",
":",
"LOGGER",
".",
"debug",
"(",
"'_BaseAgent._get_rev_reg_def >>> rr_id: %s'",
",",
"rr_id",
")",
"rv_json",
"=",
"json",
".",
"dumps",
"(",
"{",
"}",
")",
"with... | 0b1c17cca3bd178b6e6974af84dbac1dfce5cf45 |
train | _BaseAgent.get_cred_def | Get credential definition from ledger by its identifier.
Raise AbsentCredDef for no such credential definition, logging any error condition and raising
BadLedgerTxn on bad request. Raise ClosedPool if cred def not in cache and pool is closed.
Retrieve the credential definition from the agent's... | von_agent/agent/base.py | async def get_cred_def(self, cd_id: str) -> str:
"""
Get credential definition from ledger by its identifier.
Raise AbsentCredDef for no such credential definition, logging any error condition and raising
BadLedgerTxn on bad request. Raise ClosedPool if cred def not in cache and pool is... | async def get_cred_def(self, cd_id: str) -> str:
"""
Get credential definition from ledger by its identifier.
Raise AbsentCredDef for no such credential definition, logging any error condition and raising
BadLedgerTxn on bad request. Raise ClosedPool if cred def not in cache and pool is... | [
"Get",
"credential",
"definition",
"from",
"ledger",
"by",
"its",
"identifier",
"."
] | PSPC-SPAC-buyandsell/von_agent | python | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/base.py#L331-L371 | [
"async",
"def",
"get_cred_def",
"(",
"self",
",",
"cd_id",
":",
"str",
")",
"->",
"str",
":",
"LOGGER",
".",
"debug",
"(",
"'_BaseAgent.get_cred_def >>> cd_id: %s'",
",",
"cd_id",
")",
"rv_json",
"=",
"json",
".",
"dumps",
"(",
"{",
"}",
")",
"with",
"CR... | 0b1c17cca3bd178b6e6974af84dbac1dfce5cf45 |
train | _BaseAgent.get_schema | Get schema from ledger by SchemaKey namedtuple (origin DID, name, version),
sequence number, or schema identifier.
Raise AbsentSchema for no such schema, logging any error condition and raising
BadLedgerTxn on bad request.
Retrieve the schema from the agent's schema cache if it has it;... | von_agent/agent/base.py | async def get_schema(self, index: Union[SchemaKey, int, str]) -> str:
"""
Get schema from ledger by SchemaKey namedtuple (origin DID, name, version),
sequence number, or schema identifier.
Raise AbsentSchema for no such schema, logging any error condition and raising
BadLedgerTx... | async def get_schema(self, index: Union[SchemaKey, int, str]) -> str:
"""
Get schema from ledger by SchemaKey namedtuple (origin DID, name, version),
sequence number, or schema identifier.
Raise AbsentSchema for no such schema, logging any error condition and raising
BadLedgerTx... | [
"Get",
"schema",
"from",
"ledger",
"by",
"SchemaKey",
"namedtuple",
"(",
"origin",
"DID",
"name",
"version",
")",
"sequence",
"number",
"or",
"schema",
"identifier",
"."
] | PSPC-SPAC-buyandsell/von_agent | python | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/base.py#L373-L434 | [
"async",
"def",
"get_schema",
"(",
"self",
",",
"index",
":",
"Union",
"[",
"SchemaKey",
",",
"int",
",",
"str",
"]",
")",
"->",
"str",
":",
"LOGGER",
".",
"debug",
"(",
"'_BaseAgent.get_schema >>> index: %s'",
",",
"index",
")",
"rv_json",
"=",
"json",
... | 0b1c17cca3bd178b6e6974af84dbac1dfce5cf45 |
train | _BaseAgent.get_txn | Find a transaction on the distributed ledger by its sequence number.
:param txn: transaction number
:return: json sequence number of transaction, null for no match | von_agent/agent/base.py | async def get_txn(self, txn: int) -> str:
"""
Find a transaction on the distributed ledger by its sequence number.
:param txn: transaction number
:return: json sequence number of transaction, null for no match
"""
LOGGER.debug('_BaseAgent.get_txn >>> txn: %s', txn)
... | async def get_txn(self, txn: int) -> str:
"""
Find a transaction on the distributed ledger by its sequence number.
:param txn: transaction number
:return: json sequence number of transaction, null for no match
"""
LOGGER.debug('_BaseAgent.get_txn >>> txn: %s', txn)
... | [
"Find",
"a",
"transaction",
"on",
"the",
"distributed",
"ledger",
"by",
"its",
"sequence",
"number",
"."
] | PSPC-SPAC-buyandsell/von_agent | python | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/base.py#L436-L452 | [
"async",
"def",
"get_txn",
"(",
"self",
",",
"txn",
":",
"int",
")",
"->",
"str",
":",
"LOGGER",
".",
"debug",
"(",
"'_BaseAgent.get_txn >>> txn: %s'",
",",
"txn",
")",
"rv_json",
"=",
"json",
".",
"dumps",
"(",
"{",
"}",
")",
"req_json",
"=",
"await",... | 0b1c17cca3bd178b6e6974af84dbac1dfce5cf45 |
train | proc_forward | Resolve etype to an actual type if it is a forward reference | pyjsg/jsglib/typing_patch_37.py | def proc_forward(etype, namespace: Dict[str, Any]):
""" Resolve etype to an actual type if it is a forward reference """
return etype._evaluate(namespace, namespace) if type(etype) is ForwardRef else etype | def proc_forward(etype, namespace: Dict[str, Any]):
""" Resolve etype to an actual type if it is a forward reference """
return etype._evaluate(namespace, namespace) if type(etype) is ForwardRef else etype | [
"Resolve",
"etype",
"to",
"an",
"actual",
"type",
"if",
"it",
"is",
"a",
"forward",
"reference"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/jsglib/typing_patch_37.py#L8-L10 | [
"def",
"proc_forward",
"(",
"etype",
",",
"namespace",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
":",
"return",
"etype",
".",
"_evaluate",
"(",
"namespace",
",",
"namespace",
")",
"if",
"type",
"(",
"etype",
")",
"is",
"ForwardRef",
"else",
"etype... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | is_union | Determine whether etype is a Union | pyjsg/jsglib/typing_patch_37.py | def is_union(etype) -> bool:
""" Determine whether etype is a Union """
return getattr(etype, '__origin__', None) is not None and \
getattr(etype.__origin__, '_name', None) and\
etype.__origin__._name == 'Union' | def is_union(etype) -> bool:
""" Determine whether etype is a Union """
return getattr(etype, '__origin__', None) is not None and \
getattr(etype.__origin__, '_name', None) and\
etype.__origin__._name == 'Union' | [
"Determine",
"whether",
"etype",
"is",
"a",
"Union"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/jsglib/typing_patch_37.py#L13-L17 | [
"def",
"is_union",
"(",
"etype",
")",
"->",
"bool",
":",
"return",
"getattr",
"(",
"etype",
",",
"'__origin__'",
",",
"None",
")",
"is",
"not",
"None",
"and",
"getattr",
"(",
"etype",
".",
"__origin__",
",",
"'_name'",
",",
"None",
")",
"and",
"etype",... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | union_conforms | Determine whether element conforms to at least one of the types in etype
:param element: element to test
:param etype: type to test against
:param namespace: Namespace to use for resolving forward references
:param conforms: conformance test function
:return: True if element conforms to at least on... | pyjsg/jsglib/typing_patch_37.py | def union_conforms(element: Union, etype, namespace: Dict[str, Any], conforms: Callable) -> bool:
""" Determine whether element conforms to at least one of the types in etype
:param element: element to test
:param etype: type to test against
:param namespace: Namespace to use for resolving forward refe... | def union_conforms(element: Union, etype, namespace: Dict[str, Any], conforms: Callable) -> bool:
""" Determine whether element conforms to at least one of the types in etype
:param element: element to test
:param etype: type to test against
:param namespace: Namespace to use for resolving forward refe... | [
"Determine",
"whether",
"element",
"conforms",
"to",
"at",
"least",
"one",
"of",
"the",
"types",
"in",
"etype"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/jsglib/typing_patch_37.py#L30-L39 | [
"def",
"union_conforms",
"(",
"element",
":",
"Union",
",",
"etype",
",",
"namespace",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"conforms",
":",
"Callable",
")",
"->",
"bool",
":",
"return",
"any",
"(",
"conforms",
"(",
"element",
",",
"t",
","... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | unset | Unset the TypedFields on the input `entity`.
Args:
entity: A mixbox.Entity object.
*types: A variable-length list of TypedField subclasses. If not
provided, defaults to TypedField. | mixbox/fields.py | def unset(entity, *types):
"""Unset the TypedFields on the input `entity`.
Args:
entity: A mixbox.Entity object.
*types: A variable-length list of TypedField subclasses. If not
provided, defaults to TypedField.
"""
if not types:
types = (TypedField,)
fields = li... | def unset(entity, *types):
"""Unset the TypedFields on the input `entity`.
Args:
entity: A mixbox.Entity object.
*types: A variable-length list of TypedField subclasses. If not
provided, defaults to TypedField.
"""
if not types:
types = (TypedField,)
fields = li... | [
"Unset",
"the",
"TypedFields",
"on",
"the",
"input",
"entity",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/fields.py#L17-L32 | [
"def",
"unset",
"(",
"entity",
",",
"*",
"types",
")",
":",
"if",
"not",
"types",
":",
"types",
"=",
"(",
"TypedField",
",",
")",
"fields",
"=",
"list",
"(",
"entity",
".",
"_fields",
".",
"keys",
"(",
")",
")",
"remove",
"=",
"(",
"x",
"for",
... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | _matches | Return True if the input TypedField `field` contains instance attributes
that match the input parameters.
Args:
field: A TypedField instance.
params: A dictionary of TypedField instance attribute-to-value mappings.
Returns:
True if the input TypedField matches the input parameters. | mixbox/fields.py | def _matches(field, params):
"""Return True if the input TypedField `field` contains instance attributes
that match the input parameters.
Args:
field: A TypedField instance.
params: A dictionary of TypedField instance attribute-to-value mappings.
Returns:
True if the input Type... | def _matches(field, params):
"""Return True if the input TypedField `field` contains instance attributes
that match the input parameters.
Args:
field: A TypedField instance.
params: A dictionary of TypedField instance attribute-to-value mappings.
Returns:
True if the input Type... | [
"Return",
"True",
"if",
"the",
"input",
"TypedField",
"field",
"contains",
"instance",
"attributes",
"that",
"match",
"the",
"input",
"parameters",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/fields.py#L35-L47 | [
"def",
"_matches",
"(",
"field",
",",
"params",
")",
":",
"fieldattrs",
"=",
"six",
".",
"iteritems",
"(",
"params",
")",
"return",
"all",
"(",
"getattr",
"(",
"field",
",",
"attr",
")",
"==",
"val",
"for",
"attr",
",",
"val",
"in",
"fieldattrs",
")"... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | iterfields | Iterate over the input class members and yield its TypedFields.
Args:
klass: A class (usually an Entity subclass).
Yields:
(class attribute name, TypedField instance) tuples. | mixbox/fields.py | def iterfields(klass):
"""Iterate over the input class members and yield its TypedFields.
Args:
klass: A class (usually an Entity subclass).
Yields:
(class attribute name, TypedField instance) tuples.
"""
is_field = lambda x: isinstance(x, TypedField)
for name, field in inspec... | def iterfields(klass):
"""Iterate over the input class members and yield its TypedFields.
Args:
klass: A class (usually an Entity subclass).
Yields:
(class attribute name, TypedField instance) tuples.
"""
is_field = lambda x: isinstance(x, TypedField)
for name, field in inspec... | [
"Iterate",
"over",
"the",
"input",
"class",
"members",
"and",
"yield",
"its",
"TypedFields",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/fields.py#L50-L62 | [
"def",
"iterfields",
"(",
"klass",
")",
":",
"is_field",
"=",
"lambda",
"x",
":",
"isinstance",
"(",
"x",
",",
"TypedField",
")",
"for",
"name",
",",
"field",
"in",
"inspect",
".",
"getmembers",
"(",
"klass",
",",
"predicate",
"=",
"is_field",
")",
":"... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | find | Return all TypedFields found on the input `Entity` that were initialized
with the input **kwargs.
Example:
>>> find(myentity, multiple=True, type_=Foo)
Note:
TypedFields.__init__() can accept a string or a class as a type_
argument, but this method expects a class.
Args:
... | mixbox/fields.py | def find(entity, **kwargs):
"""Return all TypedFields found on the input `Entity` that were initialized
with the input **kwargs.
Example:
>>> find(myentity, multiple=True, type_=Foo)
Note:
TypedFields.__init__() can accept a string or a class as a type_
argument, but this metho... | def find(entity, **kwargs):
"""Return all TypedFields found on the input `Entity` that were initialized
with the input **kwargs.
Example:
>>> find(myentity, multiple=True, type_=Foo)
Note:
TypedFields.__init__() can accept a string or a class as a type_
argument, but this metho... | [
"Return",
"all",
"TypedFields",
"found",
"on",
"the",
"input",
"Entity",
"that",
"were",
"initialized",
"with",
"the",
"input",
"**",
"kwargs",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/fields.py#L65-L88 | [
"def",
"find",
"(",
"entity",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"typedfields",
"=",
"entity",
".",
"typed_fields",
"(",
")",
"except",
"AttributeError",
":",
"typedfields",
"=",
"iterfields",
"(",
"entity",
".",
"__class__",
")",
"matching",
... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | TypedField._clean | Validate and clean a candidate value for this field. | mixbox/fields.py | def _clean(self, value):
"""Validate and clean a candidate value for this field."""
if value is None:
return None
elif self.type_ is None:
return value
elif self.check_type(value):
return value
elif self.is_type_castable: # noqa
re... | def _clean(self, value):
"""Validate and clean a candidate value for this field."""
if value is None:
return None
elif self.type_ is None:
return value
elif self.check_type(value):
return value
elif self.is_type_castable: # noqa
re... | [
"Validate",
"and",
"clean",
"a",
"candidate",
"value",
"for",
"this",
"field",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/fields.py#L177-L190 | [
"def",
"_clean",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"elif",
"self",
".",
"type_",
"is",
"None",
":",
"return",
"value",
"elif",
"self",
".",
"check_type",
"(",
"value",
")",
":",
"return",
"value"... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | TypedField.transformer | Return the class for this field that transforms non-Entity objects
(e.g., dicts or binding objects) into Entity instances.
Any non-None value returned from this method should implement a
from_obj() and from_dict() method.
Returns:
None if no type_ or factory is defined by t... | mixbox/fields.py | def transformer(self):
"""Return the class for this field that transforms non-Entity objects
(e.g., dicts or binding objects) into Entity instances.
Any non-None value returned from this method should implement a
from_obj() and from_dict() method.
Returns:
None if n... | def transformer(self):
"""Return the class for this field that transforms non-Entity objects
(e.g., dicts or binding objects) into Entity instances.
Any non-None value returned from this method should implement a
from_obj() and from_dict() method.
Returns:
None if n... | [
"Return",
"the",
"class",
"for",
"this",
"field",
"that",
"transforms",
"non",
"-",
"Entity",
"objects",
"(",
"e",
".",
"g",
".",
"dicts",
"or",
"binding",
"objects",
")",
"into",
"Entity",
"instances",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/fields.py#L260-L276 | [
"def",
"transformer",
"(",
"self",
")",
":",
"if",
"self",
".",
"factory",
":",
"return",
"self",
".",
"factory",
"elif",
"self",
".",
"type_",
":",
"return",
"self",
".",
"type_",
"else",
":",
"return",
"None"
] | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.