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 | AccessControl.get_resource | Returns a specific resource by resource id. | predix/security/acs.py | def get_resource(self, resource_id):
"""
Returns a specific resource by resource id.
"""
# resource_id could be a path such as '/asset/123' so quote
uri = self._get_resource_uri(guid=resource_id)
return self.service._get(uri) | def get_resource(self, resource_id):
"""
Returns a specific resource by resource id.
"""
# resource_id could be a path such as '/asset/123' so quote
uri = self._get_resource_uri(guid=resource_id)
return self.service._get(uri) | [
"Returns",
"a",
"specific",
"resource",
"by",
"resource",
"id",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L81-L87 | [
"def",
"get_resource",
"(",
"self",
",",
"resource_id",
")",
":",
"# resource_id could be a path such as '/asset/123' so quote",
"uri",
"=",
"self",
".",
"_get_resource_uri",
"(",
"guid",
"=",
"resource_id",
")",
"return",
"self",
".",
"service",
".",
"_get",
"(",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | AccessControl._post_resource | Create new resources and associated attributes.
Example:
acs.post_resource([
{
"resourceIdentifier": "masaya",
"parents": [],
"attributes": [
{
"issuer": "default",
... | predix/security/acs.py | def _post_resource(self, body):
"""
Create new resources and associated attributes.
Example:
acs.post_resource([
{
"resourceIdentifier": "masaya",
"parents": [],
"attributes": [
{
... | def _post_resource(self, body):
"""
Create new resources and associated attributes.
Example:
acs.post_resource([
{
"resourceIdentifier": "masaya",
"parents": [],
"attributes": [
{
... | [
"Create",
"new",
"resources",
"and",
"associated",
"attributes",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L89-L117 | [
"def",
"_post_resource",
"(",
"self",
",",
"body",
")",
":",
"assert",
"isinstance",
"(",
"body",
",",
"(",
"list",
")",
")",
",",
"\"POST for requires body to be a list\"",
"uri",
"=",
"self",
".",
"_get_resource_uri",
"(",
")",
"return",
"self",
".",
"serv... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | AccessControl.delete_resource | Remove a specific resource by its identifier. | predix/security/acs.py | def delete_resource(self, resource_id):
"""
Remove a specific resource by its identifier.
"""
# resource_id could be a path such as '/asset/123' so quote
uri = self._get_resource_uri(guid=resource_id)
return self.service._delete(uri) | def delete_resource(self, resource_id):
"""
Remove a specific resource by its identifier.
"""
# resource_id could be a path such as '/asset/123' so quote
uri = self._get_resource_uri(guid=resource_id)
return self.service._delete(uri) | [
"Remove",
"a",
"specific",
"resource",
"by",
"its",
"identifier",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L119-L125 | [
"def",
"delete_resource",
"(",
"self",
",",
"resource_id",
")",
":",
"# resource_id could be a path such as '/asset/123' so quote",
"uri",
"=",
"self",
".",
"_get_resource_uri",
"(",
"guid",
"=",
"resource_id",
")",
"return",
"self",
".",
"service",
".",
"_delete",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | AccessControl._put_resource | Update a resource for the given resource id. The body is not
a list but a dictionary of a single resource. | predix/security/acs.py | def _put_resource(self, resource_id, body):
"""
Update a resource for the given resource id. The body is not
a list but a dictionary of a single resource.
"""
assert isinstance(body, (dict)), "PUT requires body to be a dict."
# resource_id could be a path such as '/asset... | def _put_resource(self, resource_id, body):
"""
Update a resource for the given resource id. The body is not
a list but a dictionary of a single resource.
"""
assert isinstance(body, (dict)), "PUT requires body to be a dict."
# resource_id could be a path such as '/asset... | [
"Update",
"a",
"resource",
"for",
"the",
"given",
"resource",
"id",
".",
"The",
"body",
"is",
"not",
"a",
"list",
"but",
"a",
"dictionary",
"of",
"a",
"single",
"resource",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L127-L135 | [
"def",
"_put_resource",
"(",
"self",
",",
"resource_id",
",",
"body",
")",
":",
"assert",
"isinstance",
"(",
"body",
",",
"(",
"dict",
")",
")",
",",
"\"PUT requires body to be a dict.\"",
"# resource_id could be a path such as '/asset/123' so quote",
"uri",
"=",
"sel... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | AccessControl.add_resource | Will add the given resource with a given identifier and attribute
dictionary.
example/
add_resource('/asset/12', {'id': 12, 'manufacturer': 'GE'}) | predix/security/acs.py | def add_resource(self, resource_id, attributes, parents=[],
issuer='default'):
"""
Will add the given resource with a given identifier and attribute
dictionary.
example/
add_resource('/asset/12', {'id': 12, 'manufacturer': 'GE'})
"""
# MA... | def add_resource(self, resource_id, attributes, parents=[],
issuer='default'):
"""
Will add the given resource with a given identifier and attribute
dictionary.
example/
add_resource('/asset/12', {'id': 12, 'manufacturer': 'GE'})
"""
# MA... | [
"Will",
"add",
"the",
"given",
"resource",
"with",
"a",
"given",
"identifier",
"and",
"attribute",
"dictionary",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L137-L164 | [
"def",
"add_resource",
"(",
"self",
",",
"resource_id",
",",
"attributes",
",",
"parents",
"=",
"[",
"]",
",",
"issuer",
"=",
"'default'",
")",
":",
"# MAINT: consider test to avoid adding duplicate resource id",
"assert",
"isinstance",
"(",
"attributes",
",",
"(",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | AccessControl._get_subject_uri | Returns the full path that uniquely identifies
the subject endpoint. | predix/security/acs.py | def _get_subject_uri(self, guid=None):
"""
Returns the full path that uniquely identifies
the subject endpoint.
"""
uri = self.uri + '/v1/subject'
if guid:
uri += '/' + urllib.quote_plus(guid)
return uri | def _get_subject_uri(self, guid=None):
"""
Returns the full path that uniquely identifies
the subject endpoint.
"""
uri = self.uri + '/v1/subject'
if guid:
uri += '/' + urllib.quote_plus(guid)
return uri | [
"Returns",
"the",
"full",
"path",
"that",
"uniquely",
"identifies",
"the",
"subject",
"endpoint",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L166-L174 | [
"def",
"_get_subject_uri",
"(",
"self",
",",
"guid",
"=",
"None",
")",
":",
"uri",
"=",
"self",
".",
"uri",
"+",
"'/v1/subject'",
"if",
"guid",
":",
"uri",
"+=",
"'/'",
"+",
"urllib",
".",
"quote_plus",
"(",
"guid",
")",
"return",
"uri"
] | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | AccessControl.get_subject | Returns a specific subject by subject id. | predix/security/acs.py | def get_subject(self, subject_id):
"""
Returns a specific subject by subject id.
"""
# subject_id could be a path such as '/user/j12y' so quote
uri = self._get_subject_uri(guid=subject_id)
return self.service._get(uri) | def get_subject(self, subject_id):
"""
Returns a specific subject by subject id.
"""
# subject_id could be a path such as '/user/j12y' so quote
uri = self._get_subject_uri(guid=subject_id)
return self.service._get(uri) | [
"Returns",
"a",
"specific",
"subject",
"by",
"subject",
"id",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L183-L189 | [
"def",
"get_subject",
"(",
"self",
",",
"subject_id",
")",
":",
"# subject_id could be a path such as '/user/j12y' so quote",
"uri",
"=",
"self",
".",
"_get_subject_uri",
"(",
"guid",
"=",
"subject_id",
")",
"return",
"self",
".",
"service",
".",
"_get",
"(",
"uri... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | AccessControl._post_subject | Create new subjects and associated attributes.
Example:
acs.post_subject([
{
"subjectIdentifier": "/role/evangelist",
"parents": [],
"attributes": [
{
"issuer": "default"... | predix/security/acs.py | def _post_subject(self, body):
"""
Create new subjects and associated attributes.
Example:
acs.post_subject([
{
"subjectIdentifier": "/role/evangelist",
"parents": [],
"attributes": [
... | def _post_subject(self, body):
"""
Create new subjects and associated attributes.
Example:
acs.post_subject([
{
"subjectIdentifier": "/role/evangelist",
"parents": [],
"attributes": [
... | [
"Create",
"new",
"subjects",
"and",
"associated",
"attributes",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L191-L220 | [
"def",
"_post_subject",
"(",
"self",
",",
"body",
")",
":",
"assert",
"isinstance",
"(",
"body",
",",
"(",
"list",
")",
")",
",",
"\"POST requires body to be a list\"",
"uri",
"=",
"self",
".",
"_get_subject_uri",
"(",
")",
"return",
"self",
".",
"service",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | AccessControl.delete_subject | Remove a specific subject by its identifier. | predix/security/acs.py | def delete_subject(self, subject_id):
"""
Remove a specific subject by its identifier.
"""
# subject_id could be a path such as '/role/analyst' so quote
uri = self._get_subject_uri(guid=subject_id)
return self.service._delete(uri) | def delete_subject(self, subject_id):
"""
Remove a specific subject by its identifier.
"""
# subject_id could be a path such as '/role/analyst' so quote
uri = self._get_subject_uri(guid=subject_id)
return self.service._delete(uri) | [
"Remove",
"a",
"specific",
"subject",
"by",
"its",
"identifier",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L222-L228 | [
"def",
"delete_subject",
"(",
"self",
",",
"subject_id",
")",
":",
"# subject_id could be a path such as '/role/analyst' so quote",
"uri",
"=",
"self",
".",
"_get_subject_uri",
"(",
"guid",
"=",
"subject_id",
")",
"return",
"self",
".",
"service",
".",
"_delete",
"(... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | AccessControl._put_subject | Update a subject for the given subject id. The body is not
a list but a dictionary of a single resource. | predix/security/acs.py | def _put_subject(self, subject_id, body):
"""
Update a subject for the given subject id. The body is not
a list but a dictionary of a single resource.
"""
assert isinstance(body, (dict)), "PUT requires body to be dict."
# subject_id could be a path such as '/asset/123' ... | def _put_subject(self, subject_id, body):
"""
Update a subject for the given subject id. The body is not
a list but a dictionary of a single resource.
"""
assert isinstance(body, (dict)), "PUT requires body to be dict."
# subject_id could be a path such as '/asset/123' ... | [
"Update",
"a",
"subject",
"for",
"the",
"given",
"subject",
"id",
".",
"The",
"body",
"is",
"not",
"a",
"list",
"but",
"a",
"dictionary",
"of",
"a",
"single",
"resource",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L230-L239 | [
"def",
"_put_subject",
"(",
"self",
",",
"subject_id",
",",
"body",
")",
":",
"assert",
"isinstance",
"(",
"body",
",",
"(",
"dict",
")",
")",
",",
"\"PUT requires body to be dict.\"",
"# subject_id could be a path such as '/asset/123' so quote",
"uri",
"=",
"self",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | AccessControl.add_subject | Will add the given subject with a given identifier and attribute
dictionary.
example/
add_subject('/user/j12y', {'username': 'j12y'}) | predix/security/acs.py | def add_subject(self, subject_id, attributes, parents=[],
issuer='default'):
"""
Will add the given subject with a given identifier and attribute
dictionary.
example/
add_subject('/user/j12y', {'username': 'j12y'})
"""
# MAINT: consider t... | def add_subject(self, subject_id, attributes, parents=[],
issuer='default'):
"""
Will add the given subject with a given identifier and attribute
dictionary.
example/
add_subject('/user/j12y', {'username': 'j12y'})
"""
# MAINT: consider t... | [
"Will",
"add",
"the",
"given",
"subject",
"with",
"a",
"given",
"identifier",
"and",
"attribute",
"dictionary",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L241-L268 | [
"def",
"add_subject",
"(",
"self",
",",
"subject_id",
",",
"attributes",
",",
"parents",
"=",
"[",
"]",
",",
"issuer",
"=",
"'default'",
")",
":",
"# MAINT: consider test to avoid adding duplicate subject id",
"assert",
"isinstance",
"(",
"attributes",
",",
"(",
"... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | AccessControl._get_monitoring_heartbeat | Tests whether or not the ACS service being monitored is alive. | predix/security/acs.py | def _get_monitoring_heartbeat(self):
"""
Tests whether or not the ACS service being monitored is alive.
"""
target = self.uri + '/monitoring/heartbeat'
response = self.session.get(target)
return response | def _get_monitoring_heartbeat(self):
"""
Tests whether or not the ACS service being monitored is alive.
"""
target = self.uri + '/monitoring/heartbeat'
response = self.session.get(target)
return response | [
"Tests",
"whether",
"or",
"not",
"the",
"ACS",
"service",
"being",
"monitored",
"is",
"alive",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L270-L276 | [
"def",
"_get_monitoring_heartbeat",
"(",
"self",
")",
":",
"target",
"=",
"self",
".",
"uri",
"+",
"'/monitoring/heartbeat'",
"response",
"=",
"self",
".",
"session",
".",
"get",
"(",
"target",
")",
"return",
"response"
] | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | AccessControl.is_alive | Will test whether the ACS service is up and alive. | predix/security/acs.py | def is_alive(self):
"""
Will test whether the ACS service is up and alive.
"""
response = self.get_monitoring_heartbeat()
if response.status_code == 200 and response.content == 'alive':
return True
return False | def is_alive(self):
"""
Will test whether the ACS service is up and alive.
"""
response = self.get_monitoring_heartbeat()
if response.status_code == 200 and response.content == 'alive':
return True
return False | [
"Will",
"test",
"whether",
"the",
"ACS",
"service",
"is",
"up",
"and",
"alive",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L278-L286 | [
"def",
"is_alive",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"get_monitoring_heartbeat",
"(",
")",
"if",
"response",
".",
"status_code",
"==",
"200",
"and",
"response",
".",
"content",
"==",
"'alive'",
":",
"return",
"True",
"return",
"False"
] | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | AccessControl._get_policy_set_uri | Returns the full path that uniquely identifies
the subject endpoint. | predix/security/acs.py | def _get_policy_set_uri(self, guid=None):
"""
Returns the full path that uniquely identifies
the subject endpoint.
"""
uri = self.uri + '/v1/policy-set'
if guid:
uri += '/' + urllib.quote_plus(guid)
return uri | def _get_policy_set_uri(self, guid=None):
"""
Returns the full path that uniquely identifies
the subject endpoint.
"""
uri = self.uri + '/v1/policy-set'
if guid:
uri += '/' + urllib.quote_plus(guid)
return uri | [
"Returns",
"the",
"full",
"path",
"that",
"uniquely",
"identifies",
"the",
"subject",
"endpoint",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L288-L296 | [
"def",
"_get_policy_set_uri",
"(",
"self",
",",
"guid",
"=",
"None",
")",
":",
"uri",
"=",
"self",
".",
"uri",
"+",
"'/v1/policy-set'",
"if",
"guid",
":",
"uri",
"+=",
"'/'",
"+",
"urllib",
".",
"quote_plus",
"(",
"guid",
")",
"return",
"uri"
] | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | AccessControl._put_policy_set | Will create or update a policy set for the given path. | predix/security/acs.py | def _put_policy_set(self, policy_set_id, body):
"""
Will create or update a policy set for the given path.
"""
assert isinstance(body, (dict)), "PUT requires body to be a dict."
uri = self._get_policy_set_uri(guid=policy_set_id)
return self.service._put(uri, body) | def _put_policy_set(self, policy_set_id, body):
"""
Will create or update a policy set for the given path.
"""
assert isinstance(body, (dict)), "PUT requires body to be a dict."
uri = self._get_policy_set_uri(guid=policy_set_id)
return self.service._put(uri, body) | [
"Will",
"create",
"or",
"update",
"a",
"policy",
"set",
"for",
"the",
"given",
"path",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L305-L311 | [
"def",
"_put_policy_set",
"(",
"self",
",",
"policy_set_id",
",",
"body",
")",
":",
"assert",
"isinstance",
"(",
"body",
",",
"(",
"dict",
")",
")",
",",
"\"PUT requires body to be a dict.\"",
"uri",
"=",
"self",
".",
"_get_policy_set_uri",
"(",
"guid",
"=",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | AccessControl._get_policy_set | Get a specific policy set by id. | predix/security/acs.py | def _get_policy_set(self, policy_set_id):
"""
Get a specific policy set by id.
"""
uri = self._get_policy_set_uri(guid=policy_set_id)
return self.service._get(uri) | def _get_policy_set(self, policy_set_id):
"""
Get a specific policy set by id.
"""
uri = self._get_policy_set_uri(guid=policy_set_id)
return self.service._get(uri) | [
"Get",
"a",
"specific",
"policy",
"set",
"by",
"id",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L313-L318 | [
"def",
"_get_policy_set",
"(",
"self",
",",
"policy_set_id",
")",
":",
"uri",
"=",
"self",
".",
"_get_policy_set_uri",
"(",
"guid",
"=",
"policy_set_id",
")",
"return",
"self",
".",
"service",
".",
"_get",
"(",
"uri",
")"
] | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | AccessControl.delete_policy_set | Delete a specific policy set by id. Method is idempotent. | predix/security/acs.py | def delete_policy_set(self, policy_set_id):
"""
Delete a specific policy set by id. Method is idempotent.
"""
uri = self._get_policy_set_uri(guid=policy_set_id)
return self.service._delete(uri) | def delete_policy_set(self, policy_set_id):
"""
Delete a specific policy set by id. Method is idempotent.
"""
uri = self._get_policy_set_uri(guid=policy_set_id)
return self.service._delete(uri) | [
"Delete",
"a",
"specific",
"policy",
"set",
"by",
"id",
".",
"Method",
"is",
"idempotent",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L320-L325 | [
"def",
"delete_policy_set",
"(",
"self",
",",
"policy_set_id",
")",
":",
"uri",
"=",
"self",
".",
"_get_policy_set_uri",
"(",
"guid",
"=",
"policy_set_id",
")",
"return",
"self",
".",
"service",
".",
"_delete",
"(",
"uri",
")"
] | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | AccessControl.add_policy | Will create a new policy set to enforce the given policy details.
The name is just a helpful descriptor for the policy.
The action maps to a HTTP verb.
Policies are evaluated against resources and subjects. They are
identified by matching a uriTemplate or attributes.
Example... | predix/security/acs.py | def add_policy(self, name, action, resource, subject, condition,
policy_set_id=None, effect='PERMIT'):
"""
Will create a new policy set to enforce the given policy details.
The name is just a helpful descriptor for the policy.
The action maps to a HTTP verb.
Polici... | def add_policy(self, name, action, resource, subject, condition,
policy_set_id=None, effect='PERMIT'):
"""
Will create a new policy set to enforce the given policy details.
The name is just a helpful descriptor for the policy.
The action maps to a HTTP verb.
Polici... | [
"Will",
"create",
"a",
"new",
"policy",
"set",
"to",
"enforce",
"the",
"given",
"policy",
"details",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L327-L391 | [
"def",
"add_policy",
"(",
"self",
",",
"name",
",",
"action",
",",
"resource",
",",
"subject",
",",
"condition",
",",
"policy_set_id",
"=",
"None",
",",
"effect",
"=",
"'PERMIT'",
")",
":",
"# If not given a policy set id will generate one",
"if",
"not",
"policy... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | AccessControl.is_allowed | Evaluate a policy-set against a subject and resource.
example/
is_allowed('/user/j12y', 'GET', '/asset/12') | predix/security/acs.py | def is_allowed(self, subject_id, action, resource_id, policy_sets=[]):
"""
Evaluate a policy-set against a subject and resource.
example/
is_allowed('/user/j12y', 'GET', '/asset/12')
"""
body = {
"action": action,
"subjectIdentifier": subjec... | def is_allowed(self, subject_id, action, resource_id, policy_sets=[]):
"""
Evaluate a policy-set against a subject and resource.
example/
is_allowed('/user/j12y', 'GET', '/asset/12')
"""
body = {
"action": action,
"subjectIdentifier": subjec... | [
"Evaluate",
"a",
"policy",
"-",
"set",
"against",
"a",
"subject",
"and",
"resource",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L393-L423 | [
"def",
"is_allowed",
"(",
"self",
",",
"subject_id",
",",
"action",
",",
"resource_id",
",",
"policy_sets",
"=",
"[",
"]",
")",
":",
"body",
"=",
"{",
"\"action\"",
":",
"action",
",",
"\"subjectIdentifier\"",
":",
"subject_id",
",",
"\"resourceIdentifier\"",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | download | Main download function | homura.py | def download(url, path=None, headers=None, session=None, show_progress=True,
resume=True, auto_retry=True, max_rst_retries=5,
pass_through_opts=None, cainfo=None, user_agent=None, auth=None):
"""Main download function"""
hm = Homura(url, path, headers, session, show_progress, resume,
... | def download(url, path=None, headers=None, session=None, show_progress=True,
resume=True, auto_retry=True, max_rst_retries=5,
pass_through_opts=None, cainfo=None, user_agent=None, auth=None):
"""Main download function"""
hm = Homura(url, path, headers, session, show_progress, resume,
... | [
"Main",
"download",
"function"
] | shichao-an/homura | python | https://github.com/shichao-an/homura/blob/87d1b698e1196963a23fc1c615c12020daf77dcc/homura.py#L304-L311 | [
"def",
"download",
"(",
"url",
",",
"path",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"session",
"=",
"None",
",",
"show_progress",
"=",
"True",
",",
"resume",
"=",
"True",
",",
"auto_retry",
"=",
"True",
",",
"max_rst_retries",
"=",
"5",
",",
"... | 87d1b698e1196963a23fc1c615c12020daf77dcc |
train | Homura._fill_in_cainfo | Fill in the path of the PEM file containing the CA certificate.
The priority is: 1. user provided path, 2. path to the cacert.pem
bundle provided by certifi (if installed), 3. let pycurl use the
system path where libcurl's cacert bundle is assumed to be stored,
as established at libcurl... | homura.py | def _fill_in_cainfo(self):
"""Fill in the path of the PEM file containing the CA certificate.
The priority is: 1. user provided path, 2. path to the cacert.pem
bundle provided by certifi (if installed), 3. let pycurl use the
system path where libcurl's cacert bundle is assumed to be sto... | def _fill_in_cainfo(self):
"""Fill in the path of the PEM file containing the CA certificate.
The priority is: 1. user provided path, 2. path to the cacert.pem
bundle provided by certifi (if installed), 3. let pycurl use the
system path where libcurl's cacert bundle is assumed to be sto... | [
"Fill",
"in",
"the",
"path",
"of",
"the",
"PEM",
"file",
"containing",
"the",
"CA",
"certificate",
"."
] | shichao-an/homura | python | https://github.com/shichao-an/homura/blob/87d1b698e1196963a23fc1c615c12020daf77dcc/homura.py#L159-L175 | [
"def",
"_fill_in_cainfo",
"(",
"self",
")",
":",
"if",
"self",
".",
"cainfo",
":",
"cainfo",
"=",
"self",
".",
"cainfo",
"else",
":",
"try",
":",
"cainfo",
"=",
"certifi",
".",
"where",
"(",
")",
"except",
"AttributeError",
":",
"cainfo",
"=",
"None",
... | 87d1b698e1196963a23fc1c615c12020daf77dcc |
train | Homura.curl | Sending a single cURL request to download | homura.py | def curl(self):
"""Sending a single cURL request to download"""
c = self._pycurl
# Resume download
if os.path.exists(self.path) and self.resume:
mode = 'ab'
self.downloaded = os.path.getsize(self.path)
c.setopt(pycurl.RESUME_FROM, self.downloaded)
... | def curl(self):
"""Sending a single cURL request to download"""
c = self._pycurl
# Resume download
if os.path.exists(self.path) and self.resume:
mode = 'ab'
self.downloaded = os.path.getsize(self.path)
c.setopt(pycurl.RESUME_FROM, self.downloaded)
... | [
"Sending",
"a",
"single",
"cURL",
"request",
"to",
"download"
] | shichao-an/homura | python | https://github.com/shichao-an/homura/blob/87d1b698e1196963a23fc1c615c12020daf77dcc/homura.py#L177-L203 | [
"def",
"curl",
"(",
"self",
")",
":",
"c",
"=",
"self",
".",
"_pycurl",
"# Resume download",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"path",
")",
"and",
"self",
".",
"resume",
":",
"mode",
"=",
"'ab'",
"self",
".",
"downloaded",
"... | 87d1b698e1196963a23fc1c615c12020daf77dcc |
train | Homura.start | Start downloading, handling auto retry, download resume and path
moving | homura.py | def start(self):
"""
Start downloading, handling auto retry, download resume and path
moving
"""
if not self.auto_retry:
self.curl()
return
while not self.is_finished:
try:
self.curl()
except pycurl.error as ... | def start(self):
"""
Start downloading, handling auto retry, download resume and path
moving
"""
if not self.auto_retry:
self.curl()
return
while not self.is_finished:
try:
self.curl()
except pycurl.error as ... | [
"Start",
"downloading",
"handling",
"auto",
"retry",
"download",
"resume",
"and",
"path",
"moving"
] | shichao-an/homura | python | https://github.com/shichao-an/homura/blob/87d1b698e1196963a23fc1c615c12020daf77dcc/homura.py#L205-L234 | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"auto_retry",
":",
"self",
".",
"curl",
"(",
")",
"return",
"while",
"not",
"self",
".",
"is_finished",
":",
"try",
":",
"self",
".",
"curl",
"(",
")",
"except",
"pycurl",
".",
"error... | 87d1b698e1196963a23fc1c615c12020daf77dcc |
train | Homura._move_path | Move the downloaded file to the authentic path (identified by
effective URL) | homura.py | def _move_path(self):
"""
Move the downloaded file to the authentic path (identified by
effective URL)
"""
if is_temp_path(self._path) and self._pycurl is not None:
eurl = self._pycurl.getinfo(pycurl.EFFECTIVE_URL)
er = get_resource_name(eurl)
... | def _move_path(self):
"""
Move the downloaded file to the authentic path (identified by
effective URL)
"""
if is_temp_path(self._path) and self._pycurl is not None:
eurl = self._pycurl.getinfo(pycurl.EFFECTIVE_URL)
er = get_resource_name(eurl)
... | [
"Move",
"the",
"downloaded",
"file",
"to",
"the",
"authentic",
"path",
"(",
"identified",
"by",
"effective",
"URL",
")"
] | shichao-an/homura | python | https://github.com/shichao-an/homura/blob/87d1b698e1196963a23fc1c615c12020daf77dcc/homura.py#L289-L301 | [
"def",
"_move_path",
"(",
"self",
")",
":",
"if",
"is_temp_path",
"(",
"self",
".",
"_path",
")",
"and",
"self",
".",
"_pycurl",
"is",
"not",
"None",
":",
"eurl",
"=",
"self",
".",
"_pycurl",
".",
"getinfo",
"(",
"pycurl",
".",
"EFFECTIVE_URL",
")",
... | 87d1b698e1196963a23fc1c615c12020daf77dcc |
train | UserAccountAuthentication.create | Create a new instance of the UAA service. Requires a
secret password for the 'admin' user account. | predix/admin/uaa.py | def create(self, secret, **kwargs):
"""
Create a new instance of the UAA service. Requires a
secret password for the 'admin' user account.
"""
parameters = {"adminClientSecret": secret}
self.service.create(parameters=parameters)
# Store URI into environment vari... | def create(self, secret, **kwargs):
"""
Create a new instance of the UAA service. Requires a
secret password for the 'admin' user account.
"""
parameters = {"adminClientSecret": secret}
self.service.create(parameters=parameters)
# Store URI into environment vari... | [
"Create",
"a",
"new",
"instance",
"of",
"the",
"UAA",
"service",
".",
"Requires",
"a",
"secret",
"password",
"for",
"the",
"admin",
"user",
"account",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/uaa.py#L53-L65 | [
"def",
"create",
"(",
"self",
",",
"secret",
",",
"*",
"*",
"kwargs",
")",
":",
"parameters",
"=",
"{",
"\"adminClientSecret\"",
":",
"secret",
"}",
"self",
".",
"service",
".",
"create",
"(",
"parameters",
"=",
"parameters",
")",
"# Store URI into environme... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication.add_to_manifest | Add useful details to the manifest about this service
so that it can be used in an application.
:param manifest: An predix.admin.app.Manifest object
instance that manages reading/writing manifest config
for a cloud foundry app. | predix/admin/uaa.py | def add_to_manifest(self, manifest):
"""
Add useful details to the manifest about this service
so that it can be used in an application.
:param manifest: An predix.admin.app.Manifest object
instance that manages reading/writing manifest config
for a cloud foundry... | def add_to_manifest(self, manifest):
"""
Add useful details to the manifest about this service
so that it can be used in an application.
:param manifest: An predix.admin.app.Manifest object
instance that manages reading/writing manifest config
for a cloud foundry... | [
"Add",
"useful",
"details",
"to",
"the",
"manifest",
"about",
"this",
"service",
"so",
"that",
"it",
"can",
"be",
"used",
"in",
"an",
"application",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/uaa.py#L67-L84 | [
"def",
"add_to_manifest",
"(",
"self",
",",
"manifest",
")",
":",
"# Add this service to list of services",
"manifest",
".",
"add_service",
"(",
"self",
".",
"service",
".",
"name",
")",
"# Add environment variable to manifest",
"varname",
"=",
"predix",
".",
"config"... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication.authenticate | Authenticate into the UAA instance as the admin user. | predix/admin/uaa.py | def authenticate(self):
"""
Authenticate into the UAA instance as the admin user.
"""
# Make sure we've stored uri for use
predix.config.set_env_value(self.use_class, 'uri', self._get_uri())
self.uaac = predix.security.uaa.UserAccountAuthentication()
self.uaac.au... | def authenticate(self):
"""
Authenticate into the UAA instance as the admin user.
"""
# Make sure we've stored uri for use
predix.config.set_env_value(self.use_class, 'uri', self._get_uri())
self.uaac = predix.security.uaa.UserAccountAuthentication()
self.uaac.au... | [
"Authenticate",
"into",
"the",
"UAA",
"instance",
"as",
"the",
"admin",
"user",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/uaa.py#L86-L96 | [
"def",
"authenticate",
"(",
"self",
")",
":",
"# Make sure we've stored uri for use",
"predix",
".",
"config",
".",
"set_env_value",
"(",
"self",
".",
"use_class",
",",
"'uri'",
",",
"self",
".",
"_get_uri",
"(",
")",
")",
"self",
".",
"uaac",
"=",
"predix",... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication._create_secret | Use a cryptograhically-secure Pseudorandom number generator for picking
a combination of letters, digits, and punctuation to be our secret.
:param length: how long to make the secret (12 seems ok most of the time) | predix/admin/uaa.py | def _create_secret(self, length=12):
"""
Use a cryptograhically-secure Pseudorandom number generator for picking
a combination of letters, digits, and punctuation to be our secret.
:param length: how long to make the secret (12 seems ok most of the time)
"""
# Charset w... | def _create_secret(self, length=12):
"""
Use a cryptograhically-secure Pseudorandom number generator for picking
a combination of letters, digits, and punctuation to be our secret.
:param length: how long to make the secret (12 seems ok most of the time)
"""
# Charset w... | [
"Use",
"a",
"cryptograhically",
"-",
"secure",
"Pseudorandom",
"number",
"generator",
"for",
"picking",
"a",
"combination",
"of",
"letters",
"digits",
"and",
"punctuation",
"to",
"be",
"our",
"secret",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/uaa.py#L104-L115 | [
"def",
"_create_secret",
"(",
"self",
",",
"length",
"=",
"12",
")",
":",
"# Charset will have 64 +- characters",
"charset",
"=",
"string",
".",
"digits",
"+",
"string",
".",
"ascii_letters",
"+",
"'+-'",
"return",
"\"\"",
".",
"join",
"(",
"random",
".",
"S... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication.create_client | Create a new client for use by applications. | predix/admin/uaa.py | def create_client(self, client_id, client_secret):
"""
Create a new client for use by applications.
"""
assert self.is_admin, "Must authenticate() as admin to create client"
return self.uaac.create_client(client_id, client_secret) | def create_client(self, client_id, client_secret):
"""
Create a new client for use by applications.
"""
assert self.is_admin, "Must authenticate() as admin to create client"
return self.uaac.create_client(client_id, client_secret) | [
"Create",
"a",
"new",
"client",
"for",
"use",
"by",
"applications",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/uaa.py#L117-L122 | [
"def",
"create_client",
"(",
"self",
",",
"client_id",
",",
"client_secret",
")",
":",
"assert",
"self",
".",
"is_admin",
",",
"\"Must authenticate() as admin to create client\"",
"return",
"self",
".",
"uaac",
".",
"create_client",
"(",
"client_id",
",",
"client_se... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication.add_client_to_manifest | Add the client credentials to the specified manifest. | predix/admin/uaa.py | def add_client_to_manifest(self, client_id, client_secret, manifest):
"""
Add the client credentials to the specified manifest.
"""
assert self.is_admin, "Must authenticate() as admin to create client"
return self.uaac.add_client_to_manifest(client_id, client_secret,
... | def add_client_to_manifest(self, client_id, client_secret, manifest):
"""
Add the client credentials to the specified manifest.
"""
assert self.is_admin, "Must authenticate() as admin to create client"
return self.uaac.add_client_to_manifest(client_id, client_secret,
... | [
"Add",
"the",
"client",
"credentials",
"to",
"the",
"specified",
"manifest",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/uaa.py#L124-L130 | [
"def",
"add_client_to_manifest",
"(",
"self",
",",
"client_id",
",",
"client_secret",
",",
"manifest",
")",
":",
"assert",
"self",
".",
"is_admin",
",",
"\"Must authenticate() as admin to create client\"",
"return",
"self",
".",
"uaac",
".",
"add_client_to_manifest",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication._get_uaa_uri | Returns the URI endpoint for an instance of a UAA
service instance from environment inspection. | predix/security/uaa.py | def _get_uaa_uri(self):
"""
Returns the URI endpoint for an instance of a UAA
service instance from environment inspection.
"""
if 'VCAP_SERVICES' in os.environ:
services = json.loads(os.getenv('VCAP_SERVICES'))
predix_uaa = services['predix-uaa'][0]['cred... | def _get_uaa_uri(self):
"""
Returns the URI endpoint for an instance of a UAA
service instance from environment inspection.
"""
if 'VCAP_SERVICES' in os.environ:
services = json.loads(os.getenv('VCAP_SERVICES'))
predix_uaa = services['predix-uaa'][0]['cred... | [
"Returns",
"the",
"URI",
"endpoint",
"for",
"an",
"instance",
"of",
"a",
"UAA",
"service",
"instance",
"from",
"environment",
"inspection",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L35-L45 | [
"def",
"_get_uaa_uri",
"(",
"self",
")",
":",
"if",
"'VCAP_SERVICES'",
"in",
"os",
".",
"environ",
":",
"services",
"=",
"json",
".",
"loads",
"(",
"os",
".",
"getenv",
"(",
"'VCAP_SERVICES'",
")",
")",
"predix_uaa",
"=",
"services",
"[",
"'predix-uaa'",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication._authenticate_client | Returns response of authenticating with the given client and
secret. | predix/security/uaa.py | def _authenticate_client(self, client, secret):
"""
Returns response of authenticating with the given client and
secret.
"""
client_s = str.join(':', [client, secret])
credentials = base64.b64encode(client_s.encode('utf-8')).decode('utf-8')
headers = {
... | def _authenticate_client(self, client, secret):
"""
Returns response of authenticating with the given client and
secret.
"""
client_s = str.join(':', [client, secret])
credentials = base64.b64encode(client_s.encode('utf-8')).decode('utf-8')
headers = {
... | [
"Returns",
"response",
"of",
"authenticating",
"with",
"the",
"given",
"client",
"and",
"secret",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L47-L76 | [
"def",
"_authenticate_client",
"(",
"self",
",",
"client",
",",
"secret",
")",
":",
"client_s",
"=",
"str",
".",
"join",
"(",
"':'",
",",
"[",
"client",
",",
"secret",
"]",
")",
"credentials",
"=",
"base64",
".",
"b64encode",
"(",
"client_s",
".",
"enc... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication._authenticate_user | Returns the response of authenticating with the given
user and password. | predix/security/uaa.py | def _authenticate_user(self, user, password):
"""
Returns the response of authenticating with the given
user and password.
"""
headers = self._get_headers()
params = {
'username': user,
'password': password,
'grant_type': 'p... | def _authenticate_user(self, user, password):
"""
Returns the response of authenticating with the given
user and password.
"""
headers = self._get_headers()
params = {
'username': user,
'password': password,
'grant_type': 'p... | [
"Returns",
"the",
"response",
"of",
"authenticating",
"with",
"the",
"given",
"user",
"and",
"password",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L78-L101 | [
"def",
"_authenticate_user",
"(",
"self",
",",
"user",
",",
"password",
")",
":",
"headers",
"=",
"self",
".",
"_get_headers",
"(",
")",
"params",
"=",
"{",
"'username'",
":",
"user",
",",
"'password'",
":",
"password",
",",
"'grant_type'",
":",
"'password... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication.is_expired_token | For a given client will test whether or not the token
has expired.
This is for testing a client object and does not look up
from client_id. You can use _get_client_from_cache() to
lookup a client from client_id. | predix/security/uaa.py | def is_expired_token(self, client):
"""
For a given client will test whether or not the token
has expired.
This is for testing a client object and does not look up
from client_id. You can use _get_client_from_cache() to
lookup a client from client_id.
"""
... | def is_expired_token(self, client):
"""
For a given client will test whether or not the token
has expired.
This is for testing a client object and does not look up
from client_id. You can use _get_client_from_cache() to
lookup a client from client_id.
"""
... | [
"For",
"a",
"given",
"client",
"will",
"test",
"whether",
"or",
"not",
"the",
"token",
"has",
"expired",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L103-L119 | [
"def",
"is_expired_token",
"(",
"self",
",",
"client",
")",
":",
"if",
"'expires'",
"not",
"in",
"client",
":",
"return",
"True",
"expires",
"=",
"dateutil",
".",
"parser",
".",
"parse",
"(",
"client",
"[",
"'expires'",
"]",
")",
"if",
"expires",
"<",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication._initialize_uaa_cache | If we don't yet have a uaa cache we need to
initialize it. As there may be more than one
UAA instance we index by issuer and then store
any clients, users, etc. | predix/security/uaa.py | def _initialize_uaa_cache(self):
"""
If we don't yet have a uaa cache we need to
initialize it. As there may be more than one
UAA instance we index by issuer and then store
any clients, users, etc.
"""
try:
os.makedirs(os.path.dirname(self._cache_path... | def _initialize_uaa_cache(self):
"""
If we don't yet have a uaa cache we need to
initialize it. As there may be more than one
UAA instance we index by issuer and then store
any clients, users, etc.
"""
try:
os.makedirs(os.path.dirname(self._cache_path... | [
"If",
"we",
"don",
"t",
"yet",
"have",
"a",
"uaa",
"cache",
"we",
"need",
"to",
"initialize",
"it",
".",
"As",
"there",
"may",
"be",
"more",
"than",
"one",
"UAA",
"instance",
"we",
"index",
"by",
"issuer",
"and",
"then",
"store",
"any",
"clients",
"u... | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L121-L137 | [
"def",
"_initialize_uaa_cache",
"(",
"self",
")",
":",
"try",
":",
"os",
".",
"makedirs",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"self",
".",
"_cache_path",
")",
")",
"except",
"OSError",
"as",
"exc",
":",
"if",
"exc",
".",
"errno",
"!=",
"errn... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication._read_uaa_cache | Read cache of UAA client/user details. | predix/security/uaa.py | def _read_uaa_cache(self):
"""
Read cache of UAA client/user details.
"""
self._cache_path = os.path.expanduser('~/.predix/uaa.json')
if not os.path.exists(self._cache_path):
return self._initialize_uaa_cache()
with open(self._cache_path, 'r') as data:
... | def _read_uaa_cache(self):
"""
Read cache of UAA client/user details.
"""
self._cache_path = os.path.expanduser('~/.predix/uaa.json')
if not os.path.exists(self._cache_path):
return self._initialize_uaa_cache()
with open(self._cache_path, 'r') as data:
... | [
"Read",
"cache",
"of",
"UAA",
"client",
"/",
"user",
"details",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L139-L148 | [
"def",
"_read_uaa_cache",
"(",
"self",
")",
":",
"self",
".",
"_cache_path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~/.predix/uaa.json'",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"_cache_path",
")",
":",
"return",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication._get_client_from_cache | For the given client_id return what is
cached. | predix/security/uaa.py | def _get_client_from_cache(self, client_id):
"""
For the given client_id return what is
cached.
"""
data = self._read_uaa_cache()
# Only if we've cached any for this issuer
if self.uri not in data:
return
for client in data[self.uri]:
... | def _get_client_from_cache(self, client_id):
"""
For the given client_id return what is
cached.
"""
data = self._read_uaa_cache()
# Only if we've cached any for this issuer
if self.uri not in data:
return
for client in data[self.uri]:
... | [
"For",
"the",
"given",
"client_id",
"return",
"what",
"is",
"cached",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L150-L163 | [
"def",
"_get_client_from_cache",
"(",
"self",
",",
"client_id",
")",
":",
"data",
"=",
"self",
".",
"_read_uaa_cache",
"(",
")",
"# Only if we've cached any for this issuer",
"if",
"self",
".",
"uri",
"not",
"in",
"data",
":",
"return",
"for",
"client",
"in",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication._write_to_uaa_cache | Cache the client details into a cached file on disk. | predix/security/uaa.py | def _write_to_uaa_cache(self, new_item):
"""
Cache the client details into a cached file on disk.
"""
data = self._read_uaa_cache()
# Initialize client list if first time
if self.uri not in data:
data[self.uri] = []
# Remove existing client record an... | def _write_to_uaa_cache(self, new_item):
"""
Cache the client details into a cached file on disk.
"""
data = self._read_uaa_cache()
# Initialize client list if first time
if self.uri not in data:
data[self.uri] = []
# Remove existing client record an... | [
"Cache",
"the",
"client",
"details",
"into",
"a",
"cached",
"file",
"on",
"disk",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L165-L191 | [
"def",
"_write_to_uaa_cache",
"(",
"self",
",",
"new_item",
")",
":",
"data",
"=",
"self",
".",
"_read_uaa_cache",
"(",
")",
"# Initialize client list if first time",
"if",
"self",
".",
"uri",
"not",
"in",
"data",
":",
"data",
"[",
"self",
".",
"uri",
"]",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication.authenticate | Authenticate the given client against UAA. The resulting token
will be cached for reuse. | predix/security/uaa.py | def authenticate(self, client_id, client_secret, use_cache=True):
"""
Authenticate the given client against UAA. The resulting token
will be cached for reuse.
"""
# We will reuse a token for as long as we have one cached
# and it hasn't expired.
if use_cache:
... | def authenticate(self, client_id, client_secret, use_cache=True):
"""
Authenticate the given client against UAA. The resulting token
will be cached for reuse.
"""
# We will reuse a token for as long as we have one cached
# and it hasn't expired.
if use_cache:
... | [
"Authenticate",
"the",
"given",
"client",
"against",
"UAA",
".",
"The",
"resulting",
"token",
"will",
"be",
"cached",
"for",
"reuse",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L193-L224 | [
"def",
"authenticate",
"(",
"self",
",",
"client_id",
",",
"client_secret",
",",
"use_cache",
"=",
"True",
")",
":",
"# We will reuse a token for as long as we have one cached",
"# and it hasn't expired.",
"if",
"use_cache",
":",
"client",
"=",
"self",
".",
"_get_client... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication.logout | Log currently authenticated user out, invalidating any existing tokens. | predix/security/uaa.py | def logout(self):
"""
Log currently authenticated user out, invalidating any existing tokens.
"""
# Remove token from local cache
# MAINT: need to expire token on server
data = self._read_uaa_cache()
if self.uri in data:
for client in data[self.uri]:
... | def logout(self):
"""
Log currently authenticated user out, invalidating any existing tokens.
"""
# Remove token from local cache
# MAINT: need to expire token on server
data = self._read_uaa_cache()
if self.uri in data:
for client in data[self.uri]:
... | [
"Log",
"currently",
"authenticated",
"user",
"out",
"invalidating",
"any",
"existing",
"tokens",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L226-L239 | [
"def",
"logout",
"(",
"self",
")",
":",
"# Remove token from local cache",
"# MAINT: need to expire token on server",
"data",
"=",
"self",
".",
"_read_uaa_cache",
"(",
")",
"if",
"self",
".",
"uri",
"in",
"data",
":",
"for",
"client",
"in",
"data",
"[",
"self",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication._post | Simple POST request for a given uri path. | predix/security/uaa.py | def _post(self, uri, data, headers=None):
"""
Simple POST request for a given uri path.
"""
if not headers:
headers = self._get_headers()
logging.debug("URI=" + str(uri))
logging.debug("HEADERS=" + str(headers))
logging.debug("BODY=" + str(data))
... | def _post(self, uri, data, headers=None):
"""
Simple POST request for a given uri path.
"""
if not headers:
headers = self._get_headers()
logging.debug("URI=" + str(uri))
logging.debug("HEADERS=" + str(headers))
logging.debug("BODY=" + str(data))
... | [
"Simple",
"POST",
"request",
"for",
"a",
"given",
"uri",
"path",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L272-L291 | [
"def",
"_post",
"(",
"self",
",",
"uri",
",",
"data",
",",
"headers",
"=",
"None",
")",
":",
"if",
"not",
"headers",
":",
"headers",
"=",
"self",
".",
"_get_headers",
"(",
")",
"logging",
".",
"debug",
"(",
"\"URI=\"",
"+",
"str",
"(",
"uri",
")",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication.get_token | Returns the bare access token for the authorized client. | predix/security/uaa.py | def get_token(self):
"""
Returns the bare access token for the authorized client.
"""
if not self.authenticated:
raise ValueError("Must authenticate() as a client first.")
# If token has expired we'll need to refresh and get a new
# client credential
... | def get_token(self):
"""
Returns the bare access token for the authorized client.
"""
if not self.authenticated:
raise ValueError("Must authenticate() as a client first.")
# If token has expired we'll need to refresh and get a new
# client credential
... | [
"Returns",
"the",
"bare",
"access",
"token",
"for",
"the",
"authorized",
"client",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L293-L307 | [
"def",
"get_token",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"authenticated",
":",
"raise",
"ValueError",
"(",
"\"Must authenticate() as a client first.\"",
")",
"# If token has expired we'll need to refresh and get a new",
"# client credential",
"if",
"self",
".",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication.get_scopes | Returns the scopes for the authenticated client. | predix/security/uaa.py | def get_scopes(self):
"""
Returns the scopes for the authenticated client.
"""
if not self.authenticated:
raise ValueError("Must authenticate() as a client first.")
scope = self.client['scope']
return scope.split() | def get_scopes(self):
"""
Returns the scopes for the authenticated client.
"""
if not self.authenticated:
raise ValueError("Must authenticate() as a client first.")
scope = self.client['scope']
return scope.split() | [
"Returns",
"the",
"scopes",
"for",
"the",
"authenticated",
"client",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L309-L317 | [
"def",
"get_scopes",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"authenticated",
":",
"raise",
"ValueError",
"(",
"\"Must authenticate() as a client first.\"",
")",
"scope",
"=",
"self",
".",
"client",
"[",
"'scope'",
"]",
"return",
"scope",
".",
"split"... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication.assert_has_permission | Warn that the required scope is not found in the scopes
granted to the currently authenticated user.
::
# The admin user should have client admin permissions
uaa.assert_has_permission('admin', 'clients.admin') | predix/security/uaa.py | def assert_has_permission(self, scope_required):
"""
Warn that the required scope is not found in the scopes
granted to the currently authenticated user.
::
# The admin user should have client admin permissions
uaa.assert_has_permission('admin', 'clients.admin')... | def assert_has_permission(self, scope_required):
"""
Warn that the required scope is not found in the scopes
granted to the currently authenticated user.
::
# The admin user should have client admin permissions
uaa.assert_has_permission('admin', 'clients.admin')... | [
"Warn",
"that",
"the",
"required",
"scope",
"is",
"not",
"found",
"in",
"the",
"scopes",
"granted",
"to",
"the",
"currently",
"authenticated",
"user",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L334-L355 | [
"def",
"assert_has_permission",
"(",
"self",
",",
"scope_required",
")",
":",
"if",
"not",
"self",
".",
"authenticated",
":",
"raise",
"ValueError",
"(",
"\"Must first authenticate()\"",
")",
"if",
"scope_required",
"not",
"in",
"self",
".",
"get_scopes",
"(",
"... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication.grant_client_permissions | Grant the given client_id permissions for managing clients.
- clients.admin: super user scope to create, modify, delete
- clients.write: scope ot create and modify clients
- clients.read: scope to read info about clients
- clients.secret: scope to change password of a client | predix/security/uaa.py | def grant_client_permissions(self, client_id, admin=False, write=False,
read=False, secret=False):
"""
Grant the given client_id permissions for managing clients.
- clients.admin: super user scope to create, modify, delete
- clients.write: scope ot create and modify clients
... | def grant_client_permissions(self, client_id, admin=False, write=False,
read=False, secret=False):
"""
Grant the given client_id permissions for managing clients.
- clients.admin: super user scope to create, modify, delete
- clients.write: scope ot create and modify clients
... | [
"Grant",
"the",
"given",
"client_id",
"permissions",
"for",
"managing",
"clients",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L357-L385 | [
"def",
"grant_client_permissions",
"(",
"self",
",",
"client_id",
",",
"admin",
"=",
"False",
",",
"write",
"=",
"False",
",",
"read",
"=",
"False",
",",
"secret",
"=",
"False",
")",
":",
"self",
".",
"assert_has_permission",
"(",
"'clients.admin'",
")",
"... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication.get_clients | Returns the clients stored in the instance of UAA. | predix/security/uaa.py | def get_clients(self):
"""
Returns the clients stored in the instance of UAA.
"""
self.assert_has_permission('clients.read')
uri = self.uri + '/oauth/clients'
headers = self.get_authorization_headers()
response = requests.get(uri, headers=headers)
return ... | def get_clients(self):
"""
Returns the clients stored in the instance of UAA.
"""
self.assert_has_permission('clients.read')
uri = self.uri + '/oauth/clients'
headers = self.get_authorization_headers()
response = requests.get(uri, headers=headers)
return ... | [
"Returns",
"the",
"clients",
"stored",
"in",
"the",
"instance",
"of",
"UAA",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L387-L396 | [
"def",
"get_clients",
"(",
"self",
")",
":",
"self",
".",
"assert_has_permission",
"(",
"'clients.read'",
")",
"uri",
"=",
"self",
".",
"uri",
"+",
"'/oauth/clients'",
"headers",
"=",
"self",
".",
"get_authorization_headers",
"(",
")",
"response",
"=",
"reques... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication.get_client | Returns details about a specific client by the client_id. | predix/security/uaa.py | def get_client(self, client_id):
"""
Returns details about a specific client by the client_id.
"""
self.assert_has_permission('clients.read')
uri = self.uri + '/oauth/clients/' + client_id
headers = self.get_authorization_headers()
response = requests.get(uri, he... | def get_client(self, client_id):
"""
Returns details about a specific client by the client_id.
"""
self.assert_has_permission('clients.read')
uri = self.uri + '/oauth/clients/' + client_id
headers = self.get_authorization_headers()
response = requests.get(uri, he... | [
"Returns",
"details",
"about",
"a",
"specific",
"client",
"by",
"the",
"client_id",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L398-L411 | [
"def",
"get_client",
"(",
"self",
",",
"client_id",
")",
":",
"self",
".",
"assert_has_permission",
"(",
"'clients.read'",
")",
"uri",
"=",
"self",
".",
"uri",
"+",
"'/oauth/clients/'",
"+",
"client_id",
"headers",
"=",
"self",
".",
"get_authorization_headers",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication.update_client_grants | Will extend the client with additional scopes or
authorities. Any existing scopes and authorities will be left
as is unless asked to replace entirely. | predix/security/uaa.py | def update_client_grants(self, client_id, scope=[], authorities=[],
grant_types=[], redirect_uri=[], replace=False):
"""
Will extend the client with additional scopes or
authorities. Any existing scopes and authorities will be left
as is unless asked to replace entirely.
... | def update_client_grants(self, client_id, scope=[], authorities=[],
grant_types=[], redirect_uri=[], replace=False):
"""
Will extend the client with additional scopes or
authorities. Any existing scopes and authorities will be left
as is unless asked to replace entirely.
... | [
"Will",
"extend",
"the",
"client",
"with",
"additional",
"scopes",
"or",
"authorities",
".",
"Any",
"existing",
"scopes",
"and",
"authorities",
"will",
"be",
"left",
"as",
"is",
"unless",
"asked",
"to",
"replace",
"entirely",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L413-L476 | [
"def",
"update_client_grants",
"(",
"self",
",",
"client_id",
",",
"scope",
"=",
"[",
"]",
",",
"authorities",
"=",
"[",
"]",
",",
"grant_types",
"=",
"[",
"]",
",",
"redirect_uri",
"=",
"[",
"]",
",",
"replace",
"=",
"False",
")",
":",
"self",
".",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication.grant_scim_permissions | Grant the given client_id permissions for managing users. System
for Cross-domain Identity Management (SCIM) are required for accessing
/Users and /Groups endpoints of UAA.
- scim.read: scope for read access to all SCIM endpoints
- scim.write: scope for write access to all SCIM endpoin... | predix/security/uaa.py | def grant_scim_permissions(self, client_id, read=False, write=False,
create=False, userids=False, zones=False, invite=False,
openid=False):
"""
Grant the given client_id permissions for managing users. System
for Cross-domain Identity Management (SCIM) are required for a... | def grant_scim_permissions(self, client_id, read=False, write=False,
create=False, userids=False, zones=False, invite=False,
openid=False):
"""
Grant the given client_id permissions for managing users. System
for Cross-domain Identity Management (SCIM) are required for a... | [
"Grant",
"the",
"given",
"client_id",
"permissions",
"for",
"managing",
"users",
".",
"System",
"for",
"Cross",
"-",
"domain",
"Identity",
"Management",
"(",
"SCIM",
")",
"are",
"required",
"for",
"accessing",
"/",
"Users",
"and",
"/",
"Groups",
"endpoints",
... | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L478-L520 | [
"def",
"grant_scim_permissions",
"(",
"self",
",",
"client_id",
",",
"read",
"=",
"False",
",",
"write",
"=",
"False",
",",
"create",
"=",
"False",
",",
"userids",
"=",
"False",
",",
"zones",
"=",
"False",
",",
"invite",
"=",
"False",
",",
"openid",
"=... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication.create_client | Will create a new client for your application use.
- client_credentials: allows client to get access token
- refresh_token: can be used to get new access token when expired
without re-authenticating
- authorization_code: redirection-based flow for user authentication
More det... | predix/security/uaa.py | def create_client(self, client_id, client_secret, manifest=None,
client_credentials=True, refresh_token=True,
authorization_code=False, redirect_uri=[]):
"""
Will create a new client for your application use.
- client_credentials: allows client to get access token
... | def create_client(self, client_id, client_secret, manifest=None,
client_credentials=True, refresh_token=True,
authorization_code=False, redirect_uri=[]):
"""
Will create a new client for your application use.
- client_credentials: allows client to get access token
... | [
"Will",
"create",
"a",
"new",
"client",
"for",
"your",
"application",
"use",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L522-L594 | [
"def",
"create_client",
"(",
"self",
",",
"client_id",
",",
"client_secret",
",",
"manifest",
"=",
"None",
",",
"client_credentials",
"=",
"True",
",",
"refresh_token",
"=",
"True",
",",
"authorization_code",
"=",
"False",
",",
"redirect_uri",
"=",
"[",
"]",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication.add_client_to_manifest | Add the given client / secret to the manifest for use in
the application. | predix/security/uaa.py | def add_client_to_manifest(self, client_id, client_secret, manifest):
"""
Add the given client / secret to the manifest for use in
the application.
"""
client_id_key = 'PREDIX_APP_CLIENT_ID'
manifest.add_env_var(client_id_key, client_id)
client_secret_key = 'PRED... | def add_client_to_manifest(self, client_id, client_secret, manifest):
"""
Add the given client / secret to the manifest for use in
the application.
"""
client_id_key = 'PREDIX_APP_CLIENT_ID'
manifest.add_env_var(client_id_key, client_id)
client_secret_key = 'PRED... | [
"Add",
"the",
"given",
"client",
"/",
"secret",
"to",
"the",
"manifest",
"for",
"use",
"in",
"the",
"application",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L596-L607 | [
"def",
"add_client_to_manifest",
"(",
"self",
",",
"client_id",
",",
"client_secret",
",",
"manifest",
")",
":",
"client_id_key",
"=",
"'PREDIX_APP_CLIENT_ID'",
"manifest",
".",
"add_env_var",
"(",
"client_id_key",
",",
"client_id",
")",
"client_secret_key",
"=",
"'... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication.create_user | Creates a new user account with the required details.
::
create_user('j12y', 'my-secret', 'Delancey', 'Jayson', 'volcano@ge.com') | predix/security/uaa.py | def create_user(self, username, password, family_name, given_name, primary_email,
details={}):
"""
Creates a new user account with the required details.
::
create_user('j12y', 'my-secret', 'Delancey', 'Jayson', 'volcano@ge.com')
"""
self.assert_has_perm... | def create_user(self, username, password, family_name, given_name, primary_email,
details={}):
"""
Creates a new user account with the required details.
::
create_user('j12y', 'my-secret', 'Delancey', 'Jayson', 'volcano@ge.com')
"""
self.assert_has_perm... | [
"Creates",
"a",
"new",
"user",
"account",
"with",
"the",
"required",
"details",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L619-L647 | [
"def",
"create_user",
"(",
"self",
",",
"username",
",",
"password",
",",
"family_name",
",",
"given_name",
",",
"primary_email",
",",
"details",
"=",
"{",
"}",
")",
":",
"self",
".",
"assert_has_permission",
"(",
"'scim.write'",
")",
"data",
"=",
"{",
"'u... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication.delete_user | Delete user with given id. | predix/security/uaa.py | def delete_user(self, id):
"""
Delete user with given id.
"""
self.assert_has_permission('scim.write')
uri = self.uri + '/Users/%s' % id
headers = self._get_headers()
logging.debug("URI=" + str(uri))
logging.debug("HEADERS=" + str(headers))
resp... | def delete_user(self, id):
"""
Delete user with given id.
"""
self.assert_has_permission('scim.write')
uri = self.uri + '/Users/%s' % id
headers = self._get_headers()
logging.debug("URI=" + str(uri))
logging.debug("HEADERS=" + str(headers))
resp... | [
"Delete",
"user",
"with",
"given",
"id",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L649-L667 | [
"def",
"delete_user",
"(",
"self",
",",
"id",
")",
":",
"self",
".",
"assert_has_permission",
"(",
"'scim.write'",
")",
"uri",
"=",
"self",
".",
"uri",
"+",
"'/Users/%s'",
"%",
"id",
"headers",
"=",
"self",
".",
"_get_headers",
"(",
")",
"logging",
".",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication.get_users | Returns users accounts stored in UAA.
See https://docs.cloudfoundry.org/api/uaa/#list63
For filtering help, see:
http://www.simplecloud.info/specs/draft-scim-api-01.html#query-resources | predix/security/uaa.py | def get_users(self, filter=None, sortBy=None, sortOrder=None,
startIndex=None, count=None):
"""
Returns users accounts stored in UAA.
See https://docs.cloudfoundry.org/api/uaa/#list63
For filtering help, see:
http://www.simplecloud.info/specs/draft-scim-api-01.html#q... | def get_users(self, filter=None, sortBy=None, sortOrder=None,
startIndex=None, count=None):
"""
Returns users accounts stored in UAA.
See https://docs.cloudfoundry.org/api/uaa/#list63
For filtering help, see:
http://www.simplecloud.info/specs/draft-scim-api-01.html#q... | [
"Returns",
"users",
"accounts",
"stored",
"in",
"UAA",
".",
"See",
"https",
":",
"//",
"docs",
".",
"cloudfoundry",
".",
"org",
"/",
"api",
"/",
"uaa",
"/",
"#list63"
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L669-L696 | [
"def",
"get_users",
"(",
"self",
",",
"filter",
"=",
"None",
",",
"sortBy",
"=",
"None",
",",
"sortOrder",
"=",
"None",
",",
"startIndex",
"=",
"None",
",",
"count",
"=",
"None",
")",
":",
"self",
".",
"assert_has_permission",
"(",
"'scim.read'",
")",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication.get_user_by_username | Returns details for user of the given username.
If there is more than one match will only return the first. Use
get_users() for full result set. | predix/security/uaa.py | def get_user_by_username(self, username):
"""
Returns details for user of the given username.
If there is more than one match will only return the first. Use
get_users() for full result set.
"""
results = self.get_users(filter='username eq "%s"' % (username))
if... | def get_user_by_username(self, username):
"""
Returns details for user of the given username.
If there is more than one match will only return the first. Use
get_users() for full result set.
"""
results = self.get_users(filter='username eq "%s"' % (username))
if... | [
"Returns",
"details",
"for",
"user",
"of",
"the",
"given",
"username",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L698-L713 | [
"def",
"get_user_by_username",
"(",
"self",
",",
"username",
")",
":",
"results",
"=",
"self",
".",
"get_users",
"(",
"filter",
"=",
"'username eq \"%s\"'",
"%",
"(",
"username",
")",
")",
"if",
"results",
"[",
"'totalResults'",
"]",
"==",
"0",
":",
"loggi... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication.get_user_by_email | Returns details for user with the given email address.
If there is more than one match will only return the first. Use
get_users() for full result set. | predix/security/uaa.py | def get_user_by_email(self, email):
"""
Returns details for user with the given email address.
If there is more than one match will only return the first. Use
get_users() for full result set.
"""
results = self.get_users(filter='email eq "%s"' % (email))
if resu... | def get_user_by_email(self, email):
"""
Returns details for user with the given email address.
If there is more than one match will only return the first. Use
get_users() for full result set.
"""
results = self.get_users(filter='email eq "%s"' % (email))
if resu... | [
"Returns",
"details",
"for",
"user",
"with",
"the",
"given",
"email",
"address",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L715-L730 | [
"def",
"get_user_by_email",
"(",
"self",
",",
"email",
")",
":",
"results",
"=",
"self",
".",
"get_users",
"(",
"filter",
"=",
"'email eq \"%s\"'",
"%",
"(",
"email",
")",
")",
"if",
"results",
"[",
"'totalResults'",
"]",
"==",
"0",
":",
"logging",
".",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | UserAccountAuthentication.get_user | Returns details about the user for the given id.
Use get_user_by_email() or get_user_by_username() for help
identifiying the id. | predix/security/uaa.py | def get_user(self, id):
"""
Returns details about the user for the given id.
Use get_user_by_email() or get_user_by_username() for help
identifiying the id.
"""
self.assert_has_permission('scim.read')
return self._get(self.uri + '/Users/%s' % (id)) | def get_user(self, id):
"""
Returns details about the user for the given id.
Use get_user_by_email() or get_user_by_username() for help
identifiying the id.
"""
self.assert_has_permission('scim.read')
return self._get(self.uri + '/Users/%s' % (id)) | [
"Returns",
"details",
"about",
"the",
"user",
"for",
"the",
"given",
"id",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L732-L740 | [
"def",
"get_user",
"(",
"self",
",",
"id",
")",
":",
"self",
".",
"assert_has_permission",
"(",
"'scim.read'",
")",
"return",
"self",
".",
"_get",
"(",
"self",
".",
"uri",
"+",
"'/Users/%s'",
"%",
"(",
"id",
")",
")"
] | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | TimeSeries.create | Create an instance of the Time Series Service with the typical
starting settings. | predix/admin/timeseries.py | def create(self):
"""
Create an instance of the Time Series Service with the typical
starting settings.
"""
self.service.create()
predix.config.set_env_value(self.use_class, 'ingest_uri',
self.get_ingest_uri())
predix.config.set_env_value(self.use... | def create(self):
"""
Create an instance of the Time Series Service with the typical
starting settings.
"""
self.service.create()
predix.config.set_env_value(self.use_class, 'ingest_uri',
self.get_ingest_uri())
predix.config.set_env_value(self.use... | [
"Create",
"an",
"instance",
"of",
"the",
"Time",
"Series",
"Service",
"with",
"the",
"typical",
"starting",
"settings",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/timeseries.py#L31-L46 | [
"def",
"create",
"(",
"self",
")",
":",
"self",
".",
"service",
".",
"create",
"(",
")",
"predix",
".",
"config",
".",
"set_env_value",
"(",
"self",
".",
"use_class",
",",
"'ingest_uri'",
",",
"self",
".",
"get_ingest_uri",
"(",
")",
")",
"predix",
"."... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | TimeSeries.grant_client | Grant the given client id all the scopes and authorities
needed to work with the timeseries service. | predix/admin/timeseries.py | def grant_client(self, client_id, read=True, write=True):
"""
Grant the given client id all the scopes and authorities
needed to work with the timeseries service.
"""
scopes = ['openid']
authorities = ['uaa.resource']
if write:
for zone in self.servic... | def grant_client(self, client_id, read=True, write=True):
"""
Grant the given client id all the scopes and authorities
needed to work with the timeseries service.
"""
scopes = ['openid']
authorities = ['uaa.resource']
if write:
for zone in self.servic... | [
"Grant",
"the",
"given",
"client",
"id",
"all",
"the",
"scopes",
"and",
"authorities",
"needed",
"to",
"work",
"with",
"the",
"timeseries",
"service",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/timeseries.py#L48-L69 | [
"def",
"grant_client",
"(",
"self",
",",
"client_id",
",",
"read",
"=",
"True",
",",
"write",
"=",
"True",
")",
":",
"scopes",
"=",
"[",
"'openid'",
"]",
"authorities",
"=",
"[",
"'uaa.resource'",
"]",
"if",
"write",
":",
"for",
"zone",
"in",
"self",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | TimeSeries.get_query_uri | Return the uri used for queries on time series data. | predix/admin/timeseries.py | def get_query_uri(self):
"""
Return the uri used for queries on time series data.
"""
# Query URI has extra path we don't want so strip it off here
query_uri = self.service.settings.data['query']['uri']
query_uri = urlparse(query_uri)
return query_uri.scheme + ':/... | def get_query_uri(self):
"""
Return the uri used for queries on time series data.
"""
# Query URI has extra path we don't want so strip it off here
query_uri = self.service.settings.data['query']['uri']
query_uri = urlparse(query_uri)
return query_uri.scheme + ':/... | [
"Return",
"the",
"uri",
"used",
"for",
"queries",
"on",
"time",
"series",
"data",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/timeseries.py#L91-L98 | [
"def",
"get_query_uri",
"(",
"self",
")",
":",
"# Query URI has extra path we don't want so strip it off here",
"query_uri",
"=",
"self",
".",
"service",
".",
"settings",
".",
"data",
"[",
"'query'",
"]",
"[",
"'uri'",
"]",
"query_uri",
"=",
"urlparse",
"(",
"quer... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | TimeSeries.add_to_manifest | Add useful details to the manifest about this service
so that it can be used in an application.
:param manifest: An predix.admin.app.Manifest object
instance that manages reading/writing manifest config
for a cloud foundry app. | predix/admin/timeseries.py | def add_to_manifest(self, manifest):
"""
Add useful details to the manifest about this service
so that it can be used in an application.
:param manifest: An predix.admin.app.Manifest object
instance that manages reading/writing manifest config
for a cloud foundry... | def add_to_manifest(self, manifest):
"""
Add useful details to the manifest about this service
so that it can be used in an application.
:param manifest: An predix.admin.app.Manifest object
instance that manages reading/writing manifest config
for a cloud foundry... | [
"Add",
"useful",
"details",
"to",
"the",
"manifest",
"about",
"this",
"service",
"so",
"that",
"it",
"can",
"be",
"used",
"in",
"an",
"application",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/timeseries.py#L100-L125 | [
"def",
"add_to_manifest",
"(",
"self",
",",
"manifest",
")",
":",
"# Add this service to list of services",
"manifest",
".",
"add_service",
"(",
"self",
".",
"service",
".",
"name",
")",
"# Add environment variables",
"uri",
"=",
"predix",
".",
"config",
".",
"get... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | find_requirements | This method tries to determine the requirements of a particular project
by inspecting the possible places that they could be defined.
It will attempt, in order:
1) to parse setup.py in the root for an install_requires value
2) to read a requirements.txt file or a requirements.pip in the root
3) to... | requirements_detector/detect.py | def find_requirements(path):
"""
This method tries to determine the requirements of a particular project
by inspecting the possible places that they could be defined.
It will attempt, in order:
1) to parse setup.py in the root for an install_requires value
2) to read a requirements.txt file or... | def find_requirements(path):
"""
This method tries to determine the requirements of a particular project
by inspecting the possible places that they could be defined.
It will attempt, in order:
1) to parse setup.py in the root for an install_requires value
2) to read a requirements.txt file or... | [
"This",
"method",
"tries",
"to",
"determine",
"the",
"requirements",
"of",
"a",
"particular",
"project",
"by",
"inspecting",
"the",
"possible",
"places",
"that",
"they",
"could",
"be",
"defined",
"."
] | landscapeio/requirements-detector | python | https://github.com/landscapeio/requirements-detector/blob/22cb3fdd6b7f7f6c2eaee40ef8db540ef453b840/requirements_detector/detect.py#L67-L118 | [
"def",
"find_requirements",
"(",
"path",
")",
":",
"requirements",
"=",
"[",
"]",
"setup_py",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"'setup.py'",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"setup_py",
")",
"and",
"os",
".",
... | 22cb3fdd6b7f7f6c2eaee40ef8db540ef453b840 |
train | App.get_app_guid | Returns the GUID for the app instance with
the given name. | predix/admin/cf/apps.py | def get_app_guid(self, app_name):
"""
Returns the GUID for the app instance with
the given name.
"""
summary = self.space.get_space_summary()
for app in summary['apps']:
if app['name'] == app_name:
return app['guid'] | def get_app_guid(self, app_name):
"""
Returns the GUID for the app instance with
the given name.
"""
summary = self.space.get_space_summary()
for app in summary['apps']:
if app['name'] == app_name:
return app['guid'] | [
"Returns",
"the",
"GUID",
"for",
"the",
"app",
"instance",
"with",
"the",
"given",
"name",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/cf/apps.py#L16-L24 | [
"def",
"get_app_guid",
"(",
"self",
",",
"app_name",
")",
":",
"summary",
"=",
"self",
".",
"space",
".",
"get_space_summary",
"(",
")",
"for",
"app",
"in",
"summary",
"[",
"'apps'",
"]",
":",
"if",
"app",
"[",
"'name'",
"]",
"==",
"app_name",
":",
"... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | App.delete_app | Delete the given app.
Will fail intentionally if there are any service
bindings. You must delete those first. | predix/admin/cf/apps.py | def delete_app(self, app_name):
"""
Delete the given app.
Will fail intentionally if there are any service
bindings. You must delete those first.
"""
if app_name not in self.space.get_apps():
logging.warning("App not found so... succeeded?")
retu... | def delete_app(self, app_name):
"""
Delete the given app.
Will fail intentionally if there are any service
bindings. You must delete those first.
"""
if app_name not in self.space.get_apps():
logging.warning("App not found so... succeeded?")
retu... | [
"Delete",
"the",
"given",
"app",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/cf/apps.py#L26-L38 | [
"def",
"delete_app",
"(",
"self",
",",
"app_name",
")",
":",
"if",
"app_name",
"not",
"in",
"self",
".",
"space",
".",
"get_apps",
"(",
")",
":",
"logging",
".",
"warning",
"(",
"\"App not found so... succeeded?\"",
")",
"return",
"True",
"guid",
"=",
"sel... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | ServiceConfig._get_service_config | Reads in config file of UAA credential information
or generates one as a side-effect if not yet
initialized. | predix/admin/config.py | def _get_service_config(self):
"""
Reads in config file of UAA credential information
or generates one as a side-effect if not yet
initialized.
"""
# Should work for windows, osx, and linux environments
if not os.path.exists(self.config_path):
try:
... | def _get_service_config(self):
"""
Reads in config file of UAA credential information
or generates one as a side-effect if not yet
initialized.
"""
# Should work for windows, osx, and linux environments
if not os.path.exists(self.config_path):
try:
... | [
"Reads",
"in",
"config",
"file",
"of",
"UAA",
"credential",
"information",
"or",
"generates",
"one",
"as",
"a",
"side",
"-",
"effect",
"if",
"not",
"yet",
"initialized",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/config.py#L23-L40 | [
"def",
"_get_service_config",
"(",
"self",
")",
":",
"# Should work for windows, osx, and linux environments",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"config_path",
")",
":",
"try",
":",
"os",
".",
"makedirs",
"(",
"os",
".",
"path",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | ServiceConfig._write_service_config | Will write the config out to disk. | predix/admin/config.py | def _write_service_config(self):
"""
Will write the config out to disk.
"""
with open(self.config_path, 'w') as output:
output.write(json.dumps(self.data, sort_keys=True, indent=4)) | def _write_service_config(self):
"""
Will write the config out to disk.
"""
with open(self.config_path, 'w') as output:
output.write(json.dumps(self.data, sort_keys=True, indent=4)) | [
"Will",
"write",
"the",
"config",
"out",
"to",
"disk",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/config.py#L42-L47 | [
"def",
"_write_service_config",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"config_path",
",",
"'w'",
")",
"as",
"output",
":",
"output",
".",
"write",
"(",
"json",
".",
"dumps",
"(",
"self",
".",
"data",
",",
"sort_keys",
"=",
"True",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | BlobStore.create | Create an instance of the Blob Store Service with the typical
starting settings. | predix/admin/blobstore.py | def create(self, **kwargs):
"""
Create an instance of the Blob Store Service with the typical
starting settings.
"""
self.service.create(**kwargs)
predix.config.set_env_value(self.use_class, 'url',
self.service.settings.data['url'])
predix.config.... | def create(self, **kwargs):
"""
Create an instance of the Blob Store Service with the typical
starting settings.
"""
self.service.create(**kwargs)
predix.config.set_env_value(self.use_class, 'url',
self.service.settings.data['url'])
predix.config.... | [
"Create",
"an",
"instance",
"of",
"the",
"Blob",
"Store",
"Service",
"with",
"the",
"typical",
"starting",
"settings",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/blobstore.py#L28-L44 | [
"def",
"create",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"service",
".",
"create",
"(",
"*",
"*",
"kwargs",
")",
"predix",
".",
"config",
".",
"set_env_value",
"(",
"self",
".",
"use_class",
",",
"'url'",
",",
"self",
".",
"ser... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | BlobStore.add_to_manifest | Add useful details to the manifest about this service
so that it can be used in an application.
:param manifest: An predix.admin.app.Manifest object
instance that manages reading/writing manifest config
for a cloud foundry app. | predix/admin/blobstore.py | def add_to_manifest(self, manifest):
"""
Add useful details to the manifest about this service
so that it can be used in an application.
:param manifest: An predix.admin.app.Manifest object
instance that manages reading/writing manifest config
for a cloud foundry... | def add_to_manifest(self, manifest):
"""
Add useful details to the manifest about this service
so that it can be used in an application.
:param manifest: An predix.admin.app.Manifest object
instance that manages reading/writing manifest config
for a cloud foundry... | [
"Add",
"useful",
"details",
"to",
"the",
"manifest",
"about",
"this",
"service",
"so",
"that",
"it",
"can",
"be",
"used",
"in",
"an",
"application",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/blobstore.py#L46-L75 | [
"def",
"add_to_manifest",
"(",
"self",
",",
"manifest",
")",
":",
"# Add this service to the list of services",
"manifest",
".",
"add_service",
"(",
"self",
".",
"service",
".",
"name",
")",
"# Add environment variables",
"url",
"=",
"predix",
".",
"config",
".",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Subscriber.subscribe | return a generator for all subscribe messages
:return: None | predix/data/eventhub/subscriber.py | def subscribe(self):
"""
return a generator for all subscribe messages
:return: None
"""
while self.run_subscribe_generator:
if len(self._rx_messages) != 0:
yield self._rx_messages.pop(0)
return | def subscribe(self):
"""
return a generator for all subscribe messages
:return: None
"""
while self.run_subscribe_generator:
if len(self._rx_messages) != 0:
yield self._rx_messages.pop(0)
return | [
"return",
"a",
"generator",
"for",
"all",
"subscribe",
"messages",
":",
"return",
":",
"None"
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/data/eventhub/subscriber.py#L97-L105 | [
"def",
"subscribe",
"(",
"self",
")",
":",
"while",
"self",
".",
"run_subscribe_generator",
":",
"if",
"len",
"(",
"self",
".",
"_rx_messages",
")",
"!=",
"0",
":",
"yield",
"self",
".",
"_rx_messages",
".",
"pop",
"(",
"0",
")",
"return"
] | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Subscriber.send_acks | send acks to the service
:param message: EventHub_pb2.Message
:return: None | predix/data/eventhub/subscriber.py | def send_acks(self, message):
"""
send acks to the service
:param message: EventHub_pb2.Message
:return: None
"""
if isinstance(message, EventHub_pb2.Message):
ack = EventHub_pb2.Ack(partition=message.partition, offset=message.offset)
self.grpc_man... | def send_acks(self, message):
"""
send acks to the service
:param message: EventHub_pb2.Message
:return: None
"""
if isinstance(message, EventHub_pb2.Message):
ack = EventHub_pb2.Ack(partition=message.partition, offset=message.offset)
self.grpc_man... | [
"send",
"acks",
"to",
"the",
"service",
":",
"param",
"message",
":",
"EventHub_pb2",
".",
"Message",
":",
"return",
":",
"None"
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/data/eventhub/subscriber.py#L107-L121 | [
"def",
"send_acks",
"(",
"self",
",",
"message",
")",
":",
"if",
"isinstance",
"(",
"message",
",",
"EventHub_pb2",
".",
"Message",
")",
":",
"ack",
"=",
"EventHub_pb2",
".",
"Ack",
"(",
"partition",
"=",
"message",
".",
"partition",
",",
"offset",
"=",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Subscriber._generate_subscribe_headers | generate the subscribe stub headers based on the supplied config
:return: i | predix/data/eventhub/subscriber.py | def _generate_subscribe_headers(self):
"""
generate the subscribe stub headers based on the supplied config
:return: i
"""
headers =[]
headers.append(('predix-zone-id', self.eventhub_client.zone_id))
token = self.eventhub_client.service._get_bearer_token()
... | def _generate_subscribe_headers(self):
"""
generate the subscribe stub headers based on the supplied config
:return: i
"""
headers =[]
headers.append(('predix-zone-id', self.eventhub_client.zone_id))
token = self.eventhub_client.service._get_bearer_token()
... | [
"generate",
"the",
"subscribe",
"stub",
"headers",
"based",
"on",
"the",
"supplied",
"config",
":",
"return",
":",
"i"
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/data/eventhub/subscriber.py#L123-L153 | [
"def",
"_generate_subscribe_headers",
"(",
"self",
")",
":",
"headers",
"=",
"[",
"]",
"headers",
".",
"append",
"(",
"(",
"'predix-zone-id'",
",",
"self",
".",
"eventhub_client",
".",
"zone_id",
")",
")",
"token",
"=",
"self",
".",
"eventhub_client",
".",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | ParkingPlanning._get_assets | Returns the raw results of an asset search for a given bounding
box. | predix/ie/parking.py | def _get_assets(self, bbox, size=None, page=None, asset_type=None,
device_type=None, event_type=None, media_type=None):
"""
Returns the raw results of an asset search for a given bounding
box.
"""
uri = self.uri + '/v1/assets/search'
headers = self._get_header... | def _get_assets(self, bbox, size=None, page=None, asset_type=None,
device_type=None, event_type=None, media_type=None):
"""
Returns the raw results of an asset search for a given bounding
box.
"""
uri = self.uri + '/v1/assets/search'
headers = self._get_header... | [
"Returns",
"the",
"raw",
"results",
"of",
"an",
"asset",
"search",
"for",
"a",
"given",
"bounding",
"box",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/ie/parking.py#L85-L146 | [
"def",
"_get_assets",
"(",
"self",
",",
"bbox",
",",
"size",
"=",
"None",
",",
"page",
"=",
"None",
",",
"asset_type",
"=",
"None",
",",
"device_type",
"=",
"None",
",",
"event_type",
"=",
"None",
",",
"media_type",
"=",
"None",
")",
":",
"uri",
"=",... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | ParkingPlanning.get_assets | Query the assets stored in the intelligent environment for a given
bounding box and query.
Assets can be filtered by type of asset, event, or media available.
- device_type=['DATASIM']
- asset_type=['CAMERA']
- event_type=['PKIN']
- media_type=['IMAGE']
... | predix/ie/parking.py | def get_assets(self, bbox, **kwargs):
"""
Query the assets stored in the intelligent environment for a given
bounding box and query.
Assets can be filtered by type of asset, event, or media available.
- device_type=['DATASIM']
- asset_type=['CAMERA']
... | def get_assets(self, bbox, **kwargs):
"""
Query the assets stored in the intelligent environment for a given
bounding box and query.
Assets can be filtered by type of asset, event, or media available.
- device_type=['DATASIM']
- asset_type=['CAMERA']
... | [
"Query",
"the",
"assets",
"stored",
"in",
"the",
"intelligent",
"environment",
"for",
"a",
"given",
"bounding",
"box",
"and",
"query",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/ie/parking.py#L148-L188 | [
"def",
"get_assets",
"(",
"self",
",",
"bbox",
",",
"*",
"*",
"kwargs",
")",
":",
"response",
"=",
"self",
".",
"_get_assets",
"(",
"bbox",
",",
"*",
"*",
"kwargs",
")",
"# Remove broken HATEOAS _links but identify asset uid first",
"assets",
"=",
"[",
"]",
... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | ParkingPlanning._get_asset | Returns raw response for an given asset by its unique id. | predix/ie/parking.py | def _get_asset(self, asset_uid):
"""
Returns raw response for an given asset by its unique id.
"""
uri = self.uri + '/v2/assets/' + asset_uid
headers = self._get_headers()
return self.service._get(uri, headers=headers) | def _get_asset(self, asset_uid):
"""
Returns raw response for an given asset by its unique id.
"""
uri = self.uri + '/v2/assets/' + asset_uid
headers = self._get_headers()
return self.service._get(uri, headers=headers) | [
"Returns",
"raw",
"response",
"for",
"an",
"given",
"asset",
"by",
"its",
"unique",
"id",
"."
] | PredixDev/predixpy | python | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/ie/parking.py#L190-L198 | [
"def",
"_get_asset",
"(",
"self",
",",
"asset_uid",
")",
":",
"uri",
"=",
"self",
".",
"uri",
"+",
"'/v2/assets/'",
"+",
"asset_uid",
"headers",
"=",
"self",
".",
"_get_headers",
"(",
")",
"return",
"self",
".",
"service",
".",
"_get",
"(",
"uri",
",",... | a0cb34cf40f716229351bb6d90d6ecace958c81f |
train | Hysteresis.label | Label input grid with hysteresis method.
Args:
input_grid: 2D array of values.
Returns:
Labeled output grid. | hagelslag/processing/Hysteresis.py | def label(self, input_grid):
"""
Label input grid with hysteresis method.
Args:
input_grid: 2D array of values.
Returns:
Labeled output grid.
"""
unset = 0
high_labels, num_labels = label(input_grid > self.high_thresh)
region_rank... | def label(self, input_grid):
"""
Label input grid with hysteresis method.
Args:
input_grid: 2D array of values.
Returns:
Labeled output grid.
"""
unset = 0
high_labels, num_labels = label(input_grid > self.high_thresh)
region_rank... | [
"Label",
"input",
"grid",
"with",
"hysteresis",
"method",
"."
] | djgagne/hagelslag | python | https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/Hysteresis.py#L20-L49 | [
"def",
"label",
"(",
"self",
",",
"input_grid",
")",
":",
"unset",
"=",
"0",
"high_labels",
",",
"num_labels",
"=",
"label",
"(",
"input_grid",
">",
"self",
".",
"high_thresh",
")",
"region_ranking",
"=",
"np",
".",
"argsort",
"(",
"maximum",
"(",
"input... | 6fb6c3df90bf4867e13a97d3460b14471d107df1 |
train | Hysteresis.size_filter | Remove labeled objects that do not meet size threshold criteria.
Args:
labeled_grid: 2D output from label method.
min_size: minimum size of object in pixels.
Returns:
labeled grid with smaller objects removed. | hagelslag/processing/Hysteresis.py | def size_filter(labeled_grid, min_size):
"""
Remove labeled objects that do not meet size threshold criteria.
Args:
labeled_grid: 2D output from label method.
min_size: minimum size of object in pixels.
Returns:
labeled grid with smaller objects remo... | def size_filter(labeled_grid, min_size):
"""
Remove labeled objects that do not meet size threshold criteria.
Args:
labeled_grid: 2D output from label method.
min_size: minimum size of object in pixels.
Returns:
labeled grid with smaller objects remo... | [
"Remove",
"labeled",
"objects",
"that",
"do",
"not",
"meet",
"size",
"threshold",
"criteria",
"."
] | djgagne/hagelslag | python | https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/Hysteresis.py#L52-L72 | [
"def",
"size_filter",
"(",
"labeled_grid",
",",
"min_size",
")",
":",
"out_grid",
"=",
"np",
".",
"zeros",
"(",
"labeled_grid",
".",
"shape",
",",
"dtype",
"=",
"int",
")",
"slices",
"=",
"find_objects",
"(",
"labeled_grid",
")",
"j",
"=",
"1",
"for",
... | 6fb6c3df90bf4867e13a97d3460b14471d107df1 |
train | roc_curve | Plots a set receiver/relative operating characteristic (ROC) curves from DistributedROC objects.
The ROC curve shows how well a forecast discriminates between two outcomes over a series of thresholds. It
features Probability of Detection (True Positive Rate) on the y-axis and Probability of False Detection
... | hagelslag/evaluation/MetricPlotter.py | def roc_curve(roc_objs, obj_labels, colors, markers, filename, figsize=(8, 8),
xlabel="Probability of False Detection",
ylabel="Probability of Detection",
title="ROC Curve", ticks=np.arange(0, 1.1, 0.1), dpi=300,
legend_params=None, bootstrap_sets=None, ci=(2.5, 9... | def roc_curve(roc_objs, obj_labels, colors, markers, filename, figsize=(8, 8),
xlabel="Probability of False Detection",
ylabel="Probability of Detection",
title="ROC Curve", ticks=np.arange(0, 1.1, 0.1), dpi=300,
legend_params=None, bootstrap_sets=None, ci=(2.5, 9... | [
"Plots",
"a",
"set",
"receiver",
"/",
"relative",
"operating",
"characteristic",
"(",
"ROC",
")",
"curves",
"from",
"DistributedROC",
"objects",
"."
] | djgagne/hagelslag | python | https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/evaluation/MetricPlotter.py#L6-L73 | [
"def",
"roc_curve",
"(",
"roc_objs",
",",
"obj_labels",
",",
"colors",
",",
"markers",
",",
"filename",
",",
"figsize",
"=",
"(",
"8",
",",
"8",
")",
",",
"xlabel",
"=",
"\"Probability of False Detection\"",
",",
"ylabel",
"=",
"\"Probability of Detection\"",
... | 6fb6c3df90bf4867e13a97d3460b14471d107df1 |
train | performance_diagram | Draws a performance diagram from a set of DistributedROC objects.
A performance diagram is a variation on the ROC curve in which the Probability of False Detection on the
x-axis has been replaced with the Success Ratio (1-False Alarm Ratio or Precision). The diagram also shows
the Critical Success Index (C... | hagelslag/evaluation/MetricPlotter.py | def performance_diagram(roc_objs, obj_labels, colors, markers, filename, figsize=(8, 8),
xlabel="Success Ratio (1-FAR)",
ylabel="Probability of Detection", ticks=np.arange(0, 1.1, 0.1),
dpi=300, csi_cmap="Blues",
csi_label="... | def performance_diagram(roc_objs, obj_labels, colors, markers, filename, figsize=(8, 8),
xlabel="Success Ratio (1-FAR)",
ylabel="Probability of Detection", ticks=np.arange(0, 1.1, 0.1),
dpi=300, csi_cmap="Blues",
csi_label="... | [
"Draws",
"a",
"performance",
"diagram",
"from",
"a",
"set",
"of",
"DistributedROC",
"objects",
"."
] | djgagne/hagelslag | python | https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/evaluation/MetricPlotter.py#L76-L159 | [
"def",
"performance_diagram",
"(",
"roc_objs",
",",
"obj_labels",
",",
"colors",
",",
"markers",
",",
"filename",
",",
"figsize",
"=",
"(",
"8",
",",
"8",
")",
",",
"xlabel",
"=",
"\"Success Ratio (1-FAR)\"",
",",
"ylabel",
"=",
"\"Probability of Detection\"",
... | 6fb6c3df90bf4867e13a97d3460b14471d107df1 |
train | reliability_diagram | Plot reliability curves against a 1:1 diagonal to determine if probability forecasts are consistent with their
observed relative frequency.
Args:
rel_objs (list): List of DistributedReliability objects.
obj_labels (list): List of labels describing the forecast model associated with each curve.
... | hagelslag/evaluation/MetricPlotter.py | def reliability_diagram(rel_objs, obj_labels, colors, markers, filename, figsize=(8, 8), xlabel="Forecast Probability",
ylabel="Observed Relative Frequency", ticks=np.arange(0, 1.05, 0.05), dpi=300, inset_size=1.5,
title="Reliability Diagram", legend_params=None, bootstra... | def reliability_diagram(rel_objs, obj_labels, colors, markers, filename, figsize=(8, 8), xlabel="Forecast Probability",
ylabel="Observed Relative Frequency", ticks=np.arange(0, 1.05, 0.05), dpi=300, inset_size=1.5,
title="Reliability Diagram", legend_params=None, bootstra... | [
"Plot",
"reliability",
"curves",
"against",
"a",
"1",
":",
"1",
"diagonal",
"to",
"determine",
"if",
"probability",
"forecasts",
"are",
"consistent",
"with",
"their",
"observed",
"relative",
"frequency",
"."
] | djgagne/hagelslag | python | https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/evaluation/MetricPlotter.py#L162-L217 | [
"def",
"reliability_diagram",
"(",
"rel_objs",
",",
"obj_labels",
",",
"colors",
",",
"markers",
",",
"filename",
",",
"figsize",
"=",
"(",
"8",
",",
"8",
")",
",",
"xlabel",
"=",
"\"Forecast Probability\"",
",",
"ylabel",
"=",
"\"Observed Relative Frequency\"",... | 6fb6c3df90bf4867e13a97d3460b14471d107df1 |
train | attributes_diagram | Plot reliability curves against a 1:1 diagonal to determine if probability forecasts are consistent with their
observed relative frequency. Also adds gray areas to show where the climatological probabilities lie and what
areas result in a positive Brier Skill Score.
Args:
rel_objs (list): List of D... | hagelslag/evaluation/MetricPlotter.py | def attributes_diagram(rel_objs, obj_labels, colors, markers, filename, figsize=(8, 8), xlabel="Forecast Probability",
ylabel="Observed Relative Frequency", ticks=np.arange(0, 1.05, 0.05), dpi=300,
title="Attributes Diagram", legend_params=None, inset_params=None,
... | def attributes_diagram(rel_objs, obj_labels, colors, markers, filename, figsize=(8, 8), xlabel="Forecast Probability",
ylabel="Observed Relative Frequency", ticks=np.arange(0, 1.05, 0.05), dpi=300,
title="Attributes Diagram", legend_params=None, inset_params=None,
... | [
"Plot",
"reliability",
"curves",
"against",
"a",
"1",
":",
"1",
"diagonal",
"to",
"determine",
"if",
"probability",
"forecasts",
"are",
"consistent",
"with",
"their",
"observed",
"relative",
"frequency",
".",
"Also",
"adds",
"gray",
"areas",
"to",
"show",
"whe... | djgagne/hagelslag | python | https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/evaluation/MetricPlotter.py#L220-L288 | [
"def",
"attributes_diagram",
"(",
"rel_objs",
",",
"obj_labels",
",",
"colors",
",",
"markers",
",",
"filename",
",",
"figsize",
"=",
"(",
"8",
",",
"8",
")",
",",
"xlabel",
"=",
"\"Forecast Probability\"",
",",
"ylabel",
"=",
"\"Observed Relative Frequency\"",
... | 6fb6c3df90bf4867e13a97d3460b14471d107df1 |
train | RunScriptDialog.get_string | Return a string value that the user enters. Raises exception for cancel. | nion/swift/ScriptsDialog.py | def get_string(self, prompt, default_str=None) -> str:
"""Return a string value that the user enters. Raises exception for cancel."""
accept_event = threading.Event()
value_ref = [None]
def perform():
def accepted(text):
value_ref[0] = text
ac... | def get_string(self, prompt, default_str=None) -> str:
"""Return a string value that the user enters. Raises exception for cancel."""
accept_event = threading.Event()
value_ref = [None]
def perform():
def accepted(text):
value_ref[0] = text
ac... | [
"Return",
"a",
"string",
"value",
"that",
"the",
"user",
"enters",
".",
"Raises",
"exception",
"for",
"cancel",
"."
] | nion-software/nionswift | python | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/ScriptsDialog.py#L388-L415 | [
"def",
"get_string",
"(",
"self",
",",
"prompt",
",",
"default_str",
"=",
"None",
")",
"->",
"str",
":",
"accept_event",
"=",
"threading",
".",
"Event",
"(",
")",
"value_ref",
"=",
"[",
"None",
"]",
"def",
"perform",
"(",
")",
":",
"def",
"accepted",
... | d43693eaf057b8683b9638e575000f055fede452 |
train | RunScriptDialog.__accept_reject | Return a boolean value for accept/reject. | nion/swift/ScriptsDialog.py | def __accept_reject(self, prompt, accepted_text, rejected_text, display_rejected):
"""Return a boolean value for accept/reject."""
accept_event = threading.Event()
result_ref = [False]
def perform():
def accepted():
result_ref[0] = True
accept... | def __accept_reject(self, prompt, accepted_text, rejected_text, display_rejected):
"""Return a boolean value for accept/reject."""
accept_event = threading.Event()
result_ref = [False]
def perform():
def accepted():
result_ref[0] = True
accept... | [
"Return",
"a",
"boolean",
"value",
"for",
"accept",
"/",
"reject",
"."
] | nion-software/nionswift | python | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/ScriptsDialog.py#L444-L470 | [
"def",
"__accept_reject",
"(",
"self",
",",
"prompt",
",",
"accepted_text",
",",
"rejected_text",
",",
"display_rejected",
")",
":",
"accept_event",
"=",
"threading",
".",
"Event",
"(",
")",
"result_ref",
"=",
"[",
"False",
"]",
"def",
"perform",
"(",
")",
... | d43693eaf057b8683b9638e575000f055fede452 |
train | Variable.compute_weight | Returns the weight (w) using OLS of r * w = gp._ytr | EvoDAG/node.py | def compute_weight(self, r, ytr=None, mask=None):
"""Returns the weight (w) using OLS of r * w = gp._ytr """
ytr = self._ytr if ytr is None else ytr
mask = self._mask if mask is None else mask
return compute_weight(r, ytr, mask) | def compute_weight(self, r, ytr=None, mask=None):
"""Returns the weight (w) using OLS of r * w = gp._ytr """
ytr = self._ytr if ytr is None else ytr
mask = self._mask if mask is None else mask
return compute_weight(r, ytr, mask) | [
"Returns",
"the",
"weight",
"(",
"w",
")",
"using",
"OLS",
"of",
"r",
"*",
"w",
"=",
"gp",
".",
"_ytr"
] | mgraffg/EvoDAG | python | https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/node.py#L129-L133 | [
"def",
"compute_weight",
"(",
"self",
",",
"r",
",",
"ytr",
"=",
"None",
",",
"mask",
"=",
"None",
")",
":",
"ytr",
"=",
"self",
".",
"_ytr",
"if",
"ytr",
"is",
"None",
"else",
"ytr",
"mask",
"=",
"self",
".",
"_mask",
"if",
"mask",
"is",
"None",... | e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5 |
train | Variable.isfinite | Test whether the predicted values are finite | EvoDAG/node.py | def isfinite(self):
"Test whether the predicted values are finite"
if self._multiple_outputs:
if self.hy_test is not None:
r = [(hy.isfinite() and (hyt is None or hyt.isfinite()))
for hy, hyt in zip(self.hy, self.hy_test)]
else:
... | def isfinite(self):
"Test whether the predicted values are finite"
if self._multiple_outputs:
if self.hy_test is not None:
r = [(hy.isfinite() and (hyt is None or hyt.isfinite()))
for hy, hyt in zip(self.hy, self.hy_test)]
else:
... | [
"Test",
"whether",
"the",
"predicted",
"values",
"are",
"finite"
] | mgraffg/EvoDAG | python | https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/node.py#L192-L202 | [
"def",
"isfinite",
"(",
"self",
")",
":",
"if",
"self",
".",
"_multiple_outputs",
":",
"if",
"self",
".",
"hy_test",
"is",
"not",
"None",
":",
"r",
"=",
"[",
"(",
"hy",
".",
"isfinite",
"(",
")",
"and",
"(",
"hyt",
"is",
"None",
"or",
"hyt",
".",... | e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5 |
train | value_of_named_argument_in_function | Parse an arbitrary block of python code to get the value of a named argument
from inside a function call | hatchery/helpers.py | def value_of_named_argument_in_function(argument_name, function_name, search_str,
resolve_varname=False):
""" Parse an arbitrary block of python code to get the value of a named argument
from inside a function call
"""
try:
search_str = unicode(search_... | def value_of_named_argument_in_function(argument_name, function_name, search_str,
resolve_varname=False):
""" Parse an arbitrary block of python code to get the value of a named argument
from inside a function call
"""
try:
search_str = unicode(search_... | [
"Parse",
"an",
"arbitrary",
"block",
"of",
"python",
"code",
"to",
"get",
"the",
"value",
"of",
"a",
"named",
"argument",
"from",
"inside",
"a",
"function",
"call"
] | ajk8/hatchery | python | https://github.com/ajk8/hatchery/blob/e068c9f5366d2c98225babb03d4cde36c710194f/hatchery/helpers.py#L17-L73 | [
"def",
"value_of_named_argument_in_function",
"(",
"argument_name",
",",
"function_name",
",",
"search_str",
",",
"resolve_varname",
"=",
"False",
")",
":",
"try",
":",
"search_str",
"=",
"unicode",
"(",
"search_str",
")",
"except",
"NameError",
":",
"pass",
"read... | e068c9f5366d2c98225babb03d4cde36c710194f |
train | regex_in_file | Search for a regex in a file
If return_match is True, return the found object instead of a boolean | hatchery/helpers.py | def regex_in_file(regex, filepath, return_match=False):
""" Search for a regex in a file
If return_match is True, return the found object instead of a boolean
"""
file_content = get_file_content(filepath)
re_method = funcy.re_find if return_match else funcy.re_test
return re_method(regex, file_... | def regex_in_file(regex, filepath, return_match=False):
""" Search for a regex in a file
If return_match is True, return the found object instead of a boolean
"""
file_content = get_file_content(filepath)
re_method = funcy.re_find if return_match else funcy.re_test
return re_method(regex, file_... | [
"Search",
"for",
"a",
"regex",
"in",
"a",
"file"
] | ajk8/hatchery | python | https://github.com/ajk8/hatchery/blob/e068c9f5366d2c98225babb03d4cde36c710194f/hatchery/helpers.py#L95-L102 | [
"def",
"regex_in_file",
"(",
"regex",
",",
"filepath",
",",
"return_match",
"=",
"False",
")",
":",
"file_content",
"=",
"get_file_content",
"(",
"filepath",
")",
"re_method",
"=",
"funcy",
".",
"re_find",
"if",
"return_match",
"else",
"funcy",
".",
"re_test",... | e068c9f5366d2c98225babb03d4cde36c710194f |
train | regex_in_package_file | Search for a regex in a file contained within the package directory
If return_match is True, return the found object instead of a boolean | hatchery/helpers.py | def regex_in_package_file(regex, filename, package_name, return_match=False):
""" Search for a regex in a file contained within the package directory
If return_match is True, return the found object instead of a boolean
"""
filepath = package_file_path(filename, package_name)
return regex_in_file(r... | def regex_in_package_file(regex, filename, package_name, return_match=False):
""" Search for a regex in a file contained within the package directory
If return_match is True, return the found object instead of a boolean
"""
filepath = package_file_path(filename, package_name)
return regex_in_file(r... | [
"Search",
"for",
"a",
"regex",
"in",
"a",
"file",
"contained",
"within",
"the",
"package",
"directory"
] | ajk8/hatchery | python | https://github.com/ajk8/hatchery/blob/e068c9f5366d2c98225babb03d4cde36c710194f/hatchery/helpers.py#L106-L112 | [
"def",
"regex_in_package_file",
"(",
"regex",
",",
"filename",
",",
"package_name",
",",
"return_match",
"=",
"False",
")",
":",
"filepath",
"=",
"package_file_path",
"(",
"filename",
",",
"package_name",
")",
"return",
"regex_in_file",
"(",
"regex",
",",
"filep... | e068c9f5366d2c98225babb03d4cde36c710194f |
train | string_is_url | Test to see if a string is a URL or not, defined in this case as a string for which
urlparse returns a scheme component
>>> string_is_url('somestring')
False
>>> string_is_url('https://some.domain.org/path')
True | hatchery/helpers.py | def string_is_url(test_str):
""" Test to see if a string is a URL or not, defined in this case as a string for which
urlparse returns a scheme component
>>> string_is_url('somestring')
False
>>> string_is_url('https://some.domain.org/path')
True
"""
parsed = urlparse.urlparse(test_str)
... | def string_is_url(test_str):
""" Test to see if a string is a URL or not, defined in this case as a string for which
urlparse returns a scheme component
>>> string_is_url('somestring')
False
>>> string_is_url('https://some.domain.org/path')
True
"""
parsed = urlparse.urlparse(test_str)
... | [
"Test",
"to",
"see",
"if",
"a",
"string",
"is",
"a",
"URL",
"or",
"not",
"defined",
"in",
"this",
"case",
"as",
"a",
"string",
"for",
"which",
"urlparse",
"returns",
"a",
"scheme",
"component"
] | ajk8/hatchery | python | https://github.com/ajk8/hatchery/blob/e068c9f5366d2c98225babb03d4cde36c710194f/hatchery/helpers.py#L116-L126 | [
"def",
"string_is_url",
"(",
"test_str",
")",
":",
"parsed",
"=",
"urlparse",
".",
"urlparse",
"(",
"test_str",
")",
"return",
"parsed",
".",
"scheme",
"is",
"not",
"None",
"and",
"parsed",
".",
"scheme",
"!=",
"''"
] | e068c9f5366d2c98225babb03d4cde36c710194f |
train | TransactionManager.item_transaction | Begin transaction state for item.
A transaction state is exists to prevent writing out to disk, mainly for performance reasons.
All changes to the object are delayed until the transaction state exits.
This method is thread safe. | nion/swift/model/DocumentModel.py | def item_transaction(self, item) -> Transaction:
"""Begin transaction state for item.
A transaction state is exists to prevent writing out to disk, mainly for performance reasons.
All changes to the object are delayed until the transaction state exits.
This method is thread safe.
... | def item_transaction(self, item) -> Transaction:
"""Begin transaction state for item.
A transaction state is exists to prevent writing out to disk, mainly for performance reasons.
All changes to the object are delayed until the transaction state exits.
This method is thread safe.
... | [
"Begin",
"transaction",
"state",
"for",
"item",
"."
] | nion-software/nionswift | python | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/DocumentModel.py#L174-L185 | [
"def",
"item_transaction",
"(",
"self",
",",
"item",
")",
"->",
"Transaction",
":",
"items",
"=",
"self",
".",
"__build_transaction_items",
"(",
"item",
")",
"transaction",
"=",
"Transaction",
"(",
"self",
",",
"item",
",",
"items",
")",
"self",
".",
"__tr... | d43693eaf057b8683b9638e575000f055fede452 |
train | DocumentModel.insert_data_item | Insert a new data item into document model.
This method is NOT threadsafe. | nion/swift/model/DocumentModel.py | def insert_data_item(self, before_index, data_item, auto_display: bool = True) -> None:
"""Insert a new data item into document model.
This method is NOT threadsafe.
"""
assert data_item is not None
assert data_item not in self.data_items
assert before_index <= len(self.... | def insert_data_item(self, before_index, data_item, auto_display: bool = True) -> None:
"""Insert a new data item into document model.
This method is NOT threadsafe.
"""
assert data_item is not None
assert data_item not in self.data_items
assert before_index <= len(self.... | [
"Insert",
"a",
"new",
"data",
"item",
"into",
"document",
"model",
"."
] | nion-software/nionswift | python | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/DocumentModel.py#L541-L557 | [
"def",
"insert_data_item",
"(",
"self",
",",
"before_index",
",",
"data_item",
",",
"auto_display",
":",
"bool",
"=",
"True",
")",
"->",
"None",
":",
"assert",
"data_item",
"is",
"not",
"None",
"assert",
"data_item",
"not",
"in",
"self",
".",
"data_items",
... | d43693eaf057b8683b9638e575000f055fede452 |
train | DocumentModel.remove_data_item | Remove data item from document model.
This method is NOT threadsafe. | nion/swift/model/DocumentModel.py | def remove_data_item(self, data_item: DataItem.DataItem, *, safe: bool=False) -> typing.Optional[typing.Sequence]:
"""Remove data item from document model.
This method is NOT threadsafe.
"""
# remove data item from any computations
return self.__cascade_delete(data_item, safe=sa... | def remove_data_item(self, data_item: DataItem.DataItem, *, safe: bool=False) -> typing.Optional[typing.Sequence]:
"""Remove data item from document model.
This method is NOT threadsafe.
"""
# remove data item from any computations
return self.__cascade_delete(data_item, safe=sa... | [
"Remove",
"data",
"item",
"from",
"document",
"model",
"."
] | nion-software/nionswift | python | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/DocumentModel.py#L586-L592 | [
"def",
"remove_data_item",
"(",
"self",
",",
"data_item",
":",
"DataItem",
".",
"DataItem",
",",
"*",
",",
"safe",
":",
"bool",
"=",
"False",
")",
"->",
"typing",
".",
"Optional",
"[",
"typing",
".",
"Sequence",
"]",
":",
"# remove data item from any computa... | d43693eaf057b8683b9638e575000f055fede452 |
train | DocumentModel.__cascade_delete_inner | Cascade delete an item.
Returns an undelete log that can be used to undo the cascade deletion.
Builds a cascade of items to be deleted and dependencies to be removed when the passed item is deleted. Then
removes computations that are no longer valid. Removing a computation may result in more d... | nion/swift/model/DocumentModel.py | def __cascade_delete_inner(self, master_item, safe: bool=False) -> typing.Optional[typing.Sequence]:
"""Cascade delete an item.
Returns an undelete log that can be used to undo the cascade deletion.
Builds a cascade of items to be deleted and dependencies to be removed when the passed item is ... | def __cascade_delete_inner(self, master_item, safe: bool=False) -> typing.Optional[typing.Sequence]:
"""Cascade delete an item.
Returns an undelete log that can be used to undo the cascade deletion.
Builds a cascade of items to be deleted and dependencies to be removed when the passed item is ... | [
"Cascade",
"delete",
"an",
"item",
"."
] | nion-software/nionswift | python | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/DocumentModel.py#L852-L956 | [
"def",
"__cascade_delete_inner",
"(",
"self",
",",
"master_item",
",",
"safe",
":",
"bool",
"=",
"False",
")",
"->",
"typing",
".",
"Optional",
"[",
"typing",
".",
"Sequence",
"]",
":",
"# print(f\"cascade {master_item}\")",
"# this horrible little hack ensures that c... | d43693eaf057b8683b9638e575000f055fede452 |
train | DocumentModel.get_dependent_items | Return the list of data items containing data that directly depends on data in this item. | nion/swift/model/DocumentModel.py | def get_dependent_items(self, item) -> typing.List:
"""Return the list of data items containing data that directly depends on data in this item."""
with self.__dependency_tree_lock:
return copy.copy(self.__dependency_tree_source_to_target_map.get(weakref.ref(item), list())) | def get_dependent_items(self, item) -> typing.List:
"""Return the list of data items containing data that directly depends on data in this item."""
with self.__dependency_tree_lock:
return copy.copy(self.__dependency_tree_source_to_target_map.get(weakref.ref(item), list())) | [
"Return",
"the",
"list",
"of",
"data",
"items",
"containing",
"data",
"that",
"directly",
"depends",
"on",
"data",
"in",
"this",
"item",
"."
] | nion-software/nionswift | python | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/DocumentModel.py#L1151-L1154 | [
"def",
"get_dependent_items",
"(",
"self",
",",
"item",
")",
"->",
"typing",
".",
"List",
":",
"with",
"self",
".",
"__dependency_tree_lock",
":",
"return",
"copy",
".",
"copy",
"(",
"self",
".",
"__dependency_tree_source_to_target_map",
".",
"get",
"(",
"weak... | d43693eaf057b8683b9638e575000f055fede452 |
train | DocumentModel.__get_deep_dependent_item_set | Return the list of data items containing data that directly depends on data in this item. | nion/swift/model/DocumentModel.py | def __get_deep_dependent_item_set(self, item, item_set) -> None:
"""Return the list of data items containing data that directly depends on data in this item."""
if not item in item_set:
item_set.add(item)
with self.__dependency_tree_lock:
for dependent in self.get... | def __get_deep_dependent_item_set(self, item, item_set) -> None:
"""Return the list of data items containing data that directly depends on data in this item."""
if not item in item_set:
item_set.add(item)
with self.__dependency_tree_lock:
for dependent in self.get... | [
"Return",
"the",
"list",
"of",
"data",
"items",
"containing",
"data",
"that",
"directly",
"depends",
"on",
"data",
"in",
"this",
"item",
"."
] | nion-software/nionswift | python | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/DocumentModel.py#L1156-L1162 | [
"def",
"__get_deep_dependent_item_set",
"(",
"self",
",",
"item",
",",
"item_set",
")",
"->",
"None",
":",
"if",
"not",
"item",
"in",
"item_set",
":",
"item_set",
".",
"add",
"(",
"item",
")",
"with",
"self",
".",
"__dependency_tree_lock",
":",
"for",
"dep... | d43693eaf057b8683b9638e575000f055fede452 |
train | DocumentModel.get_dependent_data_items | Return the list of data items containing data that directly depends on data in this item. | nion/swift/model/DocumentModel.py | def get_dependent_data_items(self, data_item: DataItem.DataItem) -> typing.List[DataItem.DataItem]:
"""Return the list of data items containing data that directly depends on data in this item."""
with self.__dependency_tree_lock:
return [data_item for data_item in self.__dependency_tree_sour... | def get_dependent_data_items(self, data_item: DataItem.DataItem) -> typing.List[DataItem.DataItem]:
"""Return the list of data items containing data that directly depends on data in this item."""
with self.__dependency_tree_lock:
return [data_item for data_item in self.__dependency_tree_sour... | [
"Return",
"the",
"list",
"of",
"data",
"items",
"containing",
"data",
"that",
"directly",
"depends",
"on",
"data",
"in",
"this",
"item",
"."
] | nion-software/nionswift | python | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/DocumentModel.py#L1168-L1171 | [
"def",
"get_dependent_data_items",
"(",
"self",
",",
"data_item",
":",
"DataItem",
".",
"DataItem",
")",
"->",
"typing",
".",
"List",
"[",
"DataItem",
".",
"DataItem",
"]",
":",
"with",
"self",
".",
"__dependency_tree_lock",
":",
"return",
"[",
"data_item",
... | d43693eaf057b8683b9638e575000f055fede452 |
train | DocumentModel.transaction_context | Return a context object for a document-wide transaction. | nion/swift/model/DocumentModel.py | def transaction_context(self):
"""Return a context object for a document-wide transaction."""
class DocumentModelTransaction:
def __init__(self, document_model):
self.__document_model = document_model
def __enter__(self):
self.__document_model.per... | def transaction_context(self):
"""Return a context object for a document-wide transaction."""
class DocumentModelTransaction:
def __init__(self, document_model):
self.__document_model = document_model
def __enter__(self):
self.__document_model.per... | [
"Return",
"a",
"context",
"object",
"for",
"a",
"document",
"-",
"wide",
"transaction",
"."
] | nion-software/nionswift | python | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/DocumentModel.py#L1195-L1209 | [
"def",
"transaction_context",
"(",
"self",
")",
":",
"class",
"DocumentModelTransaction",
":",
"def",
"__init__",
"(",
"self",
",",
"document_model",
")",
":",
"self",
".",
"__document_model",
"=",
"document_model",
"def",
"__enter__",
"(",
"self",
")",
":",
"... | d43693eaf057b8683b9638e575000f055fede452 |
train | DocumentModel.data_item_live | Return a context manager to put the data item in a 'live state'. | nion/swift/model/DocumentModel.py | def data_item_live(self, data_item):
""" Return a context manager to put the data item in a 'live state'. """
class LiveContextManager:
def __init__(self, manager, object):
self.__manager = manager
self.__object = object
def __enter__(self):
... | def data_item_live(self, data_item):
""" Return a context manager to put the data item in a 'live state'. """
class LiveContextManager:
def __init__(self, manager, object):
self.__manager = manager
self.__object = object
def __enter__(self):
... | [
"Return",
"a",
"context",
"manager",
"to",
"put",
"the",
"data",
"item",
"in",
"a",
"live",
"state",
"."
] | nion-software/nionswift | python | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/DocumentModel.py#L1227-L1238 | [
"def",
"data_item_live",
"(",
"self",
",",
"data_item",
")",
":",
"class",
"LiveContextManager",
":",
"def",
"__init__",
"(",
"self",
",",
"manager",
",",
"object",
")",
":",
"self",
".",
"__manager",
"=",
"manager",
"self",
".",
"__object",
"=",
"object",... | d43693eaf057b8683b9638e575000f055fede452 |
train | DocumentModel.begin_data_item_live | Begins a live state for the data item.
The live state is propagated to dependent data items.
This method is thread safe. See slow_test_dependent_data_item_removed_while_live_data_item_becomes_unlive. | nion/swift/model/DocumentModel.py | def begin_data_item_live(self, data_item):
"""Begins a live state for the data item.
The live state is propagated to dependent data items.
This method is thread safe. See slow_test_dependent_data_item_removed_while_live_data_item_becomes_unlive.
"""
with self.__live_data_items_... | def begin_data_item_live(self, data_item):
"""Begins a live state for the data item.
The live state is propagated to dependent data items.
This method is thread safe. See slow_test_dependent_data_item_removed_while_live_data_item_becomes_unlive.
"""
with self.__live_data_items_... | [
"Begins",
"a",
"live",
"state",
"for",
"the",
"data",
"item",
"."
] | nion-software/nionswift | python | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/DocumentModel.py#L1240-L1253 | [
"def",
"begin_data_item_live",
"(",
"self",
",",
"data_item",
")",
":",
"with",
"self",
".",
"__live_data_items_lock",
":",
"old_live_count",
"=",
"self",
".",
"__live_data_items",
".",
"get",
"(",
"data_item",
".",
"uuid",
",",
"0",
")",
"self",
".",
"__liv... | d43693eaf057b8683b9638e575000f055fede452 |
train | DocumentModel.end_data_item_live | Ends a live state for the data item.
The live-ness property is propagated to dependent data items, similar to the transactions.
This method is thread safe. | nion/swift/model/DocumentModel.py | def end_data_item_live(self, data_item):
"""Ends a live state for the data item.
The live-ness property is propagated to dependent data items, similar to the transactions.
This method is thread safe.
"""
with self.__live_data_items_lock:
live_count = self.__live_dat... | def end_data_item_live(self, data_item):
"""Ends a live state for the data item.
The live-ness property is propagated to dependent data items, similar to the transactions.
This method is thread safe.
"""
with self.__live_data_items_lock:
live_count = self.__live_dat... | [
"Ends",
"a",
"live",
"state",
"for",
"the",
"data",
"item",
"."
] | nion-software/nionswift | python | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/DocumentModel.py#L1255-L1269 | [
"def",
"end_data_item_live",
"(",
"self",
",",
"data_item",
")",
":",
"with",
"self",
".",
"__live_data_items_lock",
":",
"live_count",
"=",
"self",
".",
"__live_data_items",
".",
"get",
"(",
"data_item",
".",
"uuid",
",",
"0",
")",
"-",
"1",
"assert",
"li... | d43693eaf057b8683b9638e575000f055fede452 |
train | DocumentModel.__construct_data_item_reference | Construct a data item reference.
Construct a data item reference and assign a data item to it. Update data item session id and session metadata.
Also connect the data channel processor.
This method is thread safe. | nion/swift/model/DocumentModel.py | def __construct_data_item_reference(self, hardware_source: HardwareSource.HardwareSource, data_channel: HardwareSource.DataChannel):
"""Construct a data item reference.
Construct a data item reference and assign a data item to it. Update data item session id and session metadata.
Also connect t... | def __construct_data_item_reference(self, hardware_source: HardwareSource.HardwareSource, data_channel: HardwareSource.DataChannel):
"""Construct a data item reference.
Construct a data item reference and assign a data item to it. Update data item session id and session metadata.
Also connect t... | [
"Construct",
"a",
"data",
"item",
"reference",
"."
] | nion-software/nionswift | python | https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/DocumentModel.py#L2072-L2113 | [
"def",
"__construct_data_item_reference",
"(",
"self",
",",
"hardware_source",
":",
"HardwareSource",
".",
"HardwareSource",
",",
"data_channel",
":",
"HardwareSource",
".",
"DataChannel",
")",
":",
"session_id",
"=",
"self",
".",
"session_id",
"key",
"=",
"self",
... | d43693eaf057b8683b9638e575000f055fede452 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.