repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/decorators.py | resolve_sid | def resolve_sid(f):
"""View handler decorator that adds SID resolve and PID validation.
- For v1 calls, assume that ``did`` is a pid and raise NotFound exception if it's
not valid.
- For v2 calls, if DID is a valid PID, return it. If not, try to resolve it as a
SID and, if successful, return th... | python | def resolve_sid(f):
"""View handler decorator that adds SID resolve and PID validation.
- For v1 calls, assume that ``did`` is a pid and raise NotFound exception if it's
not valid.
- For v2 calls, if DID is a valid PID, return it. If not, try to resolve it as a
SID and, if successful, return th... | [
"def",
"resolve_sid",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"request",
",",
"did",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"pid",
"=",
"resolve_sid_func",
"(",
"request",
",",
"did",
... | View handler decorator that adds SID resolve and PID validation.
- For v1 calls, assume that ``did`` is a pid and raise NotFound exception if it's
not valid.
- For v2 calls, if DID is a valid PID, return it. If not, try to resolve it as a
SID and, if successful, return the new PID. Else, raise NotF... | [
"View",
"handler",
"decorator",
"that",
"adds",
"SID",
"resolve",
"and",
"PID",
"validation",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/decorators.py#L39-L54 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/decorators.py | decode_did | def decode_did(f):
"""View handler decorator that decodes "%2f" ("/") in SID or PID extracted from URL
path segment by Django."""
@functools.wraps(f)
def wrapper(request, did, *args, **kwargs):
return f(request, decode_path_segment(did), *args, **kwargs)
return wrapper | python | def decode_did(f):
"""View handler decorator that decodes "%2f" ("/") in SID or PID extracted from URL
path segment by Django."""
@functools.wraps(f)
def wrapper(request, did, *args, **kwargs):
return f(request, decode_path_segment(did), *args, **kwargs)
return wrapper | [
"def",
"decode_did",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"request",
",",
"did",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"f",
"(",
"request",
",",
"decode_path_segment",
"(... | View handler decorator that decodes "%2f" ("/") in SID or PID extracted from URL
path segment by Django. | [
"View",
"handler",
"decorator",
"that",
"decodes",
"%2f",
"(",
"/",
")",
"in",
"SID",
"or",
"PID",
"extracted",
"from",
"URL",
"path",
"segment",
"by",
"Django",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/decorators.py#L74-L82 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/decorators.py | trusted_permission | def trusted_permission(f):
"""Access only by D1 infrastructure."""
@functools.wraps(f)
def wrapper(request, *args, **kwargs):
trusted(request)
return f(request, *args, **kwargs)
return wrapper | python | def trusted_permission(f):
"""Access only by D1 infrastructure."""
@functools.wraps(f)
def wrapper(request, *args, **kwargs):
trusted(request)
return f(request, *args, **kwargs)
return wrapper | [
"def",
"trusted_permission",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"trusted",
"(",
"request",
")",
"return",
"f",
"(",
"request",
",... | Access only by D1 infrastructure. | [
"Access",
"only",
"by",
"D1",
"infrastructure",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/decorators.py#L108-L116 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/decorators.py | list_objects_access | def list_objects_access(f):
"""Access to listObjects() controlled by settings.PUBLIC_OBJECT_LIST."""
@functools.wraps(f)
def wrapper(request, *args, **kwargs):
if not django.conf.settings.PUBLIC_OBJECT_LIST:
trusted(request)
return f(request, *args, **kwargs)
return wrapper | python | def list_objects_access(f):
"""Access to listObjects() controlled by settings.PUBLIC_OBJECT_LIST."""
@functools.wraps(f)
def wrapper(request, *args, **kwargs):
if not django.conf.settings.PUBLIC_OBJECT_LIST:
trusted(request)
return f(request, *args, **kwargs)
return wrapper | [
"def",
"list_objects_access",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"django",
".",
"conf",
".",
"settings",
".",
"PUBLI... | Access to listObjects() controlled by settings.PUBLIC_OBJECT_LIST. | [
"Access",
"to",
"listObjects",
"()",
"controlled",
"by",
"settings",
".",
"PUBLIC_OBJECT_LIST",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/decorators.py#L119-L128 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/decorators.py | get_log_records_access | def get_log_records_access(f):
"""Access to getLogRecords() controlled by settings.PUBLIC_LOG_RECORDS."""
@functools.wraps(f)
def wrapper(request, *args, **kwargs):
if not django.conf.settings.PUBLIC_LOG_RECORDS:
trusted(request)
return f(request, *args, **kwargs)
return wr... | python | def get_log_records_access(f):
"""Access to getLogRecords() controlled by settings.PUBLIC_LOG_RECORDS."""
@functools.wraps(f)
def wrapper(request, *args, **kwargs):
if not django.conf.settings.PUBLIC_LOG_RECORDS:
trusted(request)
return f(request, *args, **kwargs)
return wr... | [
"def",
"get_log_records_access",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"django",
".",
"conf",
".",
"settings",
".",
"PU... | Access to getLogRecords() controlled by settings.PUBLIC_LOG_RECORDS. | [
"Access",
"to",
"getLogRecords",
"()",
"controlled",
"by",
"settings",
".",
"PUBLIC_LOG_RECORDS",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/decorators.py#L131-L140 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/decorators.py | assert_create_update_delete_permission | def assert_create_update_delete_permission(f):
"""Access only by subjects with Create/Update/Delete permission and by trusted
infrastructure (CNs)."""
@functools.wraps(f)
def wrapper(request, *args, **kwargs):
d1_gmn.app.auth.assert_create_update_delete_permission(request)
return f(requ... | python | def assert_create_update_delete_permission(f):
"""Access only by subjects with Create/Update/Delete permission and by trusted
infrastructure (CNs)."""
@functools.wraps(f)
def wrapper(request, *args, **kwargs):
d1_gmn.app.auth.assert_create_update_delete_permission(request)
return f(requ... | [
"def",
"assert_create_update_delete_permission",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"d1_gmn",
".",
"app",
".",
"auth",
".",
"assert_c... | Access only by subjects with Create/Update/Delete permission and by trusted
infrastructure (CNs). | [
"Access",
"only",
"by",
"subjects",
"with",
"Create",
"/",
"Update",
"/",
"Delete",
"permission",
"and",
"by",
"trusted",
"infrastructure",
"(",
"CNs",
")",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/decorators.py#L155-L164 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/decorators.py | authenticated | def authenticated(f):
"""Access only with a valid session."""
@functools.wraps(f)
def wrapper(request, *args, **kwargs):
if d1_common.const.SUBJECT_AUTHENTICATED not in request.all_subjects_set:
raise d1_common.types.exceptions.NotAuthorized(
0,
'Access a... | python | def authenticated(f):
"""Access only with a valid session."""
@functools.wraps(f)
def wrapper(request, *args, **kwargs):
if d1_common.const.SUBJECT_AUTHENTICATED not in request.all_subjects_set:
raise d1_common.types.exceptions.NotAuthorized(
0,
'Access a... | [
"def",
"authenticated",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"d1_common",
".",
"const",
".",
"SUBJECT_AUTHENTICATED",
"not",
"i... | Access only with a valid session. | [
"Access",
"only",
"with",
"a",
"valid",
"session",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/decorators.py#L167-L182 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/decorators.py | required_permission | def required_permission(f, level):
"""Assert that subject has access at given level or higher for object."""
@functools.wraps(f)
def wrapper(request, pid, *args, **kwargs):
d1_gmn.app.auth.assert_allowed(request, level, pid)
return f(request, pid, *args, **kwargs)
return wrapper | python | def required_permission(f, level):
"""Assert that subject has access at given level or higher for object."""
@functools.wraps(f)
def wrapper(request, pid, *args, **kwargs):
d1_gmn.app.auth.assert_allowed(request, level, pid)
return f(request, pid, *args, **kwargs)
return wrapper | [
"def",
"required_permission",
"(",
"f",
",",
"level",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"request",
",",
"pid",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"d1_gmn",
".",
"app",
".",
"auth",
"... | Assert that subject has access at given level or higher for object. | [
"Assert",
"that",
"subject",
"has",
"access",
"at",
"given",
"level",
"or",
"higher",
"for",
"object",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/decorators.py#L204-L212 |
DataONEorg/d1_python | lib_client/src/d1_client/baseclient.py | DataONEBaseClient._read_and_deserialize_dataone_type | def _read_and_deserialize_dataone_type(self, response):
"""Given a response body, try to create an instance of a DataONE type.
The return value will be either an instance of a type or a DataONE exception.
"""
try:
return d1_common.xml.deserialize(response.content)
e... | python | def _read_and_deserialize_dataone_type(self, response):
"""Given a response body, try to create an instance of a DataONE type.
The return value will be either an instance of a type or a DataONE exception.
"""
try:
return d1_common.xml.deserialize(response.content)
e... | [
"def",
"_read_and_deserialize_dataone_type",
"(",
"self",
",",
"response",
")",
":",
"try",
":",
"return",
"d1_common",
".",
"xml",
".",
"deserialize",
"(",
"response",
".",
"content",
")",
"except",
"ValueError",
"as",
"e",
":",
"self",
".",
"_raise_service_f... | Given a response body, try to create an instance of a DataONE type.
The return value will be either an instance of a type or a DataONE exception. | [
"Given",
"a",
"response",
"body",
"try",
"to",
"create",
"an",
"instance",
"of",
"a",
"DataONE",
"type",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/baseclient.py#L319-L328 |
DataONEorg/d1_python | lib_client/src/d1_client/baseclient.py | DataONEBaseClient.get | def get(self, pid, stream=False, vendorSpecific=None):
"""Initiate a MNRead.get(). Return a Requests Response object from which the
object bytes can be retrieved.
When ``stream`` is False, Requests buffers the entire object in memory before
returning the Response. This can exhaust avail... | python | def get(self, pid, stream=False, vendorSpecific=None):
"""Initiate a MNRead.get(). Return a Requests Response object from which the
object bytes can be retrieved.
When ``stream`` is False, Requests buffers the entire object in memory before
returning the Response. This can exhaust avail... | [
"def",
"get",
"(",
"self",
",",
"pid",
",",
"stream",
"=",
"False",
",",
"vendorSpecific",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"getResponse",
"(",
"pid",
",",
"stream",
",",
"vendorSpecific",
")",
"return",
"self",
".",
"_read_stream_res... | Initiate a MNRead.get(). Return a Requests Response object from which the
object bytes can be retrieved.
When ``stream`` is False, Requests buffers the entire object in memory before
returning the Response. This can exhaust available memory on the local machine
when retrieving large sci... | [
"Initiate",
"a",
"MNRead",
".",
"get",
"()",
".",
"Return",
"a",
"Requests",
"Response",
"object",
"from",
"which",
"the",
"object",
"bytes",
"can",
"be",
"retrieved",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/baseclient.py#L494-L516 |
DataONEorg/d1_python | lib_client/src/d1_client/baseclient.py | DataONEBaseClient.get_and_save | def get_and_save(
self, pid, sciobj_stream, create_missing_dirs=False, vendorSpecific=None
):
"""Like MNRead.get(), but also retrieve the object bytes and store them in a
stream. This method does not have the potential issue with excessive memory
usage that get() with ``stream``=Fals... | python | def get_and_save(
self, pid, sciobj_stream, create_missing_dirs=False, vendorSpecific=None
):
"""Like MNRead.get(), but also retrieve the object bytes and store them in a
stream. This method does not have the potential issue with excessive memory
usage that get() with ``stream``=Fals... | [
"def",
"get_and_save",
"(",
"self",
",",
"pid",
",",
"sciobj_stream",
",",
"create_missing_dirs",
"=",
"False",
",",
"vendorSpecific",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"get",
"(",
"pid",
",",
"stream",
"=",
"True",
",",
"vendorSpecific"... | Like MNRead.get(), but also retrieve the object bytes and store them in a
stream. This method does not have the potential issue with excessive memory
usage that get() with ``stream``=False has.
Also see MNRead.get(). | [
"Like",
"MNRead",
".",
"get",
"()",
"but",
"also",
"retrieve",
"the",
"object",
"bytes",
"and",
"store",
"them",
"in",
"a",
"stream",
".",
"This",
"method",
"does",
"not",
"have",
"the",
"potential",
"issue",
"with",
"excessive",
"memory",
"usage",
"that",... | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/baseclient.py#L518-L541 |
DataONEorg/d1_python | lib_client/src/d1_client/baseclient.py | DataONEBaseClient.describe | def describe(self, pid, vendorSpecific=None):
"""Note: If the server returns a status code other than 200 OK, a ServiceFailure
will be raised, as this method is based on a HEAD request, which cannot carry
exception information."""
response = self.describeResponse(pid, vendorSpecific=vend... | python | def describe(self, pid, vendorSpecific=None):
"""Note: If the server returns a status code other than 200 OK, a ServiceFailure
will be raised, as this method is based on a HEAD request, which cannot carry
exception information."""
response = self.describeResponse(pid, vendorSpecific=vend... | [
"def",
"describe",
"(",
"self",
",",
"pid",
",",
"vendorSpecific",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"describeResponse",
"(",
"pid",
",",
"vendorSpecific",
"=",
"vendorSpecific",
")",
"return",
"self",
".",
"_read_header_response",
"(",
"r... | Note: If the server returns a status code other than 200 OK, a ServiceFailure
will be raised, as this method is based on a HEAD request, which cannot carry
exception information. | [
"Note",
":",
"If",
"the",
"server",
"returns",
"a",
"status",
"code",
"other",
"than",
"200",
"OK",
"a",
"ServiceFailure",
"will",
"be",
"raised",
"as",
"this",
"method",
"is",
"based",
"on",
"a",
"HEAD",
"request",
"which",
"cannot",
"carry",
"exception",... | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/baseclient.py#L564-L569 |
DataONEorg/d1_python | lib_client/src/d1_client/baseclient.py | DataONEBaseClient.isAuthorized | def isAuthorized(self, pid, action, vendorSpecific=None):
"""Return True if user is allowed to perform ``action`` on ``pid``, else
False."""
response = self.isAuthorizedResponse(pid, action, vendorSpecific)
return self._read_boolean_401_response(response) | python | def isAuthorized(self, pid, action, vendorSpecific=None):
"""Return True if user is allowed to perform ``action`` on ``pid``, else
False."""
response = self.isAuthorizedResponse(pid, action, vendorSpecific)
return self._read_boolean_401_response(response) | [
"def",
"isAuthorized",
"(",
"self",
",",
"pid",
",",
"action",
",",
"vendorSpecific",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"isAuthorizedResponse",
"(",
"pid",
",",
"action",
",",
"vendorSpecific",
")",
"return",
"self",
".",
"_read_boolean_40... | Return True if user is allowed to perform ``action`` on ``pid``, else
False. | [
"Return",
"True",
"if",
"user",
"is",
"allowed",
"to",
"perform",
"action",
"on",
"pid",
"else",
"False",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/baseclient.py#L675-L679 |
genialis/resolwe | resolwe/rest/serializers.py | SelectiveFieldMixin.fields | def fields(self):
"""Filter fields based on request query parameters."""
fields = super().fields
return apply_subfield_projection(self, copy.copy(fields)) | python | def fields(self):
"""Filter fields based on request query parameters."""
fields = super().fields
return apply_subfield_projection(self, copy.copy(fields)) | [
"def",
"fields",
"(",
"self",
")",
":",
"fields",
"=",
"super",
"(",
")",
".",
"fields",
"return",
"apply_subfield_projection",
"(",
"self",
",",
"copy",
".",
"copy",
"(",
"fields",
")",
")"
] | Filter fields based on request query parameters. | [
"Filter",
"fields",
"based",
"on",
"request",
"query",
"parameters",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/rest/serializers.py#L11-L14 |
genialis/resolwe | resolwe/flow/utils/iterators.py | iterate_fields | def iterate_fields(fields, schema, path_prefix=None):
"""Iterate over all field values sub-fields.
This will iterate over all field values. Some fields defined in the schema
might not be visited.
:param fields: field values to iterate over
:type fields: dict
:param schema: schema to iterate ov... | python | def iterate_fields(fields, schema, path_prefix=None):
"""Iterate over all field values sub-fields.
This will iterate over all field values. Some fields defined in the schema
might not be visited.
:param fields: field values to iterate over
:type fields: dict
:param schema: schema to iterate ov... | [
"def",
"iterate_fields",
"(",
"fields",
",",
"schema",
",",
"path_prefix",
"=",
"None",
")",
":",
"if",
"path_prefix",
"is",
"not",
"None",
"and",
"path_prefix",
"!=",
"''",
"and",
"path_prefix",
"[",
"-",
"1",
"]",
"!=",
"'.'",
":",
"path_prefix",
"+=",... | Iterate over all field values sub-fields.
This will iterate over all field values. Some fields defined in the schema
might not be visited.
:param fields: field values to iterate over
:type fields: dict
:param schema: schema to iterate over
:type schema: dict
:return: (field schema, field v... | [
"Iterate",
"over",
"all",
"field",
"values",
"sub",
"-",
"fields",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/iterators.py#L5-L32 |
genialis/resolwe | resolwe/flow/utils/iterators.py | iterate_schema | def iterate_schema(fields, schema, path_prefix=''):
"""Iterate over all schema sub-fields.
This will iterate over all field definitions in the schema. Some field v
alues might be None.
:param fields: field values to iterate over
:type fields: dict
:param schema: schema to iterate over
:typ... | python | def iterate_schema(fields, schema, path_prefix=''):
"""Iterate over all schema sub-fields.
This will iterate over all field definitions in the schema. Some field v
alues might be None.
:param fields: field values to iterate over
:type fields: dict
:param schema: schema to iterate over
:typ... | [
"def",
"iterate_schema",
"(",
"fields",
",",
"schema",
",",
"path_prefix",
"=",
"''",
")",
":",
"if",
"path_prefix",
"and",
"path_prefix",
"[",
"-",
"1",
"]",
"!=",
"'.'",
":",
"path_prefix",
"+=",
"'.'",
"for",
"field_schema",
"in",
"schema",
":",
"name... | Iterate over all schema sub-fields.
This will iterate over all field definitions in the schema. Some field v
alues might be None.
:param fields: field values to iterate over
:type fields: dict
:param schema: schema to iterate over
:type schema: dict
:param path_prefix: dot separated path p... | [
"Iterate",
"over",
"all",
"schema",
"sub",
"-",
"fields",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/iterators.py#L35-L61 |
genialis/resolwe | resolwe/flow/utils/iterators.py | iterate_dict | def iterate_dict(container, exclude=None, path=None):
"""Iterate over a nested dictionary.
The dictionary is iterated over in a depth first manner.
:param container: Dictionary to iterate over
:param exclude: Optional callable, which is given key and value as
arguments and may return True to s... | python | def iterate_dict(container, exclude=None, path=None):
"""Iterate over a nested dictionary.
The dictionary is iterated over in a depth first manner.
:param container: Dictionary to iterate over
:param exclude: Optional callable, which is given key and value as
arguments and may return True to s... | [
"def",
"iterate_dict",
"(",
"container",
",",
"exclude",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"[",
"]",
"for",
"key",
",",
"value",
"in",
"container",
".",
"items",
"(",
")",
":",
"if",
"c... | Iterate over a nested dictionary.
The dictionary is iterated over in a depth first manner.
:param container: Dictionary to iterate over
:param exclude: Optional callable, which is given key and value as
arguments and may return True to stop iteration of that branch
:return: (path, key, value) ... | [
"Iterate",
"over",
"a",
"nested",
"dictionary",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/iterators.py#L64-L85 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/middleware/session_cert.py | get_subjects | def get_subjects(request):
"""Get all subjects in the certificate.
- Returns: primary_str (primary subject), equivalent_set (equivalent identities,
groups and group memberships)
- The primary subject is the certificate subject DN, serialized to a DataONE
compliant subject string.
"""
i... | python | def get_subjects(request):
"""Get all subjects in the certificate.
- Returns: primary_str (primary subject), equivalent_set (equivalent identities,
groups and group memberships)
- The primary subject is the certificate subject DN, serialized to a DataONE
compliant subject string.
"""
i... | [
"def",
"get_subjects",
"(",
"request",
")",
":",
"if",
"_is_certificate_provided",
"(",
"request",
")",
":",
"try",
":",
"return",
"get_authenticated_subjects",
"(",
"request",
".",
"META",
"[",
"'SSL_CLIENT_CERT'",
"]",
")",
"except",
"Exception",
"as",
"e",
... | Get all subjects in the certificate.
- Returns: primary_str (primary subject), equivalent_set (equivalent identities,
groups and group memberships)
- The primary subject is the certificate subject DN, serialized to a DataONE
compliant subject string. | [
"Get",
"all",
"subjects",
"in",
"the",
"certificate",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/middleware/session_cert.py#L38-L56 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/middleware/session_cert.py | get_authenticated_subjects | def get_authenticated_subjects(cert_pem):
"""Return primary subject and set of equivalents authenticated by certificate.
- ``cert_pem`` can be str or bytes
"""
if isinstance(cert_pem, str):
cert_pem = cert_pem.encode('utf-8')
return d1_common.cert.subjects.extract_subjects(cert_pem) | python | def get_authenticated_subjects(cert_pem):
"""Return primary subject and set of equivalents authenticated by certificate.
- ``cert_pem`` can be str or bytes
"""
if isinstance(cert_pem, str):
cert_pem = cert_pem.encode('utf-8')
return d1_common.cert.subjects.extract_subjects(cert_pem) | [
"def",
"get_authenticated_subjects",
"(",
"cert_pem",
")",
":",
"if",
"isinstance",
"(",
"cert_pem",
",",
"str",
")",
":",
"cert_pem",
"=",
"cert_pem",
".",
"encode",
"(",
"'utf-8'",
")",
"return",
"d1_common",
".",
"cert",
".",
"subjects",
".",
"extract_sub... | Return primary subject and set of equivalents authenticated by certificate.
- ``cert_pem`` can be str or bytes | [
"Return",
"primary",
"subject",
"and",
"set",
"of",
"equivalents",
"authenticated",
"by",
"certificate",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/middleware/session_cert.py#L59-L67 |
genialis/resolwe | resolwe/permissions/mixins.py | ResolwePermissionsMixin.get_serializer_class | def get_serializer_class(self):
"""Augment base serializer class.
Include permissions information with objects.
"""
base_class = super().get_serializer_class()
class SerializerWithPermissions(base_class):
"""Augment serializer class."""
def get_fields(... | python | def get_serializer_class(self):
"""Augment base serializer class.
Include permissions information with objects.
"""
base_class = super().get_serializer_class()
class SerializerWithPermissions(base_class):
"""Augment serializer class."""
def get_fields(... | [
"def",
"get_serializer_class",
"(",
"self",
")",
":",
"base_class",
"=",
"super",
"(",
")",
".",
"get_serializer_class",
"(",
")",
"class",
"SerializerWithPermissions",
"(",
"base_class",
")",
":",
"\"\"\"Augment serializer class.\"\"\"",
"def",
"get_fields",
"(",
"... | Augment base serializer class.
Include permissions information with objects. | [
"Augment",
"base",
"serializer",
"class",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/permissions/mixins.py#L31-L58 |
genialis/resolwe | resolwe/permissions/mixins.py | ResolwePermissionsMixin.detail_permissions | def detail_permissions(self, request, pk=None):
"""Get or set permissions API endpoint."""
obj = self.get_object()
if request.method == 'POST':
content_type = ContentType.objects.get_for_model(obj)
payload = request.data
share_content = strtobool(payload.pop(... | python | def detail_permissions(self, request, pk=None):
"""Get or set permissions API endpoint."""
obj = self.get_object()
if request.method == 'POST':
content_type = ContentType.objects.get_for_model(obj)
payload = request.data
share_content = strtobool(payload.pop(... | [
"def",
"detail_permissions",
"(",
"self",
",",
"request",
",",
"pk",
"=",
"None",
")",
":",
"obj",
"=",
"self",
".",
"get_object",
"(",
")",
"if",
"request",
".",
"method",
"==",
"'POST'",
":",
"content_type",
"=",
"ContentType",
".",
"objects",
".",
"... | Get or set permissions API endpoint. | [
"Get",
"or",
"set",
"permissions",
"API",
"endpoint",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/permissions/mixins.py#L70-L101 |
genialis/resolwe | resolwe/flow/models/collection.py | BaseCollection.save | def save(self, *args, **kwargs):
"""Perform descriptor validation and save object."""
if self.descriptor_schema:
try:
validate_schema(self.descriptor, self.descriptor_schema.schema) # pylint: disable=no-member
self.descriptor_dirty = False
except ... | python | def save(self, *args, **kwargs):
"""Perform descriptor validation and save object."""
if self.descriptor_schema:
try:
validate_schema(self.descriptor, self.descriptor_schema.schema) # pylint: disable=no-member
self.descriptor_dirty = False
except ... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"descriptor_schema",
":",
"try",
":",
"validate_schema",
"(",
"self",
".",
"descriptor",
",",
"self",
".",
"descriptor_schema",
".",
"schema",
")",
"# p... | Perform descriptor validation and save object. | [
"Perform",
"descriptor",
"validation",
"and",
"save",
"object",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/models/collection.py#L40-L51 |
genialis/resolwe | resolwe/flow/models/collection.py | Collection.duplicate | def duplicate(self, contributor=None):
"""Duplicate (make a copy)."""
duplicate = Collection.objects.get(id=self.id)
duplicate.pk = None
duplicate.slug = None
duplicate.name = 'Copy of {}'.format(self.name)
duplicate.duplicated = now()
if contributor:
... | python | def duplicate(self, contributor=None):
"""Duplicate (make a copy)."""
duplicate = Collection.objects.get(id=self.id)
duplicate.pk = None
duplicate.slug = None
duplicate.name = 'Copy of {}'.format(self.name)
duplicate.duplicated = now()
if contributor:
... | [
"def",
"duplicate",
"(",
"self",
",",
"contributor",
"=",
"None",
")",
":",
"duplicate",
"=",
"Collection",
".",
"objects",
".",
"get",
"(",
"id",
"=",
"self",
".",
"id",
")",
"duplicate",
".",
"pk",
"=",
"None",
"duplicate",
".",
"slug",
"=",
"None"... | Duplicate (make a copy). | [
"Duplicate",
"(",
"make",
"a",
"copy",
")",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/models/collection.py#L91-L118 |
wilson-eft/wilson | wilson/util/wetutil.py | _scalar2array | def _scalar2array(d):
"""Convert a dictionary with scalar elements and string indices '_1234'
to a dictionary of arrays. Unspecified entries are np.nan."""
da = {}
for k, v in d.items():
if '_' not in k:
da[k] = v
else:
name = ''.join(k.split('_')[:-1])
... | python | def _scalar2array(d):
"""Convert a dictionary with scalar elements and string indices '_1234'
to a dictionary of arrays. Unspecified entries are np.nan."""
da = {}
for k, v in d.items():
if '_' not in k:
da[k] = v
else:
name = ''.join(k.split('_')[:-1])
... | [
"def",
"_scalar2array",
"(",
"d",
")",
":",
"da",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"d",
".",
"items",
"(",
")",
":",
"if",
"'_'",
"not",
"in",
"k",
":",
"da",
"[",
"k",
"]",
"=",
"v",
"else",
":",
"name",
"=",
"''",
".",
"join",... | Convert a dictionary with scalar elements and string indices '_1234'
to a dictionary of arrays. Unspecified entries are np.nan. | [
"Convert",
"a",
"dictionary",
"with",
"scalar",
"elements",
"and",
"string",
"indices",
"_1234",
"to",
"a",
"dictionary",
"of",
"arrays",
".",
"Unspecified",
"entries",
"are",
"np",
".",
"nan",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/util/wetutil.py#L41-L57 |
wilson-eft/wilson | wilson/util/wetutil.py | _symm_herm | def _symm_herm(C):
"""To get rid of NaNs produced by _scalar2array, symmetrize operators
where C_ijkl = C_jilk*"""
nans = np.isnan(C)
C[nans] = np.einsum('jilk', C)[nans].conj()
return C | python | def _symm_herm(C):
"""To get rid of NaNs produced by _scalar2array, symmetrize operators
where C_ijkl = C_jilk*"""
nans = np.isnan(C)
C[nans] = np.einsum('jilk', C)[nans].conj()
return C | [
"def",
"_symm_herm",
"(",
"C",
")",
":",
"nans",
"=",
"np",
".",
"isnan",
"(",
"C",
")",
"C",
"[",
"nans",
"]",
"=",
"np",
".",
"einsum",
"(",
"'jilk'",
",",
"C",
")",
"[",
"nans",
"]",
".",
"conj",
"(",
")",
"return",
"C"
] | To get rid of NaNs produced by _scalar2array, symmetrize operators
where C_ijkl = C_jilk* | [
"To",
"get",
"rid",
"of",
"NaNs",
"produced",
"by",
"_scalar2array",
"symmetrize",
"operators",
"where",
"C_ijkl",
"=",
"C_jilk",
"*"
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/util/wetutil.py#L60-L65 |
wilson-eft/wilson | wilson/util/wetutil.py | _symm_current | def _symm_current(C):
"""To get rid of NaNs produced by _scalar2array, symmetrize operators
where C_ijkl = C_klij"""
nans = np.isnan(C)
C[nans] = np.einsum('klij', C)[nans]
return C | python | def _symm_current(C):
"""To get rid of NaNs produced by _scalar2array, symmetrize operators
where C_ijkl = C_klij"""
nans = np.isnan(C)
C[nans] = np.einsum('klij', C)[nans]
return C | [
"def",
"_symm_current",
"(",
"C",
")",
":",
"nans",
"=",
"np",
".",
"isnan",
"(",
"C",
")",
"C",
"[",
"nans",
"]",
"=",
"np",
".",
"einsum",
"(",
"'klij'",
",",
"C",
")",
"[",
"nans",
"]",
"return",
"C"
] | To get rid of NaNs produced by _scalar2array, symmetrize operators
where C_ijkl = C_klij | [
"To",
"get",
"rid",
"of",
"NaNs",
"produced",
"by",
"_scalar2array",
"symmetrize",
"operators",
"where",
"C_ijkl",
"=",
"C_klij"
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/util/wetutil.py#L68-L73 |
wilson-eft/wilson | wilson/util/wetutil.py | _antisymm_12 | def _antisymm_12(C):
"""To get rid of NaNs produced by _scalar2array, antisymmetrize the first
two indices of operators where C_ijkl = -C_jikl"""
nans = np.isnan(C)
C[nans] = -np.einsum('jikl', C)[nans]
return C | python | def _antisymm_12(C):
"""To get rid of NaNs produced by _scalar2array, antisymmetrize the first
two indices of operators where C_ijkl = -C_jikl"""
nans = np.isnan(C)
C[nans] = -np.einsum('jikl', C)[nans]
return C | [
"def",
"_antisymm_12",
"(",
"C",
")",
":",
"nans",
"=",
"np",
".",
"isnan",
"(",
"C",
")",
"C",
"[",
"nans",
"]",
"=",
"-",
"np",
".",
"einsum",
"(",
"'jikl'",
",",
"C",
")",
"[",
"nans",
"]",
"return",
"C"
] | To get rid of NaNs produced by _scalar2array, antisymmetrize the first
two indices of operators where C_ijkl = -C_jikl | [
"To",
"get",
"rid",
"of",
"NaNs",
"produced",
"by",
"_scalar2array",
"antisymmetrize",
"the",
"first",
"two",
"indices",
"of",
"operators",
"where",
"C_ijkl",
"=",
"-",
"C_jikl"
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/util/wetutil.py#L75-L80 |
wilson-eft/wilson | wilson/util/wetutil.py | JMS_to_array | def JMS_to_array(C, sectors=None):
"""For a dictionary with JMS Wilson coefficients, return a dictionary
of arrays."""
if sectors is None:
wc_keys = wcxf.Basis['WET', 'JMS'].all_wcs
else:
try:
wc_keys = [k for s in sectors for k in wcxf.Basis['WET', 'JMS'].sectors[s]]
... | python | def JMS_to_array(C, sectors=None):
"""For a dictionary with JMS Wilson coefficients, return a dictionary
of arrays."""
if sectors is None:
wc_keys = wcxf.Basis['WET', 'JMS'].all_wcs
else:
try:
wc_keys = [k for s in sectors for k in wcxf.Basis['WET', 'JMS'].sectors[s]]
... | [
"def",
"JMS_to_array",
"(",
"C",
",",
"sectors",
"=",
"None",
")",
":",
"if",
"sectors",
"is",
"None",
":",
"wc_keys",
"=",
"wcxf",
".",
"Basis",
"[",
"'WET'",
",",
"'JMS'",
"]",
".",
"all_wcs",
"else",
":",
"try",
":",
"wc_keys",
"=",
"[",
"k",
... | For a dictionary with JMS Wilson coefficients, return a dictionary
of arrays. | [
"For",
"a",
"dictionary",
"with",
"JMS",
"Wilson",
"coefficients",
"return",
"a",
"dictionary",
"of",
"arrays",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/util/wetutil.py#L83-L105 |
wilson-eft/wilson | wilson/util/wetutil.py | symmetrize_JMS_dict | def symmetrize_JMS_dict(C):
"""For a dictionary with JMS Wilson coefficients but keys that might not be
in the non-redundant basis, return a dictionary with keys from the basis
and values conjugated if necessary."""
wc_keys = set(wcxf.Basis['WET', 'JMS'].all_wcs)
Cs = {}
for op, v in C.items():
... | python | def symmetrize_JMS_dict(C):
"""For a dictionary with JMS Wilson coefficients but keys that might not be
in the non-redundant basis, return a dictionary with keys from the basis
and values conjugated if necessary."""
wc_keys = set(wcxf.Basis['WET', 'JMS'].all_wcs)
Cs = {}
for op, v in C.items():
... | [
"def",
"symmetrize_JMS_dict",
"(",
"C",
")",
":",
"wc_keys",
"=",
"set",
"(",
"wcxf",
".",
"Basis",
"[",
"'WET'",
",",
"'JMS'",
"]",
".",
"all_wcs",
")",
"Cs",
"=",
"{",
"}",
"for",
"op",
",",
"v",
"in",
"C",
".",
"items",
"(",
")",
":",
"if",
... | For a dictionary with JMS Wilson coefficients but keys that might not be
in the non-redundant basis, return a dictionary with keys from the basis
and values conjugated if necessary. | [
"For",
"a",
"dictionary",
"with",
"JMS",
"Wilson",
"coefficients",
"but",
"keys",
"that",
"might",
"not",
"be",
"in",
"the",
"non",
"-",
"redundant",
"basis",
"return",
"a",
"dictionary",
"with",
"keys",
"from",
"the",
"basis",
"and",
"values",
"conjugated",... | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/util/wetutil.py#L108-L146 |
wilson-eft/wilson | wilson/util/wetutil.py | rotate_down | def rotate_down(C_in, p):
"""Redefinition of all Wilson coefficients in the JMS basis when rotating
down-type quark fields from the flavour to the mass basis.
C_in is expected to be an array-valued dictionary containg a key
for all Wilson coefficient matrices."""
C = C_in.copy()
V = ckmutil.ckm... | python | def rotate_down(C_in, p):
"""Redefinition of all Wilson coefficients in the JMS basis when rotating
down-type quark fields from the flavour to the mass basis.
C_in is expected to be an array-valued dictionary containg a key
for all Wilson coefficient matrices."""
C = C_in.copy()
V = ckmutil.ckm... | [
"def",
"rotate_down",
"(",
"C_in",
",",
"p",
")",
":",
"C",
"=",
"C_in",
".",
"copy",
"(",
")",
"V",
"=",
"ckmutil",
".",
"ckm",
".",
"ckm_tree",
"(",
"p",
"[",
"\"Vus\"",
"]",
",",
"p",
"[",
"\"Vub\"",
"]",
",",
"p",
"[",
"\"Vcb\"",
"]",
","... | Redefinition of all Wilson coefficients in the JMS basis when rotating
down-type quark fields from the flavour to the mass basis.
C_in is expected to be an array-valued dictionary containg a key
for all Wilson coefficient matrices. | [
"Redefinition",
"of",
"all",
"Wilson",
"coefficients",
"in",
"the",
"JMS",
"basis",
"when",
"rotating",
"down",
"-",
"type",
"quark",
"fields",
"from",
"the",
"flavour",
"to",
"the",
"mass",
"basis",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/util/wetutil.py#L149-L211 |
wilson-eft/wilson | wilson/util/wetutil.py | scale_dict_wet | def scale_dict_wet(C):
"""To account for the fact that arXiv:Jenkins:2017jig uses a flavour
non-redundant basis in contrast to WCxf, symmetry factors of two have to
be introduced in several places for operators that are symmetric
under the interchange of two currents."""
return {k: v / _scale_dict[k... | python | def scale_dict_wet(C):
"""To account for the fact that arXiv:Jenkins:2017jig uses a flavour
non-redundant basis in contrast to WCxf, symmetry factors of two have to
be introduced in several places for operators that are symmetric
under the interchange of two currents."""
return {k: v / _scale_dict[k... | [
"def",
"scale_dict_wet",
"(",
"C",
")",
":",
"return",
"{",
"k",
":",
"v",
"/",
"_scale_dict",
"[",
"k",
"]",
"for",
"k",
",",
"v",
"in",
"C",
".",
"items",
"(",
")",
"}"
] | To account for the fact that arXiv:Jenkins:2017jig uses a flavour
non-redundant basis in contrast to WCxf, symmetry factors of two have to
be introduced in several places for operators that are symmetric
under the interchange of two currents. | [
"To",
"account",
"for",
"the",
"fact",
"that",
"arXiv",
":",
"Jenkins",
":",
"2017jig",
"uses",
"a",
"flavour",
"non",
"-",
"redundant",
"basis",
"in",
"contrast",
"to",
"WCxf",
"symmetry",
"factors",
"of",
"two",
"have",
"to",
"be",
"introduced",
"in",
... | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/util/wetutil.py#L232-L237 |
wilson-eft/wilson | wilson/util/wetutil.py | unscale_dict_wet | def unscale_dict_wet(C):
"""Undo the scaling applied in `scale_dict_wet`."""
return {k: _scale_dict[k] * v for k, v in C.items()} | python | def unscale_dict_wet(C):
"""Undo the scaling applied in `scale_dict_wet`."""
return {k: _scale_dict[k] * v for k, v in C.items()} | [
"def",
"unscale_dict_wet",
"(",
"C",
")",
":",
"return",
"{",
"k",
":",
"_scale_dict",
"[",
"k",
"]",
"*",
"v",
"for",
"k",
",",
"v",
"in",
"C",
".",
"items",
"(",
")",
"}"
] | Undo the scaling applied in `scale_dict_wet`. | [
"Undo",
"the",
"scaling",
"applied",
"in",
"scale_dict_wet",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/util/wetutil.py#L240-L242 |
DataONEorg/d1_python | dev_tools/src/d1_dev/update-requirements-txt.py | write_reqs | def write_reqs(req_path, req_list):
"""
Args:
req_path:
req_list:
"""
with open(req_path, 'w') as f:
f.write('\n'.join(req_list) + "\n") | python | def write_reqs(req_path, req_list):
"""
Args:
req_path:
req_list:
"""
with open(req_path, 'w') as f:
f.write('\n'.join(req_list) + "\n") | [
"def",
"write_reqs",
"(",
"req_path",
",",
"req_list",
")",
":",
"with",
"open",
"(",
"req_path",
",",
"'w'",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"'\\n'",
".",
"join",
"(",
"req_list",
")",
"+",
"\"\\n\"",
")"
] | Args:
req_path:
req_list: | [
"Args",
":",
"req_path",
":",
"req_list",
":"
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/dev_tools/src/d1_dev/update-requirements-txt.py#L60-L67 |
genialis/resolwe | resolwe/flow/managers/workload_connectors/local.py | Connector.submit | def submit(self, data, runtime_dir, argv):
"""Run process locally.
For details, see
:meth:`~resolwe.flow.managers.workload_connectors.base.BaseConnector.submit`.
"""
logger.debug(__(
"Connector '{}' running for Data with id {} ({}).",
self.__class__.__mod... | python | def submit(self, data, runtime_dir, argv):
"""Run process locally.
For details, see
:meth:`~resolwe.flow.managers.workload_connectors.base.BaseConnector.submit`.
"""
logger.debug(__(
"Connector '{}' running for Data with id {} ({}).",
self.__class__.__mod... | [
"def",
"submit",
"(",
"self",
",",
"data",
",",
"runtime_dir",
",",
"argv",
")",
":",
"logger",
".",
"debug",
"(",
"__",
"(",
"\"Connector '{}' running for Data with id {} ({}).\"",
",",
"self",
".",
"__class__",
".",
"__module__",
",",
"data",
".",
"id",
",... | Run process locally.
For details, see
:meth:`~resolwe.flow.managers.workload_connectors.base.BaseConnector.submit`. | [
"Run",
"process",
"locally",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/workload_connectors/local.py#L21-L37 |
DataONEorg/d1_python | lib_common/src/d1_common/checksum.py | create_checksum_object_from_stream | def create_checksum_object_from_stream(
f, algorithm=d1_common.const.DEFAULT_CHECKSUM_ALGORITHM
):
"""Calculate the checksum of a stream.
Args:
f: file-like object
Only requirement is a ``read()`` method that returns ``bytes``.
algorithm: str
Checksum algorithm, ``MD5`` or ``SH... | python | def create_checksum_object_from_stream(
f, algorithm=d1_common.const.DEFAULT_CHECKSUM_ALGORITHM
):
"""Calculate the checksum of a stream.
Args:
f: file-like object
Only requirement is a ``read()`` method that returns ``bytes``.
algorithm: str
Checksum algorithm, ``MD5`` or ``SH... | [
"def",
"create_checksum_object_from_stream",
"(",
"f",
",",
"algorithm",
"=",
"d1_common",
".",
"const",
".",
"DEFAULT_CHECKSUM_ALGORITHM",
")",
":",
"checksum_str",
"=",
"calculate_checksum_on_stream",
"(",
"f",
",",
"algorithm",
")",
"checksum_pyxb",
"=",
"d1_common... | Calculate the checksum of a stream.
Args:
f: file-like object
Only requirement is a ``read()`` method that returns ``bytes``.
algorithm: str
Checksum algorithm, ``MD5`` or ``SHA1`` / ``SHA-1``.
Returns:
Populated Checksum PyXB object. | [
"Calculate",
"the",
"checksum",
"of",
"a",
"stream",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/checksum.py#L43-L62 |
DataONEorg/d1_python | lib_common/src/d1_common/checksum.py | create_checksum_object_from_iterator | def create_checksum_object_from_iterator(
itr, algorithm=d1_common.const.DEFAULT_CHECKSUM_ALGORITHM
):
"""Calculate the checksum of an iterator.
Args:
itr: iterable
Object which supports the iterator protocol.
algorithm: str
Checksum algorithm, ``MD5`` or ``SHA1`` / ``SHA-1``.
... | python | def create_checksum_object_from_iterator(
itr, algorithm=d1_common.const.DEFAULT_CHECKSUM_ALGORITHM
):
"""Calculate the checksum of an iterator.
Args:
itr: iterable
Object which supports the iterator protocol.
algorithm: str
Checksum algorithm, ``MD5`` or ``SHA1`` / ``SHA-1``.
... | [
"def",
"create_checksum_object_from_iterator",
"(",
"itr",
",",
"algorithm",
"=",
"d1_common",
".",
"const",
".",
"DEFAULT_CHECKSUM_ALGORITHM",
")",
":",
"checksum_str",
"=",
"calculate_checksum_on_iterator",
"(",
"itr",
",",
"algorithm",
")",
"checksum_pyxb",
"=",
"d... | Calculate the checksum of an iterator.
Args:
itr: iterable
Object which supports the iterator protocol.
algorithm: str
Checksum algorithm, ``MD5`` or ``SHA1`` / ``SHA-1``.
Returns:
Populated Checksum PyXB object. | [
"Calculate",
"the",
"checksum",
"of",
"an",
"iterator",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/checksum.py#L65-L84 |
DataONEorg/d1_python | lib_common/src/d1_common/checksum.py | create_checksum_object_from_bytes | def create_checksum_object_from_bytes(
b, algorithm=d1_common.const.DEFAULT_CHECKSUM_ALGORITHM
):
"""Calculate the checksum of ``bytes``.
Warning:
This method requires the entire object to be buffered in (virtual) memory, which
should normally be avoided in production code.
Args:
b: ... | python | def create_checksum_object_from_bytes(
b, algorithm=d1_common.const.DEFAULT_CHECKSUM_ALGORITHM
):
"""Calculate the checksum of ``bytes``.
Warning:
This method requires the entire object to be buffered in (virtual) memory, which
should normally be avoided in production code.
Args:
b: ... | [
"def",
"create_checksum_object_from_bytes",
"(",
"b",
",",
"algorithm",
"=",
"d1_common",
".",
"const",
".",
"DEFAULT_CHECKSUM_ALGORITHM",
")",
":",
"checksum_str",
"=",
"calculate_checksum_on_bytes",
"(",
"b",
",",
"algorithm",
")",
"checksum_pyxb",
"=",
"d1_common",... | Calculate the checksum of ``bytes``.
Warning:
This method requires the entire object to be buffered in (virtual) memory, which
should normally be avoided in production code.
Args:
b: bytes
Raw bytes
algorithm: str
Checksum algorithm, ``MD5`` or ``SHA1`` / ``SHA-1``.
... | [
"Calculate",
"the",
"checksum",
"of",
"bytes",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/checksum.py#L87-L110 |
DataONEorg/d1_python | lib_common/src/d1_common/checksum.py | calculate_checksum_on_stream | def calculate_checksum_on_stream(
f,
algorithm=d1_common.const.DEFAULT_CHECKSUM_ALGORITHM,
chunk_size=DEFAULT_CHUNK_SIZE,
):
"""Calculate the checksum of a stream.
Args:
f: file-like object
Only requirement is a ``read()`` method that returns ``bytes``.
algorithm: str
C... | python | def calculate_checksum_on_stream(
f,
algorithm=d1_common.const.DEFAULT_CHECKSUM_ALGORITHM,
chunk_size=DEFAULT_CHUNK_SIZE,
):
"""Calculate the checksum of a stream.
Args:
f: file-like object
Only requirement is a ``read()`` method that returns ``bytes``.
algorithm: str
C... | [
"def",
"calculate_checksum_on_stream",
"(",
"f",
",",
"algorithm",
"=",
"d1_common",
".",
"const",
".",
"DEFAULT_CHECKSUM_ALGORITHM",
",",
"chunk_size",
"=",
"DEFAULT_CHUNK_SIZE",
",",
")",
":",
"checksum_calc",
"=",
"get_checksum_calculator_by_dataone_designator",
"(",
... | Calculate the checksum of a stream.
Args:
f: file-like object
Only requirement is a ``read()`` method that returns ``bytes``.
algorithm: str
Checksum algorithm, ``MD5`` or ``SHA1`` / ``SHA-1``.
chunk_size : int
Number of bytes to read from the file and add to the checksu... | [
"Calculate",
"the",
"checksum",
"of",
"a",
"stream",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/checksum.py#L116-L143 |
DataONEorg/d1_python | lib_common/src/d1_common/checksum.py | calculate_checksum_on_iterator | def calculate_checksum_on_iterator(
itr, algorithm=d1_common.const.DEFAULT_CHECKSUM_ALGORITHM
):
"""Calculate the checksum of an iterator.
Args:
itr: iterable
Object which supports the iterator protocol.
algorithm: str
Checksum algorithm, ``MD5`` or ``SHA1`` / ``SHA-1``.
R... | python | def calculate_checksum_on_iterator(
itr, algorithm=d1_common.const.DEFAULT_CHECKSUM_ALGORITHM
):
"""Calculate the checksum of an iterator.
Args:
itr: iterable
Object which supports the iterator protocol.
algorithm: str
Checksum algorithm, ``MD5`` or ``SHA1`` / ``SHA-1``.
R... | [
"def",
"calculate_checksum_on_iterator",
"(",
"itr",
",",
"algorithm",
"=",
"d1_common",
".",
"const",
".",
"DEFAULT_CHECKSUM_ALGORITHM",
")",
":",
"checksum_calc",
"=",
"get_checksum_calculator_by_dataone_designator",
"(",
"algorithm",
")",
"for",
"chunk",
"in",
"itr",... | Calculate the checksum of an iterator.
Args:
itr: iterable
Object which supports the iterator protocol.
algorithm: str
Checksum algorithm, ``MD5`` or ``SHA1`` / ``SHA-1``.
Returns:
str : Checksum as a hexadecimal string, with length decided by the algorithm. | [
"Calculate",
"the",
"checksum",
"of",
"an",
"iterator",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/checksum.py#L146-L165 |
DataONEorg/d1_python | lib_common/src/d1_common/checksum.py | calculate_checksum_on_bytes | def calculate_checksum_on_bytes(
b, algorithm=d1_common.const.DEFAULT_CHECKSUM_ALGORITHM
):
"""Calculate the checksum of ``bytes``.
Warning: This method requires the entire object to be buffered in (virtual) memory,
which should normally be avoided in production code.
Args:
b: bytes
... | python | def calculate_checksum_on_bytes(
b, algorithm=d1_common.const.DEFAULT_CHECKSUM_ALGORITHM
):
"""Calculate the checksum of ``bytes``.
Warning: This method requires the entire object to be buffered in (virtual) memory,
which should normally be avoided in production code.
Args:
b: bytes
... | [
"def",
"calculate_checksum_on_bytes",
"(",
"b",
",",
"algorithm",
"=",
"d1_common",
".",
"const",
".",
"DEFAULT_CHECKSUM_ALGORITHM",
")",
":",
"checksum_calc",
"=",
"get_checksum_calculator_by_dataone_designator",
"(",
"algorithm",
")",
"checksum_calc",
".",
"update",
"... | Calculate the checksum of ``bytes``.
Warning: This method requires the entire object to be buffered in (virtual) memory,
which should normally be avoided in production code.
Args:
b: bytes
Raw bytes
algorithm: str
Checksum algorithm, ``MD5`` or ``SHA1`` / ``SHA-1``.
Retur... | [
"Calculate",
"the",
"checksum",
"of",
"bytes",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/checksum.py#L168-L189 |
DataONEorg/d1_python | lib_common/src/d1_common/checksum.py | are_checksums_equal | def are_checksums_equal(checksum_a_pyxb, checksum_b_pyxb):
"""Determine if checksums are equal.
Args:
checksum_a_pyxb, checksum_b_pyxb: PyXB Checksum objects to compare.
Returns:
bool
- **True**: The checksums contain the same hexadecimal values calculated with
the same algo... | python | def are_checksums_equal(checksum_a_pyxb, checksum_b_pyxb):
"""Determine if checksums are equal.
Args:
checksum_a_pyxb, checksum_b_pyxb: PyXB Checksum objects to compare.
Returns:
bool
- **True**: The checksums contain the same hexadecimal values calculated with
the same algo... | [
"def",
"are_checksums_equal",
"(",
"checksum_a_pyxb",
",",
"checksum_b_pyxb",
")",
":",
"if",
"checksum_a_pyxb",
".",
"algorithm",
"!=",
"checksum_b_pyxb",
".",
"algorithm",
":",
"raise",
"ValueError",
"(",
"'Cannot compare checksums calculated with different algorithms. '",
... | Determine if checksums are equal.
Args:
checksum_a_pyxb, checksum_b_pyxb: PyXB Checksum objects to compare.
Returns:
bool
- **True**: The checksums contain the same hexadecimal values calculated with
the same algorithm. Identical checksums guarantee (for all practical
... | [
"Determine",
"if",
"checksums",
"are",
"equal",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/checksum.py#L195-L220 |
DataONEorg/d1_python | lib_common/src/d1_common/checksum.py | format_checksum | def format_checksum(checksum_pyxb):
"""Create string representation of a PyXB Checksum object.
Args:
PyXB Checksum object
Returns:
str : Combined hexadecimal value and algorithm name.
"""
return '{}/{}'.format(
checksum_pyxb.algorithm.upper().replace('-', ''), checksum_pyxb.va... | python | def format_checksum(checksum_pyxb):
"""Create string representation of a PyXB Checksum object.
Args:
PyXB Checksum object
Returns:
str : Combined hexadecimal value and algorithm name.
"""
return '{}/{}'.format(
checksum_pyxb.algorithm.upper().replace('-', ''), checksum_pyxb.va... | [
"def",
"format_checksum",
"(",
"checksum_pyxb",
")",
":",
"return",
"'{}/{}'",
".",
"format",
"(",
"checksum_pyxb",
".",
"algorithm",
".",
"upper",
"(",
")",
".",
"replace",
"(",
"'-'",
",",
"''",
")",
",",
"checksum_pyxb",
".",
"value",
"(",
")",
".",
... | Create string representation of a PyXB Checksum object.
Args:
PyXB Checksum object
Returns:
str : Combined hexadecimal value and algorithm name. | [
"Create",
"string",
"representation",
"of",
"a",
"PyXB",
"Checksum",
"object",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/checksum.py#L289-L301 |
genialis/resolwe | resolwe/flow/management/commands/runlistener.py | Command.handle | def handle(self, *args, **kwargs):
"""Run the executor listener. This method never returns."""
listener = ExecutorListener(redis_params=getattr(settings, 'FLOW_MANAGER', {}).get('REDIS_CONNECTION', {}))
def _killer(signum, frame):
"""Kill the listener on receipt of a signal."""
... | python | def handle(self, *args, **kwargs):
"""Run the executor listener. This method never returns."""
listener = ExecutorListener(redis_params=getattr(settings, 'FLOW_MANAGER', {}).get('REDIS_CONNECTION', {}))
def _killer(signum, frame):
"""Kill the listener on receipt of a signal."""
... | [
"def",
"handle",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"listener",
"=",
"ExecutorListener",
"(",
"redis_params",
"=",
"getattr",
"(",
"settings",
",",
"'FLOW_MANAGER'",
",",
"{",
"}",
")",
".",
"get",
"(",
"'REDIS_CONNECTION'"... | Run the executor listener. This method never returns. | [
"Run",
"the",
"executor",
"listener",
".",
"This",
"method",
"never",
"returns",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/management/commands/runlistener.py#L33-L52 |
genialis/resolwe | resolwe/rest/projection.py | apply_subfield_projection | def apply_subfield_projection(field, value, deep=False):
"""Apply projection from request context.
The passed dictionary may be mutated.
:param field: An instance of `Field` or `Serializer`
:type field: `Field` or `Serializer`
:param value: Dictionary to apply the projection to
:type value: di... | python | def apply_subfield_projection(field, value, deep=False):
"""Apply projection from request context.
The passed dictionary may be mutated.
:param field: An instance of `Field` or `Serializer`
:type field: `Field` or `Serializer`
:param value: Dictionary to apply the projection to
:type value: di... | [
"def",
"apply_subfield_projection",
"(",
"field",
",",
"value",
",",
"deep",
"=",
"False",
")",
":",
"# Discover the root manually. We cannot use either `self.root` or `self.context`",
"# due to a bug with incorrect caching (see DRF issue #5087).",
"prefix",
"=",
"[",
"]",
"root"... | Apply projection from request context.
The passed dictionary may be mutated.
:param field: An instance of `Field` or `Serializer`
:type field: `Field` or `Serializer`
:param value: Dictionary to apply the projection to
:type value: dict
:param deep: Also process all deep projections
:type ... | [
"Apply",
"projection",
"from",
"request",
"context",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/rest/projection.py#L8-L64 |
genialis/resolwe | resolwe/rest/projection.py | apply_projection | def apply_projection(projection, value):
"""Apply projection."""
if isinstance(value, Sequence):
# Apply projection to each item in the list.
return [
apply_projection(projection, item)
for item in value
]
elif not isinstance(value, Mapping):
# Non-dic... | python | def apply_projection(projection, value):
"""Apply projection."""
if isinstance(value, Sequence):
# Apply projection to each item in the list.
return [
apply_projection(projection, item)
for item in value
]
elif not isinstance(value, Mapping):
# Non-dic... | [
"def",
"apply_projection",
"(",
"projection",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"Sequence",
")",
":",
"# Apply projection to each item in the list.",
"return",
"[",
"apply_projection",
"(",
"projection",
",",
"item",
")",
"for",
"item"... | Apply projection. | [
"Apply",
"projection",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/rest/projection.py#L67-L96 |
genialis/resolwe | resolwe/flow/serializers/relation.py | RelationSerializer._create_partitions | def _create_partitions(self, instance, partitions):
"""Create partitions."""
for partition in partitions:
RelationPartition.objects.create(
relation=instance,
entity=partition['entity'],
label=partition.get('label', None),
posit... | python | def _create_partitions(self, instance, partitions):
"""Create partitions."""
for partition in partitions:
RelationPartition.objects.create(
relation=instance,
entity=partition['entity'],
label=partition.get('label', None),
posit... | [
"def",
"_create_partitions",
"(",
"self",
",",
"instance",
",",
"partitions",
")",
":",
"for",
"partition",
"in",
"partitions",
":",
"RelationPartition",
".",
"objects",
".",
"create",
"(",
"relation",
"=",
"instance",
",",
"entity",
"=",
"partition",
"[",
"... | Create partitions. | [
"Create",
"partitions",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/serializers/relation.py#L57-L65 |
genialis/resolwe | resolwe/flow/serializers/relation.py | RelationSerializer.create | def create(self, validated_data):
"""Create ``Relation`` object and add partitions of ``Entities``."""
# `partitions` field is renamed to `relationpartition_set` based on source of nested serializer
partitions = validated_data.pop('relationpartition_set')
with transaction.atomic():
... | python | def create(self, validated_data):
"""Create ``Relation`` object and add partitions of ``Entities``."""
# `partitions` field is renamed to `relationpartition_set` based on source of nested serializer
partitions = validated_data.pop('relationpartition_set')
with transaction.atomic():
... | [
"def",
"create",
"(",
"self",
",",
"validated_data",
")",
":",
"# `partitions` field is renamed to `relationpartition_set` based on source of nested serializer",
"partitions",
"=",
"validated_data",
".",
"pop",
"(",
"'relationpartition_set'",
")",
"with",
"transaction",
".",
... | Create ``Relation`` object and add partitions of ``Entities``. | [
"Create",
"Relation",
"object",
"and",
"add",
"partitions",
"of",
"Entities",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/serializers/relation.py#L67-L76 |
genialis/resolwe | resolwe/flow/serializers/relation.py | RelationSerializer.update | def update(self, instance, validated_data):
"""Update ``Relation``."""
# `partitions` field is renamed to `relationpartition_set` based on source of nested serializer
partitions = validated_data.pop('relationpartition_set', None)
with transaction.atomic():
instance = super()... | python | def update(self, instance, validated_data):
"""Update ``Relation``."""
# `partitions` field is renamed to `relationpartition_set` based on source of nested serializer
partitions = validated_data.pop('relationpartition_set', None)
with transaction.atomic():
instance = super()... | [
"def",
"update",
"(",
"self",
",",
"instance",
",",
"validated_data",
")",
":",
"# `partitions` field is renamed to `relationpartition_set` based on source of nested serializer",
"partitions",
"=",
"validated_data",
".",
"pop",
"(",
"'relationpartition_set'",
",",
"None",
")"... | Update ``Relation``. | [
"Update",
"Relation",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/serializers/relation.py#L78-L91 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/util.py | output | def output(file_like_object, path, verbose=False):
"""Display or save file like object."""
if not path:
for line in file_like_object:
if verbose:
print_info(line.rstrip())
else:
print(line.rstrip())
else:
try:
object_file = ... | python | def output(file_like_object, path, verbose=False):
"""Display or save file like object."""
if not path:
for line in file_like_object:
if verbose:
print_info(line.rstrip())
else:
print(line.rstrip())
else:
try:
object_file = ... | [
"def",
"output",
"(",
"file_like_object",
",",
"path",
",",
"verbose",
"=",
"False",
")",
":",
"if",
"not",
"path",
":",
"for",
"line",
"in",
"file_like_object",
":",
"if",
"verbose",
":",
"print_info",
"(",
"line",
".",
"rstrip",
"(",
")",
")",
"else"... | Display or save file like object. | [
"Display",
"or",
"save",
"file",
"like",
"object",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/util.py#L61-L81 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/util.py | _print_level | def _print_level(level, msg):
"""Print the information in Unicode safe manner."""
for l in str(msg.rstrip()).split("\n"):
print("{0:<9s}{1}".format(level, str(l))) | python | def _print_level(level, msg):
"""Print the information in Unicode safe manner."""
for l in str(msg.rstrip()).split("\n"):
print("{0:<9s}{1}".format(level, str(l))) | [
"def",
"_print_level",
"(",
"level",
",",
"msg",
")",
":",
"for",
"l",
"in",
"str",
"(",
"msg",
".",
"rstrip",
"(",
")",
")",
".",
"split",
"(",
"\"\\n\"",
")",
":",
"print",
"(",
"\"{0:<9s}{1}\"",
".",
"format",
"(",
"level",
",",
"str",
"(",
"l... | Print the information in Unicode safe manner. | [
"Print",
"the",
"information",
"in",
"Unicode",
"safe",
"manner",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/util.py#L147-L150 |
genialis/resolwe | resolwe/flow/utils/docs/autoprocess.py | get_process_definition_start | def get_process_definition_start(fname, slug):
"""Find the first line of process definition.
The first line of process definition is the line with a slug.
:param str fname: Path to filename with processes
:param string slug: process slug
:return: line where the process definiton starts
:rtype:... | python | def get_process_definition_start(fname, slug):
"""Find the first line of process definition.
The first line of process definition is the line with a slug.
:param str fname: Path to filename with processes
:param string slug: process slug
:return: line where the process definiton starts
:rtype:... | [
"def",
"get_process_definition_start",
"(",
"fname",
",",
"slug",
")",
":",
"with",
"open",
"(",
"fname",
")",
"as",
"file_",
":",
"for",
"i",
",",
"line",
"in",
"enumerate",
"(",
"file_",
")",
":",
"if",
"re",
".",
"search",
"(",
"r'slug:\\s*{}'",
"."... | Find the first line of process definition.
The first line of process definition is the line with a slug.
:param str fname: Path to filename with processes
:param string slug: process slug
:return: line where the process definiton starts
:rtype: int | [
"Find",
"the",
"first",
"line",
"of",
"process",
"definition",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/docs/autoprocess.py#L45-L61 |
genialis/resolwe | resolwe/flow/utils/docs/autoprocess.py | get_processes | def get_processes(process_dir, base_source_uri):
"""Find processes in path.
:param str process_dir: Path to the directory where to search for processes
:param str base_source_uri: Base URL of the source code repository with process definitions
:return: Dictionary of processes where keys are URLs pointi... | python | def get_processes(process_dir, base_source_uri):
"""Find processes in path.
:param str process_dir: Path to the directory where to search for processes
:param str base_source_uri: Base URL of the source code repository with process definitions
:return: Dictionary of processes where keys are URLs pointi... | [
"def",
"get_processes",
"(",
"process_dir",
",",
"base_source_uri",
")",
":",
"global",
"PROCESS_CACHE",
"# pylint: disable=global-statement",
"if",
"PROCESS_CACHE",
"is",
"not",
"None",
":",
"return",
"PROCESS_CACHE",
"all_process_files",
"=",
"[",
"]",
"process_file_e... | Find processes in path.
:param str process_dir: Path to the directory where to search for processes
:param str base_source_uri: Base URL of the source code repository with process definitions
:return: Dictionary of processes where keys are URLs pointing to processes'
source code and values are processe... | [
"Find",
"processes",
"in",
"path",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/docs/autoprocess.py#L64-L109 |
genialis/resolwe | resolwe/flow/utils/docs/autoprocess.py | setup | def setup(app):
"""Register directives.
When sphinx loads the extension (= imports the extension module) it
also executes the setup() function. Setup is the way extension
informs Sphinx about everything that the extension enables: which
config_values are introduced, which custom nodes/directives/ro... | python | def setup(app):
"""Register directives.
When sphinx loads the extension (= imports the extension module) it
also executes the setup() function. Setup is the way extension
informs Sphinx about everything that the extension enables: which
config_values are introduced, which custom nodes/directives/ro... | [
"def",
"setup",
"(",
"app",
")",
":",
"app",
".",
"add_config_value",
"(",
"'autoprocess_process_dir'",
",",
"''",
",",
"'env'",
")",
"app",
".",
"add_config_value",
"(",
"'autoprocess_source_base_url'",
",",
"''",
",",
"'env'",
")",
"app",
".",
"add_config_va... | Register directives.
When sphinx loads the extension (= imports the extension module) it
also executes the setup() function. Setup is the way extension
informs Sphinx about everything that the extension enables: which
config_values are introduced, which custom nodes/directives/roles
and which event... | [
"Register",
"directives",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/docs/autoprocess.py#L414-L437 |
genialis/resolwe | resolwe/flow/utils/docs/autoprocess.py | AutoProcessDirective.make_field | def make_field(self, field_name, field_body):
"""Fill content into nodes.
:param string field_name: Field name of the field
:param field_name: Field body if the field
:type field_name: str or instance of docutils.nodes
:return: field instance filled with given name and body
... | python | def make_field(self, field_name, field_body):
"""Fill content into nodes.
:param string field_name: Field name of the field
:param field_name: Field body if the field
:type field_name: str or instance of docutils.nodes
:return: field instance filled with given name and body
... | [
"def",
"make_field",
"(",
"self",
",",
"field_name",
",",
"field_body",
")",
":",
"name",
"=",
"nodes",
".",
"field_name",
"(",
")",
"name",
"+=",
"nodes",
".",
"Text",
"(",
"field_name",
")",
"paragraph",
"=",
"nodes",
".",
"paragraph",
"(",
")",
"if"... | Fill content into nodes.
:param string field_name: Field name of the field
:param field_name: Field body if the field
:type field_name: str or instance of docutils.nodes
:return: field instance filled with given name and body
:rtype: nodes.field | [
"Fill",
"content",
"into",
"nodes",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/docs/autoprocess.py#L121-L148 |
genialis/resolwe | resolwe/flow/utils/docs/autoprocess.py | AutoProcessDirective.make_properties_list | def make_properties_list(self, field):
"""Fill the ``field`` into a properties list and return it.
:param dict field: the content of the property list to make
:return: field_list instance filled with given field
:rtype: nodes.field_list
"""
properties_list = nodes.field... | python | def make_properties_list(self, field):
"""Fill the ``field`` into a properties list and return it.
:param dict field: the content of the property list to make
:return: field_list instance filled with given field
:rtype: nodes.field_list
"""
properties_list = nodes.field... | [
"def",
"make_properties_list",
"(",
"self",
",",
"field",
")",
":",
"properties_list",
"=",
"nodes",
".",
"field_list",
"(",
")",
"# changing the order of elements in this list affects",
"# the order in which they are displayed",
"property_names",
"=",
"[",
"'label'",
",",
... | Fill the ``field`` into a properties list and return it.
:param dict field: the content of the property list to make
:return: field_list instance filled with given field
:rtype: nodes.field_list | [
"Fill",
"the",
"field",
"into",
"a",
"properties",
"list",
"and",
"return",
"it",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/docs/autoprocess.py#L150-L196 |
genialis/resolwe | resolwe/flow/utils/docs/autoprocess.py | AutoProcessDirective.make_process_header | def make_process_header(self, slug, typ, version, source_uri, description, inputs):
"""Generate a process definition header.
:param str slug: process' slug
:param str typ: process' type
:param str version: process' version
:param str source_uri: url to the process definition
... | python | def make_process_header(self, slug, typ, version, source_uri, description, inputs):
"""Generate a process definition header.
:param str slug: process' slug
:param str typ: process' type
:param str version: process' version
:param str source_uri: url to the process definition
... | [
"def",
"make_process_header",
"(",
"self",
",",
"slug",
",",
"typ",
",",
"version",
",",
"source_uri",
",",
"description",
",",
"inputs",
")",
":",
"node",
"=",
"addnodes",
".",
"desc",
"(",
")",
"signode",
"=",
"addnodes",
".",
"desc_signature",
"(",
"s... | Generate a process definition header.
:param str slug: process' slug
:param str typ: process' type
:param str version: process' version
:param str source_uri: url to the process definition
:param str description: process' description
:param dict inputs: process' inputs | [
"Generate",
"a",
"process",
"definition",
"header",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/docs/autoprocess.py#L198-L242 |
genialis/resolwe | resolwe/flow/utils/docs/autoprocess.py | AutoProcessDirective.make_process_node | def make_process_node(self, process):
"""Fill the content of process definiton node.
:param dict process: process data as given from yaml.load function
:return: process node
"""
name = process['name']
slug = process['slug']
typ = process['type']
version ... | python | def make_process_node(self, process):
"""Fill the content of process definiton node.
:param dict process: process data as given from yaml.load function
:return: process node
"""
name = process['name']
slug = process['slug']
typ = process['type']
version ... | [
"def",
"make_process_node",
"(",
"self",
",",
"process",
")",
":",
"name",
"=",
"process",
"[",
"'name'",
"]",
"slug",
"=",
"process",
"[",
"'slug'",
"]",
"typ",
"=",
"process",
"[",
"'type'",
"]",
"version",
"=",
"process",
"[",
"'version'",
"]",
"des... | Fill the content of process definiton node.
:param dict process: process data as given from yaml.load function
:return: process node | [
"Fill",
"the",
"content",
"of",
"process",
"definiton",
"node",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/docs/autoprocess.py#L244-L295 |
genialis/resolwe | resolwe/flow/utils/docs/autoprocess.py | AutoProcessDirective.run | def run(self):
"""Create a list of process definitions."""
config = self.state.document.settings.env.config
# Get all processes:
processes = get_processes(config.autoprocess_process_dir, config.autoprocess_source_base_url)
process_nodes = []
for process in sorted(proces... | python | def run(self):
"""Create a list of process definitions."""
config = self.state.document.settings.env.config
# Get all processes:
processes = get_processes(config.autoprocess_process_dir, config.autoprocess_source_base_url)
process_nodes = []
for process in sorted(proces... | [
"def",
"run",
"(",
"self",
")",
":",
"config",
"=",
"self",
".",
"state",
".",
"document",
".",
"settings",
".",
"env",
".",
"config",
"# Get all processes:",
"processes",
"=",
"get_processes",
"(",
"config",
".",
"autoprocess_process_dir",
",",
"config",
".... | Create a list of process definitions. | [
"Create",
"a",
"list",
"of",
"process",
"definitions",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/docs/autoprocess.py#L297-L308 |
genialis/resolwe | resolwe/flow/utils/docs/autoprocess.py | AutoProcessCategoryDirective.run | def run(self):
"""Create a category tree."""
config = self.state.document.settings.env.config
# Group processes by category
processes = get_processes(config.autoprocess_process_dir, config.autoprocess_source_base_url)
processes.sort(key=itemgetter('category'))
categorize... | python | def run(self):
"""Create a category tree."""
config = self.state.document.settings.env.config
# Group processes by category
processes = get_processes(config.autoprocess_process_dir, config.autoprocess_source_base_url)
processes.sort(key=itemgetter('category'))
categorize... | [
"def",
"run",
"(",
"self",
")",
":",
"config",
"=",
"self",
".",
"state",
".",
"document",
".",
"settings",
".",
"env",
".",
"config",
"# Group processes by category",
"processes",
"=",
"get_processes",
"(",
"config",
".",
"autoprocess_process_dir",
",",
"conf... | Create a category tree. | [
"Create",
"a",
"category",
"tree",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/docs/autoprocess.py#L320-L371 |
genialis/resolwe | resolwe/flow/utils/docs/autoprocess.py | AutoProcessTypesDirective.run | def run(self):
"""Create a type list."""
config = self.state.document.settings.env.config
# Group processes by category
processes = get_processes(config.autoprocess_process_dir, config.autoprocess_source_base_url)
processes.sort(key=itemgetter('type'))
processes_by_types... | python | def run(self):
"""Create a type list."""
config = self.state.document.settings.env.config
# Group processes by category
processes = get_processes(config.autoprocess_process_dir, config.autoprocess_source_base_url)
processes.sort(key=itemgetter('type'))
processes_by_types... | [
"def",
"run",
"(",
"self",
")",
":",
"config",
"=",
"self",
".",
"state",
".",
"document",
".",
"settings",
".",
"env",
".",
"config",
"# Group processes by category",
"processes",
"=",
"get_processes",
"(",
"config",
".",
"autoprocess_process_dir",
",",
"conf... | Create a type list. | [
"Create",
"a",
"type",
"list",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/docs/autoprocess.py#L383-L411 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/management/commands/async_client.py | AsyncDataONEClient.get | async def get(self, file_stream, pid, vendor_specific=None):
"""MNRead.get()
Retrieve the SciObj bytes and write them to a file or other stream.
Args:
file_stream: Open file-like object
Stream to which the SciObj bytes will be written.
pid: str
... | python | async def get(self, file_stream, pid, vendor_specific=None):
"""MNRead.get()
Retrieve the SciObj bytes and write them to a file or other stream.
Args:
file_stream: Open file-like object
Stream to which the SciObj bytes will be written.
pid: str
... | [
"async",
"def",
"get",
"(",
"self",
",",
"file_stream",
",",
"pid",
",",
"vendor_specific",
"=",
"None",
")",
":",
"async",
"with",
"await",
"self",
".",
"_retry_request",
"(",
"\"get\"",
",",
"[",
"\"object\"",
",",
"pid",
"]",
",",
"vendor_specific",
"... | MNRead.get()
Retrieve the SciObj bytes and write them to a file or other stream.
Args:
file_stream: Open file-like object
Stream to which the SciObj bytes will be written.
pid: str
vendor_specific: dict
Custom HTTP headers to includ... | [
"MNRead",
".",
"get",
"()"
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/async_client.py#L93-L116 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/management/commands/async_client.py | AsyncDataONEClient.synchronize | async def synchronize(self, pid, vendor_specific=None):
"""Send an object synchronization request to the CN."""
return await self._request_pyxb(
"post",
["synchronize", pid],
{},
mmp_dict={"pid": pid},
vendor_specific=vendor_specific,
) | python | async def synchronize(self, pid, vendor_specific=None):
"""Send an object synchronization request to the CN."""
return await self._request_pyxb(
"post",
["synchronize", pid],
{},
mmp_dict={"pid": pid},
vendor_specific=vendor_specific,
) | [
"async",
"def",
"synchronize",
"(",
"self",
",",
"pid",
",",
"vendor_specific",
"=",
"None",
")",
":",
"return",
"await",
"self",
".",
"_request_pyxb",
"(",
"\"post\"",
",",
"[",
"\"synchronize\"",
",",
"pid",
"]",
",",
"{",
"}",
",",
"mmp_dict",
"=",
... | Send an object synchronization request to the CN. | [
"Send",
"an",
"object",
"synchronization",
"request",
"to",
"the",
"CN",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/async_client.py#L182-L190 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/management/commands/async_client.py | AsyncDataONEClient._datetime_to_iso8601 | def _datetime_to_iso8601(self, query_dict):
"""Encode any datetime query parameters to ISO8601."""
return {
k: v if not isinstance(v, datetime.datetime) else v.isoformat()
for k, v in list(query_dict.items())
} | python | def _datetime_to_iso8601(self, query_dict):
"""Encode any datetime query parameters to ISO8601."""
return {
k: v if not isinstance(v, datetime.datetime) else v.isoformat()
for k, v in list(query_dict.items())
} | [
"def",
"_datetime_to_iso8601",
"(",
"self",
",",
"query_dict",
")",
":",
"return",
"{",
"k",
":",
"v",
"if",
"not",
"isinstance",
"(",
"v",
",",
"datetime",
".",
"datetime",
")",
"else",
"v",
".",
"isoformat",
"(",
")",
"for",
"k",
",",
"v",
"in",
... | Encode any datetime query parameters to ISO8601. | [
"Encode",
"any",
"datetime",
"query",
"parameters",
"to",
"ISO8601",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/async_client.py#L285-L290 |
genialis/resolwe | resolwe/rest/fields.py | ProjectableJSONField.to_representation | def to_representation(self, value):
"""Project outgoing native value."""
value = apply_subfield_projection(self, value, deep=True)
return super().to_representation(value) | python | def to_representation(self, value):
"""Project outgoing native value."""
value = apply_subfield_projection(self, value, deep=True)
return super().to_representation(value) | [
"def",
"to_representation",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"apply_subfield_projection",
"(",
"self",
",",
"value",
",",
"deep",
"=",
"True",
")",
"return",
"super",
"(",
")",
".",
"to_representation",
"(",
"value",
")"
] | Project outgoing native value. | [
"Project",
"outgoing",
"native",
"value",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/rest/fields.py#L10-L13 |
DataONEorg/d1_python | lib_client/src/d1_client/cnclient_2_0.py | CoordinatingNodeClient_2_0.synchronizeResponse | def synchronizeResponse(self, pid, vendorSpecific=None):
"""CNRead.synchronize(session, pid) → boolean POST /synchronize.
Args: pid: vendorSpecific:
"""
mmp_dict = {'pid': pid}
return self.POST(['synchronize'], fields=mmp_dict, headers=vendorSpecific) | python | def synchronizeResponse(self, pid, vendorSpecific=None):
"""CNRead.synchronize(session, pid) → boolean POST /synchronize.
Args: pid: vendorSpecific:
"""
mmp_dict = {'pid': pid}
return self.POST(['synchronize'], fields=mmp_dict, headers=vendorSpecific) | [
"def",
"synchronizeResponse",
"(",
"self",
",",
"pid",
",",
"vendorSpecific",
"=",
"None",
")",
":",
"mmp_dict",
"=",
"{",
"'pid'",
":",
"pid",
"}",
"return",
"self",
".",
"POST",
"(",
"[",
"'synchronize'",
"]",
",",
"fields",
"=",
"mmp_dict",
",",
"he... | CNRead.synchronize(session, pid) → boolean POST /synchronize.
Args: pid: vendorSpecific: | [
"CNRead",
".",
"synchronize",
"(",
"session",
"pid",
")",
"→",
"boolean",
"POST",
"/",
"synchronize",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/cnclient_2_0.py#L92-L99 |
DataONEorg/d1_python | lib_client/src/d1_client/cnclient_2_0.py | CoordinatingNodeClient_2_0.synchronize | def synchronize(self, pid, vendorSpecific=None):
"""See Also: synchronizeResponse() Args: pid: vendorSpecific:
Returns:
"""
response = self.synchronizeResponse(pid, vendorSpecific)
return self._read_boolean_response(response) | python | def synchronize(self, pid, vendorSpecific=None):
"""See Also: synchronizeResponse() Args: pid: vendorSpecific:
Returns:
"""
response = self.synchronizeResponse(pid, vendorSpecific)
return self._read_boolean_response(response) | [
"def",
"synchronize",
"(",
"self",
",",
"pid",
",",
"vendorSpecific",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"synchronizeResponse",
"(",
"pid",
",",
"vendorSpecific",
")",
"return",
"self",
".",
"_read_boolean_response",
"(",
"response",
")"
] | See Also: synchronizeResponse() Args: pid: vendorSpecific:
Returns: | [
"See",
"Also",
":",
"synchronizeResponse",
"()",
"Args",
":",
"pid",
":",
"vendorSpecific",
":"
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/cnclient_2_0.py#L101-L108 |
genialis/resolwe | resolwe/elastic/management/commands/elastic_index.py | Command.handle | def handle(self, *args, **options):
"""Command handle."""
verbosity = int(options['verbosity'])
if self.has_filter(options):
self.filter_indices(options, verbosity)
else:
# Process all indices.
index_builder.build() | python | def handle(self, *args, **options):
"""Command handle."""
verbosity = int(options['verbosity'])
if self.has_filter(options):
self.filter_indices(options, verbosity)
else:
# Process all indices.
index_builder.build() | [
"def",
"handle",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"options",
")",
":",
"verbosity",
"=",
"int",
"(",
"options",
"[",
"'verbosity'",
"]",
")",
"if",
"self",
".",
"has_filter",
"(",
"options",
")",
":",
"self",
".",
"filter_indices",
"(",
... | Command handle. | [
"Command",
"handle",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/management/commands/elastic_index.py#L23-L31 |
DataONEorg/d1_python | lib_common/src/d1_common/bagit.py | validate_bagit_file | def validate_bagit_file(bagit_path):
"""Check if a BagIt file is valid.
Raises:
ServiceFailure
If the BagIt zip archive file fails any of the following checks:
- Is a valid zip file.
- The tag and manifest files are correctly formatted.
- Contains all th... | python | def validate_bagit_file(bagit_path):
"""Check if a BagIt file is valid.
Raises:
ServiceFailure
If the BagIt zip archive file fails any of the following checks:
- Is a valid zip file.
- The tag and manifest files are correctly formatted.
- Contains all th... | [
"def",
"validate_bagit_file",
"(",
"bagit_path",
")",
":",
"_assert_zip_file",
"(",
"bagit_path",
")",
"bagit_zip",
"=",
"zipfile",
".",
"ZipFile",
"(",
"bagit_path",
")",
"manifest_info_list",
"=",
"_get_manifest_info_list",
"(",
"bagit_zip",
")",
"_validate_checksum... | Check if a BagIt file is valid.
Raises:
ServiceFailure
If the BagIt zip archive file fails any of the following checks:
- Is a valid zip file.
- The tag and manifest files are correctly formatted.
- Contains all the files listed in the manifests.
... | [
"Check",
"if",
"a",
"BagIt",
"file",
"is",
"valid",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/bagit.py#L58-L75 |
DataONEorg/d1_python | lib_common/src/d1_common/bagit.py | create_bagit_stream | def create_bagit_stream(dir_name, payload_info_list):
"""Create a stream containing a BagIt zip archive.
Args:
dir_name : str
The name of the root directory in the zip file, under which all the files
are placed (avoids "zip bombs").
payload_info_list: list
L... | python | def create_bagit_stream(dir_name, payload_info_list):
"""Create a stream containing a BagIt zip archive.
Args:
dir_name : str
The name of the root directory in the zip file, under which all the files
are placed (avoids "zip bombs").
payload_info_list: list
L... | [
"def",
"create_bagit_stream",
"(",
"dir_name",
",",
"payload_info_list",
")",
":",
"zip_file",
"=",
"zipstream",
".",
"ZipFile",
"(",
"mode",
"=",
"'w'",
",",
"compression",
"=",
"zipstream",
".",
"ZIP_DEFLATED",
")",
"_add_path",
"(",
"dir_name",
",",
"payloa... | Create a stream containing a BagIt zip archive.
Args:
dir_name : str
The name of the root directory in the zip file, under which all the files
are placed (avoids "zip bombs").
payload_info_list: list
List of payload_info_dict, each dict describing a file.
... | [
"Create",
"a",
"stream",
"containing",
"a",
"BagIt",
"zip",
"archive",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/bagit.py#L78-L103 |
DataONEorg/d1_python | lib_common/src/d1_common/bagit.py | _add_path | def _add_path(dir_name, payload_info_list):
"""Add a key with the path to each payload_info_dict."""
for payload_info_dict in payload_info_list:
file_name = payload_info_dict['filename'] or payload_info_dict['pid']
payload_info_dict['path'] = d1_common.utils.filesystem.gen_safe_path(
... | python | def _add_path(dir_name, payload_info_list):
"""Add a key with the path to each payload_info_dict."""
for payload_info_dict in payload_info_list:
file_name = payload_info_dict['filename'] or payload_info_dict['pid']
payload_info_dict['path'] = d1_common.utils.filesystem.gen_safe_path(
... | [
"def",
"_add_path",
"(",
"dir_name",
",",
"payload_info_list",
")",
":",
"for",
"payload_info_dict",
"in",
"payload_info_list",
":",
"file_name",
"=",
"payload_info_dict",
"[",
"'filename'",
"]",
"or",
"payload_info_dict",
"[",
"'pid'",
"]",
"payload_info_dict",
"["... | Add a key with the path to each payload_info_dict. | [
"Add",
"a",
"key",
"with",
"the",
"path",
"to",
"each",
"payload_info_dict",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/bagit.py#L183-L189 |
DataONEorg/d1_python | lib_common/src/d1_common/bagit.py | _add_payload_files | def _add_payload_files(zip_file, payload_info_list):
"""Add the payload files to the zip."""
payload_byte_count = 0
payload_file_count = 0
for payload_info_dict in payload_info_list:
zip_file.write_iter(payload_info_dict['path'], payload_info_dict['iter'])
payload_byte_count += payload_i... | python | def _add_payload_files(zip_file, payload_info_list):
"""Add the payload files to the zip."""
payload_byte_count = 0
payload_file_count = 0
for payload_info_dict in payload_info_list:
zip_file.write_iter(payload_info_dict['path'], payload_info_dict['iter'])
payload_byte_count += payload_i... | [
"def",
"_add_payload_files",
"(",
"zip_file",
",",
"payload_info_list",
")",
":",
"payload_byte_count",
"=",
"0",
"payload_file_count",
"=",
"0",
"for",
"payload_info_dict",
"in",
"payload_info_list",
":",
"zip_file",
".",
"write_iter",
"(",
"payload_info_dict",
"[",
... | Add the payload files to the zip. | [
"Add",
"the",
"payload",
"files",
"to",
"the",
"zip",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/bagit.py#L192-L200 |
DataONEorg/d1_python | lib_common/src/d1_common/bagit.py | _add_tag_files | def _add_tag_files(
zip_file, dir_name, payload_info_list, payload_byte_count, payload_file_count
):
"""Generate the tag files and add them to the zip."""
tag_info_list = []
_add_tag_file(zip_file, dir_name, tag_info_list, _gen_bagit_text_file_tup())
_add_tag_file(
zip_file,
dir_name... | python | def _add_tag_files(
zip_file, dir_name, payload_info_list, payload_byte_count, payload_file_count
):
"""Generate the tag files and add them to the zip."""
tag_info_list = []
_add_tag_file(zip_file, dir_name, tag_info_list, _gen_bagit_text_file_tup())
_add_tag_file(
zip_file,
dir_name... | [
"def",
"_add_tag_files",
"(",
"zip_file",
",",
"dir_name",
",",
"payload_info_list",
",",
"payload_byte_count",
",",
"payload_file_count",
")",
":",
"tag_info_list",
"=",
"[",
"]",
"_add_tag_file",
"(",
"zip_file",
",",
"dir_name",
",",
"tag_info_list",
",",
"_gen... | Generate the tag files and add them to the zip. | [
"Generate",
"the",
"tag",
"files",
"and",
"add",
"them",
"to",
"the",
"zip",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/bagit.py#L203-L218 |
DataONEorg/d1_python | lib_common/src/d1_common/bagit.py | _add_manifest_files | def _add_manifest_files(zip_file, dir_name, payload_info_list, tag_info_list):
"""Generate the manifest files and add them to the zip."""
for checksum_algorithm in _get_checksum_algorithm_set(payload_info_list):
_add_tag_file(
zip_file,
dir_name,
tag_info_list,
... | python | def _add_manifest_files(zip_file, dir_name, payload_info_list, tag_info_list):
"""Generate the manifest files and add them to the zip."""
for checksum_algorithm in _get_checksum_algorithm_set(payload_info_list):
_add_tag_file(
zip_file,
dir_name,
tag_info_list,
... | [
"def",
"_add_manifest_files",
"(",
"zip_file",
",",
"dir_name",
",",
"payload_info_list",
",",
"tag_info_list",
")",
":",
"for",
"checksum_algorithm",
"in",
"_get_checksum_algorithm_set",
"(",
"payload_info_list",
")",
":",
"_add_tag_file",
"(",
"zip_file",
",",
"dir_... | Generate the manifest files and add them to the zip. | [
"Generate",
"the",
"manifest",
"files",
"and",
"add",
"them",
"to",
"the",
"zip",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/bagit.py#L221-L229 |
DataONEorg/d1_python | lib_common/src/d1_common/bagit.py | _add_tag_manifest_file | def _add_tag_manifest_file(zip_file, dir_name, tag_info_list):
"""Generate the tag manifest file and add it to the zip."""
_add_tag_file(
zip_file, dir_name, tag_info_list, _gen_tag_manifest_file_tup(tag_info_list)
) | python | def _add_tag_manifest_file(zip_file, dir_name, tag_info_list):
"""Generate the tag manifest file and add it to the zip."""
_add_tag_file(
zip_file, dir_name, tag_info_list, _gen_tag_manifest_file_tup(tag_info_list)
) | [
"def",
"_add_tag_manifest_file",
"(",
"zip_file",
",",
"dir_name",
",",
"tag_info_list",
")",
":",
"_add_tag_file",
"(",
"zip_file",
",",
"dir_name",
",",
"tag_info_list",
",",
"_gen_tag_manifest_file_tup",
"(",
"tag_info_list",
")",
")"
] | Generate the tag manifest file and add it to the zip. | [
"Generate",
"the",
"tag",
"manifest",
"file",
"and",
"add",
"it",
"to",
"the",
"zip",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/bagit.py#L232-L236 |
DataONEorg/d1_python | lib_common/src/d1_common/bagit.py | _add_tag_file | def _add_tag_file(zip_file, dir_name, tag_info_list, tag_tup):
"""Add a tag file to zip_file and record info for the tag manifest file."""
tag_name, tag_str = tag_tup
tag_path = d1_common.utils.filesystem.gen_safe_path(dir_name, tag_name)
tag_iter = _create_and_add_tag_iter(zip_file, tag_path, tag_str)
... | python | def _add_tag_file(zip_file, dir_name, tag_info_list, tag_tup):
"""Add a tag file to zip_file and record info for the tag manifest file."""
tag_name, tag_str = tag_tup
tag_path = d1_common.utils.filesystem.gen_safe_path(dir_name, tag_name)
tag_iter = _create_and_add_tag_iter(zip_file, tag_path, tag_str)
... | [
"def",
"_add_tag_file",
"(",
"zip_file",
",",
"dir_name",
",",
"tag_info_list",
",",
"tag_tup",
")",
":",
"tag_name",
",",
"tag_str",
"=",
"tag_tup",
"tag_path",
"=",
"d1_common",
".",
"utils",
".",
"filesystem",
".",
"gen_safe_path",
"(",
"dir_name",
",",
"... | Add a tag file to zip_file and record info for the tag manifest file. | [
"Add",
"a",
"tag",
"file",
"to",
"zip_file",
"and",
"record",
"info",
"for",
"the",
"tag",
"manifest",
"file",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/bagit.py#L239-L251 |
genialis/resolwe | resolwe/elastic/management/commands/elastic_purge.py | Command.handle | def handle(self, *args, **options):
"""Command handle."""
verbosity = int(options['verbosity'])
skip_mapping = options['skip_mapping']
if self.has_filter(options):
self.filter_indices(options, verbosity, skip_mapping=skip_mapping)
else:
# Process all indi... | python | def handle(self, *args, **options):
"""Command handle."""
verbosity = int(options['verbosity'])
skip_mapping = options['skip_mapping']
if self.has_filter(options):
self.filter_indices(options, verbosity, skip_mapping=skip_mapping)
else:
# Process all indi... | [
"def",
"handle",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"options",
")",
":",
"verbosity",
"=",
"int",
"(",
"options",
"[",
"'verbosity'",
"]",
")",
"skip_mapping",
"=",
"options",
"[",
"'skip_mapping'",
"]",
"if",
"self",
".",
"has_filter",
"(",... | Command handle. | [
"Command",
"handle",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/management/commands/elastic_purge.py#L36-L45 |
DataONEorg/d1_python | lib_common/src/d1_common/node.py | pyxb_to_dict | def pyxb_to_dict(node_list_pyxb):
"""
Returns:
dict : Representation of ``node_list_pyxb``, keyed on the Node identifier
(``urn:node:*``).
Example::
{
u'urn:node:ARCTIC': {
'base_url': u'https://arcticdata.io/metacat/d1/mn',
'description': u'The US National Science Foundati... | python | def pyxb_to_dict(node_list_pyxb):
"""
Returns:
dict : Representation of ``node_list_pyxb``, keyed on the Node identifier
(``urn:node:*``).
Example::
{
u'urn:node:ARCTIC': {
'base_url': u'https://arcticdata.io/metacat/d1/mn',
'description': u'The US National Science Foundati... | [
"def",
"pyxb_to_dict",
"(",
"node_list_pyxb",
")",
":",
"f_dict",
"=",
"{",
"}",
"for",
"f_pyxb",
"in",
"sorted",
"(",
"node_list_pyxb",
".",
"node",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
".",
"identifier",
".",
"value",
"(",
")",
")",
":",
"f_di... | Returns:
dict : Representation of ``node_list_pyxb``, keyed on the Node identifier
(``urn:node:*``).
Example::
{
u'urn:node:ARCTIC': {
'base_url': u'https://arcticdata.io/metacat/d1/mn',
'description': u'The US National Science Foundation...',
'name': u'Arctic Data Center... | [
"Returns",
":",
"dict",
":",
"Representation",
"of",
"node_list_pyxb",
"keyed",
"on",
"the",
"Node",
"identifier",
"(",
"urn",
":",
"node",
":",
"*",
")",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/node.py#L21-L71 |
genialis/resolwe | resolwe/permissions/filters.py | ResolwePermissionsFilter.filter_queryset | def filter_queryset(self, request, queryset, view):
"""Filter permissions queryset."""
user = request.user
app_label = queryset.model._meta.app_label # pylint: disable=protected-access
model_name = queryset.model._meta.model_name # pylint: disable=protected-access
kwargs = {}... | python | def filter_queryset(self, request, queryset, view):
"""Filter permissions queryset."""
user = request.user
app_label = queryset.model._meta.app_label # pylint: disable=protected-access
model_name = queryset.model._meta.model_name # pylint: disable=protected-access
kwargs = {}... | [
"def",
"filter_queryset",
"(",
"self",
",",
"request",
",",
"queryset",
",",
"view",
")",
":",
"user",
"=",
"request",
".",
"user",
"app_label",
"=",
"queryset",
".",
"model",
".",
"_meta",
".",
"app_label",
"# pylint: disable=protected-access",
"model_name",
... | Filter permissions queryset. | [
"Filter",
"permissions",
"queryset",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/permissions/filters.py#L16-L34 |
genialis/resolwe | resolwe/permissions/permissions.py | ResolwePermissions.has_object_permission | def has_object_permission(self, request, view, obj):
"""Check object permissions."""
# admins can do anything
if request.user.is_superuser:
return True
# `share` permission is required for editing permissions
if 'permissions' in view.action:
self.perms_ma... | python | def has_object_permission(self, request, view, obj):
"""Check object permissions."""
# admins can do anything
if request.user.is_superuser:
return True
# `share` permission is required for editing permissions
if 'permissions' in view.action:
self.perms_ma... | [
"def",
"has_object_permission",
"(",
"self",
",",
"request",
",",
"view",
",",
"obj",
")",
":",
"# admins can do anything",
"if",
"request",
".",
"user",
".",
"is_superuser",
":",
"return",
"True",
"# `share` permission is required for editing permissions",
"if",
"'pe... | Check object permissions. | [
"Check",
"object",
"permissions",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/permissions/permissions.py#L25-L70 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/middleware/view_handler.py | ViewHandler.get_active_subject_set | def get_active_subject_set(self, request):
"""Get a set containing all subjects for which the current connection has been
successfully authenticated."""
# Handle complete certificate in vendor specific extension.
if django.conf.settings.DEBUG_GMN:
if 'HTTP_VENDOR_INCLUDE_CERT... | python | def get_active_subject_set(self, request):
"""Get a set containing all subjects for which the current connection has been
successfully authenticated."""
# Handle complete certificate in vendor specific extension.
if django.conf.settings.DEBUG_GMN:
if 'HTTP_VENDOR_INCLUDE_CERT... | [
"def",
"get_active_subject_set",
"(",
"self",
",",
"request",
")",
":",
"# Handle complete certificate in vendor specific extension.",
"if",
"django",
".",
"conf",
".",
"settings",
".",
"DEBUG_GMN",
":",
"if",
"'HTTP_VENDOR_INCLUDE_CERTIFICATE'",
"in",
"request",
".",
"... | Get a set containing all subjects for which the current connection has been
successfully authenticated. | [
"Get",
"a",
"set",
"containing",
"all",
"subjects",
"for",
"which",
"the",
"current",
"connection",
"has",
"been",
"successfully",
"authenticated",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/middleware/view_handler.py#L80-L129 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/management/commands/util/util.py | log_setup | def log_setup(debug_bool):
"""Set up logging.
We output only to stdout. Instead of also writing to a log file, redirect stdout to
a log file when the script is executed from cron.
"""
level = logging.DEBUG if debug_bool else logging.INFO
logging.config.dictConfig(
{
"vers... | python | def log_setup(debug_bool):
"""Set up logging.
We output only to stdout. Instead of also writing to a log file, redirect stdout to
a log file when the script is executed from cron.
"""
level = logging.DEBUG if debug_bool else logging.INFO
logging.config.dictConfig(
{
"vers... | [
"def",
"log_setup",
"(",
"debug_bool",
")",
":",
"level",
"=",
"logging",
".",
"DEBUG",
"if",
"debug_bool",
"else",
"logging",
".",
"INFO",
"logging",
".",
"config",
".",
"dictConfig",
"(",
"{",
"\"version\"",
":",
"1",
",",
"\"disable_existing_loggers\"",
"... | Set up logging.
We output only to stdout. Instead of also writing to a log file, redirect stdout to
a log file when the script is executed from cron. | [
"Set",
"up",
"logging",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/util/util.py#L42-L79 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/management/commands/util/util.py | Db.connect | def connect(self, dsn):
"""Connect to DB.
dbname: the database name user: user name used to authenticate password:
password used to authenticate host: database host address (defaults to UNIX
socket if not provided) port: connection port number (defaults to 5432 if not
provided)
... | python | def connect(self, dsn):
"""Connect to DB.
dbname: the database name user: user name used to authenticate password:
password used to authenticate host: database host address (defaults to UNIX
socket if not provided) port: connection port number (defaults to 5432 if not
provided)
... | [
"def",
"connect",
"(",
"self",
",",
"dsn",
")",
":",
"self",
".",
"con",
"=",
"psycopg2",
".",
"connect",
"(",
"dsn",
")",
"self",
".",
"cur",
"=",
"self",
".",
"con",
".",
"cursor",
"(",
"cursor_factory",
"=",
"psycopg2",
".",
"extras",
".",
"Dict... | Connect to DB.
dbname: the database name user: user name used to authenticate password:
password used to authenticate host: database host address (defaults to UNIX
socket if not provided) port: connection port number (defaults to 5432 if not
provided) | [
"Connect",
"to",
"DB",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/util/util.py#L114-L126 |
genialis/resolwe | resolwe/elastic/viewsets.py | ElasticSearchMixin.get_query_param | def get_query_param(self, key, default=None):
"""Get query parameter uniformly for GET and POST requests."""
value = self.request.query_params.get(key, None)
if value is None:
value = self.request.data.get(key, None)
if value is None:
value = default
retur... | python | def get_query_param(self, key, default=None):
"""Get query parameter uniformly for GET and POST requests."""
value = self.request.query_params.get(key, None)
if value is None:
value = self.request.data.get(key, None)
if value is None:
value = default
retur... | [
"def",
"get_query_param",
"(",
"self",
",",
"key",
",",
"default",
"=",
"None",
")",
":",
"value",
"=",
"self",
".",
"request",
".",
"query_params",
".",
"get",
"(",
"key",
",",
"None",
")",
"if",
"value",
"is",
"None",
":",
"value",
"=",
"self",
"... | Get query parameter uniformly for GET and POST requests. | [
"Get",
"query",
"parameter",
"uniformly",
"for",
"GET",
"and",
"POST",
"requests",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/viewsets.py#L84-L91 |
genialis/resolwe | resolwe/elastic/viewsets.py | ElasticSearchMixin.get_query_params | def get_query_params(self):
"""Get combined query parameters (GET and POST)."""
params = self.request.query_params.copy()
params.update(self.request.data)
return params | python | def get_query_params(self):
"""Get combined query parameters (GET and POST)."""
params = self.request.query_params.copy()
params.update(self.request.data)
return params | [
"def",
"get_query_params",
"(",
"self",
")",
":",
"params",
"=",
"self",
".",
"request",
".",
"query_params",
".",
"copy",
"(",
")",
"params",
".",
"update",
"(",
"self",
".",
"request",
".",
"data",
")",
"return",
"params"
] | Get combined query parameters (GET and POST). | [
"Get",
"combined",
"query",
"parameters",
"(",
"GET",
"and",
"POST",
")",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/viewsets.py#L93-L97 |
genialis/resolwe | resolwe/elastic/viewsets.py | ElasticSearchMixin.order_search | def order_search(self, search):
"""Order given search by the ordering parameter given in request.
:param search: ElasticSearch query object
"""
ordering = self.get_query_param('ordering', self.ordering)
if not ordering:
return search
sort_fields = []
... | python | def order_search(self, search):
"""Order given search by the ordering parameter given in request.
:param search: ElasticSearch query object
"""
ordering = self.get_query_param('ordering', self.ordering)
if not ordering:
return search
sort_fields = []
... | [
"def",
"order_search",
"(",
"self",
",",
"search",
")",
":",
"ordering",
"=",
"self",
".",
"get_query_param",
"(",
"'ordering'",
",",
"self",
".",
"ordering",
")",
"if",
"not",
"ordering",
":",
"return",
"search",
"sort_fields",
"=",
"[",
"]",
"for",
"ra... | Order given search by the ordering parameter given in request.
:param search: ElasticSearch query object | [
"Order",
"given",
"search",
"by",
"the",
"ordering",
"parameter",
"given",
"in",
"request",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/viewsets.py#L99-L119 |
genialis/resolwe | resolwe/elastic/viewsets.py | ElasticSearchMixin.filter_search | def filter_search(self, search):
"""Filter given search by the filter parameter given in request.
:param search: ElasticSearch query object
"""
builder = QueryBuilder(
self.filtering_fields,
self.filtering_map,
self
)
search, unmatche... | python | def filter_search(self, search):
"""Filter given search by the filter parameter given in request.
:param search: ElasticSearch query object
"""
builder = QueryBuilder(
self.filtering_fields,
self.filtering_map,
self
)
search, unmatche... | [
"def",
"filter_search",
"(",
"self",
",",
"search",
")",
":",
"builder",
"=",
"QueryBuilder",
"(",
"self",
".",
"filtering_fields",
",",
"self",
".",
"filtering_map",
",",
"self",
")",
"search",
",",
"unmatched",
"=",
"builder",
".",
"build",
"(",
"search"... | Filter given search by the filter parameter given in request.
:param search: ElasticSearch query object | [
"Filter",
"given",
"search",
"by",
"the",
"filter",
"parameter",
"given",
"in",
"request",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/viewsets.py#L131-L155 |
genialis/resolwe | resolwe/elastic/viewsets.py | ElasticSearchMixin.filter_permissions | def filter_permissions(self, search):
"""Filter given query based on permissions of the user in the request.
:param search: ElasticSearch query object
"""
user = self.request.user
if user.is_superuser:
return search
if user.is_anonymous:
user = g... | python | def filter_permissions(self, search):
"""Filter given query based on permissions of the user in the request.
:param search: ElasticSearch query object
"""
user = self.request.user
if user.is_superuser:
return search
if user.is_anonymous:
user = g... | [
"def",
"filter_permissions",
"(",
"self",
",",
"search",
")",
":",
"user",
"=",
"self",
".",
"request",
".",
"user",
"if",
"user",
".",
"is_superuser",
":",
"return",
"search",
"if",
"user",
".",
"is_anonymous",
":",
"user",
"=",
"get_anonymous_user",
"(",... | Filter given query based on permissions of the user in the request.
:param search: ElasticSearch query object | [
"Filter",
"given",
"query",
"based",
"on",
"permissions",
"of",
"the",
"user",
"in",
"the",
"request",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/viewsets.py#L157-L176 |
genialis/resolwe | resolwe/elastic/viewsets.py | PaginationMixin.paginate_response | def paginate_response(self, queryset, serializers_kwargs={}):
"""Optionally return paginated response.
If pagination parameters are provided in the request, then paginated response
is returned, otherwise response is not paginated.
"""
page = self.paginate_queryset(queryset)
... | python | def paginate_response(self, queryset, serializers_kwargs={}):
"""Optionally return paginated response.
If pagination parameters are provided in the request, then paginated response
is returned, otherwise response is not paginated.
"""
page = self.paginate_queryset(queryset)
... | [
"def",
"paginate_response",
"(",
"self",
",",
"queryset",
",",
"serializers_kwargs",
"=",
"{",
"}",
")",
":",
"page",
"=",
"self",
".",
"paginate_queryset",
"(",
"queryset",
")",
"if",
"page",
"is",
"not",
"None",
":",
"serializer",
"=",
"self",
".",
"ge... | Optionally return paginated response.
If pagination parameters are provided in the request, then paginated response
is returned, otherwise response is not paginated. | [
"Optionally",
"return",
"paginated",
"response",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/viewsets.py#L182-L195 |
genialis/resolwe | resolwe/elastic/viewsets.py | ElasticSearchBaseViewSet.search | def search(self):
"""Handle the search request."""
search = self.document_class().search() # pylint: disable=not-callable
search = self.custom_filter(search)
search = self.filter_search(search)
search = self.order_search(search)
search = self.filter_permissions(search)... | python | def search(self):
"""Handle the search request."""
search = self.document_class().search() # pylint: disable=not-callable
search = self.custom_filter(search)
search = self.filter_search(search)
search = self.order_search(search)
search = self.filter_permissions(search)... | [
"def",
"search",
"(",
"self",
")",
":",
"search",
"=",
"self",
".",
"document_class",
"(",
")",
".",
"search",
"(",
")",
"# pylint: disable=not-callable",
"search",
"=",
"self",
".",
"custom_filter",
"(",
"search",
")",
"search",
"=",
"self",
".",
"filter_... | Handle the search request. | [
"Handle",
"the",
"search",
"request",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/viewsets.py#L225-L242 |
genialis/resolwe | resolwe/elastic/viewsets.py | ElasticSearchCombinedViewSet.list_with_post | def list_with_post(self, request):
"""Endpoint handler."""
if self.is_search_request():
search = self.search()
page = self.paginate_queryset(search)
if page is None:
items = search
else:
items = page
try:
... | python | def list_with_post(self, request):
"""Endpoint handler."""
if self.is_search_request():
search = self.search()
page = self.paginate_queryset(search)
if page is None:
items = search
else:
items = page
try:
... | [
"def",
"list_with_post",
"(",
"self",
",",
"request",
")",
":",
"if",
"self",
".",
"is_search_request",
"(",
")",
":",
"search",
"=",
"self",
".",
"search",
"(",
")",
"page",
"=",
"self",
".",
"paginate_queryset",
"(",
"search",
")",
"if",
"page",
"is"... | Endpoint handler. | [
"Endpoint",
"handler",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/viewsets.py#L281-L318 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/drivers/fuse/callbacks.py | FUSECallbacks.getattr | def getattr(self, path, fh):
"""Called by FUSE when the attributes for a file or directory are required.
Returns a dictionary with keys identical to the stat C structure of stat(2).
st_atime, st_mtime and st_ctime should be floats. On OSX, st_nlink should count
all files inside the dire... | python | def getattr(self, path, fh):
"""Called by FUSE when the attributes for a file or directory are required.
Returns a dictionary with keys identical to the stat C structure of stat(2).
st_atime, st_mtime and st_ctime should be floats. On OSX, st_nlink should count
all files inside the dire... | [
"def",
"getattr",
"(",
"self",
",",
"path",
",",
"fh",
")",
":",
"self",
".",
"_raise_error_if_os_special_file",
"(",
"path",
")",
"# log.debug(u'getattr(): {0}'.format(path))",
"attribute",
"=",
"self",
".",
"_get_attributes_through_cache",
"(",
"path",
")",
"# log... | Called by FUSE when the attributes for a file or directory are required.
Returns a dictionary with keys identical to the stat C structure of stat(2).
st_atime, st_mtime and st_ctime should be floats. On OSX, st_nlink should count
all files inside the directory. On Linux, only the subdirectories... | [
"Called",
"by",
"FUSE",
"when",
"the",
"attributes",
"for",
"a",
"file",
"or",
"directory",
"are",
"required",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/fuse/callbacks.py#L62-L78 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/drivers/fuse/callbacks.py | FUSECallbacks.readdir | def readdir(self, path, fh):
"""Called by FUSE when a directory is opened.
Returns a list of file and directory names for the directory.
"""
log.debug('readdir(): {}'.format(path))
try:
dir = self._directory_cache[path]
except KeyError:
dir = sel... | python | def readdir(self, path, fh):
"""Called by FUSE when a directory is opened.
Returns a list of file and directory names for the directory.
"""
log.debug('readdir(): {}'.format(path))
try:
dir = self._directory_cache[path]
except KeyError:
dir = sel... | [
"def",
"readdir",
"(",
"self",
",",
"path",
",",
"fh",
")",
":",
"log",
".",
"debug",
"(",
"'readdir(): {}'",
".",
"format",
"(",
"path",
")",
")",
"try",
":",
"dir",
"=",
"self",
".",
"_directory_cache",
"[",
"path",
"]",
"except",
"KeyError",
":",
... | Called by FUSE when a directory is opened.
Returns a list of file and directory names for the directory. | [
"Called",
"by",
"FUSE",
"when",
"a",
"directory",
"is",
"opened",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/fuse/callbacks.py#L80-L92 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/drivers/fuse/callbacks.py | FUSECallbacks.open | def open(self, path, flags):
"""Called by FUSE when a file is opened.
Determines if the provided path and open flags are valid.
"""
log.debug('open(): {}'.format(path))
# ONEDrive is currently read only. Anything but read access is denied.
if (flags & self._READ_ONLY_AC... | python | def open(self, path, flags):
"""Called by FUSE when a file is opened.
Determines if the provided path and open flags are valid.
"""
log.debug('open(): {}'.format(path))
# ONEDrive is currently read only. Anything but read access is denied.
if (flags & self._READ_ONLY_AC... | [
"def",
"open",
"(",
"self",
",",
"path",
",",
"flags",
")",
":",
"log",
".",
"debug",
"(",
"'open(): {}'",
".",
"format",
"(",
"path",
")",
")",
"# ONEDrive is currently read only. Anything but read access is denied.",
"if",
"(",
"flags",
"&",
"self",
".",
"_R... | Called by FUSE when a file is opened.
Determines if the provided path and open flags are valid. | [
"Called",
"by",
"FUSE",
"when",
"a",
"file",
"is",
"opened",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/fuse/callbacks.py#L94-L106 |
genialis/resolwe | resolwe/flow/expression_engines/base.py | BaseExpressionEngine.get_inline_expression | def get_inline_expression(self, text):
"""Extract an inline expression from the given text."""
text = text.strip()
if not text.startswith(self.inline_tags[0]) or not text.endswith(self.inline_tags[1]):
return
return text[2:-2] | python | def get_inline_expression(self, text):
"""Extract an inline expression from the given text."""
text = text.strip()
if not text.startswith(self.inline_tags[0]) or not text.endswith(self.inline_tags[1]):
return
return text[2:-2] | [
"def",
"get_inline_expression",
"(",
"self",
",",
"text",
")",
":",
"text",
"=",
"text",
".",
"strip",
"(",
")",
"if",
"not",
"text",
".",
"startswith",
"(",
"self",
".",
"inline_tags",
"[",
"0",
"]",
")",
"or",
"not",
"text",
".",
"endswith",
"(",
... | Extract an inline expression from the given text. | [
"Extract",
"an",
"inline",
"expression",
"from",
"the",
"given",
"text",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/expression_engines/base.py#L10-L16 |
genialis/resolwe | resolwe/flow/views/relation.py | RelationViewSet._filter_queryset | def _filter_queryset(self, queryset):
"""Filter queryset by entity, label and position.
Due to a bug in django-filter these filters have to be applied
manually:
https://github.com/carltongibson/django-filter/issues/883
"""
entities = self.request.query_params.getlist('en... | python | def _filter_queryset(self, queryset):
"""Filter queryset by entity, label and position.
Due to a bug in django-filter these filters have to be applied
manually:
https://github.com/carltongibson/django-filter/issues/883
"""
entities = self.request.query_params.getlist('en... | [
"def",
"_filter_queryset",
"(",
"self",
",",
"queryset",
")",
":",
"entities",
"=",
"self",
".",
"request",
".",
"query_params",
".",
"getlist",
"(",
"'entity'",
")",
"labels",
"=",
"self",
".",
"request",
".",
"query_params",
".",
"getlist",
"(",
"'label'... | Filter queryset by entity, label and position.
Due to a bug in django-filter these filters have to be applied
manually:
https://github.com/carltongibson/django-filter/issues/883 | [
"Filter",
"queryset",
"by",
"entity",
"label",
"and",
"position",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/views/relation.py#L25-L58 |
genialis/resolwe | resolwe/flow/views/relation.py | RelationViewSet.update | def update(self, request, *args, **kwargs):
"""Update the ``Relation`` object.
Reject the update if user doesn't have ``EDIT`` permission on
the collection referenced in the ``Relation``.
"""
instance = self.get_object()
if (not request.user.has_perm('edit_collection', i... | python | def update(self, request, *args, **kwargs):
"""Update the ``Relation`` object.
Reject the update if user doesn't have ``EDIT`` permission on
the collection referenced in the ``Relation``.
"""
instance = self.get_object()
if (not request.user.has_perm('edit_collection', i... | [
"def",
"update",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"instance",
"=",
"self",
".",
"get_object",
"(",
")",
"if",
"(",
"not",
"request",
".",
"user",
".",
"has_perm",
"(",
"'edit_collection'",
",",
"instan... | Update the ``Relation`` object.
Reject the update if user doesn't have ``EDIT`` permission on
the collection referenced in the ``Relation``. | [
"Update",
"the",
"Relation",
"object",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/views/relation.py#L74-L85 |
genialis/resolwe | resolwe/elastic/signals.py | _process_permission | def _process_permission(perm):
"""Rebuild indexes affected by the given permission."""
# XXX: Optimize: rebuild only permissions, not whole document
codename = perm.permission.codename
if not codename.startswith('view') and not codename.startswith('owner'):
return
index_builder.build(perm.c... | python | def _process_permission(perm):
"""Rebuild indexes affected by the given permission."""
# XXX: Optimize: rebuild only permissions, not whole document
codename = perm.permission.codename
if not codename.startswith('view') and not codename.startswith('owner'):
return
index_builder.build(perm.c... | [
"def",
"_process_permission",
"(",
"perm",
")",
":",
"# XXX: Optimize: rebuild only permissions, not whole document",
"codename",
"=",
"perm",
".",
"permission",
".",
"codename",
"if",
"not",
"codename",
".",
"startswith",
"(",
"'view'",
")",
"and",
"not",
"codename",... | Rebuild indexes affected by the given permission. | [
"Rebuild",
"indexes",
"affected",
"by",
"the",
"given",
"permission",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/signals.py#L16-L23 |
DataONEorg/d1_python | lib_common/src/d1_common/multipart.py | parse_response | def parse_response(response, encoding='utf-8'):
"""Parse a multipart Requests.Response into a tuple of BodyPart objects.
Args:
response: Requests.Response
encoding:
The parser will assume that any text in the HTML body is encoded with this
encoding when decoding it for use in the `... | python | def parse_response(response, encoding='utf-8'):
"""Parse a multipart Requests.Response into a tuple of BodyPart objects.
Args:
response: Requests.Response
encoding:
The parser will assume that any text in the HTML body is encoded with this
encoding when decoding it for use in the `... | [
"def",
"parse_response",
"(",
"response",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"return",
"requests_toolbelt",
".",
"multipart",
".",
"decoder",
".",
"MultipartDecoder",
".",
"from_response",
"(",
"response",
",",
"encoding",
")",
".",
"parts"
] | Parse a multipart Requests.Response into a tuple of BodyPart objects.
Args:
response: Requests.Response
encoding:
The parser will assume that any text in the HTML body is encoded with this
encoding when decoding it for use in the ``text`` attribute.
Returns:
tuple of BodyPar... | [
"Parse",
"a",
"multipart",
"Requests",
".",
"Response",
"into",
"a",
"tuple",
"of",
"BodyPart",
"objects",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/multipart.py#L23-L41 |
DataONEorg/d1_python | lib_common/src/d1_common/multipart.py | parse_str | def parse_str(mmp_bytes, content_type, encoding='utf-8'):
"""Parse multipart document bytes into a tuple of BodyPart objects.
Args:
mmp_bytes: bytes
Multipart document.
content_type : str
Must be on the form, ``multipart/form-data; boundary=<BOUNDARY>``, where
``<BOUNDARY>`... | python | def parse_str(mmp_bytes, content_type, encoding='utf-8'):
"""Parse multipart document bytes into a tuple of BodyPart objects.
Args:
mmp_bytes: bytes
Multipart document.
content_type : str
Must be on the form, ``multipart/form-data; boundary=<BOUNDARY>``, where
``<BOUNDARY>`... | [
"def",
"parse_str",
"(",
"mmp_bytes",
",",
"content_type",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"return",
"requests_toolbelt",
".",
"multipart",
".",
"decoder",
".",
"MultipartDecoder",
"(",
"mmp_bytes",
",",
"content_type",
",",
"encoding",
")",
".",
"p... | Parse multipart document bytes into a tuple of BodyPart objects.
Args:
mmp_bytes: bytes
Multipart document.
content_type : str
Must be on the form, ``multipart/form-data; boundary=<BOUNDARY>``, where
``<BOUNDARY>`` is the string that separates the parts of the multipart documen... | [
"Parse",
"multipart",
"document",
"bytes",
"into",
"a",
"tuple",
"of",
"BodyPart",
"objects",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/multipart.py#L44-L68 |
DataONEorg/d1_python | lib_common/src/d1_common/multipart.py | normalize | def normalize(body_part_tup,):
"""Normalize a tuple of BodyPart objects to a string.
Normalization is done by sorting the body_parts by the Content- Disposition headers,
which is typically on the form, ``form-data; name="name_of_part``.
"""
return '\n\n'.join(
[
'{}\n\n{}'.form... | python | def normalize(body_part_tup,):
"""Normalize a tuple of BodyPart objects to a string.
Normalization is done by sorting the body_parts by the Content- Disposition headers,
which is typically on the form, ``form-data; name="name_of_part``.
"""
return '\n\n'.join(
[
'{}\n\n{}'.form... | [
"def",
"normalize",
"(",
"body_part_tup",
",",
")",
":",
"return",
"'\\n\\n'",
".",
"join",
"(",
"[",
"'{}\\n\\n{}'",
".",
"format",
"(",
"str",
"(",
"p",
".",
"headers",
"[",
"b'Content-Disposition'",
"]",
",",
"p",
".",
"encoding",
")",
",",
"p",
"."... | Normalize a tuple of BodyPart objects to a string.
Normalization is done by sorting the body_parts by the Content- Disposition headers,
which is typically on the form, ``form-data; name="name_of_part``. | [
"Normalize",
"a",
"tuple",
"of",
"BodyPart",
"objects",
"to",
"a",
"string",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/multipart.py#L71-L87 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.