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 | lib_common/src/d1_common/url.py | find_url_mismatches | def find_url_mismatches(a_url, b_url):
"""Given two URLs, return a list of any mismatches.
If the list is empty, the URLs are equivalent. Implemented by parsing and comparing
the elements. See RFC 1738 for details.
"""
diff_list = []
a_parts = urllib.parse.urlparse(a_url)
b_parts = urllib.... | python | def find_url_mismatches(a_url, b_url):
"""Given two URLs, return a list of any mismatches.
If the list is empty, the URLs are equivalent. Implemented by parsing and comparing
the elements. See RFC 1738 for details.
"""
diff_list = []
a_parts = urllib.parse.urlparse(a_url)
b_parts = urllib.... | [
"def",
"find_url_mismatches",
"(",
"a_url",
",",
"b_url",
")",
":",
"diff_list",
"=",
"[",
"]",
"a_parts",
"=",
"urllib",
".",
"parse",
".",
"urlparse",
"(",
"a_url",
")",
"b_parts",
"=",
"urllib",
".",
"parse",
".",
"urlparse",
"(",
"b_url",
")",
"# s... | Given two URLs, return a list of any mismatches.
If the list is empty, the URLs are equivalent. Implemented by parsing and comparing
the elements. See RFC 1738 for details. | [
"Given",
"two",
"URLs",
"return",
"a",
"list",
"of",
"any",
"mismatches",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/url.py#L260-L328 |
genialis/resolwe | resolwe/toolkit/tools/parse_tabular_file.py | main | def main():
"""Run the program."""
args = parse_arguments()
ext = os.path.splitext(args.input_file)[-1].lower()
with gzip.open(args.output_file, mode='wt') as outfile:
csvwriter = csv.writer(outfile, delimiter=str('\t'), lineterminator='\n')
try:
if ext in ('.tab', '.txt', ... | python | def main():
"""Run the program."""
args = parse_arguments()
ext = os.path.splitext(args.input_file)[-1].lower()
with gzip.open(args.output_file, mode='wt') as outfile:
csvwriter = csv.writer(outfile, delimiter=str('\t'), lineterminator='\n')
try:
if ext in ('.tab', '.txt', ... | [
"def",
"main",
"(",
")",
":",
"args",
"=",
"parse_arguments",
"(",
")",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"args",
".",
"input_file",
")",
"[",
"-",
"1",
"]",
".",
"lower",
"(",
")",
"with",
"gzip",
".",
"open",
"(",
"args",
"... | Run the program. | [
"Run",
"the",
"program",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/toolkit/tools/parse_tabular_file.py#L19-L47 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_processor.py | CommandProcessor.search | def search(self, line):
"""CN search."""
if self._session.get(d1_cli.impl.session.QUERY_ENGINE_NAME) == "solr":
return self._search_solr(line)
raise d1_cli.impl.exceptions.InvalidArguments(
"Unsupported query engine: {}".format(
self._session.get(d1_cli.im... | python | def search(self, line):
"""CN search."""
if self._session.get(d1_cli.impl.session.QUERY_ENGINE_NAME) == "solr":
return self._search_solr(line)
raise d1_cli.impl.exceptions.InvalidArguments(
"Unsupported query engine: {}".format(
self._session.get(d1_cli.im... | [
"def",
"search",
"(",
"self",
",",
"line",
")",
":",
"if",
"self",
".",
"_session",
".",
"get",
"(",
"d1_cli",
".",
"impl",
".",
"session",
".",
"QUERY_ENGINE_NAME",
")",
"==",
"\"solr\"",
":",
"return",
"self",
".",
"_search_solr",
"(",
"line",
")",
... | CN search. | [
"CN",
"search",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_processor.py#L93-L101 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_processor.py | CommandProcessor.resolve | def resolve(self, pid):
"""Get Object Locations for Object."""
client = d1_cli.impl.client.CLICNClient(
**self._cn_client_connect_params_from_session()
)
object_location_list_pyxb = client.resolve(pid)
for location in object_location_list_pyxb.objectLocation:
... | python | def resolve(self, pid):
"""Get Object Locations for Object."""
client = d1_cli.impl.client.CLICNClient(
**self._cn_client_connect_params_from_session()
)
object_location_list_pyxb = client.resolve(pid)
for location in object_location_list_pyxb.objectLocation:
... | [
"def",
"resolve",
"(",
"self",
",",
"pid",
")",
":",
"client",
"=",
"d1_cli",
".",
"impl",
".",
"client",
".",
"CLICNClient",
"(",
"*",
"*",
"self",
".",
"_cn_client_connect_params_from_session",
"(",
")",
")",
"object_location_list_pyxb",
"=",
"client",
"."... | Get Object Locations for Object. | [
"Get",
"Object",
"Locations",
"for",
"Object",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_processor.py#L111-L118 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_processor.py | CommandProcessor.science_object_get | def science_object_get(self, pid, path):
"""First try the MN set in the session.
Then try to resolve via the CN set in the session.
"""
mn_client = d1_cli.impl.client.CLIMNClient(
**self._mn_client_connect_params_from_session()
)
try:
response = ... | python | def science_object_get(self, pid, path):
"""First try the MN set in the session.
Then try to resolve via the CN set in the session.
"""
mn_client = d1_cli.impl.client.CLIMNClient(
**self._mn_client_connect_params_from_session()
)
try:
response = ... | [
"def",
"science_object_get",
"(",
"self",
",",
"pid",
",",
"path",
")",
":",
"mn_client",
"=",
"d1_cli",
".",
"impl",
".",
"client",
".",
"CLIMNClient",
"(",
"*",
"*",
"self",
".",
"_mn_client_connect_params_from_session",
"(",
")",
")",
"try",
":",
"respo... | First try the MN set in the session.
Then try to resolve via the CN set in the session. | [
"First",
"try",
"the",
"MN",
"set",
"in",
"the",
"session",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_processor.py#L136-L169 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_processor.py | CommandProcessor.science_object_create | def science_object_create(self, pid, path, format_id=None):
"""Create a new Science Object on a Member Node."""
self._queue_science_object_create(pid, path, format_id) | python | def science_object_create(self, pid, path, format_id=None):
"""Create a new Science Object on a Member Node."""
self._queue_science_object_create(pid, path, format_id) | [
"def",
"science_object_create",
"(",
"self",
",",
"pid",
",",
"path",
",",
"format_id",
"=",
"None",
")",
":",
"self",
".",
"_queue_science_object_create",
"(",
"pid",
",",
"path",
",",
"format_id",
")"
] | Create a new Science Object on a Member Node. | [
"Create",
"a",
"new",
"Science",
"Object",
"on",
"a",
"Member",
"Node",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_processor.py#L223-L225 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_processor.py | CommandProcessor.science_object_update | def science_object_update(self, pid_old, path, pid_new, format_id=None):
"""Obsolete a Science Object on a Member Node with a different one."""
self._queue_science_object_update(pid_old, path, pid_new, format_id) | python | def science_object_update(self, pid_old, path, pid_new, format_id=None):
"""Obsolete a Science Object on a Member Node with a different one."""
self._queue_science_object_update(pid_old, path, pid_new, format_id) | [
"def",
"science_object_update",
"(",
"self",
",",
"pid_old",
",",
"path",
",",
"pid_new",
",",
"format_id",
"=",
"None",
")",
":",
"self",
".",
"_queue_science_object_update",
"(",
"pid_old",
",",
"path",
",",
"pid_new",
",",
"format_id",
")"
] | Obsolete a Science Object on a Member Node with a different one. | [
"Obsolete",
"a",
"Science",
"Object",
"on",
"a",
"Member",
"Node",
"with",
"a",
"different",
"one",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_processor.py#L227-L229 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_processor.py | CommandProcessor._output | def _output(self, file_like_object, path=None):
"""Display or save file like object."""
if not path:
self._output_to_display(file_like_object)
else:
self._output_to_file(file_like_object, path) | python | def _output(self, file_like_object, path=None):
"""Display or save file like object."""
if not path:
self._output_to_display(file_like_object)
else:
self._output_to_file(file_like_object, path) | [
"def",
"_output",
"(",
"self",
",",
"file_like_object",
",",
"path",
"=",
"None",
")",
":",
"if",
"not",
"path",
":",
"self",
".",
"_output_to_display",
"(",
"file_like_object",
")",
"else",
":",
"self",
".",
"_output_to_file",
"(",
"file_like_object",
",",
... | 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/command_processor.py#L242-L247 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_processor.py | CommandProcessor._search_solr | def _search_solr(self, line):
"""Perform a SOLR search."""
try:
query_str = self._create_solr_query(line)
client = d1_cli.impl.client.CLICNClient(
**self._cn_client_connect_params_from_session()
)
object_list_pyxb = client.search(
... | python | def _search_solr(self, line):
"""Perform a SOLR search."""
try:
query_str = self._create_solr_query(line)
client = d1_cli.impl.client.CLICNClient(
**self._cn_client_connect_params_from_session()
)
object_list_pyxb = client.search(
... | [
"def",
"_search_solr",
"(",
"self",
",",
"line",
")",
":",
"try",
":",
"query_str",
"=",
"self",
".",
"_create_solr_query",
"(",
"line",
")",
"client",
"=",
"d1_cli",
".",
"impl",
".",
"client",
".",
"CLICNClient",
"(",
"*",
"*",
"self",
".",
"_cn_clie... | Perform a SOLR search. | [
"Perform",
"a",
"SOLR",
"search",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_processor.py#L288-L323 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_processor.py | CommandProcessor._create_solr_query | def _create_solr_query(self, line):
"""Actual search - easier to test. """
p0 = ""
if line:
p0 = line.strip()
p1 = self._query_string_to_solr_filter(line)
p2 = self._object_format_to_solr_filter(line)
p3 = self._time_span_to_solr_filter()
result = p0 +... | python | def _create_solr_query(self, line):
"""Actual search - easier to test. """
p0 = ""
if line:
p0 = line.strip()
p1 = self._query_string_to_solr_filter(line)
p2 = self._object_format_to_solr_filter(line)
p3 = self._time_span_to_solr_filter()
result = p0 +... | [
"def",
"_create_solr_query",
"(",
"self",
",",
"line",
")",
":",
"p0",
"=",
"\"\"",
"if",
"line",
":",
"p0",
"=",
"line",
".",
"strip",
"(",
")",
"p1",
"=",
"self",
".",
"_query_string_to_solr_filter",
"(",
"line",
")",
"p2",
"=",
"self",
".",
"_obje... | Actual search - easier to test. | [
"Actual",
"search",
"-",
"easier",
"to",
"test",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_processor.py#L325-L334 |
genialis/resolwe | resolwe/flow/expression_engines/jinja/filters.py | apply_filter_list | def apply_filter_list(func, obj):
"""Apply `func` to list or tuple `obj` element-wise and directly otherwise."""
if isinstance(obj, (list, tuple)):
return [func(item) for item in obj]
return func(obj) | python | def apply_filter_list(func, obj):
"""Apply `func` to list or tuple `obj` element-wise and directly otherwise."""
if isinstance(obj, (list, tuple)):
return [func(item) for item in obj]
return func(obj) | [
"def",
"apply_filter_list",
"(",
"func",
",",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"[",
"func",
"(",
"item",
")",
"for",
"item",
"in",
"obj",
"]",
"return",
"func",
"(",
"obj",
... | Apply `func` to list or tuple `obj` element-wise and directly otherwise. | [
"Apply",
"func",
"to",
"list",
"or",
"tuple",
"obj",
"element",
"-",
"wise",
"and",
"directly",
"otherwise",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/expression_engines/jinja/filters.py#L13-L17 |
genialis/resolwe | resolwe/flow/expression_engines/jinja/filters.py | _get_data_attr | def _get_data_attr(data, attr):
"""Get data object field."""
if isinstance(data, dict):
# `Data` object's id is hydrated as `__id` in expression engine
data = data['__id']
data_obj = Data.objects.get(id=data)
return getattr(data_obj, attr) | python | def _get_data_attr(data, attr):
"""Get data object field."""
if isinstance(data, dict):
# `Data` object's id is hydrated as `__id` in expression engine
data = data['__id']
data_obj = Data.objects.get(id=data)
return getattr(data_obj, attr) | [
"def",
"_get_data_attr",
"(",
"data",
",",
"attr",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"# `Data` object's id is hydrated as `__id` in expression engine",
"data",
"=",
"data",
"[",
"'__id'",
"]",
"data_obj",
"=",
"Data",
".",
"object... | Get data object field. | [
"Get",
"data",
"object",
"field",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/expression_engines/jinja/filters.py#L20-L28 |
genialis/resolwe | resolwe/flow/expression_engines/jinja/filters.py | input_ | def input_(data, field_path):
"""Return a hydrated value of the ``input`` field."""
data_obj = Data.objects.get(id=data['__id'])
inputs = copy.deepcopy(data_obj.input)
# XXX: Optimize by hydrating only the required field (major refactoring).
hydrate_input_references(inputs, data_obj.process.input_s... | python | def input_(data, field_path):
"""Return a hydrated value of the ``input`` field."""
data_obj = Data.objects.get(id=data['__id'])
inputs = copy.deepcopy(data_obj.input)
# XXX: Optimize by hydrating only the required field (major refactoring).
hydrate_input_references(inputs, data_obj.process.input_s... | [
"def",
"input_",
"(",
"data",
",",
"field_path",
")",
":",
"data_obj",
"=",
"Data",
".",
"objects",
".",
"get",
"(",
"id",
"=",
"data",
"[",
"'__id'",
"]",
")",
"inputs",
"=",
"copy",
".",
"deepcopy",
"(",
"data_obj",
".",
"input",
")",
"# XXX: Optim... | Return a hydrated value of the ``input`` field. | [
"Return",
"a",
"hydrated",
"value",
"of",
"the",
"input",
"field",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/expression_engines/jinja/filters.py#L41-L50 |
genialis/resolwe | resolwe/flow/expression_engines/jinja/filters.py | _get_hydrated_path | def _get_hydrated_path(field):
"""Return HydratedPath object for file-type field."""
# Get only file path if whole file object is given.
if isinstance(field, str) and hasattr(field, 'file_name'):
# field is already actually a HydratedPath object
return field
if isinstance(field, dict) a... | python | def _get_hydrated_path(field):
"""Return HydratedPath object for file-type field."""
# Get only file path if whole file object is given.
if isinstance(field, str) and hasattr(field, 'file_name'):
# field is already actually a HydratedPath object
return field
if isinstance(field, dict) a... | [
"def",
"_get_hydrated_path",
"(",
"field",
")",
":",
"# Get only file path if whole file object is given.",
"if",
"isinstance",
"(",
"field",
",",
"str",
")",
"and",
"hasattr",
"(",
"field",
",",
"'file_name'",
")",
":",
"# field is already actually a HydratedPath object"... | Return HydratedPath object for file-type field. | [
"Return",
"HydratedPath",
"object",
"for",
"file",
"-",
"type",
"field",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/expression_engines/jinja/filters.py#L88-L101 |
genialis/resolwe | resolwe/flow/expression_engines/jinja/filters.py | get_url | def get_url(field):
"""Return file's url based on base url set in settings."""
hydrated_path = _get_hydrated_path(field)
base_url = getattr(settings, 'RESOLWE_HOST_URL', 'localhost')
return "{}/data/{}/{}".format(base_url, hydrated_path.data_id, hydrated_path.file_name) | python | def get_url(field):
"""Return file's url based on base url set in settings."""
hydrated_path = _get_hydrated_path(field)
base_url = getattr(settings, 'RESOLWE_HOST_URL', 'localhost')
return "{}/data/{}/{}".format(base_url, hydrated_path.data_id, hydrated_path.file_name) | [
"def",
"get_url",
"(",
"field",
")",
":",
"hydrated_path",
"=",
"_get_hydrated_path",
"(",
"field",
")",
"base_url",
"=",
"getattr",
"(",
"settings",
",",
"'RESOLWE_HOST_URL'",
",",
"'localhost'",
")",
"return",
"\"{}/data/{}/{}\"",
".",
"format",
"(",
"base_url... | Return file's url based on base url set in settings. | [
"Return",
"file",
"s",
"url",
"based",
"on",
"base",
"url",
"set",
"in",
"settings",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/expression_engines/jinja/filters.py#L104-L108 |
genialis/resolwe | resolwe/flow/expression_engines/jinja/filters.py | descriptor | def descriptor(obj, path=''):
"""Return descriptor of given object.
If ``path`` is specified, only the content on that path is
returned.
"""
if isinstance(obj, dict):
# Current object is hydrated, so we need to get descriptor from
# dict representation.
desc = obj['__descrip... | python | def descriptor(obj, path=''):
"""Return descriptor of given object.
If ``path`` is specified, only the content on that path is
returned.
"""
if isinstance(obj, dict):
# Current object is hydrated, so we need to get descriptor from
# dict representation.
desc = obj['__descrip... | [
"def",
"descriptor",
"(",
"obj",
",",
"path",
"=",
"''",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"dict",
")",
":",
"# Current object is hydrated, so we need to get descriptor from",
"# dict representation.",
"desc",
"=",
"obj",
"[",
"'__descriptor'",
"]",
"... | Return descriptor of given object.
If ``path`` is specified, only the content on that path is
returned. | [
"Return",
"descriptor",
"of",
"given",
"object",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/expression_engines/jinja/filters.py#L117-L135 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/clients/onedrive_solr_client.py | OneDriveSolrClient._close_open_date_ranges | def _close_open_date_ranges(self, record):
"""If a date range is missing the start or end date, close it by copying the
date from the existing value."""
date_ranges = (('beginDate', 'endDate'),)
for begin, end in date_ranges:
if begin in record and end in record:
... | python | def _close_open_date_ranges(self, record):
"""If a date range is missing the start or end date, close it by copying the
date from the existing value."""
date_ranges = (('beginDate', 'endDate'),)
for begin, end in date_ranges:
if begin in record and end in record:
... | [
"def",
"_close_open_date_ranges",
"(",
"self",
",",
"record",
")",
":",
"date_ranges",
"=",
"(",
"(",
"'beginDate'",
",",
"'endDate'",
")",
",",
")",
"for",
"begin",
",",
"end",
"in",
"date_ranges",
":",
"if",
"begin",
"in",
"record",
"and",
"end",
"in",... | If a date range is missing the start or end date, close it by copying the
date from the existing value. | [
"If",
"a",
"date",
"range",
"is",
"missing",
"the",
"start",
"or",
"end",
"date",
"close",
"it",
"by",
"copying",
"the",
"date",
"from",
"the",
"existing",
"value",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/clients/onedrive_solr_client.py#L77-L87 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py | SolrConnection.escapeQueryTerm | def escapeQueryTerm(self, term):
"""
+ - && || ! ( ) { } [ ] ^ " ~ * ? : \
"""
reserved = [
'+',
'-',
'&',
'|',
'!',
'(',
')',
'{',
'}',
'[',
']',
'^',
... | python | def escapeQueryTerm(self, term):
"""
+ - && || ! ( ) { } [ ] ^ " ~ * ? : \
"""
reserved = [
'+',
'-',
'&',
'|',
'!',
'(',
')',
'{',
'}',
'[',
']',
'^',
... | [
"def",
"escapeQueryTerm",
"(",
"self",
",",
"term",
")",
":",
"reserved",
"=",
"[",
"'+'",
",",
"'-'",
",",
"'&'",
",",
"'|'",
",",
"'!'",
",",
"'('",
",",
"')'",
",",
"'{'",
",",
"'}'",
",",
"'['",
",",
"']'",
",",
"'^'",
",",
"'\"'",
",",
"... | + - && || ! ( ) { } [ ] ^ " ~ * ? : \ | [
"+",
"-",
"&&",
"||",
"!",
"(",
")",
"{",
"}",
"[",
"]",
"^",
"~",
"*",
"?",
":",
"\\"
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py#L217-L243 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py | SolrConnection.prepareQueryTerm | def prepareQueryTerm(self, field, term):
"""Prepare a query term for inclusion in a query.
This escapes the term and if necessary, wraps the term in quotes.
"""
if term == "*":
return term
addstar = False
if term[len(term) - 1] == '*':
addstar = ... | python | def prepareQueryTerm(self, field, term):
"""Prepare a query term for inclusion in a query.
This escapes the term and if necessary, wraps the term in quotes.
"""
if term == "*":
return term
addstar = False
if term[len(term) - 1] == '*':
addstar = ... | [
"def",
"prepareQueryTerm",
"(",
"self",
",",
"field",
",",
"term",
")",
":",
"if",
"term",
"==",
"\"*\"",
":",
"return",
"term",
"addstar",
"=",
"False",
"if",
"term",
"[",
"len",
"(",
"term",
")",
"-",
"1",
"]",
"==",
"'*'",
":",
"addstar",
"=",
... | Prepare a query term for inclusion in a query.
This escapes the term and if necessary, wraps the term in quotes. | [
"Prepare",
"a",
"query",
"term",
"for",
"inclusion",
"in",
"a",
"query",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py#L245-L262 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py | SolrConnection.coerceType | def coerceType(self, ftype, value):
"""Returns unicode(value) after trying to coerce it into the SOLR field type.
@param ftype(string) The SOLR field type for the value
@param value(any) The value that is to be represented as Unicode text.
"""
if value is None:
retu... | python | def coerceType(self, ftype, value):
"""Returns unicode(value) after trying to coerce it into the SOLR field type.
@param ftype(string) The SOLR field type for the value
@param value(any) The value that is to be represented as Unicode text.
"""
if value is None:
retu... | [
"def",
"coerceType",
"(",
"self",
",",
"ftype",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"if",
"ftype",
"==",
"'string'",
":",
"return",
"str",
"(",
"value",
")",
"elif",
"ftype",
"==",
"'text'",
":",
"return",
"str... | Returns unicode(value) after trying to coerce it into the SOLR field type.
@param ftype(string) The SOLR field type for the value
@param value(any) The value that is to be represented as Unicode text. | [
"Returns",
"unicode",
"(",
"value",
")",
"after",
"trying",
"to",
"coerce",
"it",
"into",
"the",
"SOLR",
"field",
"type",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py#L283-L314 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py | SolrConnection.getSolrType | def getSolrType(self, field):
"""Returns the SOLR type of the specified field name.
Assumes the convention of dynamic fields using an underscore + type character
code for the field name.
"""
ftype = 'string'
try:
ftype = self.fieldtypes[field]
re... | python | def getSolrType(self, field):
"""Returns the SOLR type of the specified field name.
Assumes the convention of dynamic fields using an underscore + type character
code for the field name.
"""
ftype = 'string'
try:
ftype = self.fieldtypes[field]
re... | [
"def",
"getSolrType",
"(",
"self",
",",
"field",
")",
":",
"ftype",
"=",
"'string'",
"try",
":",
"ftype",
"=",
"self",
".",
"fieldtypes",
"[",
"field",
"]",
"return",
"ftype",
"except",
"Exception",
":",
"pass",
"fta",
"=",
"field",
".",
"split",
"(",
... | Returns the SOLR type of the specified field name.
Assumes the convention of dynamic fields using an underscore + type character
code for the field name. | [
"Returns",
"the",
"SOLR",
"type",
"of",
"the",
"specified",
"field",
"name",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py#L316-L338 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py | SolrConnection.addDocs | def addDocs(self, docs):
"""docs is a list of fields that are a dictionary of name:value for a record."""
lst = ['<add>']
for fields in docs:
self.__add(lst, fields)
lst.append('</add>')
xstr = ''.join(lst)
return self.doUpdateXML(xstr) | python | def addDocs(self, docs):
"""docs is a list of fields that are a dictionary of name:value for a record."""
lst = ['<add>']
for fields in docs:
self.__add(lst, fields)
lst.append('</add>')
xstr = ''.join(lst)
return self.doUpdateXML(xstr) | [
"def",
"addDocs",
"(",
"self",
",",
"docs",
")",
":",
"lst",
"=",
"[",
"'<add>'",
"]",
"for",
"fields",
"in",
"docs",
":",
"self",
".",
"__add",
"(",
"lst",
",",
"fields",
")",
"lst",
".",
"append",
"(",
"'</add>'",
")",
"xstr",
"=",
"''",
".",
... | docs is a list of fields that are a dictionary of name:value for a record. | [
"docs",
"is",
"a",
"list",
"of",
"fields",
"that",
"are",
"a",
"dictionary",
"of",
"name",
":",
"value",
"for",
"a",
"record",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py#L370-L377 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py | SolrConnection.count | def count(self, q='*:*', fq=None):
"""Return the number of entries that match query."""
params = {'q': q, 'rows': '0'}
if fq is not None:
params['fq'] = fq
res = self.search(params)
hits = res['response']['numFound']
return hits | python | def count(self, q='*:*', fq=None):
"""Return the number of entries that match query."""
params = {'q': q, 'rows': '0'}
if fq is not None:
params['fq'] = fq
res = self.search(params)
hits = res['response']['numFound']
return hits | [
"def",
"count",
"(",
"self",
",",
"q",
"=",
"'*:*'",
",",
"fq",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'q'",
":",
"q",
",",
"'rows'",
":",
"'0'",
"}",
"if",
"fq",
"is",
"not",
"None",
":",
"params",
"[",
"'fq'",
"]",
"=",
"fq",
"res",
... | Return the number of entries that match query. | [
"Return",
"the",
"number",
"of",
"entries",
"that",
"match",
"query",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py#L406-L413 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py | SolrConnection.getIds | def getIds(self, query='*:*', fq=None, start=0, rows=1000):
"""Returns a dictionary of: matches: number of matches failed: if true, then an
exception was thrown start: starting index ids: [id, id, ...]
See also the SOLRSearchResponseIterator class
"""
params = {'q': query, 'sta... | python | def getIds(self, query='*:*', fq=None, start=0, rows=1000):
"""Returns a dictionary of: matches: number of matches failed: if true, then an
exception was thrown start: starting index ids: [id, id, ...]
See also the SOLRSearchResponseIterator class
"""
params = {'q': query, 'sta... | [
"def",
"getIds",
"(",
"self",
",",
"query",
"=",
"'*:*'",
",",
"fq",
"=",
"None",
",",
"start",
"=",
"0",
",",
"rows",
"=",
"1000",
")",
":",
"params",
"=",
"{",
"'q'",
":",
"query",
",",
"'start'",
":",
"str",
"(",
"start",
")",
",",
"'rows'",... | Returns a dictionary of: matches: number of matches failed: if true, then an
exception was thrown start: starting index ids: [id, id, ...]
See also the SOLRSearchResponseIterator class | [
"Returns",
"a",
"dictionary",
"of",
":",
"matches",
":",
"number",
"of",
"matches",
"failed",
":",
"if",
"true",
"then",
"an",
"exception",
"was",
"thrown",
"start",
":",
"starting",
"index",
"ids",
":",
"[",
"id",
"id",
"...",
"]"
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py#L415-L439 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py | SolrConnection.get | def get(self, id):
"""Retrieves the specified document."""
params = {'q': 'id:%s' % str(id), 'wt': 'python'}
request = urllib.parse.urlencode(params, doseq=True)
data = None
try:
rsp = self.doPost(self.solrBase + '', request, self.formheaders)
data = eval(... | python | def get(self, id):
"""Retrieves the specified document."""
params = {'q': 'id:%s' % str(id), 'wt': 'python'}
request = urllib.parse.urlencode(params, doseq=True)
data = None
try:
rsp = self.doPost(self.solrBase + '', request, self.formheaders)
data = eval(... | [
"def",
"get",
"(",
"self",
",",
"id",
")",
":",
"params",
"=",
"{",
"'q'",
":",
"'id:%s'",
"%",
"str",
"(",
"id",
")",
",",
"'wt'",
":",
"'python'",
"}",
"request",
"=",
"urllib",
".",
"parse",
".",
"urlencode",
"(",
"params",
",",
"doseq",
"=",
... | Retrieves the specified document. | [
"Retrieves",
"the",
"specified",
"document",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py#L441-L453 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py | SolrConnection.getFields | def getFields(self, numTerms=1):
"""Retrieve a list of fields. The response looks something like:
{
'responseHeader':{
'status':0,
'QTime':44},
'index':{
'numDocs':2000,
'maxDoc':2000,
'numTerms':23791,
'version':1227298371173,
'optimized':True,
'current':True,
'hasDeletio... | python | def getFields(self, numTerms=1):
"""Retrieve a list of fields. The response looks something like:
{
'responseHeader':{
'status':0,
'QTime':44},
'index':{
'numDocs':2000,
'maxDoc':2000,
'numTerms':23791,
'version':1227298371173,
'optimized':True,
'current':True,
'hasDeletio... | [
"def",
"getFields",
"(",
"self",
",",
"numTerms",
"=",
"1",
")",
":",
"if",
"self",
".",
"_fields",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_fields",
"params",
"=",
"{",
"'numTerms'",
":",
"str",
"(",
"numTerms",
")",
",",
"'wt'",
":",
"'... | Retrieve a list of fields. The response looks something like:
{
'responseHeader':{
'status':0,
'QTime':44},
'index':{
'numDocs':2000,
'maxDoc':2000,
'numTerms':23791,
'version':1227298371173,
'optimized':True,
'current':True,
'hasDeletions':False,
'directory':'org.apache.lucen... | [
"Retrieve",
"a",
"list",
"of",
"fields",
".",
"The",
"response",
"looks",
"something",
"like",
":",
"{",
"responseHeader",
":",
"{",
"status",
":",
"0",
"QTime",
":",
"44",
"}",
"index",
":",
"{",
"numDocs",
":",
"2000",
"maxDoc",
":",
"2000",
"numTerm... | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py#L455-L499 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py | SolrConnection.fieldValues | def fieldValues(self, name, q="*:*", fq=None, maxvalues=-1):
"""Retrieve the unique values for a field, along with their usage counts.
http://localhost:8080/solr/select/?q=*:*&rows=0&facet=true&inde
nt=on&wt=python&facet.field=genus_s&facet.limit=10&facet.zeros=false&fa
cet.sort=false.
... | python | def fieldValues(self, name, q="*:*", fq=None, maxvalues=-1):
"""Retrieve the unique values for a field, along with their usage counts.
http://localhost:8080/solr/select/?q=*:*&rows=0&facet=true&inde
nt=on&wt=python&facet.field=genus_s&facet.limit=10&facet.zeros=false&fa
cet.sort=false.
... | [
"def",
"fieldValues",
"(",
"self",
",",
"name",
",",
"q",
"=",
"\"*:*\"",
",",
"fq",
"=",
"None",
",",
"maxvalues",
"=",
"-",
"1",
")",
":",
"params",
"=",
"{",
"'q'",
":",
"q",
",",
"'rows'",
":",
"'0'",
",",
"'facet'",
":",
"'true'",
",",
"'f... | Retrieve the unique values for a field, along with their usage counts.
http://localhost:8080/solr/select/?q=*:*&rows=0&facet=true&inde
nt=on&wt=python&facet.field=genus_s&facet.limit=10&facet.zeros=false&fa
cet.sort=false.
@param name(string) Name of field to retrieve values for
... | [
"Retrieve",
"the",
"unique",
"values",
"for",
"a",
"field",
"along",
"with",
"their",
"usage",
"counts",
".",
"http",
":",
"//",
"localhost",
":",
"8080",
"/",
"solr",
"/",
"select",
"/",
"?q",
"=",
"*",
":",
"*",
"&rows",
"=",
"0&facet",
"=",
"true&... | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py#L501-L530 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py | SolrConnection.fieldMinMax | def fieldMinMax(self, name, q='*:*', fq=None):
"""Returns the minimum and maximum values of the specified field. This requires
two search calls to the service, each requesting a single value of a single
field.
@param name(string) Name of the field
@param q(string) Query identify... | python | def fieldMinMax(self, name, q='*:*', fq=None):
"""Returns the minimum and maximum values of the specified field. This requires
two search calls to the service, each requesting a single value of a single
field.
@param name(string) Name of the field
@param q(string) Query identify... | [
"def",
"fieldMinMax",
"(",
"self",
",",
"name",
",",
"q",
"=",
"'*:*'",
",",
"fq",
"=",
"None",
")",
":",
"minmax",
"=",
"[",
"None",
",",
"None",
"]",
"oldpersist",
"=",
"self",
".",
"persistent",
"self",
".",
"persistent",
"=",
"True",
"params",
... | Returns the minimum and maximum values of the specified field. This requires
two search calls to the service, each requesting a single value of a single
field.
@param name(string) Name of the field
@param q(string) Query identifying range of records for min and max values
@param... | [
"Returns",
"the",
"minimum",
"and",
"maximum",
"values",
"of",
"the",
"specified",
"field",
".",
"This",
"requires",
"two",
"search",
"calls",
"to",
"the",
"service",
"each",
"requesting",
"a",
"single",
"value",
"of",
"a",
"single",
"field",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py#L532-L569 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py | SolrConnection.getftype | def getftype(self, name):
"""Returns the python type for the specified field name. The field list is
cached so multiple calls do not invoke a getFields request each time.
@param name(string) The name of the SOLR field
@returns Python type of the field.
"""
fields = sel... | python | def getftype(self, name):
"""Returns the python type for the specified field name. The field list is
cached so multiple calls do not invoke a getFields request each time.
@param name(string) The name of the SOLR field
@returns Python type of the field.
"""
fields = sel... | [
"def",
"getftype",
"(",
"self",
",",
"name",
")",
":",
"fields",
"=",
"self",
".",
"getFields",
"(",
")",
"try",
":",
"fld",
"=",
"fields",
"[",
"'fields'",
"]",
"[",
"name",
"]",
"except",
"Exception",
":",
"return",
"str",
"if",
"fld",
"[",
"'typ... | Returns the python type for the specified field name. The field list is
cached so multiple calls do not invoke a getFields request each time.
@param name(string) The name of the SOLR field
@returns Python type of the field. | [
"Returns",
"the",
"python",
"type",
"for",
"the",
"specified",
"field",
"name",
".",
"The",
"field",
"list",
"is",
"cached",
"so",
"multiple",
"calls",
"do",
"not",
"invoke",
"a",
"getFields",
"request",
"each",
"time",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py#L571-L592 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py | SolrConnection.fieldAlphaHistogram | def fieldAlphaHistogram(
self, name, q='*:*', fq=None, nbins=10, includequeries=True
):
"""Generates a histogram of values from a string field. Output is:
[[low, high, count, query], ... ] Bin edges is determined by equal division
of the fields
"""
oldpersist = s... | python | def fieldAlphaHistogram(
self, name, q='*:*', fq=None, nbins=10, includequeries=True
):
"""Generates a histogram of values from a string field. Output is:
[[low, high, count, query], ... ] Bin edges is determined by equal division
of the fields
"""
oldpersist = s... | [
"def",
"fieldAlphaHistogram",
"(",
"self",
",",
"name",
",",
"q",
"=",
"'*:*'",
",",
"fq",
"=",
"None",
",",
"nbins",
"=",
"10",
",",
"includequeries",
"=",
"True",
")",
":",
"oldpersist",
"=",
"self",
".",
"persistent",
"self",
".",
"persistent",
"=",... | Generates a histogram of values from a string field. Output is:
[[low, high, count, query], ... ] Bin edges is determined by equal division
of the fields | [
"Generates",
"a",
"histogram",
"of",
"values",
"from",
"a",
"string",
"field",
".",
"Output",
"is",
":"
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py#L594-L702 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py | SolrConnection.fieldHistogram | def fieldHistogram(
self, name, q="*:*", fq=None, nbins=10, minmax=None, includequeries=True
):
"""Generates a histogram of values. Expects the field to be integer or floating
point.
@param name(string) Name of the field to compute
@param q(string) The query identifying the ... | python | def fieldHistogram(
self, name, q="*:*", fq=None, nbins=10, minmax=None, includequeries=True
):
"""Generates a histogram of values. Expects the field to be integer or floating
point.
@param name(string) Name of the field to compute
@param q(string) The query identifying the ... | [
"def",
"fieldHistogram",
"(",
"self",
",",
"name",
",",
"q",
"=",
"\"*:*\"",
",",
"fq",
"=",
"None",
",",
"nbins",
"=",
"10",
",",
"minmax",
"=",
"None",
",",
"includequeries",
"=",
"True",
")",
":",
"oldpersist",
"=",
"self",
".",
"persistent",
"sel... | Generates a histogram of values. Expects the field to be integer or floating
point.
@param name(string) Name of the field to compute
@param q(string) The query identifying the set of records for the histogram
@param fq(string) Filter query to restrict application of query
@param... | [
"Generates",
"a",
"histogram",
"of",
"values",
".",
"Expects",
"the",
"field",
"to",
"be",
"integer",
"or",
"floating",
"point",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py#L704-L798 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py | SolrConnection.fieldHistogram2d | def fieldHistogram2d(self, colname, rowname, q="*:*", fq=None, ncols=10, nrows=10):
"""Generates a 2d histogram of values. Expects the field to be integer or
floating point.
@param name1(string) Name of field1 columns to compute
@param name2(string) Name of field2 rows to compute
... | python | def fieldHistogram2d(self, colname, rowname, q="*:*", fq=None, ncols=10, nrows=10):
"""Generates a 2d histogram of values. Expects the field to be integer or
floating point.
@param name1(string) Name of field1 columns to compute
@param name2(string) Name of field2 rows to compute
... | [
"def",
"fieldHistogram2d",
"(",
"self",
",",
"colname",
",",
"rowname",
",",
"q",
"=",
"\"*:*\"",
",",
"fq",
"=",
"None",
",",
"ncols",
"=",
"10",
",",
"nrows",
"=",
"10",
")",
":",
"def",
"_mkQterm",
"(",
"name",
",",
"minv",
",",
"maxv",
",",
"... | Generates a 2d histogram of values. Expects the field to be integer or
floating point.
@param name1(string) Name of field1 columns to compute
@param name2(string) Name of field2 rows to compute
@param q(string) The query identifying the set of records for the histogram
@param fq... | [
"Generates",
"a",
"2d",
"histogram",
"of",
"values",
".",
"Expects",
"the",
"field",
"to",
"be",
"integer",
"or",
"floating",
"point",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py#L800-L924 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py | SOLRSearchResponseIterator._nextPage | def _nextPage(self, offset):
"""Retrieves the next set of results from the service."""
self.logger.debug("Iterator crecord=%s" % str(self.crecord))
params = {
'q': self.q,
'start': str(offset),
'rows': str(self.pagesize),
'fl': self.fields,
... | python | def _nextPage(self, offset):
"""Retrieves the next set of results from the service."""
self.logger.debug("Iterator crecord=%s" % str(self.crecord))
params = {
'q': self.q,
'start': str(offset),
'rows': str(self.pagesize),
'fl': self.fields,
... | [
"def",
"_nextPage",
"(",
"self",
",",
"offset",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"Iterator crecord=%s\"",
"%",
"str",
"(",
"self",
".",
"crecord",
")",
")",
"params",
"=",
"{",
"'q'",
":",
"self",
".",
"q",
",",
"'start'",
":",
... | Retrieves the next set of results from the service. | [
"Retrieves",
"the",
"next",
"set",
"of",
"results",
"from",
"the",
"service",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py#L1007-L1021 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py | SOLRValuesResponseIterator._nextPage | def _nextPage(self, offset):
"""Retrieves the next set of results from the service."""
self.logger.debug("Iterator crecord=%s" % str(self.crecord))
params = {
'q': self.q,
'rows': '0',
'facet': 'true',
'facet.field': self.field,
'facet... | python | def _nextPage(self, offset):
"""Retrieves the next set of results from the service."""
self.logger.debug("Iterator crecord=%s" % str(self.crecord))
params = {
'q': self.q,
'rows': '0',
'facet': 'true',
'facet.field': self.field,
'facet... | [
"def",
"_nextPage",
"(",
"self",
",",
"offset",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"Iterator crecord=%s\"",
"%",
"str",
"(",
"self",
".",
"crecord",
")",
")",
"params",
"=",
"{",
"'q'",
":",
"self",
".",
"q",
",",
"'rows'",
":",
... | Retrieves the next set of results from the service. | [
"Retrieves",
"the",
"next",
"set",
"of",
"results",
"from",
"the",
"service",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py#L1160-L1186 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/external.py | get_monitor_ping | def get_monitor_ping(request):
"""MNCore.ping() → Boolean."""
response = d1_gmn.app.views.util.http_response_with_boolean_true_type()
d1_gmn.app.views.headers.add_http_date_header(response)
return response | python | def get_monitor_ping(request):
"""MNCore.ping() → Boolean."""
response = d1_gmn.app.views.util.http_response_with_boolean_true_type()
d1_gmn.app.views.headers.add_http_date_header(response)
return response | [
"def",
"get_monitor_ping",
"(",
"request",
")",
":",
"response",
"=",
"d1_gmn",
".",
"app",
".",
"views",
".",
"util",
".",
"http_response_with_boolean_true_type",
"(",
")",
"d1_gmn",
".",
"app",
".",
"views",
".",
"headers",
".",
"add_http_date_header",
"(",
... | MNCore.ping() → Boolean. | [
"MNCore",
".",
"ping",
"()",
"→",
"Boolean",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/external.py#L108-L112 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/external.py | get_log | def get_log(request):
"""MNCore.getLogRecords(session[, fromDate][, toDate][, idFilter][, event]
[, start=0][, count=1000]) → Log
Sorted by timestamp, id.
"""
query = d1_gmn.app.models.EventLog.objects.all().order_by('timestamp', 'id')
if not d1_gmn.app.auth.is_trusted_subject(request):
... | python | def get_log(request):
"""MNCore.getLogRecords(session[, fromDate][, toDate][, idFilter][, event]
[, start=0][, count=1000]) → Log
Sorted by timestamp, id.
"""
query = d1_gmn.app.models.EventLog.objects.all().order_by('timestamp', 'id')
if not d1_gmn.app.auth.is_trusted_subject(request):
... | [
"def",
"get_log",
"(",
"request",
")",
":",
"query",
"=",
"d1_gmn",
".",
"app",
".",
"models",
".",
"EventLog",
".",
"objects",
".",
"all",
"(",
")",
".",
"order_by",
"(",
"'timestamp'",
",",
"'id'",
")",
"if",
"not",
"d1_gmn",
".",
"app",
".",
"au... | MNCore.getLogRecords(session[, fromDate][, toDate][, idFilter][, event]
[, start=0][, count=1000]) → Log
Sorted by timestamp, id. | [
"MNCore",
".",
"getLogRecords",
"(",
"session",
"[",
"fromDate",
"]",
"[",
"toDate",
"]",
"[",
"idFilter",
"]",
"[",
"event",
"]"
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/external.py#L121-L164 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/external.py | get_node | def get_node(request):
"""MNCore.getCapabilities() → Node."""
api_major_int = 2 if d1_gmn.app.views.util.is_v2_api(request) else 1
node_pretty_xml = d1_gmn.app.node.get_pretty_xml(api_major_int)
return django.http.HttpResponse(node_pretty_xml, d1_common.const.CONTENT_TYPE_XML) | python | def get_node(request):
"""MNCore.getCapabilities() → Node."""
api_major_int = 2 if d1_gmn.app.views.util.is_v2_api(request) else 1
node_pretty_xml = d1_gmn.app.node.get_pretty_xml(api_major_int)
return django.http.HttpResponse(node_pretty_xml, d1_common.const.CONTENT_TYPE_XML) | [
"def",
"get_node",
"(",
"request",
")",
":",
"api_major_int",
"=",
"2",
"if",
"d1_gmn",
".",
"app",
".",
"views",
".",
"util",
".",
"is_v2_api",
"(",
"request",
")",
"else",
"1",
"node_pretty_xml",
"=",
"d1_gmn",
".",
"app",
".",
"node",
".",
"get_pret... | MNCore.getCapabilities() → Node. | [
"MNCore",
".",
"getCapabilities",
"()",
"→",
"Node",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/external.py#L168-L172 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/external.py | get_object | def get_object(request, pid):
"""MNRead.get(session, did) → OctetStream."""
sciobj = d1_gmn.app.models.ScienceObject.objects.get(pid__did=pid)
content_type_str = d1_gmn.app.object_format_cache.get_content_type(
sciobj.format.format
)
# Return local or proxied SciObj bytes
response = djan... | python | def get_object(request, pid):
"""MNRead.get(session, did) → OctetStream."""
sciobj = d1_gmn.app.models.ScienceObject.objects.get(pid__did=pid)
content_type_str = d1_gmn.app.object_format_cache.get_content_type(
sciobj.format.format
)
# Return local or proxied SciObj bytes
response = djan... | [
"def",
"get_object",
"(",
"request",
",",
"pid",
")",
":",
"sciobj",
"=",
"d1_gmn",
".",
"app",
".",
"models",
".",
"ScienceObject",
".",
"objects",
".",
"get",
"(",
"pid__did",
"=",
"pid",
")",
"content_type_str",
"=",
"d1_gmn",
".",
"app",
".",
"obje... | MNRead.get(session, did) → OctetStream. | [
"MNRead",
".",
"get",
"(",
"session",
"did",
")",
"→",
"OctetStream",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/external.py#L183-L195 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/external.py | get_meta | def get_meta(request, pid):
"""MNRead.getSystemMetadata(session, pid) → SystemMetadata."""
d1_gmn.app.event_log.log_read_event(pid, request)
return django.http.HttpResponse(
d1_gmn.app.views.util.generate_sysmeta_xml_matching_api_version(request, pid),
d1_common.const.CONTENT_TYPE_XML,
) | python | def get_meta(request, pid):
"""MNRead.getSystemMetadata(session, pid) → SystemMetadata."""
d1_gmn.app.event_log.log_read_event(pid, request)
return django.http.HttpResponse(
d1_gmn.app.views.util.generate_sysmeta_xml_matching_api_version(request, pid),
d1_common.const.CONTENT_TYPE_XML,
) | [
"def",
"get_meta",
"(",
"request",
",",
"pid",
")",
":",
"d1_gmn",
".",
"app",
".",
"event_log",
".",
"log_read_event",
"(",
"pid",
",",
"request",
")",
"return",
"django",
".",
"http",
".",
"HttpResponse",
"(",
"d1_gmn",
".",
"app",
".",
"views",
".",... | MNRead.getSystemMetadata(session, pid) → SystemMetadata. | [
"MNRead",
".",
"getSystemMetadata",
"(",
"session",
"pid",
")",
"→",
"SystemMetadata",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/external.py#L221-L227 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/external.py | head_object | def head_object(request, pid):
"""MNRead.describe(session, did) → DescribeResponse."""
sciobj = d1_gmn.app.models.ScienceObject.objects.get(pid__did=pid)
response = django.http.HttpResponse()
d1_gmn.app.views.headers.add_sciobj_properties_headers_to_response(response, sciobj)
d1_gmn.app.event_log.lo... | python | def head_object(request, pid):
"""MNRead.describe(session, did) → DescribeResponse."""
sciobj = d1_gmn.app.models.ScienceObject.objects.get(pid__did=pid)
response = django.http.HttpResponse()
d1_gmn.app.views.headers.add_sciobj_properties_headers_to_response(response, sciobj)
d1_gmn.app.event_log.lo... | [
"def",
"head_object",
"(",
"request",
",",
"pid",
")",
":",
"sciobj",
"=",
"d1_gmn",
".",
"app",
".",
"models",
".",
"ScienceObject",
".",
"objects",
".",
"get",
"(",
"pid__did",
"=",
"pid",
")",
"response",
"=",
"django",
".",
"http",
".",
"HttpRespon... | MNRead.describe(session, did) → DescribeResponse. | [
"MNRead",
".",
"describe",
"(",
"session",
"did",
")",
"→",
"DescribeResponse",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/external.py#L233-L239 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/external.py | get_checksum | def get_checksum(request, pid):
"""MNRead.getChecksum(session, did[, checksumAlgorithm]) → Checksum."""
# MNRead.getChecksum() requires that a new checksum be calculated. Cannot
# simply return the checksum from the sysmeta.
#
# If the checksumAlgorithm argument was not provided, it defaults to
... | python | def get_checksum(request, pid):
"""MNRead.getChecksum(session, did[, checksumAlgorithm]) → Checksum."""
# MNRead.getChecksum() requires that a new checksum be calculated. Cannot
# simply return the checksum from the sysmeta.
#
# If the checksumAlgorithm argument was not provided, it defaults to
... | [
"def",
"get_checksum",
"(",
"request",
",",
"pid",
")",
":",
"# MNRead.getChecksum() requires that a new checksum be calculated. Cannot",
"# simply return the checksum from the sysmeta.",
"#",
"# If the checksumAlgorithm argument was not provided, it defaults to",
"# the system wide default ... | MNRead.getChecksum(session, did[, checksumAlgorithm]) → Checksum. | [
"MNRead",
".",
"getChecksum",
"(",
"session",
"did",
"[",
"checksumAlgorithm",
"]",
")",
"→",
"Checksum",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/external.py#L245-L279 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/external.py | post_error | def post_error(request):
"""MNRead.synchronizationFailed(session, message)"""
d1_gmn.app.views.assert_db.post_has_mime_parts(request, (('file', 'message'),))
try:
synchronization_failed = d1_gmn.app.views.util.deserialize(
request.FILES['message']
)
except d1_common.types.exc... | python | def post_error(request):
"""MNRead.synchronizationFailed(session, message)"""
d1_gmn.app.views.assert_db.post_has_mime_parts(request, (('file', 'message'),))
try:
synchronization_failed = d1_gmn.app.views.util.deserialize(
request.FILES['message']
)
except d1_common.types.exc... | [
"def",
"post_error",
"(",
"request",
")",
":",
"d1_gmn",
".",
"app",
".",
"views",
".",
"assert_db",
".",
"post_has_mime_parts",
"(",
"request",
",",
"(",
"(",
"'file'",
",",
"'message'",
")",
",",
")",
")",
"try",
":",
"synchronization_failed",
"=",
"d1... | MNRead.synchronizationFailed(session, message) | [
"MNRead",
".",
"synchronizationFailed",
"(",
"session",
"message",
")"
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/external.py#L293-L316 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/external.py | get_replica | def get_replica(request, pid):
"""MNReplication.getReplica(session, did) → OctetStream."""
_assert_node_is_authorized(request, pid)
sciobj = d1_gmn.app.models.ScienceObject.objects.get(pid__did=pid)
content_type_str = d1_gmn.app.object_format_cache.get_content_type(
sciobj.format.format
)
... | python | def get_replica(request, pid):
"""MNReplication.getReplica(session, did) → OctetStream."""
_assert_node_is_authorized(request, pid)
sciobj = d1_gmn.app.models.ScienceObject.objects.get(pid__did=pid)
content_type_str = d1_gmn.app.object_format_cache.get_content_type(
sciobj.format.format
)
... | [
"def",
"get_replica",
"(",
"request",
",",
"pid",
")",
":",
"_assert_node_is_authorized",
"(",
"request",
",",
"pid",
")",
"sciobj",
"=",
"d1_gmn",
".",
"app",
".",
"models",
".",
"ScienceObject",
".",
"objects",
".",
"get",
"(",
"pid__did",
"=",
"pid",
... | MNReplication.getReplica(session, did) → OctetStream. | [
"MNReplication",
".",
"getReplica",
"(",
"session",
"did",
")",
"→",
"OctetStream",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/external.py#L322-L336 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/external.py | put_meta | def put_meta(request):
"""MNStorage.updateSystemMetadata(session, pid, sysmeta) → boolean.
TODO: Currently, this call allows making breaking changes to SysMeta. We need to
clarify what can be modified and what the behavior should be when working with SIDs
and chains.
"""
if django.conf.setting... | python | def put_meta(request):
"""MNStorage.updateSystemMetadata(session, pid, sysmeta) → boolean.
TODO: Currently, this call allows making breaking changes to SysMeta. We need to
clarify what can be modified and what the behavior should be when working with SIDs
and chains.
"""
if django.conf.setting... | [
"def",
"put_meta",
"(",
"request",
")",
":",
"if",
"django",
".",
"conf",
".",
"settings",
".",
"REQUIRE_WHITELIST_FOR_UPDATE",
":",
"d1_gmn",
".",
"app",
".",
"auth",
".",
"assert_create_update_delete_permission",
"(",
"request",
")",
"d1_gmn",
".",
"app",
".... | MNStorage.updateSystemMetadata(session, pid, sysmeta) → boolean.
TODO: Currently, this call allows making breaking changes to SysMeta. We need to
clarify what can be modified and what the behavior should be when working with SIDs
and chains. | [
"MNStorage",
".",
"updateSystemMetadata",
"(",
"session",
"pid",
"sysmeta",
")",
"→",
"boolean",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/external.py#L363-L392 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/external.py | get_is_authorized | def get_is_authorized(request, pid):
"""MNAuthorization.isAuthorized(did, action) -> Boolean."""
if 'action' not in request.GET:
raise d1_common.types.exceptions.InvalidRequest(
0, 'Missing required parameter. required="action"'
)
# Convert action string to action level. Raises I... | python | def get_is_authorized(request, pid):
"""MNAuthorization.isAuthorized(did, action) -> Boolean."""
if 'action' not in request.GET:
raise d1_common.types.exceptions.InvalidRequest(
0, 'Missing required parameter. required="action"'
)
# Convert action string to action level. Raises I... | [
"def",
"get_is_authorized",
"(",
"request",
",",
"pid",
")",
":",
"if",
"'action'",
"not",
"in",
"request",
".",
"GET",
":",
"raise",
"d1_common",
".",
"types",
".",
"exceptions",
".",
"InvalidRequest",
"(",
"0",
",",
"'Missing required parameter. required=\"act... | MNAuthorization.isAuthorized(did, action) -> Boolean. | [
"MNAuthorization",
".",
"isAuthorized",
"(",
"did",
"action",
")",
"-",
">",
"Boolean",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/external.py#L403-L413 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/external.py | post_refresh_system_metadata | def post_refresh_system_metadata(request):
"""MNStorage.systemMetadataChanged(session, did, serialVersion,
dateSysMetaLastModified) → boolean."""
d1_gmn.app.views.assert_db.post_has_mime_parts(
request,
(
('field', 'pid'),
('field', 'serialVersion'),
('fie... | python | def post_refresh_system_metadata(request):
"""MNStorage.systemMetadataChanged(session, did, serialVersion,
dateSysMetaLastModified) → boolean."""
d1_gmn.app.views.assert_db.post_has_mime_parts(
request,
(
('field', 'pid'),
('field', 'serialVersion'),
('fie... | [
"def",
"post_refresh_system_metadata",
"(",
"request",
")",
":",
"d1_gmn",
".",
"app",
".",
"views",
".",
"assert_db",
".",
"post_has_mime_parts",
"(",
"request",
",",
"(",
"(",
"'field'",
",",
"'pid'",
")",
",",
"(",
"'field'",
",",
"'serialVersion'",
")",
... | MNStorage.systemMetadataChanged(session, did, serialVersion,
dateSysMetaLastModified) → boolean. | [
"MNStorage",
".",
"systemMetadataChanged",
"(",
"session",
"did",
"serialVersion",
"dateSysMetaLastModified",
")",
"→",
"boolean",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/external.py#L417-L435 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/external.py | post_object_list | def post_object_list(request):
"""MNStorage.create(session, did, object, sysmeta) → Identifier."""
d1_gmn.app.views.assert_db.post_has_mime_parts(
request, (('field', 'pid'), ('file', 'object'), ('file', 'sysmeta'))
)
url_pid = request.POST['pid']
sysmeta_pyxb = d1_gmn.app.sysmeta.deserializ... | python | def post_object_list(request):
"""MNStorage.create(session, did, object, sysmeta) → Identifier."""
d1_gmn.app.views.assert_db.post_has_mime_parts(
request, (('field', 'pid'), ('file', 'object'), ('file', 'sysmeta'))
)
url_pid = request.POST['pid']
sysmeta_pyxb = d1_gmn.app.sysmeta.deserializ... | [
"def",
"post_object_list",
"(",
"request",
")",
":",
"d1_gmn",
".",
"app",
".",
"views",
".",
"assert_db",
".",
"post_has_mime_parts",
"(",
"request",
",",
"(",
"(",
"'field'",
",",
"'pid'",
")",
",",
"(",
"'file'",
",",
"'object'",
")",
",",
"(",
"'fi... | MNStorage.create(session, did, object, sysmeta) → Identifier. | [
"MNStorage",
".",
"create",
"(",
"session",
"did",
"object",
"sysmeta",
")",
"→",
"Identifier",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/external.py#L479-L490 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/external.py | put_object | def put_object(request, old_pid):
"""MNStorage.update(session, pid, object, newPid, sysmeta) → Identifier."""
if django.conf.settings.REQUIRE_WHITELIST_FOR_UPDATE:
d1_gmn.app.auth.assert_create_update_delete_permission(request)
d1_gmn.app.util.coerce_put_post(request)
d1_gmn.app.views.assert_db.... | python | def put_object(request, old_pid):
"""MNStorage.update(session, pid, object, newPid, sysmeta) → Identifier."""
if django.conf.settings.REQUIRE_WHITELIST_FOR_UPDATE:
d1_gmn.app.auth.assert_create_update_delete_permission(request)
d1_gmn.app.util.coerce_put_post(request)
d1_gmn.app.views.assert_db.... | [
"def",
"put_object",
"(",
"request",
",",
"old_pid",
")",
":",
"if",
"django",
".",
"conf",
".",
"settings",
".",
"REQUIRE_WHITELIST_FOR_UPDATE",
":",
"d1_gmn",
".",
"app",
".",
"auth",
".",
"assert_create_update_delete_permission",
"(",
"request",
")",
"d1_gmn"... | MNStorage.update(session, pid, object, newPid, sysmeta) → Identifier. | [
"MNStorage",
".",
"update",
"(",
"session",
"pid",
"object",
"newPid",
"sysmeta",
")",
"→",
"Identifier",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/external.py#L497-L526 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/external.py | post_generate_identifier | def post_generate_identifier(request):
"""MNStorage.generateIdentifier(session, scheme[, fragment]) → Identifier."""
d1_gmn.app.views.assert_db.post_has_mime_parts(request, (('field', 'scheme'),))
if request.POST['scheme'] != 'UUID':
raise d1_common.types.exceptions.InvalidRequest(
0, 'O... | python | def post_generate_identifier(request):
"""MNStorage.generateIdentifier(session, scheme[, fragment]) → Identifier."""
d1_gmn.app.views.assert_db.post_has_mime_parts(request, (('field', 'scheme'),))
if request.POST['scheme'] != 'UUID':
raise d1_common.types.exceptions.InvalidRequest(
0, 'O... | [
"def",
"post_generate_identifier",
"(",
"request",
")",
":",
"d1_gmn",
".",
"app",
".",
"views",
".",
"assert_db",
".",
"post_has_mime_parts",
"(",
"request",
",",
"(",
"(",
"'field'",
",",
"'scheme'",
")",
",",
")",
")",
"if",
"request",
".",
"POST",
"[... | MNStorage.generateIdentifier(session, scheme[, fragment]) → Identifier. | [
"MNStorage",
".",
"generateIdentifier",
"(",
"session",
"scheme",
"[",
"fragment",
"]",
")",
"→",
"Identifier",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/external.py#L530-L541 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/external.py | put_archive | def put_archive(request, pid):
"""MNStorage.archive(session, did) → Identifier."""
d1_gmn.app.views.assert_db.is_not_replica(pid)
d1_gmn.app.views.assert_db.is_not_archived(pid)
d1_gmn.app.sysmeta.archive_sciobj(pid)
return pid | python | def put_archive(request, pid):
"""MNStorage.archive(session, did) → Identifier."""
d1_gmn.app.views.assert_db.is_not_replica(pid)
d1_gmn.app.views.assert_db.is_not_archived(pid)
d1_gmn.app.sysmeta.archive_sciobj(pid)
return pid | [
"def",
"put_archive",
"(",
"request",
",",
"pid",
")",
":",
"d1_gmn",
".",
"app",
".",
"views",
".",
"assert_db",
".",
"is_not_replica",
"(",
"pid",
")",
"d1_gmn",
".",
"app",
".",
"views",
".",
"assert_db",
".",
"is_not_archived",
"(",
"pid",
")",
"d1... | MNStorage.archive(session, did) → Identifier. | [
"MNStorage",
".",
"archive",
"(",
"session",
"did",
")",
"→",
"Identifier",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/external.py#L555-L560 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/external.py | post_replicate | def post_replicate(request):
"""MNReplication.replicate(session, sysmeta, sourceNode) → boolean."""
d1_gmn.app.views.assert_db.post_has_mime_parts(
request, (('field', 'sourceNode'), ('file', 'sysmeta'))
)
sysmeta_pyxb = d1_gmn.app.sysmeta.deserialize(request.FILES['sysmeta'])
d1_gmn.app.loc... | python | def post_replicate(request):
"""MNReplication.replicate(session, sysmeta, sourceNode) → boolean."""
d1_gmn.app.views.assert_db.post_has_mime_parts(
request, (('field', 'sourceNode'), ('file', 'sysmeta'))
)
sysmeta_pyxb = d1_gmn.app.sysmeta.deserialize(request.FILES['sysmeta'])
d1_gmn.app.loc... | [
"def",
"post_replicate",
"(",
"request",
")",
":",
"d1_gmn",
".",
"app",
".",
"views",
".",
"assert_db",
".",
"post_has_mime_parts",
"(",
"request",
",",
"(",
"(",
"'field'",
",",
"'sourceNode'",
")",
",",
"(",
"'file'",
",",
"'sysmeta'",
")",
")",
")",
... | MNReplication.replicate(session, sysmeta, sourceNode) → boolean. | [
"MNReplication",
".",
"replicate",
"(",
"session",
"sysmeta",
"sourceNode",
")",
"→",
"boolean",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/external.py#L569-L583 |
genialis/resolwe | resolwe/process/fields.py | Field.contribute_to_class | def contribute_to_class(self, process, fields, name):
"""Register this field with a specific process.
:param process: Process descriptor instance
:param fields: Fields registry to use
:param name: Field name
"""
self.name = name
self.process = process
fie... | python | def contribute_to_class(self, process, fields, name):
"""Register this field with a specific process.
:param process: Process descriptor instance
:param fields: Fields registry to use
:param name: Field name
"""
self.name = name
self.process = process
fie... | [
"def",
"contribute_to_class",
"(",
"self",
",",
"process",
",",
"fields",
",",
"name",
")",
":",
"self",
".",
"name",
"=",
"name",
"self",
".",
"process",
"=",
"process",
"fields",
"[",
"name",
"]",
"=",
"self"
] | Register this field with a specific process.
:param process: Process descriptor instance
:param fields: Fields registry to use
:param name: Field name | [
"Register",
"this",
"field",
"with",
"a",
"specific",
"process",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/fields.py#L33-L42 |
genialis/resolwe | resolwe/process/fields.py | Field.to_schema | def to_schema(self):
"""Return field schema for this field."""
if not self.name or not self.process:
raise ValueError("field is not registered with process")
schema = {
'name': self.name,
'type': self.get_field_type(),
}
if self.required is no... | python | def to_schema(self):
"""Return field schema for this field."""
if not self.name or not self.process:
raise ValueError("field is not registered with process")
schema = {
'name': self.name,
'type': self.get_field_type(),
}
if self.required is no... | [
"def",
"to_schema",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"name",
"or",
"not",
"self",
".",
"process",
":",
"raise",
"ValueError",
"(",
"\"field is not registered with process\"",
")",
"schema",
"=",
"{",
"'name'",
":",
"self",
".",
"name",
",",... | Return field schema for this field. | [
"Return",
"field",
"schema",
"for",
"this",
"field",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/fields.py#L48-L74 |
genialis/resolwe | resolwe/process/fields.py | Field.validate | def validate(self, value):
"""Validate field value."""
if self.required and value is None:
raise ValidationError("field is required")
if value is not None and self.choices is not None:
choices = [choice for choice, _ in self.choices]
if value not in choices:
... | python | def validate(self, value):
"""Validate field value."""
if self.required and value is None:
raise ValidationError("field is required")
if value is not None and self.choices is not None:
choices = [choice for choice, _ in self.choices]
if value not in choices:
... | [
"def",
"validate",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"required",
"and",
"value",
"is",
"None",
":",
"raise",
"ValidationError",
"(",
"\"field is required\"",
")",
"if",
"value",
"is",
"not",
"None",
"and",
"self",
".",
"choices",
"i... | Validate field value. | [
"Validate",
"field",
"value",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/fields.py#L80-L90 |
genialis/resolwe | resolwe/process/fields.py | Field.clean | def clean(self, value):
"""Run validators and return the clean value."""
if value is None:
value = self.default
try:
value = self.to_python(value)
self.validate(value)
except ValidationError as error:
raise ValidationError("invalid value f... | python | def clean(self, value):
"""Run validators and return the clean value."""
if value is None:
value = self.default
try:
value = self.to_python(value)
self.validate(value)
except ValidationError as error:
raise ValidationError("invalid value f... | [
"def",
"clean",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"value",
"=",
"self",
".",
"default",
"try",
":",
"value",
"=",
"self",
".",
"to_python",
"(",
"value",
")",
"self",
".",
"validate",
"(",
"value",
")",
"except"... | Run validators and return the clean value. | [
"Run",
"validators",
"and",
"return",
"the",
"clean",
"value",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/fields.py#L92-L105 |
genialis/resolwe | resolwe/process/fields.py | StringField.validate | def validate(self, value):
"""Validate field value."""
if value is not None and not isinstance(value, str):
raise ValidationError("field must be a string")
super().validate(value) | python | def validate(self, value):
"""Validate field value."""
if value is not None and not isinstance(value, str):
raise ValidationError("field must be a string")
super().validate(value) | [
"def",
"validate",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"raise",
"ValidationError",
"(",
"\"field must be a string\"",
")",
"super",
"(",
")",
".",
"valid... | Validate field value. | [
"Validate",
"field",
"value",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/fields.py#L122-L127 |
genialis/resolwe | resolwe/process/fields.py | BooleanField.validate | def validate(self, value):
"""Validate field value."""
if value is not None and not isinstance(value, bool):
raise ValidationError("field must be a boolean")
super().validate(value) | python | def validate(self, value):
"""Validate field value."""
if value is not None and not isinstance(value, bool):
raise ValidationError("field must be a boolean")
super().validate(value) | [
"def",
"validate",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"value",
",",
"bool",
")",
":",
"raise",
"ValidationError",
"(",
"\"field must be a boolean\"",
")",
"super",
"(",
")",
".",
"val... | Validate field value. | [
"Validate",
"field",
"value",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/fields.py#L141-L146 |
genialis/resolwe | resolwe/process/fields.py | IntegerField.to_output | def to_output(self, value):
"""Convert value to process output format."""
return json.loads(resolwe_runtime_utils.save(self.name, str(value))) | python | def to_output(self, value):
"""Convert value to process output format."""
return json.loads(resolwe_runtime_utils.save(self.name, str(value))) | [
"def",
"to_output",
"(",
"self",
",",
"value",
")",
":",
"return",
"json",
".",
"loads",
"(",
"resolwe_runtime_utils",
".",
"save",
"(",
"self",
".",
"name",
",",
"str",
"(",
"value",
")",
")",
")"
] | Convert value to process output format. | [
"Convert",
"value",
"to",
"process",
"output",
"format",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/fields.py#L162-L164 |
genialis/resolwe | resolwe/process/fields.py | UrlField.to_python | def to_python(self, value):
"""Convert value if needed."""
if isinstance(value, str):
return value
elif isinstance(value, dict):
try:
value = value['url']
except KeyError:
raise ValidationError("dictionary must contain an 'url' ... | python | def to_python(self, value):
"""Convert value if needed."""
if isinstance(value, str):
return value
elif isinstance(value, dict):
try:
value = value['url']
except KeyError:
raise ValidationError("dictionary must contain an 'url' ... | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"return",
"value",
"elif",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"try",
":",
"value",
"=",
"value",
"[",
"'url'",
"]",
"ex... | Convert value if needed. | [
"Convert",
"value",
"if",
"needed",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/fields.py#L219-L234 |
genialis/resolwe | resolwe/process/fields.py | FileDescriptor.import_file | def import_file(self, imported_format=None, progress_from=0.0, progress_to=None):
"""Import field source file to working directory.
:param imported_format: Import file format (extracted, compressed or both)
:param progress_from: Initial progress value
:param progress_to: Final progress ... | python | def import_file(self, imported_format=None, progress_from=0.0, progress_to=None):
"""Import field source file to working directory.
:param imported_format: Import file format (extracted, compressed or both)
:param progress_from: Initial progress value
:param progress_to: Final progress ... | [
"def",
"import_file",
"(",
"self",
",",
"imported_format",
"=",
"None",
",",
"progress_from",
"=",
"0.0",
",",
"progress_to",
"=",
"None",
")",
":",
"if",
"not",
"hasattr",
"(",
"resolwe_runtime_utils",
",",
"'import_file'",
")",
":",
"raise",
"RuntimeError",
... | Import field source file to working directory.
:param imported_format: Import file format (extracted, compressed or both)
:param progress_from: Initial progress value
:param progress_to: Final progress value
:return: Destination file path (if extracted and compressed, extracted path giv... | [
"Import",
"field",
"source",
"file",
"to",
"working",
"directory",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/fields.py#L261-L281 |
genialis/resolwe | resolwe/process/fields.py | FileField.to_python | def to_python(self, value):
"""Convert value if needed."""
if isinstance(value, FileDescriptor):
return value
elif isinstance(value, str):
return FileDescriptor(value)
elif isinstance(value, dict):
try:
path = value['file']
... | python | def to_python(self, value):
"""Convert value if needed."""
if isinstance(value, FileDescriptor):
return value
elif isinstance(value, str):
return FileDescriptor(value)
elif isinstance(value, dict):
try:
path = value['file']
... | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"FileDescriptor",
")",
":",
"return",
"value",
"elif",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"return",
"FileDescriptor",
"(",
"value",
")",
"elif"... | Convert value if needed. | [
"Convert",
"value",
"if",
"needed",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/fields.py#L293-L338 |
genialis/resolwe | resolwe/process/fields.py | FileField.to_output | def to_output(self, value):
"""Convert value to process output format."""
return json.loads(resolwe_runtime_utils.save_file(self.name, value.path, *value.refs)) | python | def to_output(self, value):
"""Convert value to process output format."""
return json.loads(resolwe_runtime_utils.save_file(self.name, value.path, *value.refs)) | [
"def",
"to_output",
"(",
"self",
",",
"value",
")",
":",
"return",
"json",
".",
"loads",
"(",
"resolwe_runtime_utils",
".",
"save_file",
"(",
"self",
".",
"name",
",",
"value",
".",
"path",
",",
"*",
"value",
".",
"refs",
")",
")"
] | Convert value to process output format. | [
"Convert",
"value",
"to",
"process",
"output",
"format",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/fields.py#L340-L342 |
genialis/resolwe | resolwe/process/fields.py | DirField.to_python | def to_python(self, value):
"""Convert value if needed."""
if isinstance(value, DirDescriptor):
return value
elif isinstance(value, str):
return DirDescriptor(value)
elif isinstance(value, dict):
try:
path = value['dir']
exc... | python | def to_python(self, value):
"""Convert value if needed."""
if isinstance(value, DirDescriptor):
return value
elif isinstance(value, str):
return DirDescriptor(value)
elif isinstance(value, dict):
try:
path = value['dir']
exc... | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"DirDescriptor",
")",
":",
"return",
"value",
"elif",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"return",
"DirDescriptor",
"(",
"value",
")",
"elif",
... | Convert value if needed. | [
"Convert",
"value",
"if",
"needed",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/fields.py#L373-L408 |
genialis/resolwe | resolwe/process/fields.py | ListField.contribute_to_class | def contribute_to_class(self, process, fields, name):
"""Register this field with a specific process.
:param process: Process descriptor instance
:param fields: Fields registry to use
:param name: Field name
"""
super().contribute_to_class(process, fields, name)
... | python | def contribute_to_class(self, process, fields, name):
"""Register this field with a specific process.
:param process: Process descriptor instance
:param fields: Fields registry to use
:param name: Field name
"""
super().contribute_to_class(process, fields, name)
... | [
"def",
"contribute_to_class",
"(",
"self",
",",
"process",
",",
"fields",
",",
"name",
")",
":",
"super",
"(",
")",
".",
"contribute_to_class",
"(",
"process",
",",
"fields",
",",
"name",
")",
"self",
".",
"inner",
".",
"name",
"=",
"name",
"self",
"."... | Register this field with a specific process.
:param process: Process descriptor instance
:param fields: Fields registry to use
:param name: Field name | [
"Register",
"this",
"field",
"with",
"a",
"specific",
"process",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/fields.py#L437-L447 |
genialis/resolwe | resolwe/process/fields.py | ListField.to_output | def to_output(self, value):
"""Convert value to process output format."""
return {self.name: [self.inner.to_output(v)[self.name] for v in value]} | python | def to_output(self, value):
"""Convert value to process output format."""
return {self.name: [self.inner.to_output(v)[self.name] for v in value]} | [
"def",
"to_output",
"(",
"self",
",",
"value",
")",
":",
"return",
"{",
"self",
".",
"name",
":",
"[",
"self",
".",
"inner",
".",
"to_output",
"(",
"v",
")",
"[",
"self",
".",
"name",
"]",
"for",
"v",
"in",
"value",
"]",
"}"
] | Convert value to process output format. | [
"Convert",
"value",
"to",
"process",
"output",
"format",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/fields.py#L453-L455 |
genialis/resolwe | resolwe/process/fields.py | ListField.validate | def validate(self, value):
"""Validate field value."""
if value is not None:
if not isinstance(value, list):
raise ValidationError("field must be a list")
for index, element in enumerate(value):
try:
self.inner.validate(element... | python | def validate(self, value):
"""Validate field value."""
if value is not None:
if not isinstance(value, list):
raise ValidationError("field must be a list")
for index, element in enumerate(value):
try:
self.inner.validate(element... | [
"def",
"validate",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"list",
")",
":",
"raise",
"ValidationError",
"(",
"\"field must be a list\"",
")",
"for",
"index",
",",
"eleme... | Validate field value. | [
"Validate",
"field",
"value",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/fields.py#L461-L476 |
genialis/resolwe | resolwe/process/fields.py | DataDescriptor._get | def _get(self, key):
"""Return given key from cache."""
self._populate_cache()
if key not in self._cache:
raise AttributeError("DataField has no member {}".format(key))
return self._cache[key] | python | def _get(self, key):
"""Return given key from cache."""
self._populate_cache()
if key not in self._cache:
raise AttributeError("DataField has no member {}".format(key))
return self._cache[key] | [
"def",
"_get",
"(",
"self",
",",
"key",
")",
":",
"self",
".",
"_populate_cache",
"(",
")",
"if",
"key",
"not",
"in",
"self",
".",
"_cache",
":",
"raise",
"AttributeError",
"(",
"\"DataField has no member {}\"",
".",
"format",
"(",
"key",
")",
")",
"retu... | Return given key from cache. | [
"Return",
"given",
"key",
"from",
"cache",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/fields.py#L522-L528 |
genialis/resolwe | resolwe/process/fields.py | DataField.to_python | def to_python(self, value):
"""Convert value if needed."""
cache = None
if value is None:
return None
if isinstance(value, DataDescriptor):
return value
elif isinstance(value, dict):
# Allow pre-hydrated data objects.
cache = value... | python | def to_python(self, value):
"""Convert value if needed."""
cache = None
if value is None:
return None
if isinstance(value, DataDescriptor):
return value
elif isinstance(value, dict):
# Allow pre-hydrated data objects.
cache = value... | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"cache",
"=",
"None",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"if",
"isinstance",
"(",
"value",
",",
"DataDescriptor",
")",
":",
"return",
"value",
"elif",
"isinstance",
"(",
"value",
... | Convert value if needed. | [
"Convert",
"value",
"if",
"needed",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/fields.py#L576-L594 |
genialis/resolwe | resolwe/process/fields.py | GroupField.contribute_to_class | def contribute_to_class(self, process, fields, name):
"""Register this field with a specific process.
:param process: Process descriptor instance
:param fields: Fields registry to use
:param name: Field name
"""
# Use order-preserving definition namespace (__dict__) to r... | python | def contribute_to_class(self, process, fields, name):
"""Register this field with a specific process.
:param process: Process descriptor instance
:param fields: Fields registry to use
:param name: Field name
"""
# Use order-preserving definition namespace (__dict__) to r... | [
"def",
"contribute_to_class",
"(",
"self",
",",
"process",
",",
"fields",
",",
"name",
")",
":",
"# Use order-preserving definition namespace (__dict__) to respect the",
"# order of GroupField's fields definition.",
"for",
"field_name",
"in",
"self",
".",
"field_group",
".",
... | Register this field with a specific process.
:param process: Process descriptor instance
:param fields: Fields registry to use
:param name: Field name | [
"Register",
"this",
"field",
"with",
"a",
"specific",
"process",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/fields.py#L632-L648 |
genialis/resolwe | resolwe/process/fields.py | GroupField.to_python | def to_python(self, value):
"""Convert value if needed."""
if isinstance(value, GroupDescriptor):
value = value._value # pylint: disable=protected-access
result = {}
for name, field in self.fields.items():
result[name] = field.to_python(value.get(name, None))
... | python | def to_python(self, value):
"""Convert value if needed."""
if isinstance(value, GroupDescriptor):
value = value._value # pylint: disable=protected-access
result = {}
for name, field in self.fields.items():
result[name] = field.to_python(value.get(name, None))
... | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"GroupDescriptor",
")",
":",
"value",
"=",
"value",
".",
"_value",
"# pylint: disable=protected-access",
"result",
"=",
"{",
"}",
"for",
"name",
",",
"field",
"... | Convert value if needed. | [
"Convert",
"value",
"if",
"needed",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/fields.py#L650-L659 |
genialis/resolwe | resolwe/process/fields.py | GroupField.to_schema | def to_schema(self):
"""Return field schema for this field."""
schema = super().to_schema()
if self.disabled is not None:
schema['disabled'] = self.disabled
if self.collapsed is not None:
schema['collapsed'] = self.collapsed
group = []
for field i... | python | def to_schema(self):
"""Return field schema for this field."""
schema = super().to_schema()
if self.disabled is not None:
schema['disabled'] = self.disabled
if self.collapsed is not None:
schema['collapsed'] = self.collapsed
group = []
for field i... | [
"def",
"to_schema",
"(",
"self",
")",
":",
"schema",
"=",
"super",
"(",
")",
".",
"to_schema",
"(",
")",
"if",
"self",
".",
"disabled",
"is",
"not",
"None",
":",
"schema",
"[",
"'disabled'",
"]",
"=",
"self",
".",
"disabled",
"if",
"self",
".",
"co... | Return field schema for this field. | [
"Return",
"field",
"schema",
"for",
"this",
"field",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/fields.py#L661-L674 |
genialis/resolwe | resolwe/flow/managers/state.py | update_constants | def update_constants():
"""Recreate channel name constants with changed settings.
This kludge is mostly needed due to the way Django settings are
patched for testing and how modules need to be imported throughout
the project. On import time, settings are not patched yet, but some
of the code needs ... | python | def update_constants():
"""Recreate channel name constants with changed settings.
This kludge is mostly needed due to the way Django settings are
patched for testing and how modules need to be imported throughout
the project. On import time, settings are not patched yet, but some
of the code needs ... | [
"def",
"update_constants",
"(",
")",
":",
"global",
"MANAGER_CONTROL_CHANNEL",
",",
"MANAGER_EXECUTOR_CHANNELS",
"# pylint: disable=global-statement",
"global",
"MANAGER_LISTENER_STATS",
",",
"MANAGER_STATE_PREFIX",
"# pylint: disable=global-statement",
"redis_prefix",
"=",
"getatt... | Recreate channel name constants with changed settings.
This kludge is mostly needed due to the way Django settings are
patched for testing and how modules need to be imported throughout
the project. On import time, settings are not patched yet, but some
of the code needs static values immediately. Upda... | [
"Recreate",
"channel",
"name",
"constants",
"with",
"changed",
"settings",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/state.py#L33-L52 |
genialis/resolwe | resolwe/flow/managers/state.py | ManagerState.destroy_channels | def destroy_channels(self):
"""Destroy Redis channels managed by this state instance."""
for item_name in dir(self):
item = getattr(self, item_name)
if isinstance(item, self.RedisAtomicBase):
self.redis.delete(item.item_name) | python | def destroy_channels(self):
"""Destroy Redis channels managed by this state instance."""
for item_name in dir(self):
item = getattr(self, item_name)
if isinstance(item, self.RedisAtomicBase):
self.redis.delete(item.item_name) | [
"def",
"destroy_channels",
"(",
"self",
")",
":",
"for",
"item_name",
"in",
"dir",
"(",
"self",
")",
":",
"item",
"=",
"getattr",
"(",
"self",
",",
"item_name",
")",
"if",
"isinstance",
"(",
"item",
",",
"self",
".",
"RedisAtomicBase",
")",
":",
"self"... | Destroy Redis channels managed by this state instance. | [
"Destroy",
"Redis",
"channels",
"managed",
"by",
"this",
"state",
"instance",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/state.py#L201-L206 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/subject_info_renderer.py | SubjectInfoRenderer.render_to_image_file | def render_to_image_file(
self, image_out_path, width_pixels=None, height_pixels=None, dpi=90
):
"""Render the SubjectInfo to an image file.
Args:
image_out_path : str
Path to where image image will be written. Valid extensions are
``.svg,`` ``.pd... | python | def render_to_image_file(
self, image_out_path, width_pixels=None, height_pixels=None, dpi=90
):
"""Render the SubjectInfo to an image file.
Args:
image_out_path : str
Path to where image image will be written. Valid extensions are
``.svg,`` ``.pd... | [
"def",
"render_to_image_file",
"(",
"self",
",",
"image_out_path",
",",
"width_pixels",
"=",
"None",
",",
"height_pixels",
"=",
"None",
",",
"dpi",
"=",
"90",
")",
":",
"self",
".",
"_render_type",
"=",
"\"file\"",
"self",
".",
"_tree",
".",
"render",
"(",... | Render the SubjectInfo to an image file.
Args:
image_out_path : str
Path to where image image will be written. Valid extensions are
``.svg,`` ``.pdf``, and ``.png``.
width_pixels : int
Width of image to write.
height_pixels :... | [
"Render",
"the",
"SubjectInfo",
"to",
"an",
"image",
"file",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/subject_info_renderer.py#L72-L105 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/subject_info_renderer.py | SubjectInfoRenderer.browse_in_qt5_ui | def browse_in_qt5_ui(self):
"""Browse and edit the SubjectInfo in a simple Qt5 based UI."""
self._render_type = "browse"
self._tree.show(tree_style=self._get_tree_style()) | python | def browse_in_qt5_ui(self):
"""Browse and edit the SubjectInfo in a simple Qt5 based UI."""
self._render_type = "browse"
self._tree.show(tree_style=self._get_tree_style()) | [
"def",
"browse_in_qt5_ui",
"(",
"self",
")",
":",
"self",
".",
"_render_type",
"=",
"\"browse\"",
"self",
".",
"_tree",
".",
"show",
"(",
"tree_style",
"=",
"self",
".",
"_get_tree_style",
"(",
")",
")"
] | Browse and edit the SubjectInfo in a simple Qt5 based UI. | [
"Browse",
"and",
"edit",
"the",
"SubjectInfo",
"in",
"a",
"simple",
"Qt5",
"based",
"UI",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/subject_info_renderer.py#L107-L110 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/subject_info_renderer.py | SubjectInfoRenderer._gen_etetoolkit_tree | def _gen_etetoolkit_tree(self, node, subject_info_tree):
"""Copy SubjectInfoTree to a ETE Tree."""
for si_node in subject_info_tree.child_list:
if si_node.type_str == TYPE_NODE_TAG:
child = self._add_type_node(node, si_node.label_str)
elif si_node.type_str == SUBJ... | python | def _gen_etetoolkit_tree(self, node, subject_info_tree):
"""Copy SubjectInfoTree to a ETE Tree."""
for si_node in subject_info_tree.child_list:
if si_node.type_str == TYPE_NODE_TAG:
child = self._add_type_node(node, si_node.label_str)
elif si_node.type_str == SUBJ... | [
"def",
"_gen_etetoolkit_tree",
"(",
"self",
",",
"node",
",",
"subject_info_tree",
")",
":",
"for",
"si_node",
"in",
"subject_info_tree",
".",
"child_list",
":",
"if",
"si_node",
".",
"type_str",
"==",
"TYPE_NODE_TAG",
":",
"child",
"=",
"self",
".",
"_add_typ... | Copy SubjectInfoTree to a ETE Tree. | [
"Copy",
"SubjectInfoTree",
"to",
"a",
"ETE",
"Tree",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/subject_info_renderer.py#L124-L135 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/subject_info_renderer.py | SubjectInfoRenderer._add_type_node | def _add_type_node(self, node, label):
"""Add a node representing a SubjectInfo type."""
child = node.add_child(name=label)
child.add_feature(TYPE_NODE_TAG, True)
return child | python | def _add_type_node(self, node, label):
"""Add a node representing a SubjectInfo type."""
child = node.add_child(name=label)
child.add_feature(TYPE_NODE_TAG, True)
return child | [
"def",
"_add_type_node",
"(",
"self",
",",
"node",
",",
"label",
")",
":",
"child",
"=",
"node",
".",
"add_child",
"(",
"name",
"=",
"label",
")",
"child",
".",
"add_feature",
"(",
"TYPE_NODE_TAG",
",",
"True",
")",
"return",
"child"
] | Add a node representing a SubjectInfo type. | [
"Add",
"a",
"node",
"representing",
"a",
"SubjectInfo",
"type",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/subject_info_renderer.py#L137-L141 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/subject_info_renderer.py | SubjectInfoRenderer._add_subject_node | def _add_subject_node(self, node, subj_str):
"""Add a node containing a subject string."""
child = node.add_child(name=subj_str)
child.add_feature(SUBJECT_NODE_TAG, True)
return child | python | def _add_subject_node(self, node, subj_str):
"""Add a node containing a subject string."""
child = node.add_child(name=subj_str)
child.add_feature(SUBJECT_NODE_TAG, True)
return child | [
"def",
"_add_subject_node",
"(",
"self",
",",
"node",
",",
"subj_str",
")",
":",
"child",
"=",
"node",
".",
"add_child",
"(",
"name",
"=",
"subj_str",
")",
"child",
".",
"add_feature",
"(",
"SUBJECT_NODE_TAG",
",",
"True",
")",
"return",
"child"
] | Add a node containing a subject string. | [
"Add",
"a",
"node",
"containing",
"a",
"subject",
"string",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/subject_info_renderer.py#L143-L147 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/subject_info_renderer.py | SubjectInfoRenderer._get_node_path | def _get_node_path(self, node):
"""Return the path from the root to ``node`` as a list of node names."""
path = []
while node.up:
path.append(node.name)
node = node.up
return list(reversed(path)) | python | def _get_node_path(self, node):
"""Return the path from the root to ``node`` as a list of node names."""
path = []
while node.up:
path.append(node.name)
node = node.up
return list(reversed(path)) | [
"def",
"_get_node_path",
"(",
"self",
",",
"node",
")",
":",
"path",
"=",
"[",
"]",
"while",
"node",
".",
"up",
":",
"path",
".",
"append",
"(",
"node",
".",
"name",
")",
"node",
"=",
"node",
".",
"up",
"return",
"list",
"(",
"reversed",
"(",
"pa... | Return the path from the root to ``node`` as a list of node names. | [
"Return",
"the",
"path",
"from",
"the",
"root",
"to",
"node",
"as",
"a",
"list",
"of",
"node",
"names",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/subject_info_renderer.py#L149-L155 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/subject_info_renderer.py | SubjectInfoRenderer._layout | def _layout(self, node):
"""ETE calls this function to style each node before rendering.
- ETE terms:
- A Style is a specification for how to render the node itself
- A Face defines extra information that is rendered outside of the node
- Face objects are used here to provide mo... | python | def _layout(self, node):
"""ETE calls this function to style each node before rendering.
- ETE terms:
- A Style is a specification for how to render the node itself
- A Face defines extra information that is rendered outside of the node
- Face objects are used here to provide mo... | [
"def",
"_layout",
"(",
"self",
",",
"node",
")",
":",
"def",
"set_edge_style",
"(",
")",
":",
"\"\"\"Set the style for edges and make the node invisible.\"\"\"",
"node_style",
"=",
"ete3",
".",
"NodeStyle",
"(",
")",
"node_style",
"[",
"\"vt_line_color\"",
"]",
"=",... | ETE calls this function to style each node before rendering.
- ETE terms:
- A Style is a specification for how to render the node itself
- A Face defines extra information that is rendered outside of the node
- Face objects are used here to provide more control on how to draw the nodes. | [
"ETE",
"calls",
"this",
"function",
"to",
"style",
"each",
"node",
"before",
"rendering",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/subject_info_renderer.py#L167-L231 |
genialis/resolwe | resolwe/flow/executors/local/prepare.py | FlowExecutorPreparer.extend_settings | def extend_settings(self, data_id, files, secrets):
"""Prevent processes requiring access to secrets from being run."""
process = Data.objects.get(pk=data_id).process
if process.requirements.get('resources', {}).get('secrets', False):
raise PermissionDenied(
"Process ... | python | def extend_settings(self, data_id, files, secrets):
"""Prevent processes requiring access to secrets from being run."""
process = Data.objects.get(pk=data_id).process
if process.requirements.get('resources', {}).get('secrets', False):
raise PermissionDenied(
"Process ... | [
"def",
"extend_settings",
"(",
"self",
",",
"data_id",
",",
"files",
",",
"secrets",
")",
":",
"process",
"=",
"Data",
".",
"objects",
".",
"get",
"(",
"pk",
"=",
"data_id",
")",
".",
"process",
"if",
"process",
".",
"requirements",
".",
"get",
"(",
... | Prevent processes requiring access to secrets from being run. | [
"Prevent",
"processes",
"requiring",
"access",
"to",
"secrets",
"from",
"being",
"run",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/executors/local/prepare.py#L22-L30 |
genialis/resolwe | resolwe/flow/finders.py | get_finder | def get_finder(import_path):
"""Get a process finder."""
finder_class = import_string(import_path)
if not issubclass(finder_class, BaseProcessesFinder):
raise ImproperlyConfigured(
'Finder "{}" is not a subclass of "{}"'.format(finder_class, BaseProcessesFinder))
return finder_class(... | python | def get_finder(import_path):
"""Get a process finder."""
finder_class = import_string(import_path)
if not issubclass(finder_class, BaseProcessesFinder):
raise ImproperlyConfigured(
'Finder "{}" is not a subclass of "{}"'.format(finder_class, BaseProcessesFinder))
return finder_class(... | [
"def",
"get_finder",
"(",
"import_path",
")",
":",
"finder_class",
"=",
"import_string",
"(",
"import_path",
")",
"if",
"not",
"issubclass",
"(",
"finder_class",
",",
"BaseProcessesFinder",
")",
":",
"raise",
"ImproperlyConfigured",
"(",
"'Finder \"{}\" is not a subcl... | Get a process finder. | [
"Get",
"a",
"process",
"finder",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/finders.py#L67-L73 |
genialis/resolwe | resolwe/flow/finders.py | AppDirectoriesFinder._find_folders | def _find_folders(self, folder_name):
"""Return a list of sub-directories."""
found_folders = []
for app_config in apps.get_app_configs():
folder_path = os.path.join(app_config.path, folder_name)
if os.path.isdir(folder_path):
found_folders.append(folder_p... | python | def _find_folders(self, folder_name):
"""Return a list of sub-directories."""
found_folders = []
for app_config in apps.get_app_configs():
folder_path = os.path.join(app_config.path, folder_name)
if os.path.isdir(folder_path):
found_folders.append(folder_p... | [
"def",
"_find_folders",
"(",
"self",
",",
"folder_name",
")",
":",
"found_folders",
"=",
"[",
"]",
"for",
"app_config",
"in",
"apps",
".",
"get_app_configs",
"(",
")",
":",
"folder_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"app_config",
".",
"path... | Return a list of sub-directories. | [
"Return",
"a",
"list",
"of",
"sub",
"-",
"directories",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/finders.py#L43-L50 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/assert_sysmeta.py | sanity | def sanity(request, sysmeta_pyxb):
"""Check that sysmeta_pyxb is suitable for creating a new object and matches the
uploaded sciobj bytes."""
_does_not_contain_replica_sections(sysmeta_pyxb)
_is_not_archived(sysmeta_pyxb)
_obsoleted_by_not_specified(sysmeta_pyxb)
if 'HTTP_VENDOR_GMN_REMOTE_URL' ... | python | def sanity(request, sysmeta_pyxb):
"""Check that sysmeta_pyxb is suitable for creating a new object and matches the
uploaded sciobj bytes."""
_does_not_contain_replica_sections(sysmeta_pyxb)
_is_not_archived(sysmeta_pyxb)
_obsoleted_by_not_specified(sysmeta_pyxb)
if 'HTTP_VENDOR_GMN_REMOTE_URL' ... | [
"def",
"sanity",
"(",
"request",
",",
"sysmeta_pyxb",
")",
":",
"_does_not_contain_replica_sections",
"(",
"sysmeta_pyxb",
")",
"_is_not_archived",
"(",
"sysmeta_pyxb",
")",
"_obsoleted_by_not_specified",
"(",
"sysmeta_pyxb",
")",
"if",
"'HTTP_VENDOR_GMN_REMOTE_URL'",
"in... | Check that sysmeta_pyxb is suitable for creating a new object and matches the
uploaded sciobj bytes. | [
"Check",
"that",
"sysmeta_pyxb",
"is",
"suitable",
"for",
"creating",
"a",
"new",
"object",
"and",
"matches",
"the",
"uploaded",
"sciobj",
"bytes",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/assert_sysmeta.py#L36-L46 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/assert_sysmeta.py | is_valid_sid_for_new_standalone | def is_valid_sid_for_new_standalone(sysmeta_pyxb):
"""Assert that any SID in ``sysmeta_pyxb`` can be assigned to a new standalone
object."""
sid = d1_common.xml.get_opt_val(sysmeta_pyxb, 'seriesId')
if not d1_gmn.app.did.is_valid_sid_for_new_standalone(sid):
raise d1_common.types.exceptions.Iden... | python | def is_valid_sid_for_new_standalone(sysmeta_pyxb):
"""Assert that any SID in ``sysmeta_pyxb`` can be assigned to a new standalone
object."""
sid = d1_common.xml.get_opt_val(sysmeta_pyxb, 'seriesId')
if not d1_gmn.app.did.is_valid_sid_for_new_standalone(sid):
raise d1_common.types.exceptions.Iden... | [
"def",
"is_valid_sid_for_new_standalone",
"(",
"sysmeta_pyxb",
")",
":",
"sid",
"=",
"d1_common",
".",
"xml",
".",
"get_opt_val",
"(",
"sysmeta_pyxb",
",",
"'seriesId'",
")",
"if",
"not",
"d1_gmn",
".",
"app",
".",
"did",
".",
"is_valid_sid_for_new_standalone",
... | Assert that any SID in ``sysmeta_pyxb`` can be assigned to a new standalone
object. | [
"Assert",
"that",
"any",
"SID",
"in",
"sysmeta_pyxb",
"can",
"be",
"assigned",
"to",
"a",
"new",
"standalone",
"object",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/assert_sysmeta.py#L108-L119 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/assert_sysmeta.py | is_valid_sid_for_chain | def is_valid_sid_for_chain(pid, sid):
"""Assert that ``sid`` can be assigned to the single object ``pid`` or to the chain
to which ``pid`` belongs.
- If the chain does not have a SID, the new SID must be previously unused.
- If the chain already has a SID, the new SID must match the existing SID.
... | python | def is_valid_sid_for_chain(pid, sid):
"""Assert that ``sid`` can be assigned to the single object ``pid`` or to the chain
to which ``pid`` belongs.
- If the chain does not have a SID, the new SID must be previously unused.
- If the chain already has a SID, the new SID must match the existing SID.
... | [
"def",
"is_valid_sid_for_chain",
"(",
"pid",
",",
"sid",
")",
":",
"if",
"not",
"d1_gmn",
".",
"app",
".",
"did",
".",
"is_valid_sid_for_chain",
"(",
"pid",
",",
"sid",
")",
":",
"existing_sid",
"=",
"d1_gmn",
".",
"app",
".",
"revision",
".",
"get_sid_b... | Assert that ``sid`` can be assigned to the single object ``pid`` or to the chain
to which ``pid`` belongs.
- If the chain does not have a SID, the new SID must be previously unused.
- If the chain already has a SID, the new SID must match the existing SID. | [
"Assert",
"that",
"sid",
"can",
"be",
"assigned",
"to",
"the",
"single",
"object",
"pid",
"or",
"to",
"the",
"chain",
"to",
"which",
"pid",
"belongs",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/assert_sysmeta.py#L122-L138 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/assert_sysmeta.py | _does_not_contain_replica_sections | def _does_not_contain_replica_sections(sysmeta_pyxb):
"""Assert that ``sysmeta_pyxb`` does not contain any replica information."""
if len(getattr(sysmeta_pyxb, 'replica', [])):
raise d1_common.types.exceptions.InvalidSystemMetadata(
0,
'A replica section was included. A new objec... | python | def _does_not_contain_replica_sections(sysmeta_pyxb):
"""Assert that ``sysmeta_pyxb`` does not contain any replica information."""
if len(getattr(sysmeta_pyxb, 'replica', [])):
raise d1_common.types.exceptions.InvalidSystemMetadata(
0,
'A replica section was included. A new objec... | [
"def",
"_does_not_contain_replica_sections",
"(",
"sysmeta_pyxb",
")",
":",
"if",
"len",
"(",
"getattr",
"(",
"sysmeta_pyxb",
",",
"'replica'",
",",
"[",
"]",
")",
")",
":",
"raise",
"d1_common",
".",
"types",
".",
"exceptions",
".",
"InvalidSystemMetadata",
"... | Assert that ``sysmeta_pyxb`` does not contain any replica information. | [
"Assert",
"that",
"sysmeta_pyxb",
"does",
"not",
"contain",
"any",
"replica",
"information",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/assert_sysmeta.py#L141-L151 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/assert_sysmeta.py | _is_not_archived | def _is_not_archived(sysmeta_pyxb):
"""Assert that ``sysmeta_pyxb`` does not have have the archived flag set."""
if _is_archived(sysmeta_pyxb):
raise d1_common.types.exceptions.InvalidSystemMetadata(
0,
'Archived flag was set. A new object created via create() or update() '
... | python | def _is_not_archived(sysmeta_pyxb):
"""Assert that ``sysmeta_pyxb`` does not have have the archived flag set."""
if _is_archived(sysmeta_pyxb):
raise d1_common.types.exceptions.InvalidSystemMetadata(
0,
'Archived flag was set. A new object created via create() or update() '
... | [
"def",
"_is_not_archived",
"(",
"sysmeta_pyxb",
")",
":",
"if",
"_is_archived",
"(",
"sysmeta_pyxb",
")",
":",
"raise",
"d1_common",
".",
"types",
".",
"exceptions",
".",
"InvalidSystemMetadata",
"(",
"0",
",",
"'Archived flag was set. A new object created via create() ... | Assert that ``sysmeta_pyxb`` does not have have the archived flag set. | [
"Assert",
"that",
"sysmeta_pyxb",
"does",
"not",
"have",
"have",
"the",
"archived",
"flag",
"set",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/assert_sysmeta.py#L154-L164 |
DataONEorg/d1_python | lib_common/src/d1_common/env.py | get_d1_env_by_base_url | def get_d1_env_by_base_url(cn_base_url):
"""Given the BaseURL for a CN, return the DataONE environment dict for the CN's
environemnt."""
for k, v in D1_ENV_DICT:
if v['base_url'].startswith(cn_base_url):
return D1_ENV_DICT[k] | python | def get_d1_env_by_base_url(cn_base_url):
"""Given the BaseURL for a CN, return the DataONE environment dict for the CN's
environemnt."""
for k, v in D1_ENV_DICT:
if v['base_url'].startswith(cn_base_url):
return D1_ENV_DICT[k] | [
"def",
"get_d1_env_by_base_url",
"(",
"cn_base_url",
")",
":",
"for",
"k",
",",
"v",
"in",
"D1_ENV_DICT",
":",
"if",
"v",
"[",
"'base_url'",
"]",
".",
"startswith",
"(",
"cn_base_url",
")",
":",
"return",
"D1_ENV_DICT",
"[",
"k",
"]"
] | Given the BaseURL for a CN, return the DataONE environment dict for the CN's
environemnt. | [
"Given",
"the",
"BaseURL",
"for",
"a",
"CN",
"return",
"the",
"DataONE",
"environment",
"dict",
"for",
"the",
"CN",
"s",
"environemnt",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/env.py#L71-L76 |
wilson-eft/wilson | wilson/match/smeft.py | match_all | def match_all(d_SMEFT, parameters=None):
"""Match the SMEFT Warsaw basis onto the WET JMS basis."""
p = default_parameters.copy()
if parameters is not None:
# if parameters are passed in, overwrite the default values
p.update(parameters)
C = wilson.util.smeftutil.wcxf2arrays_symmetrized(... | python | def match_all(d_SMEFT, parameters=None):
"""Match the SMEFT Warsaw basis onto the WET JMS basis."""
p = default_parameters.copy()
if parameters is not None:
# if parameters are passed in, overwrite the default values
p.update(parameters)
C = wilson.util.smeftutil.wcxf2arrays_symmetrized(... | [
"def",
"match_all",
"(",
"d_SMEFT",
",",
"parameters",
"=",
"None",
")",
":",
"p",
"=",
"default_parameters",
".",
"copy",
"(",
")",
"if",
"parameters",
"is",
"not",
"None",
":",
"# if parameters are passed in, overwrite the default values",
"p",
".",
"update",
... | Match the SMEFT Warsaw basis onto the WET JMS basis. | [
"Match",
"the",
"SMEFT",
"Warsaw",
"basis",
"onto",
"the",
"WET",
"JMS",
"basis",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/match/smeft.py#L206-L221 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/middleware/response_handler.py | ResponseHandler._debug_mode_responses | def _debug_mode_responses(self, request, response):
"""Extra functionality available in debug mode.
- If pretty printed output was requested, force the content type to text. This
causes the browser to not try to format the output in any way.
- If SQL profiling is turned on, return a p... | python | def _debug_mode_responses(self, request, response):
"""Extra functionality available in debug mode.
- If pretty printed output was requested, force the content type to text. This
causes the browser to not try to format the output in any way.
- If SQL profiling is turned on, return a p... | [
"def",
"_debug_mode_responses",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"if",
"django",
".",
"conf",
".",
"settings",
".",
"DEBUG_GMN",
":",
"if",
"'pretty'",
"in",
"request",
".",
"GET",
":",
"response",
"[",
"'Content-Type'",
"]",
"=",
... | Extra functionality available in debug mode.
- If pretty printed output was requested, force the content type to text. This
causes the browser to not try to format the output in any way.
- If SQL profiling is turned on, return a page with SQL query timing
information instead of the ... | [
"Extra",
"functionality",
"available",
"in",
"debug",
"mode",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/middleware/response_handler.py#L74-L96 |
DataONEorg/d1_python | lib_client/src/d1_client/baseclient_1_1.py | DataONEBaseClient_1_1.queryResponse | def queryResponse(
self, queryEngine, query_str, vendorSpecific=None, do_post=False, **kwargs
):
"""CNRead.query(session, queryEngine, query) → OctetStream
https://releases.dataone.org/online/api-
documentation-v2.0.1/apis/CN_APIs.html#CNRead.query MNQuery.query(session,
quer... | python | def queryResponse(
self, queryEngine, query_str, vendorSpecific=None, do_post=False, **kwargs
):
"""CNRead.query(session, queryEngine, query) → OctetStream
https://releases.dataone.org/online/api-
documentation-v2.0.1/apis/CN_APIs.html#CNRead.query MNQuery.query(session,
quer... | [
"def",
"queryResponse",
"(",
"self",
",",
"queryEngine",
",",
"query_str",
",",
"vendorSpecific",
"=",
"None",
",",
"do_post",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_log",
".",
"debug",
"(",
"'Solr query: {}'",
".",
"format",
"("... | CNRead.query(session, queryEngine, query) → OctetStream
https://releases.dataone.org/online/api-
documentation-v2.0.1/apis/CN_APIs.html#CNRead.query MNQuery.query(session,
queryEngine, query) → OctetStream http://jenkins.
-1.dataone.org/jenkins/job/API%20Documentation%20-%20trunk/ws/api... | [
"CNRead",
".",
"query",
"(",
"session",
"queryEngine",
"query",
")",
"→",
"OctetStream",
"https",
":",
"//",
"releases",
".",
"dataone",
".",
"org",
"/",
"online",
"/",
"api",
"-",
"documentation",
"-",
"v2",
".",
"0",
".",
"1",
"/",
"apis",
"/",
"CN... | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/baseclient_1_1.py#L58-L86 |
DataONEorg/d1_python | lib_client/src/d1_client/baseclient_1_1.py | DataONEBaseClient_1_1.query | def query(
self, queryEngine, query_str, vendorSpecific=None, do_post=False, **kwargs
):
"""See Also: queryResponse()
Args:
queryEngine:
query_str:
vendorSpecific:
do_post:
**kwargs:
Returns:
"""
response = self.que... | python | def query(
self, queryEngine, query_str, vendorSpecific=None, do_post=False, **kwargs
):
"""See Also: queryResponse()
Args:
queryEngine:
query_str:
vendorSpecific:
do_post:
**kwargs:
Returns:
"""
response = self.que... | [
"def",
"query",
"(",
"self",
",",
"queryEngine",
",",
"query_str",
",",
"vendorSpecific",
"=",
"None",
",",
"do_post",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"response",
"=",
"self",
".",
"queryResponse",
"(",
"queryEngine",
",",
"query_str",
"... | See Also: queryResponse()
Args:
queryEngine:
query_str:
vendorSpecific:
do_post:
**kwargs:
Returns: | [
"See",
"Also",
":",
"queryResponse",
"()"
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/baseclient_1_1.py#L88-L109 |
DataONEorg/d1_python | lib_client/src/d1_client/baseclient_1_1.py | DataONEBaseClient_1_1.getQueryEngineDescriptionResponse | def getQueryEngineDescriptionResponse(self, queryEngine, vendorSpecific=None, **kwargs):
"""CNRead.getQueryEngineDescription(session, queryEngine) →
QueryEngineDescription https://releases.dataone.org/online/api-
documentation-v2.0.1/apis/CN_APIs.html#CNRead.getQueryEngineDescription
MNQ... | python | def getQueryEngineDescriptionResponse(self, queryEngine, vendorSpecific=None, **kwargs):
"""CNRead.getQueryEngineDescription(session, queryEngine) →
QueryEngineDescription https://releases.dataone.org/online/api-
documentation-v2.0.1/apis/CN_APIs.html#CNRead.getQueryEngineDescription
MNQ... | [
"def",
"getQueryEngineDescriptionResponse",
"(",
"self",
",",
"queryEngine",
",",
"vendorSpecific",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"GET",
"(",
"[",
"'query'",
",",
"queryEngine",
"]",
",",
"query",
"=",
"kwargs",
","... | CNRead.getQueryEngineDescription(session, queryEngine) →
QueryEngineDescription https://releases.dataone.org/online/api-
documentation-v2.0.1/apis/CN_APIs.html#CNRead.getQueryEngineDescription
MNQuery.getQueryEngineDescription(session, queryEngine) → QueryEngineDescription
http://jenkins... | [
"CNRead",
".",
"getQueryEngineDescription",
"(",
"session",
"queryEngine",
")",
"→",
"QueryEngineDescription",
"https",
":",
"//",
"releases",
".",
"dataone",
".",
"org",
"/",
"online",
"/",
"api",
"-",
"documentation",
"-",
"v2",
".",
"0",
".",
"1",
"/",
... | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/baseclient_1_1.py#L111-L128 |
DataONEorg/d1_python | lib_client/src/d1_client/baseclient_1_1.py | DataONEBaseClient_1_1.getQueryEngineDescription | def getQueryEngineDescription(self, queryEngine, **kwargs):
"""See Also: getQueryEngineDescriptionResponse()
Args:
queryEngine:
**kwargs:
Returns:
"""
response = self.getQueryEngineDescriptionResponse(queryEngine, **kwargs)
return self._read_dataone... | python | def getQueryEngineDescription(self, queryEngine, **kwargs):
"""See Also: getQueryEngineDescriptionResponse()
Args:
queryEngine:
**kwargs:
Returns:
"""
response = self.getQueryEngineDescriptionResponse(queryEngine, **kwargs)
return self._read_dataone... | [
"def",
"getQueryEngineDescription",
"(",
"self",
",",
"queryEngine",
",",
"*",
"*",
"kwargs",
")",
":",
"response",
"=",
"self",
".",
"getQueryEngineDescriptionResponse",
"(",
"queryEngine",
",",
"*",
"*",
"kwargs",
")",
"return",
"self",
".",
"_read_dataone_typ... | See Also: getQueryEngineDescriptionResponse()
Args:
queryEngine:
**kwargs:
Returns: | [
"See",
"Also",
":",
"getQueryEngineDescriptionResponse",
"()"
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/baseclient_1_1.py#L130-L141 |
genialis/resolwe | resolwe/elastic/builder.py | BuildArgumentsCache._get_cache_key | def _get_cache_key(self, obj):
"""Derive cache key for given object."""
if obj is not None:
# Make sure that key is REALLY unique.
return '{}-{}'.format(id(self), obj.pk)
return "{}-None".format(id(self)) | python | def _get_cache_key(self, obj):
"""Derive cache key for given object."""
if obj is not None:
# Make sure that key is REALLY unique.
return '{}-{}'.format(id(self), obj.pk)
return "{}-None".format(id(self)) | [
"def",
"_get_cache_key",
"(",
"self",
",",
"obj",
")",
":",
"if",
"obj",
"is",
"not",
"None",
":",
"# Make sure that key is REALLY unique.",
"return",
"'{}-{}'",
".",
"format",
"(",
"id",
"(",
"self",
")",
",",
"obj",
".",
"pk",
")",
"return",
"\"{}-None\"... | Derive cache key for given object. | [
"Derive",
"cache",
"key",
"for",
"given",
"object",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L45-L51 |
genialis/resolwe | resolwe/elastic/builder.py | BuildArgumentsCache.set | def set(self, obj, build_kwargs):
"""Set cached value."""
if build_kwargs is None:
build_kwargs = {}
cached = {}
if 'queryset' in build_kwargs:
cached = {
'model': build_kwargs['queryset'].model,
'pks': list(build_kwargs['queryset'... | python | def set(self, obj, build_kwargs):
"""Set cached value."""
if build_kwargs is None:
build_kwargs = {}
cached = {}
if 'queryset' in build_kwargs:
cached = {
'model': build_kwargs['queryset'].model,
'pks': list(build_kwargs['queryset'... | [
"def",
"set",
"(",
"self",
",",
"obj",
",",
"build_kwargs",
")",
":",
"if",
"build_kwargs",
"is",
"None",
":",
"build_kwargs",
"=",
"{",
"}",
"cached",
"=",
"{",
"}",
"if",
"'queryset'",
"in",
"build_kwargs",
":",
"cached",
"=",
"{",
"'model'",
":",
... | Set cached value. | [
"Set",
"cached",
"value",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L57-L76 |
genialis/resolwe | resolwe/elastic/builder.py | BuildArgumentsCache.take | def take(self, obj):
"""Get cached value and clean cache."""
cached = self._thread_local.cache[self._get_cache_key(obj)]
build_kwargs = {}
if 'model' in cached and 'pks' in cached:
build_kwargs['queryset'] = cached['model'].objects.filter(pk__in=cached['pks'])
elif ... | python | def take(self, obj):
"""Get cached value and clean cache."""
cached = self._thread_local.cache[self._get_cache_key(obj)]
build_kwargs = {}
if 'model' in cached and 'pks' in cached:
build_kwargs['queryset'] = cached['model'].objects.filter(pk__in=cached['pks'])
elif ... | [
"def",
"take",
"(",
"self",
",",
"obj",
")",
":",
"cached",
"=",
"self",
".",
"_thread_local",
".",
"cache",
"[",
"self",
".",
"_get_cache_key",
"(",
"obj",
")",
"]",
"build_kwargs",
"=",
"{",
"}",
"if",
"'model'",
"in",
"cached",
"and",
"'pks'",
"in... | Get cached value and clean cache. | [
"Get",
"cached",
"value",
"and",
"clean",
"cache",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L78-L95 |
genialis/resolwe | resolwe/elastic/builder.py | ElasticSignal.connect | def connect(self, signal, **kwargs):
"""Connect a specific signal type to this receiver."""
signal.connect(self, **kwargs)
self.connections.append((signal, kwargs)) | python | def connect(self, signal, **kwargs):
"""Connect a specific signal type to this receiver."""
signal.connect(self, **kwargs)
self.connections.append((signal, kwargs)) | [
"def",
"connect",
"(",
"self",
",",
"signal",
",",
"*",
"*",
"kwargs",
")",
":",
"signal",
".",
"connect",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"connections",
".",
"append",
"(",
"(",
"signal",
",",
"kwargs",
")",
")"
] | Connect a specific signal type to this receiver. | [
"Connect",
"a",
"specific",
"signal",
"type",
"to",
"this",
"receiver",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L121-L124 |
genialis/resolwe | resolwe/elastic/builder.py | ElasticSignal.disconnect | def disconnect(self):
"""Disconnect all connected signal types from this receiver."""
for signal, kwargs in self.connections:
signal.disconnect(self, **kwargs) | python | def disconnect(self):
"""Disconnect all connected signal types from this receiver."""
for signal, kwargs in self.connections:
signal.disconnect(self, **kwargs) | [
"def",
"disconnect",
"(",
"self",
")",
":",
"for",
"signal",
",",
"kwargs",
"in",
"self",
".",
"connections",
":",
"signal",
".",
"disconnect",
"(",
"self",
",",
"*",
"*",
"kwargs",
")"
] | Disconnect all connected signal types from this receiver. | [
"Disconnect",
"all",
"connected",
"signal",
"types",
"from",
"this",
"receiver",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L126-L129 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.