partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | SailthruClient.get_purchase | Retrieve information about a purchase using the system's unique ID or a client's ID
@param id_: a string that represents a unique_id or an extid.
@param key: a string that is either 'sid' or 'extid'. | sailthru/sailthru_client.py | def get_purchase(self, purchase_id, purchase_key='sid'):
"""
Retrieve information about a purchase using the system's unique ID or a client's ID
@param id_: a string that represents a unique_id or an extid.
@param key: a string that is either 'sid' or 'extid'.
"""
data = ... | def get_purchase(self, purchase_id, purchase_key='sid'):
"""
Retrieve information about a purchase using the system's unique ID or a client's ID
@param id_: a string that represents a unique_id or an extid.
@param key: a string that is either 'sid' or 'extid'.
"""
data = ... | [
"Retrieve",
"information",
"about",
"a",
"purchase",
"using",
"the",
"system",
"s",
"unique",
"ID",
"or",
"a",
"client",
"s",
"ID"
] | sailthru/sailthru-python-client | python | https://github.com/sailthru/sailthru-python-client/blob/22aa39ba0c5bddd7b8743e24ada331128c0f4f54/sailthru/sailthru_client.py#L507-L515 | [
"def",
"get_purchase",
"(",
"self",
",",
"purchase_id",
",",
"purchase_key",
"=",
"'sid'",
")",
":",
"data",
"=",
"{",
"'purchase_id'",
":",
"purchase_id",
",",
"'purchase_key'",
":",
"purchase_key",
"}",
"return",
"self",
".",
"api_get",
"(",
"'purchase'",
... | 22aa39ba0c5bddd7b8743e24ada331128c0f4f54 |
train | SailthruClient.stats_list | Retrieve information about your subscriber counts on a particular list, on a particular day.
http://docs.sailthru.com/api/stat | sailthru/sailthru_client.py | def stats_list(self, list=None, date=None, headers=None):
"""
Retrieve information about your subscriber counts on a particular list, on a particular day.
http://docs.sailthru.com/api/stat
"""
data = {'stat': 'list'}
if list is not None:
data['list'] = list
... | def stats_list(self, list=None, date=None, headers=None):
"""
Retrieve information about your subscriber counts on a particular list, on a particular day.
http://docs.sailthru.com/api/stat
"""
data = {'stat': 'list'}
if list is not None:
data['list'] = list
... | [
"Retrieve",
"information",
"about",
"your",
"subscriber",
"counts",
"on",
"a",
"particular",
"list",
"on",
"a",
"particular",
"day",
".",
"http",
":",
"//",
"docs",
".",
"sailthru",
".",
"com",
"/",
"api",
"/",
"stat"
] | sailthru/sailthru-python-client | python | https://github.com/sailthru/sailthru-python-client/blob/22aa39ba0c5bddd7b8743e24ada331128c0f4f54/sailthru/sailthru_client.py#L517-L527 | [
"def",
"stats_list",
"(",
"self",
",",
"list",
"=",
"None",
",",
"date",
"=",
"None",
",",
"headers",
"=",
"None",
")",
":",
"data",
"=",
"{",
"'stat'",
":",
"'list'",
"}",
"if",
"list",
"is",
"not",
"None",
":",
"data",
"[",
"'list'",
"]",
"=",
... | 22aa39ba0c5bddd7b8743e24ada331128c0f4f54 |
train | SailthruClient.stats_blast | Retrieve information about a particular blast or aggregated information from all of blasts over a specified date range.
http://docs.sailthru.com/api/stat | sailthru/sailthru_client.py | def stats_blast(self, blast_id=None, start_date=None, end_date=None, options=None):
"""
Retrieve information about a particular blast or aggregated information from all of blasts over a specified date range.
http://docs.sailthru.com/api/stat
"""
options = options or {}
da... | def stats_blast(self, blast_id=None, start_date=None, end_date=None, options=None):
"""
Retrieve information about a particular blast or aggregated information from all of blasts over a specified date range.
http://docs.sailthru.com/api/stat
"""
options = options or {}
da... | [
"Retrieve",
"information",
"about",
"a",
"particular",
"blast",
"or",
"aggregated",
"information",
"from",
"all",
"of",
"blasts",
"over",
"a",
"specified",
"date",
"range",
".",
"http",
":",
"//",
"docs",
".",
"sailthru",
".",
"com",
"/",
"api",
"/",
"stat... | sailthru/sailthru-python-client | python | https://github.com/sailthru/sailthru-python-client/blob/22aa39ba0c5bddd7b8743e24ada331128c0f4f54/sailthru/sailthru_client.py#L529-L543 | [
"def",
"stats_blast",
"(",
"self",
",",
"blast_id",
"=",
"None",
",",
"start_date",
"=",
"None",
",",
"end_date",
"=",
"None",
",",
"options",
"=",
"None",
")",
":",
"options",
"=",
"options",
"or",
"{",
"}",
"data",
"=",
"options",
".",
"copy",
"(",... | 22aa39ba0c5bddd7b8743e24ada331128c0f4f54 |
train | SailthruClient.stats_send | Retrieve information about a particular transactional or aggregated information
from transactionals from that template over a specified date range.
http://docs.sailthru.com/api/stat | sailthru/sailthru_client.py | def stats_send(self, template, start_date, end_date, options=None):
"""
Retrieve information about a particular transactional or aggregated information
from transactionals from that template over a specified date range.
http://docs.sailthru.com/api/stat
"""
options = opti... | def stats_send(self, template, start_date, end_date, options=None):
"""
Retrieve information about a particular transactional or aggregated information
from transactionals from that template over a specified date range.
http://docs.sailthru.com/api/stat
"""
options = opti... | [
"Retrieve",
"information",
"about",
"a",
"particular",
"transactional",
"or",
"aggregated",
"information",
"from",
"transactionals",
"from",
"that",
"template",
"over",
"a",
"specified",
"date",
"range",
".",
"http",
":",
"//",
"docs",
".",
"sailthru",
".",
"com... | sailthru/sailthru-python-client | python | https://github.com/sailthru/sailthru-python-client/blob/22aa39ba0c5bddd7b8743e24ada331128c0f4f54/sailthru/sailthru_client.py#L545-L558 | [
"def",
"stats_send",
"(",
"self",
",",
"template",
",",
"start_date",
",",
"end_date",
",",
"options",
"=",
"None",
")",
":",
"options",
"=",
"options",
"or",
"{",
"}",
"data",
"=",
"options",
".",
"copy",
"(",
")",
"data",
"=",
"{",
"'template'",
":... | 22aa39ba0c5bddd7b8743e24ada331128c0f4f54 |
train | SailthruClient.receive_verify_post | Returns true if the incoming request is an authenticated verify post. | sailthru/sailthru_client.py | def receive_verify_post(self, post_params):
"""
Returns true if the incoming request is an authenticated verify post.
"""
if isinstance(post_params, dict):
required_params = ['action', 'email', 'send_id', 'sig']
if not self.check_for_valid_postback_actions(requir... | def receive_verify_post(self, post_params):
"""
Returns true if the incoming request is an authenticated verify post.
"""
if isinstance(post_params, dict):
required_params = ['action', 'email', 'send_id', 'sig']
if not self.check_for_valid_postback_actions(requir... | [
"Returns",
"true",
"if",
"the",
"incoming",
"request",
"is",
"an",
"authenticated",
"verify",
"post",
"."
] | sailthru/sailthru-python-client | python | https://github.com/sailthru/sailthru-python-client/blob/22aa39ba0c5bddd7b8743e24ada331128c0f4f54/sailthru/sailthru_client.py#L566-L599 | [
"def",
"receive_verify_post",
"(",
"self",
",",
"post_params",
")",
":",
"if",
"isinstance",
"(",
"post_params",
",",
"dict",
")",
":",
"required_params",
"=",
"[",
"'action'",
",",
"'email'",
",",
"'send_id'",
",",
"'sig'",
"]",
"if",
"not",
"self",
".",
... | 22aa39ba0c5bddd7b8743e24ada331128c0f4f54 |
train | SailthruClient.receive_update_post | Update postbacks | sailthru/sailthru_client.py | def receive_update_post(self, post_params):
"""
Update postbacks
"""
if isinstance(post_params, dict):
required_params = ['action', 'email', 'sig']
if not self.check_for_valid_postback_actions(required_params, post_params):
return False
el... | def receive_update_post(self, post_params):
"""
Update postbacks
"""
if isinstance(post_params, dict):
required_params = ['action', 'email', 'sig']
if not self.check_for_valid_postback_actions(required_params, post_params):
return False
el... | [
"Update",
"postbacks"
] | sailthru/sailthru-python-client | python | https://github.com/sailthru/sailthru-python-client/blob/22aa39ba0c5bddd7b8743e24ada331128c0f4f54/sailthru/sailthru_client.py#L601-L623 | [
"def",
"receive_update_post",
"(",
"self",
",",
"post_params",
")",
":",
"if",
"isinstance",
"(",
"post_params",
",",
"dict",
")",
":",
"required_params",
"=",
"[",
"'action'",
",",
"'email'",
",",
"'sig'",
"]",
"if",
"not",
"self",
".",
"check_for_valid_pos... | 22aa39ba0c5bddd7b8743e24ada331128c0f4f54 |
train | SailthruClient.receive_hardbounce_post | Hard bounce postbacks | sailthru/sailthru_client.py | def receive_hardbounce_post(self, post_params):
"""
Hard bounce postbacks
"""
if isinstance(post_params, dict):
required_params = ['action', 'email', 'sig']
if not self.check_for_valid_postback_actions(required_params, post_params):
return False
... | def receive_hardbounce_post(self, post_params):
"""
Hard bounce postbacks
"""
if isinstance(post_params, dict):
required_params = ['action', 'email', 'sig']
if not self.check_for_valid_postback_actions(required_params, post_params):
return False
... | [
"Hard",
"bounce",
"postbacks"
] | sailthru/sailthru-python-client | python | https://github.com/sailthru/sailthru-python-client/blob/22aa39ba0c5bddd7b8743e24ada331128c0f4f54/sailthru/sailthru_client.py#L648-L689 | [
"def",
"receive_hardbounce_post",
"(",
"self",
",",
"post_params",
")",
":",
"if",
"isinstance",
"(",
"post_params",
",",
"dict",
")",
":",
"required_params",
"=",
"[",
"'action'",
",",
"'email'",
",",
"'sig'",
"]",
"if",
"not",
"self",
".",
"check_for_valid... | 22aa39ba0c5bddd7b8743e24ada331128c0f4f54 |
train | SailthruClient.check_for_valid_postback_actions | checks if post_params contain required keys | sailthru/sailthru_client.py | def check_for_valid_postback_actions(self, required_keys, post_params):
"""
checks if post_params contain required keys
"""
for key in required_keys:
if key not in post_params:
return False
return True | def check_for_valid_postback_actions(self, required_keys, post_params):
"""
checks if post_params contain required keys
"""
for key in required_keys:
if key not in post_params:
return False
return True | [
"checks",
"if",
"post_params",
"contain",
"required",
"keys"
] | sailthru/sailthru-python-client | python | https://github.com/sailthru/sailthru-python-client/blob/22aa39ba0c5bddd7b8743e24ada331128c0f4f54/sailthru/sailthru_client.py#L691-L698 | [
"def",
"check_for_valid_postback_actions",
"(",
"self",
",",
"required_keys",
",",
"post_params",
")",
":",
"for",
"key",
"in",
"required_keys",
":",
"if",
"key",
"not",
"in",
"post_params",
":",
"return",
"False",
"return",
"True"
] | 22aa39ba0c5bddd7b8743e24ada331128c0f4f54 |
train | SailthruClient.api_get | Perform an HTTP GET request, using the shared-secret auth hash.
@param action: API action call
@param data: dictionary values | sailthru/sailthru_client.py | def api_get(self, action, data, headers=None):
"""
Perform an HTTP GET request, using the shared-secret auth hash.
@param action: API action call
@param data: dictionary values
"""
return self._api_request(action, data, 'GET', headers) | def api_get(self, action, data, headers=None):
"""
Perform an HTTP GET request, using the shared-secret auth hash.
@param action: API action call
@param data: dictionary values
"""
return self._api_request(action, data, 'GET', headers) | [
"Perform",
"an",
"HTTP",
"GET",
"request",
"using",
"the",
"shared",
"-",
"secret",
"auth",
"hash",
"."
] | sailthru/sailthru-python-client | python | https://github.com/sailthru/sailthru-python-client/blob/22aa39ba0c5bddd7b8743e24ada331128c0f4f54/sailthru/sailthru_client.py#L700-L706 | [
"def",
"api_get",
"(",
"self",
",",
"action",
",",
"data",
",",
"headers",
"=",
"None",
")",
":",
"return",
"self",
".",
"_api_request",
"(",
"action",
",",
"data",
",",
"'GET'",
",",
"headers",
")"
] | 22aa39ba0c5bddd7b8743e24ada331128c0f4f54 |
train | SailthruClient.api_post | Perform an HTTP POST request, using the shared-secret auth hash.
@param action: API action call
@param data: dictionary values | sailthru/sailthru_client.py | def api_post(self, action, data, binary_data_param=None):
"""
Perform an HTTP POST request, using the shared-secret auth hash.
@param action: API action call
@param data: dictionary values
"""
binary_data_param = binary_data_param or []
if binary_data_param:
... | def api_post(self, action, data, binary_data_param=None):
"""
Perform an HTTP POST request, using the shared-secret auth hash.
@param action: API action call
@param data: dictionary values
"""
binary_data_param = binary_data_param or []
if binary_data_param:
... | [
"Perform",
"an",
"HTTP",
"POST",
"request",
"using",
"the",
"shared",
"-",
"secret",
"auth",
"hash",
"."
] | sailthru/sailthru-python-client | python | https://github.com/sailthru/sailthru-python-client/blob/22aa39ba0c5bddd7b8743e24ada331128c0f4f54/sailthru/sailthru_client.py#L708-L718 | [
"def",
"api_post",
"(",
"self",
",",
"action",
",",
"data",
",",
"binary_data_param",
"=",
"None",
")",
":",
"binary_data_param",
"=",
"binary_data_param",
"or",
"[",
"]",
"if",
"binary_data_param",
":",
"return",
"self",
".",
"api_post_multipart",
"(",
"actio... | 22aa39ba0c5bddd7b8743e24ada331128c0f4f54 |
train | SailthruClient.api_post_multipart | Perform an HTTP Multipart POST request, using the shared-secret auth hash.
@param action: API action call
@param data: dictionary values
@param: binary_data_params: array of multipart keys | sailthru/sailthru_client.py | def api_post_multipart(self, action, data, binary_data_param):
"""
Perform an HTTP Multipart POST request, using the shared-secret auth hash.
@param action: API action call
@param data: dictionary values
@param: binary_data_params: array of multipart keys
"""
bina... | def api_post_multipart(self, action, data, binary_data_param):
"""
Perform an HTTP Multipart POST request, using the shared-secret auth hash.
@param action: API action call
@param data: dictionary values
@param: binary_data_params: array of multipart keys
"""
bina... | [
"Perform",
"an",
"HTTP",
"Multipart",
"POST",
"request",
"using",
"the",
"shared",
"-",
"secret",
"auth",
"hash",
"."
] | sailthru/sailthru-python-client | python | https://github.com/sailthru/sailthru-python-client/blob/22aa39ba0c5bddd7b8743e24ada331128c0f4f54/sailthru/sailthru_client.py#L720-L742 | [
"def",
"api_post_multipart",
"(",
"self",
",",
"action",
",",
"data",
",",
"binary_data_param",
")",
":",
"binary_data",
"=",
"{",
"}",
"data",
"=",
"data",
".",
"copy",
"(",
")",
"try",
":",
"file_handles",
"=",
"[",
"]",
"for",
"param",
"in",
"binary... | 22aa39ba0c5bddd7b8743e24ada331128c0f4f54 |
train | SailthruClient._api_request | Make Request to Sailthru API with given data and api key, format and signature hash | sailthru/sailthru_client.py | def _api_request(self, action, data, request_type, headers=None):
"""
Make Request to Sailthru API with given data and api key, format and signature hash
"""
if 'file' in data:
file_data = {'file': open(data['file'], 'rb')}
else:
file_data = None
... | def _api_request(self, action, data, request_type, headers=None):
"""
Make Request to Sailthru API with given data and api key, format and signature hash
"""
if 'file' in data:
file_data = {'file': open(data['file'], 'rb')}
else:
file_data = None
... | [
"Make",
"Request",
"to",
"Sailthru",
"API",
"with",
"given",
"data",
"and",
"api",
"key",
"format",
"and",
"signature",
"hash"
] | sailthru/sailthru-python-client | python | https://github.com/sailthru/sailthru-python-client/blob/22aa39ba0c5bddd7b8743e24ada331128c0f4f54/sailthru/sailthru_client.py#L752-L761 | [
"def",
"_api_request",
"(",
"self",
",",
"action",
",",
"data",
",",
"request_type",
",",
"headers",
"=",
"None",
")",
":",
"if",
"'file'",
"in",
"data",
":",
"file_data",
"=",
"{",
"'file'",
":",
"open",
"(",
"data",
"[",
"'file'",
"]",
",",
"'rb'",... | 22aa39ba0c5bddd7b8743e24ada331128c0f4f54 |
train | SailthruClient.get_last_rate_limit_info | Get rate limit information for last API call
:param action: API endpoint
:param method: Http method, GET, POST or DELETE
:return: dict|None | sailthru/sailthru_client.py | def get_last_rate_limit_info(self, action, method):
"""
Get rate limit information for last API call
:param action: API endpoint
:param method: Http method, GET, POST or DELETE
:return: dict|None
"""
method = method.upper()
if (action in self.last_rate_lim... | def get_last_rate_limit_info(self, action, method):
"""
Get rate limit information for last API call
:param action: API endpoint
:param method: Http method, GET, POST or DELETE
:return: dict|None
"""
method = method.upper()
if (action in self.last_rate_lim... | [
"Get",
"rate",
"limit",
"information",
"for",
"last",
"API",
"call",
":",
"param",
"action",
":",
"API",
"endpoint",
":",
"param",
"method",
":",
"Http",
"method",
"GET",
"POST",
"or",
"DELETE",
":",
"return",
":",
"dict|None"
] | sailthru/sailthru-python-client | python | https://github.com/sailthru/sailthru-python-client/blob/22aa39ba0c5bddd7b8743e24ada331128c0f4f54/sailthru/sailthru_client.py#L781-L792 | [
"def",
"get_last_rate_limit_info",
"(",
"self",
",",
"action",
",",
"method",
")",
":",
"method",
"=",
"method",
".",
"upper",
"(",
")",
"if",
"(",
"action",
"in",
"self",
".",
"last_rate_limit_info",
"and",
"method",
"in",
"self",
".",
"last_rate_limit_info... | 22aa39ba0c5bddd7b8743e24ada331128c0f4f54 |
train | linked_form | When having foreign key or m2m relationships between models A and B (B has foreign key to A named parent),
we want to have a form that sits on A's viewset but creates/edits B and sets it relationship to A
automatically.
In order to do so, define linked_forms on A's viewset containing a call to linked_form ... | angular_dynamic_forms/linked_form.py | def linked_form(viewset, form_id=None, link=None, link_id=None, method=None):
"""
When having foreign key or m2m relationships between models A and B (B has foreign key to A named parent),
we want to have a form that sits on A's viewset but creates/edits B and sets it relationship to A
automatically.
... | def linked_form(viewset, form_id=None, link=None, link_id=None, method=None):
"""
When having foreign key or m2m relationships between models A and B (B has foreign key to A named parent),
we want to have a form that sits on A's viewset but creates/edits B and sets it relationship to A
automatically.
... | [
"When",
"having",
"foreign",
"key",
"or",
"m2m",
"relationships",
"between",
"models",
"A",
"and",
"B",
"(",
"B",
"has",
"foreign",
"key",
"to",
"A",
"named",
"parent",
")",
"we",
"want",
"to",
"have",
"a",
"form",
"that",
"sits",
"on",
"A",
"s",
"vi... | mesemus/django-angular-dynamic-forms | python | https://github.com/mesemus/django-angular-dynamic-forms/blob/8d4839a26a22c1cda0d317cbd80457bacc13365a/angular_dynamic_forms/linked_form.py#L7-L35 | [
"def",
"linked_form",
"(",
"viewset",
",",
"form_id",
"=",
"None",
",",
"link",
"=",
"None",
",",
"link_id",
"=",
"None",
",",
"method",
"=",
"None",
")",
":",
"return",
"{",
"'viewset'",
":",
"viewset",
",",
"'form_id'",
":",
"form_id",
",",
"'link'",... | 8d4839a26a22c1cda0d317cbd80457bacc13365a |
train | oaiid_minter | Mint record identifiers.
:param record_uuid: The record UUID.
:param data: The record data.
:returns: A :class:`invenio_pidstore.models.PersistentIdentifier` instance. | invenio_oaiserver/minters.py | def oaiid_minter(record_uuid, data):
"""Mint record identifiers.
:param record_uuid: The record UUID.
:param data: The record data.
:returns: A :class:`invenio_pidstore.models.PersistentIdentifier` instance.
"""
pid_value = data.get('_oai', {}).get('id')
if pid_value is None:
fetche... | def oaiid_minter(record_uuid, data):
"""Mint record identifiers.
:param record_uuid: The record UUID.
:param data: The record data.
:returns: A :class:`invenio_pidstore.models.PersistentIdentifier` instance.
"""
pid_value = data.get('_oai', {}).get('id')
if pid_value is None:
fetche... | [
"Mint",
"record",
"identifiers",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/minters.py#L22-L43 | [
"def",
"oaiid_minter",
"(",
"record_uuid",
",",
"data",
")",
":",
"pid_value",
"=",
"data",
".",
"get",
"(",
"'_oai'",
",",
"{",
"}",
")",
".",
"get",
"(",
"'id'",
")",
"if",
"pid_value",
"is",
"None",
":",
"fetcher_name",
"=",
"current_app",
".",
"c... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | validation_error | Return formatter validation error. | invenio_oaiserver/views/server.py | def validation_error(exception):
"""Return formatter validation error."""
messages = getattr(exception, 'messages', None)
if messages is None:
messages = getattr(exception, 'data', {'messages': None})['messages']
def extract_errors():
"""Extract errors from exception."""
if isin... | def validation_error(exception):
"""Return formatter validation error."""
messages = getattr(exception, 'messages', None)
if messages is None:
messages = getattr(exception, 'data', {'messages': None})['messages']
def extract_errors():
"""Extract errors from exception."""
if isin... | [
"Return",
"formatter",
"validation",
"error",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/views/server.py#L33-L59 | [
"def",
"validation_error",
"(",
"exception",
")",
":",
"messages",
"=",
"getattr",
"(",
"exception",
",",
"'messages'",
",",
"None",
")",
"if",
"messages",
"is",
"None",
":",
"messages",
"=",
"getattr",
"(",
"exception",
",",
"'data'",
",",
"{",
"'messages... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | response | Response endpoint. | invenio_oaiserver/views/server.py | def response(args):
"""Response endpoint."""
e_tree = getattr(xml, args['verb'].lower())(**args)
response = make_response(etree.tostring(
e_tree,
pretty_print=True,
xml_declaration=True,
encoding='UTF-8',
))
response.headers['Content-Type'] = 'text/xml'
return re... | def response(args):
"""Response endpoint."""
e_tree = getattr(xml, args['verb'].lower())(**args)
response = make_response(etree.tostring(
e_tree,
pretty_print=True,
xml_declaration=True,
encoding='UTF-8',
))
response.headers['Content-Type'] = 'text/xml'
return re... | [
"Response",
"endpoint",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/views/server.py#L82-L93 | [
"def",
"response",
"(",
"args",
")",
":",
"e_tree",
"=",
"getattr",
"(",
"xml",
",",
"args",
"[",
"'verb'",
"]",
".",
"lower",
"(",
")",
")",
"(",
"*",
"*",
"args",
")",
"response",
"=",
"make_response",
"(",
"etree",
".",
"tostring",
"(",
"e_tree"... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | OAIIDProvider.create | Create a new record identifier.
:param object_type: The object type. (Default: ``None``)
:param object_uuid: The object UUID. (Default: ``None``) | invenio_oaiserver/provider.py | def create(cls, object_type=None, object_uuid=None, **kwargs):
"""Create a new record identifier.
:param object_type: The object type. (Default: ``None``)
:param object_uuid: The object UUID. (Default: ``None``)
"""
assert 'pid_value' in kwargs
kwargs.setdefault('status... | def create(cls, object_type=None, object_uuid=None, **kwargs):
"""Create a new record identifier.
:param object_type: The object type. (Default: ``None``)
:param object_uuid: The object UUID. (Default: ``None``)
"""
assert 'pid_value' in kwargs
kwargs.setdefault('status... | [
"Create",
"a",
"new",
"record",
"identifier",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/provider.py#L30-L43 | [
"def",
"create",
"(",
"cls",
",",
"object_type",
"=",
"None",
",",
"object_uuid",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"'pid_value'",
"in",
"kwargs",
"kwargs",
".",
"setdefault",
"(",
"'status'",
",",
"cls",
".",
"default_status",
")... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | _create_percolator_mapping | Update mappings with the percolator field.
.. note::
This is only needed from ElasticSearch v5 onwards, because percolators
are now just a special type of field inside mappings. | invenio_oaiserver/percolator.py | def _create_percolator_mapping(index, doc_type):
"""Update mappings with the percolator field.
.. note::
This is only needed from ElasticSearch v5 onwards, because percolators
are now just a special type of field inside mappings.
"""
if ES_VERSION[0] >= 5:
current_search_client... | def _create_percolator_mapping(index, doc_type):
"""Update mappings with the percolator field.
.. note::
This is only needed from ElasticSearch v5 onwards, because percolators
are now just a special type of field inside mappings.
"""
if ES_VERSION[0] >= 5:
current_search_client... | [
"Update",
"mappings",
"with",
"the",
"percolator",
"field",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/percolator.py#L23-L34 | [
"def",
"_create_percolator_mapping",
"(",
"index",
",",
"doc_type",
")",
":",
"if",
"ES_VERSION",
"[",
"0",
"]",
">=",
"5",
":",
"current_search_client",
".",
"indices",
".",
"put_mapping",
"(",
"index",
"=",
"index",
",",
"doc_type",
"=",
"doc_type",
",",
... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | _percolate_query | Get results for a percolate query. | invenio_oaiserver/percolator.py | def _percolate_query(index, doc_type, percolator_doc_type, document):
"""Get results for a percolate query."""
if ES_VERSION[0] in (2, 5):
results = current_search_client.percolate(
index=index, doc_type=doc_type, allow_no_indices=True,
ignore_unavailable=True, body={'doc': docum... | def _percolate_query(index, doc_type, percolator_doc_type, document):
"""Get results for a percolate query."""
if ES_VERSION[0] in (2, 5):
results = current_search_client.percolate(
index=index, doc_type=doc_type, allow_no_indices=True,
ignore_unavailable=True, body={'doc': docum... | [
"Get",
"results",
"for",
"a",
"percolate",
"query",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/percolator.py#L37-L58 | [
"def",
"_percolate_query",
"(",
"index",
",",
"doc_type",
",",
"percolator_doc_type",
",",
"document",
")",
":",
"if",
"ES_VERSION",
"[",
"0",
"]",
"in",
"(",
"2",
",",
"5",
")",
":",
"results",
"=",
"current_search_client",
".",
"percolate",
"(",
"index",... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | _new_percolator | Create new percolator associated with the new set. | invenio_oaiserver/percolator.py | def _new_percolator(spec, search_pattern):
"""Create new percolator associated with the new set."""
if spec and search_pattern:
query = query_string_parser(search_pattern=search_pattern).to_dict()
for index in current_search.mappings.keys():
# Create the percolator doc_type in the ex... | def _new_percolator(spec, search_pattern):
"""Create new percolator associated with the new set."""
if spec and search_pattern:
query = query_string_parser(search_pattern=search_pattern).to_dict()
for index in current_search.mappings.keys():
# Create the percolator doc_type in the ex... | [
"Create",
"new",
"percolator",
"associated",
"with",
"the",
"new",
"set",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/percolator.py#L78-L91 | [
"def",
"_new_percolator",
"(",
"spec",
",",
"search_pattern",
")",
":",
"if",
"spec",
"and",
"search_pattern",
":",
"query",
"=",
"query_string_parser",
"(",
"search_pattern",
"=",
"search_pattern",
")",
".",
"to_dict",
"(",
")",
"for",
"index",
"in",
"current... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | _delete_percolator | Delete percolator associated with the new oaiset. | invenio_oaiserver/percolator.py | def _delete_percolator(spec, search_pattern):
"""Delete percolator associated with the new oaiset."""
if spec:
for index in current_search.mappings.keys():
# Create the percolator doc_type in the existing index for >= ES5
percolator_doc_type = _get_percolator_doc_type(index)
... | def _delete_percolator(spec, search_pattern):
"""Delete percolator associated with the new oaiset."""
if spec:
for index in current_search.mappings.keys():
# Create the percolator doc_type in the existing index for >= ES5
percolator_doc_type = _get_percolator_doc_type(index)
... | [
"Delete",
"percolator",
"associated",
"with",
"the",
"new",
"oaiset",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/percolator.py#L94-L104 | [
"def",
"_delete_percolator",
"(",
"spec",
",",
"search_pattern",
")",
":",
"if",
"spec",
":",
"for",
"index",
"in",
"current_search",
".",
"mappings",
".",
"keys",
"(",
")",
":",
"# Create the percolator doc_type in the existing index for >= ES5",
"percolator_doc_type",... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | _build_cache | Build sets cache. | invenio_oaiserver/percolator.py | def _build_cache():
"""Build sets cache."""
sets = current_oaiserver.sets
if sets is None:
# build sets cache
sets = current_oaiserver.sets = [
oaiset.spec for oaiset in OAISet.query.filter(
OAISet.search_pattern.is_(None)).all()]
return sets | def _build_cache():
"""Build sets cache."""
sets = current_oaiserver.sets
if sets is None:
# build sets cache
sets = current_oaiserver.sets = [
oaiset.spec for oaiset in OAISet.query.filter(
OAISet.search_pattern.is_(None)).all()]
return sets | [
"Build",
"sets",
"cache",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/percolator.py#L107-L115 | [
"def",
"_build_cache",
"(",
")",
":",
"sets",
"=",
"current_oaiserver",
".",
"sets",
"if",
"sets",
"is",
"None",
":",
"# build sets cache",
"sets",
"=",
"current_oaiserver",
".",
"sets",
"=",
"[",
"oaiset",
".",
"spec",
"for",
"oaiset",
"in",
"OAISet",
"."... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | get_record_sets | Find matching sets. | invenio_oaiserver/percolator.py | def get_record_sets(record):
"""Find matching sets."""
# get lists of sets with search_pattern equals to None but already in the
# set list inside the record
record_sets = set(record.get('_oai', {}).get('sets', []))
for spec in _build_cache():
if spec in record_sets:
yield spec
... | def get_record_sets(record):
"""Find matching sets."""
# get lists of sets with search_pattern equals to None but already in the
# set list inside the record
record_sets = set(record.get('_oai', {}).get('sets', []))
for spec in _build_cache():
if spec in record_sets:
yield spec
... | [
"Find",
"matching",
"sets",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/percolator.py#L118-L142 | [
"def",
"get_record_sets",
"(",
"record",
")",
":",
"# get lists of sets with search_pattern equals to None but already in the",
"# set list inside the record",
"record_sets",
"=",
"set",
"(",
"record",
".",
"get",
"(",
"'_oai'",
",",
"{",
"}",
")",
".",
"get",
"(",
"'... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | _records_commit | Commit all records. | invenio_oaiserver/tasks.py | def _records_commit(record_ids):
"""Commit all records."""
for record_id in record_ids:
record = Record.get_record(record_id)
record.commit() | def _records_commit(record_ids):
"""Commit all records."""
for record_id in record_ids:
record = Record.get_record(record_id)
record.commit() | [
"Commit",
"all",
"records",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/tasks.py#L25-L29 | [
"def",
"_records_commit",
"(",
"record_ids",
")",
":",
"for",
"record_id",
"in",
"record_ids",
":",
"record",
"=",
"Record",
".",
"get_record",
"(",
"record_id",
")",
"record",
".",
"commit",
"(",
")"
] | eae765e32bd816ddc5612d4b281caf205518b512 |
train | update_affected_records | Update all affected records by OAISet change.
:param spec: The record spec.
:param search_pattern: The search pattern. | invenio_oaiserver/tasks.py | def update_affected_records(spec=None, search_pattern=None):
"""Update all affected records by OAISet change.
:param spec: The record spec.
:param search_pattern: The search pattern.
"""
chunk_size = current_app.config['OAISERVER_CELERY_TASK_CHUNK_SIZE']
record_ids = get_affected_records(spec=s... | def update_affected_records(spec=None, search_pattern=None):
"""Update all affected records by OAISet change.
:param spec: The record spec.
:param search_pattern: The search pattern.
"""
chunk_size = current_app.config['OAISERVER_CELERY_TASK_CHUNK_SIZE']
record_ids = get_affected_records(spec=s... | [
"Update",
"all",
"affected",
"records",
"by",
"OAISet",
"change",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/tasks.py#L43-L55 | [
"def",
"update_affected_records",
"(",
"spec",
"=",
"None",
",",
"search_pattern",
"=",
"None",
")",
":",
"chunk_size",
"=",
"current_app",
".",
"config",
"[",
"'OAISERVER_CELERY_TASK_CHUNK_SIZE'",
"]",
"record_ids",
"=",
"get_affected_records",
"(",
"spec",
"=",
... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | envelope | Create OAI-PMH envelope for response. | invenio_oaiserver/response.py | def envelope(**kwargs):
"""Create OAI-PMH envelope for response."""
e_oaipmh = Element(etree.QName(NS_OAIPMH, 'OAI-PMH'), nsmap=NSMAP)
e_oaipmh.set(etree.QName(NS_XSI, 'schemaLocation'),
'{0} {1}'.format(NS_OAIPMH, NS_OAIPMH_XSD))
e_tree = ElementTree(element=e_oaipmh)
if current_a... | def envelope(**kwargs):
"""Create OAI-PMH envelope for response."""
e_oaipmh = Element(etree.QName(NS_OAIPMH, 'OAI-PMH'), nsmap=NSMAP)
e_oaipmh.set(etree.QName(NS_XSI, 'schemaLocation'),
'{0} {1}'.format(NS_OAIPMH, NS_OAIPMH_XSD))
e_tree = ElementTree(element=e_oaipmh)
if current_a... | [
"Create",
"OAI",
"-",
"PMH",
"envelope",
"for",
"response",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/response.py#L50-L75 | [
"def",
"envelope",
"(",
"*",
"*",
"kwargs",
")",
":",
"e_oaipmh",
"=",
"Element",
"(",
"etree",
".",
"QName",
"(",
"NS_OAIPMH",
",",
"'OAI-PMH'",
")",
",",
"nsmap",
"=",
"NSMAP",
")",
"e_oaipmh",
".",
"set",
"(",
"etree",
".",
"QName",
"(",
"NS_XSI",... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | error | Create error element. | invenio_oaiserver/response.py | def error(errors):
"""Create error element."""
e_tree, e_oaipmh = envelope()
for code, message in errors:
e_error = SubElement(e_oaipmh, etree.QName(NS_OAIPMH, 'error'))
e_error.set('code', code)
e_error.text = message
return e_tree | def error(errors):
"""Create error element."""
e_tree, e_oaipmh = envelope()
for code, message in errors:
e_error = SubElement(e_oaipmh, etree.QName(NS_OAIPMH, 'error'))
e_error.set('code', code)
e_error.text = message
return e_tree | [
"Create",
"error",
"element",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/response.py#L78-L85 | [
"def",
"error",
"(",
"errors",
")",
":",
"e_tree",
",",
"e_oaipmh",
"=",
"envelope",
"(",
")",
"for",
"code",
",",
"message",
"in",
"errors",
":",
"e_error",
"=",
"SubElement",
"(",
"e_oaipmh",
",",
"etree",
".",
"QName",
"(",
"NS_OAIPMH",
",",
"'error... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | verb | Create OAI-PMH envelope for response with verb. | invenio_oaiserver/response.py | def verb(**kwargs):
"""Create OAI-PMH envelope for response with verb."""
e_tree, e_oaipmh = envelope(**kwargs)
e_element = SubElement(e_oaipmh, etree.QName(NS_OAIPMH, kwargs['verb']))
return e_tree, e_element | def verb(**kwargs):
"""Create OAI-PMH envelope for response with verb."""
e_tree, e_oaipmh = envelope(**kwargs)
e_element = SubElement(e_oaipmh, etree.QName(NS_OAIPMH, kwargs['verb']))
return e_tree, e_element | [
"Create",
"OAI",
"-",
"PMH",
"envelope",
"for",
"response",
"with",
"verb",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/response.py#L88-L92 | [
"def",
"verb",
"(",
"*",
"*",
"kwargs",
")",
":",
"e_tree",
",",
"e_oaipmh",
"=",
"envelope",
"(",
"*",
"*",
"kwargs",
")",
"e_element",
"=",
"SubElement",
"(",
"e_oaipmh",
",",
"etree",
".",
"QName",
"(",
"NS_OAIPMH",
",",
"kwargs",
"[",
"'verb'",
"... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | identify | Create OAI-PMH response for verb Identify. | invenio_oaiserver/response.py | def identify(**kwargs):
"""Create OAI-PMH response for verb Identify."""
cfg = current_app.config
e_tree, e_identify = verb(**kwargs)
e_repositoryName = SubElement(
e_identify, etree.QName(NS_OAIPMH, 'repositoryName'))
e_repositoryName.text = cfg['OAISERVER_REPOSITORY_NAME']
e_baseURL... | def identify(**kwargs):
"""Create OAI-PMH response for verb Identify."""
cfg = current_app.config
e_tree, e_identify = verb(**kwargs)
e_repositoryName = SubElement(
e_identify, etree.QName(NS_OAIPMH, 'repositoryName'))
e_repositoryName.text = cfg['OAISERVER_REPOSITORY_NAME']
e_baseURL... | [
"Create",
"OAI",
"-",
"PMH",
"response",
"for",
"verb",
"Identify",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/response.py#L95-L153 | [
"def",
"identify",
"(",
"*",
"*",
"kwargs",
")",
":",
"cfg",
"=",
"current_app",
".",
"config",
"e_tree",
",",
"e_identify",
"=",
"verb",
"(",
"*",
"*",
"kwargs",
")",
"e_repositoryName",
"=",
"SubElement",
"(",
"e_identify",
",",
"etree",
".",
"QName",
... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | resumption_token | Attach resumption token element to a parent. | invenio_oaiserver/response.py | def resumption_token(parent, pagination, **kwargs):
"""Attach resumption token element to a parent."""
# Do not add resumptionToken if all results fit to the first page.
if pagination.page == 1 and not pagination.has_next:
return
token = serialize(pagination, **kwargs)
e_resumptionToken = S... | def resumption_token(parent, pagination, **kwargs):
"""Attach resumption token element to a parent."""
# Do not add resumptionToken if all results fit to the first page.
if pagination.page == 1 and not pagination.has_next:
return
token = serialize(pagination, **kwargs)
e_resumptionToken = S... | [
"Attach",
"resumption",
"token",
"element",
"to",
"a",
"parent",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/response.py#L156-L180 | [
"def",
"resumption_token",
"(",
"parent",
",",
"pagination",
",",
"*",
"*",
"kwargs",
")",
":",
"# Do not add resumptionToken if all results fit to the first page.",
"if",
"pagination",
".",
"page",
"==",
"1",
"and",
"not",
"pagination",
".",
"has_next",
":",
"retur... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | listsets | Create OAI-PMH response for ListSets verb. | invenio_oaiserver/response.py | def listsets(**kwargs):
"""Create OAI-PMH response for ListSets verb."""
e_tree, e_listsets = verb(**kwargs)
page = kwargs.get('resumptionToken', {}).get('page', 1)
size = current_app.config['OAISERVER_PAGE_SIZE']
oai_sets = OAISet.query.paginate(page=page, per_page=size, error_out=False)
for ... | def listsets(**kwargs):
"""Create OAI-PMH response for ListSets verb."""
e_tree, e_listsets = verb(**kwargs)
page = kwargs.get('resumptionToken', {}).get('page', 1)
size = current_app.config['OAISERVER_PAGE_SIZE']
oai_sets = OAISet.query.paginate(page=page, per_page=size, error_out=False)
for ... | [
"Create",
"OAI",
"-",
"PMH",
"response",
"for",
"ListSets",
"verb",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/response.py#L183-L209 | [
"def",
"listsets",
"(",
"*",
"*",
"kwargs",
")",
":",
"e_tree",
",",
"e_listsets",
"=",
"verb",
"(",
"*",
"*",
"kwargs",
")",
"page",
"=",
"kwargs",
".",
"get",
"(",
"'resumptionToken'",
",",
"{",
"}",
")",
".",
"get",
"(",
"'page'",
",",
"1",
")... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | listmetadataformats | Create OAI-PMH response for ListMetadataFormats verb. | invenio_oaiserver/response.py | def listmetadataformats(**kwargs):
"""Create OAI-PMH response for ListMetadataFormats verb."""
cfg = current_app.config
e_tree, e_listmetadataformats = verb(**kwargs)
if 'identifier' in kwargs:
# test if record exists
OAIIDProvider.get(pid_value=kwargs['identifier'])
for prefix, me... | def listmetadataformats(**kwargs):
"""Create OAI-PMH response for ListMetadataFormats verb."""
cfg = current_app.config
e_tree, e_listmetadataformats = verb(**kwargs)
if 'identifier' in kwargs:
# test if record exists
OAIIDProvider.get(pid_value=kwargs['identifier'])
for prefix, me... | [
"Create",
"OAI",
"-",
"PMH",
"response",
"for",
"ListMetadataFormats",
"verb",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/response.py#L212-L238 | [
"def",
"listmetadataformats",
"(",
"*",
"*",
"kwargs",
")",
":",
"cfg",
"=",
"current_app",
".",
"config",
"e_tree",
",",
"e_listmetadataformats",
"=",
"verb",
"(",
"*",
"*",
"kwargs",
")",
"if",
"'identifier'",
"in",
"kwargs",
":",
"# test if record exists",
... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | header | Attach ``<header/>`` element to a parent. | invenio_oaiserver/response.py | def header(parent, identifier, datestamp, sets=None, deleted=False):
"""Attach ``<header/>`` element to a parent."""
e_header = SubElement(parent, etree.QName(NS_OAIPMH, 'header'))
if deleted:
e_header.set('status', 'deleted')
e_identifier = SubElement(e_header, etree.QName(NS_OAIPMH, 'identifie... | def header(parent, identifier, datestamp, sets=None, deleted=False):
"""Attach ``<header/>`` element to a parent."""
e_header = SubElement(parent, etree.QName(NS_OAIPMH, 'header'))
if deleted:
e_header.set('status', 'deleted')
e_identifier = SubElement(e_header, etree.QName(NS_OAIPMH, 'identifie... | [
"Attach",
"<header",
"/",
">",
"element",
"to",
"a",
"parent",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/response.py#L241-L253 | [
"def",
"header",
"(",
"parent",
",",
"identifier",
",",
"datestamp",
",",
"sets",
"=",
"None",
",",
"deleted",
"=",
"False",
")",
":",
"e_header",
"=",
"SubElement",
"(",
"parent",
",",
"etree",
".",
"QName",
"(",
"NS_OAIPMH",
",",
"'header'",
")",
")"... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | getrecord | Create OAI-PMH response for verb Identify. | invenio_oaiserver/response.py | def getrecord(**kwargs):
"""Create OAI-PMH response for verb Identify."""
record_dumper = serializer(kwargs['metadataPrefix'])
pid = OAIIDProvider.get(pid_value=kwargs['identifier']).pid
record = Record.get_record(pid.object_uuid)
e_tree, e_getrecord = verb(**kwargs)
e_record = SubElement(e_get... | def getrecord(**kwargs):
"""Create OAI-PMH response for verb Identify."""
record_dumper = serializer(kwargs['metadataPrefix'])
pid = OAIIDProvider.get(pid_value=kwargs['identifier']).pid
record = Record.get_record(pid.object_uuid)
e_tree, e_getrecord = verb(**kwargs)
e_record = SubElement(e_get... | [
"Create",
"OAI",
"-",
"PMH",
"response",
"for",
"verb",
"Identify",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/response.py#L256-L275 | [
"def",
"getrecord",
"(",
"*",
"*",
"kwargs",
")",
":",
"record_dumper",
"=",
"serializer",
"(",
"kwargs",
"[",
"'metadataPrefix'",
"]",
")",
"pid",
"=",
"OAIIDProvider",
".",
"get",
"(",
"pid_value",
"=",
"kwargs",
"[",
"'identifier'",
"]",
")",
".",
"pi... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | listidentifiers | Create OAI-PMH response for verb ListIdentifiers. | invenio_oaiserver/response.py | def listidentifiers(**kwargs):
"""Create OAI-PMH response for verb ListIdentifiers."""
e_tree, e_listidentifiers = verb(**kwargs)
result = get_records(**kwargs)
for record in result.items:
pid = oaiid_fetcher(record['id'], record['json']['_source'])
header(
e_listidentifiers... | def listidentifiers(**kwargs):
"""Create OAI-PMH response for verb ListIdentifiers."""
e_tree, e_listidentifiers = verb(**kwargs)
result = get_records(**kwargs)
for record in result.items:
pid = oaiid_fetcher(record['id'], record['json']['_source'])
header(
e_listidentifiers... | [
"Create",
"OAI",
"-",
"PMH",
"response",
"for",
"verb",
"ListIdentifiers",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/response.py#L278-L293 | [
"def",
"listidentifiers",
"(",
"*",
"*",
"kwargs",
")",
":",
"e_tree",
",",
"e_listidentifiers",
"=",
"verb",
"(",
"*",
"*",
"kwargs",
")",
"result",
"=",
"get_records",
"(",
"*",
"*",
"kwargs",
")",
"for",
"record",
"in",
"result",
".",
"items",
":",
... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | listrecords | Create OAI-PMH response for verb ListRecords. | invenio_oaiserver/response.py | def listrecords(**kwargs):
"""Create OAI-PMH response for verb ListRecords."""
record_dumper = serializer(kwargs['metadataPrefix'])
e_tree, e_listrecords = verb(**kwargs)
result = get_records(**kwargs)
for record in result.items:
pid = oaiid_fetcher(record['id'], record['json']['_source'])... | def listrecords(**kwargs):
"""Create OAI-PMH response for verb ListRecords."""
record_dumper = serializer(kwargs['metadataPrefix'])
e_tree, e_listrecords = verb(**kwargs)
result = get_records(**kwargs)
for record in result.items:
pid = oaiid_fetcher(record['id'], record['json']['_source'])... | [
"Create",
"OAI",
"-",
"PMH",
"response",
"for",
"verb",
"ListRecords",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/response.py#L296-L317 | [
"def",
"listrecords",
"(",
"*",
"*",
"kwargs",
")",
":",
"record_dumper",
"=",
"serializer",
"(",
"kwargs",
"[",
"'metadataPrefix'",
"]",
")",
"e_tree",
",",
"e_listrecords",
"=",
"verb",
"(",
"*",
"*",
"kwargs",
")",
"result",
"=",
"get_records",
"(",
"... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | oaiid_fetcher | Fetch a record's identifier.
:param record_uuid: The record UUID.
:param data: The record data.
:returns: A :class:`invenio_pidstore.fetchers.FetchedPID` instance. | invenio_oaiserver/fetchers.py | def oaiid_fetcher(record_uuid, data):
"""Fetch a record's identifier.
:param record_uuid: The record UUID.
:param data: The record data.
:returns: A :class:`invenio_pidstore.fetchers.FetchedPID` instance.
"""
pid_value = data.get('_oai', {}).get('id')
if pid_value is None:
raise Per... | def oaiid_fetcher(record_uuid, data):
"""Fetch a record's identifier.
:param record_uuid: The record UUID.
:param data: The record data.
:returns: A :class:`invenio_pidstore.fetchers.FetchedPID` instance.
"""
pid_value = data.get('_oai', {}).get('id')
if pid_value is None:
raise Per... | [
"Fetch",
"a",
"record",
"s",
"identifier",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/fetchers.py#L19-L33 | [
"def",
"oaiid_fetcher",
"(",
"record_uuid",
",",
"data",
")",
":",
"pid_value",
"=",
"data",
".",
"get",
"(",
"'_oai'",
",",
"{",
"}",
")",
".",
"get",
"(",
"'id'",
")",
"if",
"pid_value",
"is",
"None",
":",
"raise",
"PersistentIdentifierError",
"(",
"... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | OAISet.validate_spec | Forbit updates of set identifier. | invenio_oaiserver/models.py | def validate_spec(self, key, value):
"""Forbit updates of set identifier."""
if self.spec and self.spec != value:
raise OAISetSpecUpdateError("Updating spec is not allowed.")
return value | def validate_spec(self, key, value):
"""Forbit updates of set identifier."""
if self.spec and self.spec != value:
raise OAISetSpecUpdateError("Updating spec is not allowed.")
return value | [
"Forbit",
"updates",
"of",
"set",
"identifier",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/models.py#L73-L77 | [
"def",
"validate_spec",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"if",
"self",
".",
"spec",
"and",
"self",
".",
"spec",
"!=",
"value",
":",
"raise",
"OAISetSpecUpdateError",
"(",
"\"Updating spec is not allowed.\"",
")",
"return",
"value"
] | eae765e32bd816ddc5612d4b281caf205518b512 |
train | OAISet.add_record | Add a record to the OAISet.
:param record: Record to be added.
:type record: `invenio_records.api.Record` or derivative. | invenio_oaiserver/models.py | def add_record(self, record):
"""Add a record to the OAISet.
:param record: Record to be added.
:type record: `invenio_records.api.Record` or derivative.
"""
record.setdefault('_oai', {}).setdefault('sets', [])
assert not self.has_record(record)
record['_oai'][... | def add_record(self, record):
"""Add a record to the OAISet.
:param record: Record to be added.
:type record: `invenio_records.api.Record` or derivative.
"""
record.setdefault('_oai', {}).setdefault('sets', [])
assert not self.has_record(record)
record['_oai'][... | [
"Add",
"a",
"record",
"to",
"the",
"OAISet",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/models.py#L79-L89 | [
"def",
"add_record",
"(",
"self",
",",
"record",
")",
":",
"record",
".",
"setdefault",
"(",
"'_oai'",
",",
"{",
"}",
")",
".",
"setdefault",
"(",
"'sets'",
",",
"[",
"]",
")",
"assert",
"not",
"self",
".",
"has_record",
"(",
"record",
")",
"record",... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | OAISet.remove_record | Remove a record from the OAISet.
:param record: Record to be removed.
:type record: `invenio_records.api.Record` or derivative. | invenio_oaiserver/models.py | def remove_record(self, record):
"""Remove a record from the OAISet.
:param record: Record to be removed.
:type record: `invenio_records.api.Record` or derivative.
"""
assert self.has_record(record)
record['_oai']['sets'] = [
s for s in record['_oai']['sets'... | def remove_record(self, record):
"""Remove a record from the OAISet.
:param record: Record to be removed.
:type record: `invenio_records.api.Record` or derivative.
"""
assert self.has_record(record)
record['_oai']['sets'] = [
s for s in record['_oai']['sets'... | [
"Remove",
"a",
"record",
"from",
"the",
"OAISet",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/models.py#L91-L100 | [
"def",
"remove_record",
"(",
"self",
",",
"record",
")",
":",
"assert",
"self",
".",
"has_record",
"(",
"record",
")",
"record",
"[",
"'_oai'",
"]",
"[",
"'sets'",
"]",
"=",
"[",
"s",
"for",
"s",
"in",
"record",
"[",
"'_oai'",
"]",
"[",
"'sets'",
"... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | oaiserver | Initialize OAI-PMH server. | examples/app.py | def oaiserver(sets, records):
"""Initialize OAI-PMH server."""
from invenio_db import db
from invenio_oaiserver.models import OAISet
from invenio_records.api import Record
# create a OAI Set
with db.session.begin_nested():
for i in range(sets):
db.session.add(OAISet(
... | def oaiserver(sets, records):
"""Initialize OAI-PMH server."""
from invenio_db import db
from invenio_oaiserver.models import OAISet
from invenio_records.api import Record
# create a OAI Set
with db.session.begin_nested():
for i in range(sets):
db.session.add(OAISet(
... | [
"Initialize",
"OAI",
"-",
"PMH",
"server",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/examples/app.py#L92-L138 | [
"def",
"oaiserver",
"(",
"sets",
",",
"records",
")",
":",
"from",
"invenio_db",
"import",
"db",
"from",
"invenio_oaiserver",
".",
"models",
"import",
"OAISet",
"from",
"invenio_records",
".",
"api",
"import",
"Record",
"# create a OAI Set",
"with",
"db",
".",
... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | serializer | Return etree_dumper instances.
:param metadata_prefix: One of the metadata identifiers configured in
``OAISERVER_METADATA_FORMATS``. | invenio_oaiserver/utils.py | def serializer(metadata_prefix):
"""Return etree_dumper instances.
:param metadata_prefix: One of the metadata identifiers configured in
``OAISERVER_METADATA_FORMATS``.
"""
metadataFormats = current_app.config['OAISERVER_METADATA_FORMATS']
serializer_ = metadataFormats[metadata_prefix]['ser... | def serializer(metadata_prefix):
"""Return etree_dumper instances.
:param metadata_prefix: One of the metadata identifiers configured in
``OAISERVER_METADATA_FORMATS``.
"""
metadataFormats = current_app.config['OAISERVER_METADATA_FORMATS']
serializer_ = metadataFormats[metadata_prefix]['ser... | [
"Return",
"etree_dumper",
"instances",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/utils.py#L53-L63 | [
"def",
"serializer",
"(",
"metadata_prefix",
")",
":",
"metadataFormats",
"=",
"current_app",
".",
"config",
"[",
"'OAISERVER_METADATA_FORMATS'",
"]",
"serializer_",
"=",
"metadataFormats",
"[",
"metadata_prefix",
"]",
"[",
"'serializer'",
"]",
"if",
"isinstance",
"... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | dumps_etree | Dump MARC21 compatible record.
:param pid: The :class:`invenio_pidstore.models.PersistentIdentifier`
instance.
:param record: The :class:`invenio_records.api.Record` instance.
:returns: A LXML Element instance. | invenio_oaiserver/utils.py | def dumps_etree(pid, record, **kwargs):
"""Dump MARC21 compatible record.
:param pid: The :class:`invenio_pidstore.models.PersistentIdentifier`
instance.
:param record: The :class:`invenio_records.api.Record` instance.
:returns: A LXML Element instance.
"""
from dojson.contrib.to_marc21... | def dumps_etree(pid, record, **kwargs):
"""Dump MARC21 compatible record.
:param pid: The :class:`invenio_pidstore.models.PersistentIdentifier`
instance.
:param record: The :class:`invenio_records.api.Record` instance.
:returns: A LXML Element instance.
"""
from dojson.contrib.to_marc21... | [
"Dump",
"MARC21",
"compatible",
"record",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/utils.py#L66-L77 | [
"def",
"dumps_etree",
"(",
"pid",
",",
"record",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"dojson",
".",
"contrib",
".",
"to_marc21",
"import",
"to_marc21",
"from",
"dojson",
".",
"contrib",
".",
"to_marc21",
".",
"utils",
"import",
"dumps_etree",
"retur... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | eprints_description | Generate the eprints element for the identify response.
The eprints container is used by the e-print community to describe
the content and policies of repositories.
For the full specification and schema definition visit:
http://www.openarchives.org/OAI/2.0/guidelines-eprints.htm | invenio_oaiserver/utils.py | def eprints_description(metadataPolicy, dataPolicy,
submissionPolicy=None, content=None):
"""Generate the eprints element for the identify response.
The eprints container is used by the e-print community to describe
the content and policies of repositories.
For the full specific... | def eprints_description(metadataPolicy, dataPolicy,
submissionPolicy=None, content=None):
"""Generate the eprints element for the identify response.
The eprints container is used by the e-print community to describe
the content and policies of repositories.
For the full specific... | [
"Generate",
"the",
"eprints",
"element",
"for",
"the",
"identify",
"response",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/utils.py#L96-L131 | [
"def",
"eprints_description",
"(",
"metadataPolicy",
",",
"dataPolicy",
",",
"submissionPolicy",
"=",
"None",
",",
"content",
"=",
"None",
")",
":",
"eprints",
"=",
"Element",
"(",
"etree",
".",
"QName",
"(",
"NS_EPRINTS",
"[",
"None",
"]",
",",
"'eprints'",... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | oai_identifier_description | Generate the oai-identifier element for the identify response.
The OAI identifier format is intended to provide persistent resource
identifiers for items in repositories that implement OAI-PMH.
For the full specification and schema definition visit:
http://www.openarchives.org/OAI/2.0/guidelines-oai-id... | invenio_oaiserver/utils.py | def oai_identifier_description(scheme, repositoryIdentifier,
delimiter, sampleIdentifier):
"""Generate the oai-identifier element for the identify response.
The OAI identifier format is intended to provide persistent resource
identifiers for items in repositories that impleme... | def oai_identifier_description(scheme, repositoryIdentifier,
delimiter, sampleIdentifier):
"""Generate the oai-identifier element for the identify response.
The OAI identifier format is intended to provide persistent resource
identifiers for items in repositories that impleme... | [
"Generate",
"the",
"oai",
"-",
"identifier",
"element",
"for",
"the",
"identify",
"response",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/utils.py#L134-L153 | [
"def",
"oai_identifier_description",
"(",
"scheme",
",",
"repositoryIdentifier",
",",
"delimiter",
",",
"sampleIdentifier",
")",
":",
"oai_identifier",
"=",
"Element",
"(",
"etree",
".",
"QName",
"(",
"NS_OAI_IDENTIFIER",
"[",
"None",
"]",
",",
"'oai_identifier'",
... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | friends_description | Generate the friends element for the identify response.
The friends container is recommended for use by repositories
to list confederate repositories.
For the schema definition visit:
http://www.openarchives.org/OAI/2.0/guidelines-friends.htm | invenio_oaiserver/utils.py | def friends_description(baseURLs):
"""Generate the friends element for the identify response.
The friends container is recommended for use by repositories
to list confederate repositories.
For the schema definition visit:
http://www.openarchives.org/OAI/2.0/guidelines-friends.htm
"""
friend... | def friends_description(baseURLs):
"""Generate the friends element for the identify response.
The friends container is recommended for use by repositories
to list confederate repositories.
For the schema definition visit:
http://www.openarchives.org/OAI/2.0/guidelines-friends.htm
"""
friend... | [
"Generate",
"the",
"friends",
"element",
"for",
"the",
"identify",
"response",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/utils.py#L156-L171 | [
"def",
"friends_description",
"(",
"baseURLs",
")",
":",
"friends",
"=",
"Element",
"(",
"etree",
".",
"QName",
"(",
"NS_FRIENDS",
"[",
"None",
"]",
",",
"'friends'",
")",
",",
"nsmap",
"=",
"NS_FRIENDS",
")",
"friends",
".",
"set",
"(",
"etree",
".",
... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | after_insert_oai_set | Update records on OAISet insertion. | invenio_oaiserver/receivers.py | def after_insert_oai_set(mapper, connection, target):
"""Update records on OAISet insertion."""
_new_percolator(spec=target.spec, search_pattern=target.search_pattern)
sleep(2)
update_affected_records.delay(
search_pattern=target.search_pattern
) | def after_insert_oai_set(mapper, connection, target):
"""Update records on OAISet insertion."""
_new_percolator(spec=target.spec, search_pattern=target.search_pattern)
sleep(2)
update_affected_records.delay(
search_pattern=target.search_pattern
) | [
"Update",
"records",
"on",
"OAISet",
"insertion",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/receivers.py#L36-L42 | [
"def",
"after_insert_oai_set",
"(",
"mapper",
",",
"connection",
",",
"target",
")",
":",
"_new_percolator",
"(",
"spec",
"=",
"target",
".",
"spec",
",",
"search_pattern",
"=",
"target",
".",
"search_pattern",
")",
"sleep",
"(",
"2",
")",
"update_affected_rec... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | after_update_oai_set | Update records on OAISet update. | invenio_oaiserver/receivers.py | def after_update_oai_set(mapper, connection, target):
"""Update records on OAISet update."""
_delete_percolator(spec=target.spec, search_pattern=target.search_pattern)
_new_percolator(spec=target.spec, search_pattern=target.search_pattern)
sleep(2)
update_affected_records.delay(
spec=target.... | def after_update_oai_set(mapper, connection, target):
"""Update records on OAISet update."""
_delete_percolator(spec=target.spec, search_pattern=target.search_pattern)
_new_percolator(spec=target.spec, search_pattern=target.search_pattern)
sleep(2)
update_affected_records.delay(
spec=target.... | [
"Update",
"records",
"on",
"OAISet",
"update",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/receivers.py#L45-L52 | [
"def",
"after_update_oai_set",
"(",
"mapper",
",",
"connection",
",",
"target",
")",
":",
"_delete_percolator",
"(",
"spec",
"=",
"target",
".",
"spec",
",",
"search_pattern",
"=",
"target",
".",
"search_pattern",
")",
"_new_percolator",
"(",
"spec",
"=",
"tar... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | after_delete_oai_set | Update records on OAISet deletion. | invenio_oaiserver/receivers.py | def after_delete_oai_set(mapper, connection, target):
"""Update records on OAISet deletion."""
_delete_percolator(spec=target.spec, search_pattern=target.search_pattern)
sleep(2)
update_affected_records.delay(
spec=target.spec
) | def after_delete_oai_set(mapper, connection, target):
"""Update records on OAISet deletion."""
_delete_percolator(spec=target.spec, search_pattern=target.search_pattern)
sleep(2)
update_affected_records.delay(
spec=target.spec
) | [
"Update",
"records",
"on",
"OAISet",
"deletion",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/receivers.py#L55-L61 | [
"def",
"after_delete_oai_set",
"(",
"mapper",
",",
"connection",
",",
"target",
")",
":",
"_delete_percolator",
"(",
"spec",
"=",
"target",
".",
"spec",
",",
"search_pattern",
"=",
"target",
".",
"search_pattern",
")",
"sleep",
"(",
"2",
")",
"update_affected_... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | query_string_parser | Elasticsearch query string parser. | invenio_oaiserver/query.py | def query_string_parser(search_pattern):
"""Elasticsearch query string parser."""
if not hasattr(current_oaiserver, 'query_parser'):
query_parser = current_app.config['OAISERVER_QUERY_PARSER']
if isinstance(query_parser, six.string_types):
query_parser = import_string(query_parser)
... | def query_string_parser(search_pattern):
"""Elasticsearch query string parser."""
if not hasattr(current_oaiserver, 'query_parser'):
query_parser = current_app.config['OAISERVER_QUERY_PARSER']
if isinstance(query_parser, six.string_types):
query_parser = import_string(query_parser)
... | [
"Elasticsearch",
"query",
"string",
"parser",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/query.py#L20-L27 | [
"def",
"query_string_parser",
"(",
"search_pattern",
")",
":",
"if",
"not",
"hasattr",
"(",
"current_oaiserver",
",",
"'query_parser'",
")",
":",
"query_parser",
"=",
"current_app",
".",
"config",
"[",
"'OAISERVER_QUERY_PARSER'",
"]",
"if",
"isinstance",
"(",
"que... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | get_affected_records | Get list of affected records.
:param spec: The record spec.
:param search_pattern: The search pattern.
:returns: An iterator to lazily find results. | invenio_oaiserver/query.py | def get_affected_records(spec=None, search_pattern=None):
"""Get list of affected records.
:param spec: The record spec.
:param search_pattern: The search pattern.
:returns: An iterator to lazily find results.
"""
# spec pattern query
# ---------- ---------- -------
# None ... | def get_affected_records(spec=None, search_pattern=None):
"""Get list of affected records.
:param spec: The record spec.
:param search_pattern: The search pattern.
:returns: An iterator to lazily find results.
"""
# spec pattern query
# ---------- ---------- -------
# None ... | [
"Get",
"list",
"of",
"affected",
"records",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/query.py#L39-L70 | [
"def",
"get_affected_records",
"(",
"spec",
"=",
"None",
",",
"search_pattern",
"=",
"None",
")",
":",
"# spec pattern query",
"# ---------- ---------- -------",
"# None None None",
"# None Y Y",
"# X None X",
"# X '' ... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | get_records | Get records paginated. | invenio_oaiserver/query.py | def get_records(**kwargs):
"""Get records paginated."""
page_ = kwargs.get('resumptionToken', {}).get('page', 1)
size_ = current_app.config['OAISERVER_PAGE_SIZE']
scroll = current_app.config['OAISERVER_RESUMPTION_TOKEN_EXPIRE_TIME']
scroll_id = kwargs.get('resumptionToken', {}).get('scroll_id')
... | def get_records(**kwargs):
"""Get records paginated."""
page_ = kwargs.get('resumptionToken', {}).get('page', 1)
size_ = current_app.config['OAISERVER_PAGE_SIZE']
scroll = current_app.config['OAISERVER_RESUMPTION_TOKEN_EXPIRE_TIME']
scroll_id = kwargs.get('resumptionToken', {}).get('scroll_id')
... | [
"Get",
"records",
"paginated",
"."
] | inveniosoftware/invenio-oaiserver | python | https://github.com/inveniosoftware/invenio-oaiserver/blob/eae765e32bd816ddc5612d4b281caf205518b512/invenio_oaiserver/query.py#L73-L151 | [
"def",
"get_records",
"(",
"*",
"*",
"kwargs",
")",
":",
"page_",
"=",
"kwargs",
".",
"get",
"(",
"'resumptionToken'",
",",
"{",
"}",
")",
".",
"get",
"(",
"'page'",
",",
"1",
")",
"size_",
"=",
"current_app",
".",
"config",
"[",
"'OAISERVER_PAGE_SIZE'... | eae765e32bd816ddc5612d4b281caf205518b512 |
train | get_file_path | Look for an existing path matching filename.
Try to resolve relative to the module location if the path cannot by found
using "normal" resolution. | jp_proxy_widget/js_context.py | def get_file_path(filename, local=True, relative_to_module=None, my_dir=my_dir):
"""
Look for an existing path matching filename.
Try to resolve relative to the module location if the path cannot by found
using "normal" resolution.
"""
# override my_dir if module is provided
if relative_to_m... | def get_file_path(filename, local=True, relative_to_module=None, my_dir=my_dir):
"""
Look for an existing path matching filename.
Try to resolve relative to the module location if the path cannot by found
using "normal" resolution.
"""
# override my_dir if module is provided
if relative_to_m... | [
"Look",
"for",
"an",
"existing",
"path",
"matching",
"filename",
".",
"Try",
"to",
"resolve",
"relative",
"to",
"the",
"module",
"location",
"if",
"the",
"path",
"cannot",
"by",
"found",
"using",
"normal",
"resolution",
"."
] | AaronWatters/jp_proxy_widget | python | https://github.com/AaronWatters/jp_proxy_widget/blob/e53789c9b8a587e2f6e768d16b68e0ae5b3790d9/jp_proxy_widget/js_context.py#L19-L37 | [
"def",
"get_file_path",
"(",
"filename",
",",
"local",
"=",
"True",
",",
"relative_to_module",
"=",
"None",
",",
"my_dir",
"=",
"my_dir",
")",
":",
"# override my_dir if module is provided",
"if",
"relative_to_module",
"is",
"not",
"None",
":",
"my_dir",
"=",
"o... | e53789c9b8a587e2f6e768d16b68e0ae5b3790d9 |
train | load_if_not_loaded | Load a javascript file to the Jupyter notebook context,
unless it was already loaded. | jp_proxy_widget/js_context.py | def load_if_not_loaded(widget, filenames, verbose=False, delay=0.1, force=False, local=True, evaluator=None):
"""
Load a javascript file to the Jupyter notebook context,
unless it was already loaded.
"""
if evaluator is None:
evaluator = EVALUATOR # default if not specified.
for filenam... | def load_if_not_loaded(widget, filenames, verbose=False, delay=0.1, force=False, local=True, evaluator=None):
"""
Load a javascript file to the Jupyter notebook context,
unless it was already loaded.
"""
if evaluator is None:
evaluator = EVALUATOR # default if not specified.
for filenam... | [
"Load",
"a",
"javascript",
"file",
"to",
"the",
"Jupyter",
"notebook",
"context",
"unless",
"it",
"was",
"already",
"loaded",
"."
] | AaronWatters/jp_proxy_widget | python | https://github.com/AaronWatters/jp_proxy_widget/blob/e53789c9b8a587e2f6e768d16b68e0ae5b3790d9/jp_proxy_widget/js_context.py#L71-L93 | [
"def",
"load_if_not_loaded",
"(",
"widget",
",",
"filenames",
",",
"verbose",
"=",
"False",
",",
"delay",
"=",
"0.1",
",",
"force",
"=",
"False",
",",
"local",
"=",
"True",
",",
"evaluator",
"=",
"None",
")",
":",
"if",
"evaluator",
"is",
"None",
":",
... | e53789c9b8a587e2f6e768d16b68e0ae5b3790d9 |
train | ElementWrapper._set | Proxy to set a property of the widget element. | jp_proxy_widget/proxy_widget.py | def _set(self, name, value):
"Proxy to set a property of the widget element."
return self.widget(self.widget_element._set(name, value)) | def _set(self, name, value):
"Proxy to set a property of the widget element."
return self.widget(self.widget_element._set(name, value)) | [
"Proxy",
"to",
"set",
"a",
"property",
"of",
"the",
"widget",
"element",
"."
] | AaronWatters/jp_proxy_widget | python | https://github.com/AaronWatters/jp_proxy_widget/blob/e53789c9b8a587e2f6e768d16b68e0ae5b3790d9/jp_proxy_widget/proxy_widget.py#L855-L857 | [
"def",
"_set",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"return",
"self",
".",
"widget",
"(",
"self",
".",
"widget_element",
".",
"_set",
"(",
"name",
",",
"value",
")",
")"
] | e53789c9b8a587e2f6e768d16b68e0ae5b3790d9 |
train | strip_outer_tag | Strips the outer tag, if text starts with a tag. Not entity aware;
designed to quickly strip outer tags from lxml cleaner output. Only
checks for <p> and <div> outer tags. | speedparser/speedparser.py | def strip_outer_tag(text):
"""Strips the outer tag, if text starts with a tag. Not entity aware;
designed to quickly strip outer tags from lxml cleaner output. Only
checks for <p> and <div> outer tags."""
if not text or not isinstance(text, basestring):
return text
stripped = text.strip()
... | def strip_outer_tag(text):
"""Strips the outer tag, if text starts with a tag. Not entity aware;
designed to quickly strip outer tags from lxml cleaner output. Only
checks for <p> and <div> outer tags."""
if not text or not isinstance(text, basestring):
return text
stripped = text.strip()
... | [
"Strips",
"the",
"outer",
"tag",
"if",
"text",
"starts",
"with",
"a",
"tag",
".",
"Not",
"entity",
"aware",
";",
"designed",
"to",
"quickly",
"strip",
"outer",
"tags",
"from",
"lxml",
"cleaner",
"output",
".",
"Only",
"checks",
"for",
"<p",
">",
"and",
... | jmoiron/speedparser | python | https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/speedparser.py#L94-L104 | [
"def",
"strip_outer_tag",
"(",
"text",
")",
":",
"if",
"not",
"text",
"or",
"not",
"isinstance",
"(",
"text",
",",
"basestring",
")",
":",
"return",
"text",
"stripped",
"=",
"text",
".",
"strip",
"(",
")",
"if",
"(",
"stripped",
".",
"startswith",
"(",... | e7e8d79daf73b35c9259695ad1e379476e1dfc77 |
train | munge_author | If an author contains an email and a name in it, make sure it is in
the format: "name (email)". | speedparser/speedparser.py | def munge_author(author):
"""If an author contains an email and a name in it, make sure it is in
the format: "name (email)"."""
# this loveliness is from feedparser but was not usable as a function
if '@' in author:
emailmatch = re.search(r"(([a-zA-Z0-9\_\-\.\+]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-... | def munge_author(author):
"""If an author contains an email and a name in it, make sure it is in
the format: "name (email)"."""
# this loveliness is from feedparser but was not usable as a function
if '@' in author:
emailmatch = re.search(r"(([a-zA-Z0-9\_\-\.\+]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-... | [
"If",
"an",
"author",
"contains",
"an",
"email",
"and",
"a",
"name",
"in",
"it",
"make",
"sure",
"it",
"is",
"in",
"the",
"format",
":",
"name",
"(",
"email",
")",
"."
] | jmoiron/speedparser | python | https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/speedparser.py#L121-L141 | [
"def",
"munge_author",
"(",
"author",
")",
":",
"# this loveliness is from feedparser but was not usable as a function",
"if",
"'@'",
"in",
"author",
":",
"emailmatch",
"=",
"re",
".",
"search",
"(",
"r\"(([a-zA-Z0-9\\_\\-\\.\\+]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|((... | e7e8d79daf73b35c9259695ad1e379476e1dfc77 |
train | base_url | Determine the base url for a root element. | speedparser/speedparser.py | def base_url(root):
"""Determine the base url for a root element."""
for attr, value in root.attrib.iteritems():
if attr.endswith('base') and 'http' in value:
return value
return None | def base_url(root):
"""Determine the base url for a root element."""
for attr, value in root.attrib.iteritems():
if attr.endswith('base') and 'http' in value:
return value
return None | [
"Determine",
"the",
"base",
"url",
"for",
"a",
"root",
"element",
"."
] | jmoiron/speedparser | python | https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/speedparser.py#L152-L157 | [
"def",
"base_url",
"(",
"root",
")",
":",
"for",
"attr",
",",
"value",
"in",
"root",
".",
"attrib",
".",
"iteritems",
"(",
")",
":",
"if",
"attr",
".",
"endswith",
"(",
"'base'",
")",
"and",
"'http'",
"in",
"value",
":",
"return",
"value",
"return",
... | e7e8d79daf73b35c9259695ad1e379476e1dfc77 |
train | clean_ns | Return a tag and its namespace separately. | speedparser/speedparser.py | def clean_ns(tag):
"""Return a tag and its namespace separately."""
if '}' in tag:
split = tag.split('}')
return split[0].strip('{'), split[-1]
return '', tag | def clean_ns(tag):
"""Return a tag and its namespace separately."""
if '}' in tag:
split = tag.split('}')
return split[0].strip('{'), split[-1]
return '', tag | [
"Return",
"a",
"tag",
"and",
"its",
"namespace",
"separately",
"."
] | jmoiron/speedparser | python | https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/speedparser.py#L174-L179 | [
"def",
"clean_ns",
"(",
"tag",
")",
":",
"if",
"'}'",
"in",
"tag",
":",
"split",
"=",
"tag",
".",
"split",
"(",
"'}'",
")",
"return",
"split",
"[",
"0",
"]",
".",
"strip",
"(",
"'{'",
")",
",",
"split",
"[",
"-",
"1",
"]",
"return",
"''",
","... | e7e8d79daf73b35c9259695ad1e379476e1dfc77 |
train | xpath | A safe xpath that only uses namespaces if available. | speedparser/speedparser.py | def xpath(node, query, namespaces={}):
"""A safe xpath that only uses namespaces if available."""
if namespaces and 'None' not in namespaces:
return node.xpath(query, namespaces=namespaces)
return node.xpath(query) | def xpath(node, query, namespaces={}):
"""A safe xpath that only uses namespaces if available."""
if namespaces and 'None' not in namespaces:
return node.xpath(query, namespaces=namespaces)
return node.xpath(query) | [
"A",
"safe",
"xpath",
"that",
"only",
"uses",
"namespaces",
"if",
"available",
"."
] | jmoiron/speedparser | python | https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/speedparser.py#L182-L186 | [
"def",
"xpath",
"(",
"node",
",",
"query",
",",
"namespaces",
"=",
"{",
"}",
")",
":",
"if",
"namespaces",
"and",
"'None'",
"not",
"in",
"namespaces",
":",
"return",
"node",
".",
"xpath",
"(",
"query",
",",
"namespaces",
"=",
"namespaces",
")",
"return... | e7e8d79daf73b35c9259695ad1e379476e1dfc77 |
train | innertext | Return the inner text of a node. If a node has no sub elements, this
is just node.text. Otherwise, it's node.text + sub-element-text +
node.tail. | speedparser/speedparser.py | def innertext(node):
"""Return the inner text of a node. If a node has no sub elements, this
is just node.text. Otherwise, it's node.text + sub-element-text +
node.tail."""
if not len(node):
return node.text
return (node.text or '') + ''.join([etree.tostring(c) for c in node]) + (node.tai... | def innertext(node):
"""Return the inner text of a node. If a node has no sub elements, this
is just node.text. Otherwise, it's node.text + sub-element-text +
node.tail."""
if not len(node):
return node.text
return (node.text or '') + ''.join([etree.tostring(c) for c in node]) + (node.tai... | [
"Return",
"the",
"inner",
"text",
"of",
"a",
"node",
".",
"If",
"a",
"node",
"has",
"no",
"sub",
"elements",
"this",
"is",
"just",
"node",
".",
"text",
".",
"Otherwise",
"it",
"s",
"node",
".",
"text",
"+",
"sub",
"-",
"element",
"-",
"text",
"+",
... | jmoiron/speedparser | python | https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/speedparser.py#L189-L196 | [
"def",
"innertext",
"(",
"node",
")",
":",
"if",
"not",
"len",
"(",
"node",
")",
":",
"return",
"node",
".",
"text",
"return",
"(",
"node",
".",
"text",
"or",
"''",
")",
"+",
"''",
".",
"join",
"(",
"[",
"etree",
".",
"tostring",
"(",
"c",
")",... | e7e8d79daf73b35c9259695ad1e379476e1dfc77 |
train | parse | Parse a document and return a feedparser dictionary with attr key access.
If clean_html is False, the html in the feed will not be cleaned. If
clean_html is True, a sane version of lxml.html.clean.Cleaner will be used.
If it is a Cleaner object, that cleaner will be used. If unix_timestamp is
True, th... | speedparser/speedparser.py | def parse(document, clean_html=True, unix_timestamp=False, encoding=None):
"""Parse a document and return a feedparser dictionary with attr key access.
If clean_html is False, the html in the feed will not be cleaned. If
clean_html is True, a sane version of lxml.html.clean.Cleaner will be used.
If it ... | def parse(document, clean_html=True, unix_timestamp=False, encoding=None):
"""Parse a document and return a feedparser dictionary with attr key access.
If clean_html is False, the html in the feed will not be cleaned. If
clean_html is True, a sane version of lxml.html.clean.Cleaner will be used.
If it ... | [
"Parse",
"a",
"document",
"and",
"return",
"a",
"feedparser",
"dictionary",
"with",
"attr",
"key",
"access",
".",
"If",
"clean_html",
"is",
"False",
"the",
"html",
"in",
"the",
"feed",
"will",
"not",
"be",
"cleaned",
".",
"If",
"clean_html",
"is",
"True",
... | jmoiron/speedparser | python | https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/speedparser.py#L671-L699 | [
"def",
"parse",
"(",
"document",
",",
"clean_html",
"=",
"True",
",",
"unix_timestamp",
"=",
"False",
",",
"encoding",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"clean_html",
",",
"bool",
")",
":",
"cleaner",
"=",
"default_cleaner",
"if",
"clean_html... | e7e8d79daf73b35c9259695ad1e379476e1dfc77 |
train | SpeedParserEntriesRss20.parse_entry | An attempt to parse pieces of an entry out w/o xpath, by looping
over the entry root's children and slotting them into the right places.
This is going to be way messier than SpeedParserEntries, and maybe
less cleanly usable, but it should be faster. | speedparser/speedparser.py | def parse_entry(self, entry):
"""An attempt to parse pieces of an entry out w/o xpath, by looping
over the entry root's children and slotting them into the right places.
This is going to be way messier than SpeedParserEntries, and maybe
less cleanly usable, but it should be faster."""
... | def parse_entry(self, entry):
"""An attempt to parse pieces of an entry out w/o xpath, by looping
over the entry root's children and slotting them into the right places.
This is going to be way messier than SpeedParserEntries, and maybe
less cleanly usable, but it should be faster."""
... | [
"An",
"attempt",
"to",
"parse",
"pieces",
"of",
"an",
"entry",
"out",
"w",
"/",
"o",
"xpath",
"by",
"looping",
"over",
"the",
"entry",
"root",
"s",
"children",
"and",
"slotting",
"them",
"into",
"the",
"right",
"places",
".",
"This",
"is",
"going",
"to... | jmoiron/speedparser | python | https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/speedparser.py#L255-L298 | [
"def",
"parse_entry",
"(",
"self",
",",
"entry",
")",
":",
"e",
"=",
"feedparser",
".",
"FeedParserDict",
"(",
")",
"tag_map",
"=",
"self",
".",
"tag_map",
"nslookup",
"=",
"self",
".",
"nslookup",
"for",
"child",
"in",
"entry",
".",
"getchildren",
"(",
... | e7e8d79daf73b35c9259695ad1e379476e1dfc77 |
train | FileWatcherWidget.changed_path | Find any changed path and update all changed modification times. | jp_proxy_widget/watcher.py | def changed_path(self):
"Find any changed path and update all changed modification times."
result = None # default
for path in self.paths_to_modification_times:
lastmod = self.paths_to_modification_times[path]
mod = os.path.getmtime(path)
if mod > lastmod:
... | def changed_path(self):
"Find any changed path and update all changed modification times."
result = None # default
for path in self.paths_to_modification_times:
lastmod = self.paths_to_modification_times[path]
mod = os.path.getmtime(path)
if mod > lastmod:
... | [
"Find",
"any",
"changed",
"path",
"and",
"update",
"all",
"changed",
"modification",
"times",
"."
] | AaronWatters/jp_proxy_widget | python | https://github.com/AaronWatters/jp_proxy_widget/blob/e53789c9b8a587e2f6e768d16b68e0ae5b3790d9/jp_proxy_widget/watcher.py#L124-L144 | [
"def",
"changed_path",
"(",
"self",
")",
":",
"result",
"=",
"None",
"# default",
"for",
"path",
"in",
"self",
".",
"paths_to_modification_times",
":",
"lastmod",
"=",
"self",
".",
"paths_to_modification_times",
"[",
"path",
"]",
"mod",
"=",
"os",
".",
"path... | e53789c9b8a587e2f6e768d16b68e0ae5b3790d9 |
train | _parse_date_iso8601 | Parse a variety of ISO-8601-compatible formats like 20040105 | speedparser/feedparsercompat.py | def _parse_date_iso8601(dateString):
'''Parse a variety of ISO-8601-compatible formats like 20040105'''
m = None
for _iso8601_match in _iso8601_matches:
m = _iso8601_match(dateString)
if m:
break
if not m:
return
if m.span() == (0, 0):
return
params = ... | def _parse_date_iso8601(dateString):
'''Parse a variety of ISO-8601-compatible formats like 20040105'''
m = None
for _iso8601_match in _iso8601_matches:
m = _iso8601_match(dateString)
if m:
break
if not m:
return
if m.span() == (0, 0):
return
params = ... | [
"Parse",
"a",
"variety",
"of",
"ISO",
"-",
"8601",
"-",
"compatible",
"formats",
"like",
"20040105"
] | jmoiron/speedparser | python | https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/feedparsercompat.py#L205-L281 | [
"def",
"_parse_date_iso8601",
"(",
"dateString",
")",
":",
"m",
"=",
"None",
"for",
"_iso8601_match",
"in",
"_iso8601_matches",
":",
"m",
"=",
"_iso8601_match",
"(",
"dateString",
")",
"if",
"m",
":",
"break",
"if",
"not",
"m",
":",
"return",
"if",
"m",
... | e7e8d79daf73b35c9259695ad1e379476e1dfc77 |
train | _parse_date_onblog | Parse a string according to the OnBlog 8-bit date format | speedparser/feedparsercompat.py | def _parse_date_onblog(dateString):
'''Parse a string according to the OnBlog 8-bit date format'''
m = _korean_onblog_date_re.match(dateString)
if not m:
return
w3dtfdate = '%(year)s-%(month)s-%(day)sT%(hour)s:%(minute)s:%(second)s%(zonediff)s' % \
{'year': m.group(1), 'month': m... | def _parse_date_onblog(dateString):
'''Parse a string according to the OnBlog 8-bit date format'''
m = _korean_onblog_date_re.match(dateString)
if not m:
return
w3dtfdate = '%(year)s-%(month)s-%(day)sT%(hour)s:%(minute)s:%(second)s%(zonediff)s' % \
{'year': m.group(1), 'month': m... | [
"Parse",
"a",
"string",
"according",
"to",
"the",
"OnBlog",
"8",
"-",
"bit",
"date",
"format"
] | jmoiron/speedparser | python | https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/feedparsercompat.py#L297-L306 | [
"def",
"_parse_date_onblog",
"(",
"dateString",
")",
":",
"m",
"=",
"_korean_onblog_date_re",
".",
"match",
"(",
"dateString",
")",
"if",
"not",
"m",
":",
"return",
"w3dtfdate",
"=",
"'%(year)s-%(month)s-%(day)sT%(hour)s:%(minute)s:%(second)s%(zonediff)s'",
"%",
"{",
... | e7e8d79daf73b35c9259695ad1e379476e1dfc77 |
train | _parse_date_nate | Parse a string according to the Nate 8-bit date format | speedparser/feedparsercompat.py | def _parse_date_nate(dateString):
'''Parse a string according to the Nate 8-bit date format'''
m = _korean_nate_date_re.match(dateString)
if not m:
return
hour = int(m.group(5))
ampm = m.group(4)
if (ampm == _korean_pm):
hour += 12
hour = str(hour)
if len(hour) == 1:
... | def _parse_date_nate(dateString):
'''Parse a string according to the Nate 8-bit date format'''
m = _korean_nate_date_re.match(dateString)
if not m:
return
hour = int(m.group(5))
ampm = m.group(4)
if (ampm == _korean_pm):
hour += 12
hour = str(hour)
if len(hour) == 1:
... | [
"Parse",
"a",
"string",
"according",
"to",
"the",
"Nate",
"8",
"-",
"bit",
"date",
"format"
] | jmoiron/speedparser | python | https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/feedparsercompat.py#L309-L325 | [
"def",
"_parse_date_nate",
"(",
"dateString",
")",
":",
"m",
"=",
"_korean_nate_date_re",
".",
"match",
"(",
"dateString",
")",
"if",
"not",
"m",
":",
"return",
"hour",
"=",
"int",
"(",
"m",
".",
"group",
"(",
"5",
")",
")",
"ampm",
"=",
"m",
".",
... | e7e8d79daf73b35c9259695ad1e379476e1dfc77 |
train | _parse_date_greek | Parse a string according to a Greek 8-bit date format. | speedparser/feedparsercompat.py | def _parse_date_greek(dateString):
'''Parse a string according to a Greek 8-bit date format.'''
m = _greek_date_format_re.match(dateString)
if not m:
return
wday = _greek_wdays[m.group(1)]
month = _greek_months[m.group(3)]
rfc822date = '%(wday)s, %(day)s %(month)s %(year)s %(hour)s:%(min... | def _parse_date_greek(dateString):
'''Parse a string according to a Greek 8-bit date format.'''
m = _greek_date_format_re.match(dateString)
if not m:
return
wday = _greek_wdays[m.group(1)]
month = _greek_months[m.group(3)]
rfc822date = '%(wday)s, %(day)s %(month)s %(year)s %(hour)s:%(min... | [
"Parse",
"a",
"string",
"according",
"to",
"a",
"Greek",
"8",
"-",
"bit",
"date",
"format",
"."
] | jmoiron/speedparser | python | https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/feedparsercompat.py#L366-L377 | [
"def",
"_parse_date_greek",
"(",
"dateString",
")",
":",
"m",
"=",
"_greek_date_format_re",
".",
"match",
"(",
"dateString",
")",
"if",
"not",
"m",
":",
"return",
"wday",
"=",
"_greek_wdays",
"[",
"m",
".",
"group",
"(",
"1",
")",
"]",
"month",
"=",
"_... | e7e8d79daf73b35c9259695ad1e379476e1dfc77 |
train | _parse_date_hungarian | Parse a string according to a Hungarian 8-bit date format. | speedparser/feedparsercompat.py | def _parse_date_hungarian(dateString):
'''Parse a string according to a Hungarian 8-bit date format.'''
m = _hungarian_date_format_re.match(dateString)
if not m or m.group(2) not in _hungarian_months:
return None
month = _hungarian_months[m.group(2)]
day = m.group(3)
if len(day) == 1:
... | def _parse_date_hungarian(dateString):
'''Parse a string according to a Hungarian 8-bit date format.'''
m = _hungarian_date_format_re.match(dateString)
if not m or m.group(2) not in _hungarian_months:
return None
month = _hungarian_months[m.group(2)]
day = m.group(3)
if len(day) == 1:
... | [
"Parse",
"a",
"string",
"according",
"to",
"a",
"Hungarian",
"8",
"-",
"bit",
"date",
"format",
"."
] | jmoiron/speedparser | python | https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/feedparsercompat.py#L400-L416 | [
"def",
"_parse_date_hungarian",
"(",
"dateString",
")",
":",
"m",
"=",
"_hungarian_date_format_re",
".",
"match",
"(",
"dateString",
")",
"if",
"not",
"m",
"or",
"m",
".",
"group",
"(",
"2",
")",
"not",
"in",
"_hungarian_months",
":",
"return",
"None",
"mo... | e7e8d79daf73b35c9259695ad1e379476e1dfc77 |
train | _parse_date_rfc822 | Parse an RFC822, RFC1123, RFC2822, or asctime-style date | speedparser/feedparsercompat.py | def _parse_date_rfc822(dateString):
'''Parse an RFC822, RFC1123, RFC2822, or asctime-style date'''
data = dateString.split()
if not data:
return None
if data[0][-1] in (',', '.') or data[0].lower() in rfc822._daynames:
del data[0]
if len(data) == 4:
s = data[3]
i = s.... | def _parse_date_rfc822(dateString):
'''Parse an RFC822, RFC1123, RFC2822, or asctime-style date'''
data = dateString.split()
if not data:
return None
if data[0][-1] in (',', '.') or data[0].lower() in rfc822._daynames:
del data[0]
if len(data) == 4:
s = data[3]
i = s.... | [
"Parse",
"an",
"RFC822",
"RFC1123",
"RFC2822",
"or",
"asctime",
"-",
"style",
"date"
] | jmoiron/speedparser | python | https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/feedparsercompat.py#L522-L550 | [
"def",
"_parse_date_rfc822",
"(",
"dateString",
")",
":",
"data",
"=",
"dateString",
".",
"split",
"(",
")",
"if",
"not",
"data",
":",
"return",
"None",
"if",
"data",
"[",
"0",
"]",
"[",
"-",
"1",
"]",
"in",
"(",
"','",
",",
"'.'",
")",
"or",
"da... | e7e8d79daf73b35c9259695ad1e379476e1dfc77 |
train | _parse_date_perforce | parse a date in yyyy/mm/dd hh:mm:ss TTT format | speedparser/feedparsercompat.py | def _parse_date_perforce(aDateString):
"""parse a date in yyyy/mm/dd hh:mm:ss TTT format"""
# Fri, 2006/09/15 08:19:53 EDT
_my_date_pattern = re.compile( \
r'(\w{,3}), (\d{,4})/(\d{,2})/(\d{2}) (\d{,2}):(\d{2}):(\d{2}) (\w{,3})')
m = _my_date_pattern.search(aDateString)
if m is None:
... | def _parse_date_perforce(aDateString):
"""parse a date in yyyy/mm/dd hh:mm:ss TTT format"""
# Fri, 2006/09/15 08:19:53 EDT
_my_date_pattern = re.compile( \
r'(\w{,3}), (\d{,4})/(\d{,2})/(\d{2}) (\d{,2}):(\d{2}):(\d{2}) (\w{,3})')
m = _my_date_pattern.search(aDateString)
if m is None:
... | [
"parse",
"a",
"date",
"in",
"yyyy",
"/",
"mm",
"/",
"dd",
"hh",
":",
"mm",
":",
"ss",
"TTT",
"format"
] | jmoiron/speedparser | python | https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/feedparsercompat.py#L557-L571 | [
"def",
"_parse_date_perforce",
"(",
"aDateString",
")",
":",
"# Fri, 2006/09/15 08:19:53 EDT",
"_my_date_pattern",
"=",
"re",
".",
"compile",
"(",
"r'(\\w{,3}), (\\d{,4})/(\\d{,2})/(\\d{2}) (\\d{,2}):(\\d{2}):(\\d{2}) (\\w{,3})'",
")",
"m",
"=",
"_my_date_pattern",
".",
"search... | e7e8d79daf73b35c9259695ad1e379476e1dfc77 |
train | parse_date | Parses a variety of date formats into a 9-tuple in GMT | speedparser/feedparsercompat.py | def parse_date(dateString):
'''Parses a variety of date formats into a 9-tuple in GMT'''
if not dateString:
return None
for handler in _date_handlers:
try:
date9tuple = handler(dateString)
except (KeyError, OverflowError, ValueError):
continue
if not d... | def parse_date(dateString):
'''Parses a variety of date formats into a 9-tuple in GMT'''
if not dateString:
return None
for handler in _date_handlers:
try:
date9tuple = handler(dateString)
except (KeyError, OverflowError, ValueError):
continue
if not d... | [
"Parses",
"a",
"variety",
"of",
"date",
"formats",
"into",
"a",
"9",
"-",
"tuple",
"in",
"GMT"
] | jmoiron/speedparser | python | https://github.com/jmoiron/speedparser/blob/e7e8d79daf73b35c9259695ad1e379476e1dfc77/speedparser/feedparsercompat.py#L574-L588 | [
"def",
"parse_date",
"(",
"dateString",
")",
":",
"if",
"not",
"dateString",
":",
"return",
"None",
"for",
"handler",
"in",
"_date_handlers",
":",
"try",
":",
"date9tuple",
"=",
"handler",
"(",
"dateString",
")",
"except",
"(",
"KeyError",
",",
"OverflowErro... | e7e8d79daf73b35c9259695ad1e379476e1dfc77 |
train | UnicodeUploader.handle_chunk_wrapper | wrapper to allow output redirects for handle_chunk. | jp_proxy_widget/uploader.py | def handle_chunk_wrapper(self, status, name, content, file_info):
"""wrapper to allow output redirects for handle_chunk."""
out = self.output
if out is not None:
with out:
print("handling chunk " + repr(type(content)))
self.handle_chunk(status, name, c... | def handle_chunk_wrapper(self, status, name, content, file_info):
"""wrapper to allow output redirects for handle_chunk."""
out = self.output
if out is not None:
with out:
print("handling chunk " + repr(type(content)))
self.handle_chunk(status, name, c... | [
"wrapper",
"to",
"allow",
"output",
"redirects",
"for",
"handle_chunk",
"."
] | AaronWatters/jp_proxy_widget | python | https://github.com/AaronWatters/jp_proxy_widget/blob/e53789c9b8a587e2f6e768d16b68e0ae5b3790d9/jp_proxy_widget/uploader.py#L106-L114 | [
"def",
"handle_chunk_wrapper",
"(",
"self",
",",
"status",
",",
"name",
",",
"content",
",",
"file_info",
")",
":",
"out",
"=",
"self",
".",
"output",
"if",
"out",
"is",
"not",
"None",
":",
"with",
"out",
":",
"print",
"(",
"\"handling chunk \"",
"+",
... | e53789c9b8a587e2f6e768d16b68e0ae5b3790d9 |
train | UnicodeUploader.handle_chunk | Handle one chunk of the file. Override this method for peicewise delivery or error handling. | jp_proxy_widget/uploader.py | def handle_chunk(self, status, name, content, file_info):
"Handle one chunk of the file. Override this method for peicewise delivery or error handling."
if status == "error":
msg = repr(file_info.get("message"))
exc = JavaScriptError(msg)
exc.file_info = file_info
... | def handle_chunk(self, status, name, content, file_info):
"Handle one chunk of the file. Override this method for peicewise delivery or error handling."
if status == "error":
msg = repr(file_info.get("message"))
exc = JavaScriptError(msg)
exc.file_info = file_info
... | [
"Handle",
"one",
"chunk",
"of",
"the",
"file",
".",
"Override",
"this",
"method",
"for",
"peicewise",
"delivery",
"or",
"error",
"handling",
"."
] | AaronWatters/jp_proxy_widget | python | https://github.com/AaronWatters/jp_proxy_widget/blob/e53789c9b8a587e2f6e768d16b68e0ae5b3790d9/jp_proxy_widget/uploader.py#L116-L142 | [
"def",
"handle_chunk",
"(",
"self",
",",
"status",
",",
"name",
",",
"content",
",",
"file_info",
")",
":",
"if",
"status",
"==",
"\"error\"",
":",
"msg",
"=",
"repr",
"(",
"file_info",
".",
"get",
"(",
"\"message\"",
")",
")",
"exc",
"=",
"JavaScriptE... | e53789c9b8a587e2f6e768d16b68e0ae5b3790d9 |
train | PublicAPI.get_login_url | Return a URL for a user to login/register with ORCID.
Parameters
----------
:param scope: string or iterable of strings
The scope(s) of the authorization request.
For example '/authenticate'
:param redirect_uri: string
The URI to which the user's brow... | orcid/orcid.py | def get_login_url(self, scope, redirect_uri, state=None,
family_names=None, given_names=None, email=None,
lang=None, show_login=None):
"""Return a URL for a user to login/register with ORCID.
Parameters
----------
:param scope: string or itera... | def get_login_url(self, scope, redirect_uri, state=None,
family_names=None, given_names=None, email=None,
lang=None, show_login=None):
"""Return a URL for a user to login/register with ORCID.
Parameters
----------
:param scope: string or itera... | [
"Return",
"a",
"URL",
"for",
"a",
"user",
"to",
"login",
"/",
"register",
"with",
"ORCID",
"."
] | ORCID/python-orcid | python | https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L80-L130 | [
"def",
"get_login_url",
"(",
"self",
",",
"scope",
",",
"redirect_uri",
",",
"state",
"=",
"None",
",",
"family_names",
"=",
"None",
",",
"given_names",
"=",
"None",
",",
"email",
"=",
"None",
",",
"lang",
"=",
"None",
",",
"show_login",
"=",
"None",
"... | 217a56a905f53aef94811e54b4e651a1b09c1f76 |
train | PublicAPI.search | Search the ORCID database.
Parameters
----------
:param query: string
Query in line with the chosen method.
:param method: string
One of 'lucene', 'edismax', 'dismax'
:param start: string
Index of the first record requested. Use for pagination... | orcid/orcid.py | def search(self, query, method="lucene", start=None,
rows=None, access_token=None):
"""Search the ORCID database.
Parameters
----------
:param query: string
Query in line with the chosen method.
:param method: string
One of 'lucene', 'edism... | def search(self, query, method="lucene", start=None,
rows=None, access_token=None):
"""Search the ORCID database.
Parameters
----------
:param query: string
Query in line with the chosen method.
:param method: string
One of 'lucene', 'edism... | [
"Search",
"the",
"ORCID",
"database",
"."
] | ORCID/python-orcid | python | https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L132-L166 | [
"def",
"search",
"(",
"self",
",",
"query",
",",
"method",
"=",
"\"lucene\"",
",",
"start",
"=",
"None",
",",
"rows",
"=",
"None",
",",
"access_token",
"=",
"None",
")",
":",
"if",
"access_token",
"is",
"None",
":",
"access_token",
"=",
"self",
".",
... | 217a56a905f53aef94811e54b4e651a1b09c1f76 |
train | PublicAPI.search_generator | Search the ORCID database with a generator.
The generator will yield every result.
Parameters
----------
:param query: string
Query in line with the chosen method.
:param method: string
One of 'lucene', 'edismax', 'dismax'
:param pagination: inte... | orcid/orcid.py | def search_generator(self, query, method="lucene",
pagination=10, access_token=None):
"""Search the ORCID database with a generator.
The generator will yield every result.
Parameters
----------
:param query: string
Query in line with the cho... | def search_generator(self, query, method="lucene",
pagination=10, access_token=None):
"""Search the ORCID database with a generator.
The generator will yield every result.
Parameters
----------
:param query: string
Query in line with the cho... | [
"Search",
"the",
"ORCID",
"database",
"with",
"a",
"generator",
"."
] | ORCID/python-orcid | python | https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L168-L209 | [
"def",
"search_generator",
"(",
"self",
",",
"query",
",",
"method",
"=",
"\"lucene\"",
",",
"pagination",
"=",
"10",
",",
"access_token",
"=",
"None",
")",
":",
"if",
"access_token",
"is",
"None",
":",
"access_token",
"=",
"self",
".",
"get_search_token_fro... | 217a56a905f53aef94811e54b4e651a1b09c1f76 |
train | PublicAPI.get_search_token_from_orcid | Get a token for searching ORCID records.
Parameters
----------
:param scope: string
/read-public or /read-member
Returns
-------
:returns: string
The token. | orcid/orcid.py | def get_search_token_from_orcid(self, scope='/read-public'):
"""Get a token for searching ORCID records.
Parameters
----------
:param scope: string
/read-public or /read-member
Returns
-------
:returns: string
The token.
"""
... | def get_search_token_from_orcid(self, scope='/read-public'):
"""Get a token for searching ORCID records.
Parameters
----------
:param scope: string
/read-public or /read-member
Returns
-------
:returns: string
The token.
"""
... | [
"Get",
"a",
"token",
"for",
"searching",
"ORCID",
"records",
"."
] | ORCID/python-orcid | python | https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L211-L238 | [
"def",
"get_search_token_from_orcid",
"(",
"self",
",",
"scope",
"=",
"'/read-public'",
")",
":",
"payload",
"=",
"{",
"'client_id'",
":",
"self",
".",
"_key",
",",
"'client_secret'",
":",
"self",
".",
"_secret",
",",
"'scope'",
":",
"scope",
",",
"'grant_ty... | 217a56a905f53aef94811e54b4e651a1b09c1f76 |
train | PublicAPI.get_token | Get the token.
Parameters
----------
:param user_id: string
The id of the user used for authentication.
:param password: string
The user password.
:param redirect_uri: string
The redirect uri of the institution.
:param scope: string
... | orcid/orcid.py | def get_token(self, user_id, password, redirect_uri,
scope='/read-limited'):
"""Get the token.
Parameters
----------
:param user_id: string
The id of the user used for authentication.
:param password: string
The user password.
:p... | def get_token(self, user_id, password, redirect_uri,
scope='/read-limited'):
"""Get the token.
Parameters
----------
:param user_id: string
The id of the user used for authentication.
:param password: string
The user password.
:p... | [
"Get",
"the",
"token",
"."
] | ORCID/python-orcid | python | https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L240-L263 | [
"def",
"get_token",
"(",
"self",
",",
"user_id",
",",
"password",
",",
"redirect_uri",
",",
"scope",
"=",
"'/read-limited'",
")",
":",
"response",
"=",
"self",
".",
"_authenticate",
"(",
"user_id",
",",
"password",
",",
"redirect_uri",
",",
"scope",
")",
"... | 217a56a905f53aef94811e54b4e651a1b09c1f76 |
train | PublicAPI.get_token_from_authorization_code | Like `get_token`, but using an OAuth 2 authorization code.
Use this method if you run a webserver that serves as an endpoint for
the redirect URI. The webserver can retrieve the authorization code
from the URL that is requested by ORCID.
Parameters
----------
:param red... | orcid/orcid.py | def get_token_from_authorization_code(self,
authorization_code, redirect_uri):
"""Like `get_token`, but using an OAuth 2 authorization code.
Use this method if you run a webserver that serves as an endpoint for
the redirect URI. The webserver can retrie... | def get_token_from_authorization_code(self,
authorization_code, redirect_uri):
"""Like `get_token`, but using an OAuth 2 authorization code.
Use this method if you run a webserver that serves as an endpoint for
the redirect URI. The webserver can retrie... | [
"Like",
"get_token",
"but",
"using",
"an",
"OAuth",
"2",
"authorization",
"code",
"."
] | ORCID/python-orcid | python | https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L265-L299 | [
"def",
"get_token_from_authorization_code",
"(",
"self",
",",
"authorization_code",
",",
"redirect_uri",
")",
":",
"token_dict",
"=",
"{",
"\"client_id\"",
":",
"self",
".",
"_key",
",",
"\"client_secret\"",
":",
"self",
".",
"_secret",
",",
"\"grant_type\"",
":",... | 217a56a905f53aef94811e54b4e651a1b09c1f76 |
train | PublicAPI.read_record_public | Get the public info about the researcher.
Parameters
----------
:param orcid_id: string
Id of the queried author.
:param request_type: string
For example: 'record'.
See https://members.orcid.org/api/tutorial/read-orcid-records
for possible... | orcid/orcid.py | def read_record_public(self, orcid_id, request_type, token, put_code=None,
accept_type='application/orcid+json'):
"""Get the public info about the researcher.
Parameters
----------
:param orcid_id: string
Id of the queried author.
:param re... | def read_record_public(self, orcid_id, request_type, token, put_code=None,
accept_type='application/orcid+json'):
"""Get the public info about the researcher.
Parameters
----------
:param orcid_id: string
Id of the queried author.
:param re... | [
"Get",
"the",
"public",
"info",
"about",
"the",
"researcher",
"."
] | ORCID/python-orcid | python | https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L301-L327 | [
"def",
"read_record_public",
"(",
"self",
",",
"orcid_id",
",",
"request_type",
",",
"token",
",",
"put_code",
"=",
"None",
",",
"accept_type",
"=",
"'application/orcid+json'",
")",
":",
"return",
"self",
".",
"_get_info",
"(",
"orcid_id",
",",
"self",
".",
... | 217a56a905f53aef94811e54b4e651a1b09c1f76 |
train | MemberAPI.add_record | Add a record to a profile.
Parameters
----------
:param orcid_id: string
Id of the author.
:param token: string
Token received from OAuth 2 3-legged authorization.
:param request_type: string
One of 'activities', 'education', 'employment', 'fu... | orcid/orcid.py | def add_record(self, orcid_id, token, request_type, data,
content_type='application/orcid+json'):
"""Add a record to a profile.
Parameters
----------
:param orcid_id: string
Id of the author.
:param token: string
Token received from OAu... | def add_record(self, orcid_id, token, request_type, data,
content_type='application/orcid+json'):
"""Add a record to a profile.
Parameters
----------
:param orcid_id: string
Id of the author.
:param token: string
Token received from OAu... | [
"Add",
"a",
"record",
"to",
"a",
"profile",
"."
] | ORCID/python-orcid | python | https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L475-L502 | [
"def",
"add_record",
"(",
"self",
",",
"orcid_id",
",",
"token",
",",
"request_type",
",",
"data",
",",
"content_type",
"=",
"'application/orcid+json'",
")",
":",
"return",
"self",
".",
"_update_activities",
"(",
"orcid_id",
",",
"token",
",",
"requests",
".",... | 217a56a905f53aef94811e54b4e651a1b09c1f76 |
train | MemberAPI.get_token | Get the token.
Parameters
----------
:param user_id: string
The id of the user used for authentication.
:param password: string
The user password.
:param redirect_uri: string
The redirect uri of the institution.
:param scope: string
... | orcid/orcid.py | def get_token(self, user_id, password, redirect_uri,
scope='/activities/update'):
"""Get the token.
Parameters
----------
:param user_id: string
The id of the user used for authentication.
:param password: string
The user password.
... | def get_token(self, user_id, password, redirect_uri,
scope='/activities/update'):
"""Get the token.
Parameters
----------
:param user_id: string
The id of the user used for authentication.
:param password: string
The user password.
... | [
"Get",
"the",
"token",
"."
] | ORCID/python-orcid | python | https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L504-L527 | [
"def",
"get_token",
"(",
"self",
",",
"user_id",
",",
"password",
",",
"redirect_uri",
",",
"scope",
"=",
"'/activities/update'",
")",
":",
"return",
"super",
"(",
"MemberAPI",
",",
"self",
")",
".",
"get_token",
"(",
"user_id",
",",
"password",
",",
"redi... | 217a56a905f53aef94811e54b4e651a1b09c1f76 |
train | MemberAPI.get_user_orcid | Get the user orcid from authentication process.
Parameters
----------
:param user_id: string
The id of the user used for authentication.
:param password: string
The user password.
:param redirect_uri: string
The redirect uri of the institution... | orcid/orcid.py | def get_user_orcid(self, user_id, password, redirect_uri):
"""Get the user orcid from authentication process.
Parameters
----------
:param user_id: string
The id of the user used for authentication.
:param password: string
The user password.
:para... | def get_user_orcid(self, user_id, password, redirect_uri):
"""Get the user orcid from authentication process.
Parameters
----------
:param user_id: string
The id of the user used for authentication.
:param password: string
The user password.
:para... | [
"Get",
"the",
"user",
"orcid",
"from",
"authentication",
"process",
"."
] | ORCID/python-orcid | python | https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L529-L549 | [
"def",
"get_user_orcid",
"(",
"self",
",",
"user_id",
",",
"password",
",",
"redirect_uri",
")",
":",
"response",
"=",
"self",
".",
"_authenticate",
"(",
"user_id",
",",
"password",
",",
"redirect_uri",
",",
"'/authenticate'",
")",
"return",
"response",
"[",
... | 217a56a905f53aef94811e54b4e651a1b09c1f76 |
train | MemberAPI.read_record_member | Get the member info about the researcher.
Parameters
----------
:param orcid_id: string
Id of the queried author.
:param request_type: string
For example: 'record'.
See https://members.orcid.org/api/tutorial/read-orcid-records
for possible... | orcid/orcid.py | def read_record_member(self, orcid_id, request_type, token, put_code=None,
accept_type='application/orcid+json'):
"""Get the member info about the researcher.
Parameters
----------
:param orcid_id: string
Id of the queried author.
:param re... | def read_record_member(self, orcid_id, request_type, token, put_code=None,
accept_type='application/orcid+json'):
"""Get the member info about the researcher.
Parameters
----------
:param orcid_id: string
Id of the queried author.
:param re... | [
"Get",
"the",
"member",
"info",
"about",
"the",
"researcher",
"."
] | ORCID/python-orcid | python | https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L551-L579 | [
"def",
"read_record_member",
"(",
"self",
",",
"orcid_id",
",",
"request_type",
",",
"token",
",",
"put_code",
"=",
"None",
",",
"accept_type",
"=",
"'application/orcid+json'",
")",
":",
"return",
"self",
".",
"_get_info",
"(",
"orcid_id",
",",
"self",
".",
... | 217a56a905f53aef94811e54b4e651a1b09c1f76 |
train | MemberAPI.remove_record | Add a record to a profile.
Parameters
----------
:param orcid_id: string
Id of the author.
:param token: string
Token received from OAuth 2 3-legged authorization.
:param request_type: string
One of 'activities', 'education', 'employment', 'fu... | orcid/orcid.py | def remove_record(self, orcid_id, token, request_type, put_code):
"""Add a record to a profile.
Parameters
----------
:param orcid_id: string
Id of the author.
:param token: string
Token received from OAuth 2 3-legged authorization.
:param request... | def remove_record(self, orcid_id, token, request_type, put_code):
"""Add a record to a profile.
Parameters
----------
:param orcid_id: string
Id of the author.
:param token: string
Token received from OAuth 2 3-legged authorization.
:param request... | [
"Add",
"a",
"record",
"to",
"a",
"profile",
"."
] | ORCID/python-orcid | python | https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L581-L598 | [
"def",
"remove_record",
"(",
"self",
",",
"orcid_id",
",",
"token",
",",
"request_type",
",",
"put_code",
")",
":",
"self",
".",
"_update_activities",
"(",
"orcid_id",
",",
"token",
",",
"requests",
".",
"delete",
",",
"request_type",
",",
"put_code",
"=",
... | 217a56a905f53aef94811e54b4e651a1b09c1f76 |
train | MemberAPI.update_record | Add a record to a profile.
Parameters
----------
:param orcid_id: string
Id of the author.
:param token: string
Token received from OAuth 2 3-legged authorization.
:param request_type: string
One of 'activities', 'education', 'employment', 'fu... | orcid/orcid.py | def update_record(self, orcid_id, token, request_type, data, put_code,
content_type='application/orcid+json'):
"""Add a record to a profile.
Parameters
----------
:param orcid_id: string
Id of the author.
:param token: string
Token r... | def update_record(self, orcid_id, token, request_type, data, put_code,
content_type='application/orcid+json'):
"""Add a record to a profile.
Parameters
----------
:param orcid_id: string
Id of the author.
:param token: string
Token r... | [
"Add",
"a",
"record",
"to",
"a",
"profile",
"."
] | ORCID/python-orcid | python | https://github.com/ORCID/python-orcid/blob/217a56a905f53aef94811e54b4e651a1b09c1f76/orcid/orcid.py#L674-L698 | [
"def",
"update_record",
"(",
"self",
",",
"orcid_id",
",",
"token",
",",
"request_type",
",",
"data",
",",
"put_code",
",",
"content_type",
"=",
"'application/orcid+json'",
")",
":",
"self",
".",
"_update_activities",
"(",
"orcid_id",
",",
"token",
",",
"reque... | 217a56a905f53aef94811e54b4e651a1b09c1f76 |
train | remove_duplicates | Remove any duplicates from the entity relationship table
:param apps:
:param schema_editor:
:return: | entity/migrations/0006_entity_relationship_unique.py | def remove_duplicates(apps, schema_editor):
"""
Remove any duplicates from the entity relationship table
:param apps:
:param schema_editor:
:return:
"""
# Get the model
EntityRelationship = apps.get_model('entity', 'EntityRelationship')
# Find the duplicates
duplicates = Entity... | def remove_duplicates(apps, schema_editor):
"""
Remove any duplicates from the entity relationship table
:param apps:
:param schema_editor:
:return:
"""
# Get the model
EntityRelationship = apps.get_model('entity', 'EntityRelationship')
# Find the duplicates
duplicates = Entity... | [
"Remove",
"any",
"duplicates",
"from",
"the",
"entity",
"relationship",
"table",
":",
"param",
"apps",
":",
":",
"param",
"schema_editor",
":",
":",
"return",
":"
] | ambitioninc/django-entity | python | https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/migrations/0006_entity_relationship_unique.py#L42-L75 | [
"def",
"remove_duplicates",
"(",
"apps",
",",
"schema_editor",
")",
":",
"# Get the model",
"EntityRelationship",
"=",
"apps",
".",
"get_model",
"(",
"'entity'",
",",
"'EntityRelationship'",
")",
"# Find the duplicates",
"duplicates",
"=",
"EntityRelationship",
".",
"... | ebc61f34313c52f4ef5819eb1da25b2ad837e80c |
train | BoxAuthenticateFlow.get_access_tokens | From the authorization code, get the "access token" and the "refresh token" from Box.
Args:
authorization_code (str). Authorisation code emitted by Box at the url provided by the function :func:`get_authorization_url`.
Returns:
tuple. (access_token, refresh_token)
Rais... | boxpython/auth.py | def get_access_tokens(self, authorization_code):
"""From the authorization code, get the "access token" and the "refresh token" from Box.
Args:
authorization_code (str). Authorisation code emitted by Box at the url provided by the function :func:`get_authorization_url`.
Returns:
... | def get_access_tokens(self, authorization_code):
"""From the authorization code, get the "access token" and the "refresh token" from Box.
Args:
authorization_code (str). Authorisation code emitted by Box at the url provided by the function :func:`get_authorization_url`.
Returns:
... | [
"From",
"the",
"authorization",
"code",
"get",
"the",
"access",
"token",
"and",
"the",
"refresh",
"token",
"from",
"Box",
"."
] | wesleyfr/boxpython | python | https://github.com/wesleyfr/boxpython/blob/f00a8ada6dff2c7ffc88bf89d4e15965c5adb422/boxpython/auth.py#L39-L64 | [
"def",
"get_access_tokens",
"(",
"self",
",",
"authorization_code",
")",
":",
"response",
"=",
"self",
".",
"box_request",
".",
"get_access_token",
"(",
"authorization_code",
")",
"try",
":",
"att",
"=",
"response",
".",
"json",
"(",
")",
"except",
"Exception"... | f00a8ada6dff2c7ffc88bf89d4e15965c5adb422 |
train | unpack_frame | Called to unpack a STOMP message into a dictionary.
returned = {
# STOMP Command:
'cmd' : '...',
# Headers e.g.
'headers' : {
'destination' : 'xyz',
'message-id' : 'some event',
:
etc,
}
# Body:
'body' : '...1... | lib/stomper/stomp_10.py | def unpack_frame(message):
"""Called to unpack a STOMP message into a dictionary.
returned = {
# STOMP Command:
'cmd' : '...',
# Headers e.g.
'headers' : {
'destination' : 'xyz',
'message-id' : 'some event',
:
etc,
}
... | def unpack_frame(message):
"""Called to unpack a STOMP message into a dictionary.
returned = {
# STOMP Command:
'cmd' : '...',
# Headers e.g.
'headers' : {
'destination' : 'xyz',
'message-id' : 'some event',
:
etc,
}
... | [
"Called",
"to",
"unpack",
"a",
"STOMP",
"message",
"into",
"a",
"dictionary",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_10.py#L174-L236 | [
"def",
"unpack_frame",
"(",
"message",
")",
":",
"body",
"=",
"[",
"]",
"returned",
"=",
"dict",
"(",
"cmd",
"=",
"''",
",",
"headers",
"=",
"{",
"}",
",",
"body",
"=",
"''",
")",
"breakdown",
"=",
"message",
".",
"split",
"(",
"'\\n'",
")",
"# G... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | ack | STOMP acknowledge command.
Acknowledge receipt of a specific message from the server.
messageid:
This is the id of the message we are acknowledging,
what else could it be? ;)
transactionid:
This is the id that all actions in this transaction
will have. If this is not given... | lib/stomper/stomp_10.py | def ack(messageid, transactionid=None):
"""STOMP acknowledge command.
Acknowledge receipt of a specific message from the server.
messageid:
This is the id of the message we are acknowledging,
what else could it be? ;)
transactionid:
This is the id that all actions in this tran... | def ack(messageid, transactionid=None):
"""STOMP acknowledge command.
Acknowledge receipt of a specific message from the server.
messageid:
This is the id of the message we are acknowledging,
what else could it be? ;)
transactionid:
This is the id that all actions in this tran... | [
"STOMP",
"acknowledge",
"command",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_10.py#L251-L271 | [
"def",
"ack",
"(",
"messageid",
",",
"transactionid",
"=",
"None",
")",
":",
"header",
"=",
"'message-id: %s'",
"%",
"messageid",
"if",
"transactionid",
":",
"header",
"=",
"'message-id: %s\\ntransaction: %s'",
"%",
"(",
"messageid",
",",
"transactionid",
")",
"... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | send | STOMP send command.
dest:
This is the channel we wish to subscribe to
msg:
This is the message body to be sent.
transactionid:
This is an optional field and is not needed
by default. | lib/stomper/stomp_10.py | def send(dest, msg, transactionid=None):
"""STOMP send command.
dest:
This is the channel we wish to subscribe to
msg:
This is the message body to be sent.
transactionid:
This is an optional field and is not needed
by default.
"""
transheader = ''
if tran... | def send(dest, msg, transactionid=None):
"""STOMP send command.
dest:
This is the channel we wish to subscribe to
msg:
This is the message body to be sent.
transactionid:
This is an optional field and is not needed
by default.
"""
transheader = ''
if tran... | [
"STOMP",
"send",
"command",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_10.py#L329-L348 | [
"def",
"send",
"(",
"dest",
",",
"msg",
",",
"transactionid",
"=",
"None",
")",
":",
"transheader",
"=",
"''",
"if",
"transactionid",
":",
"transheader",
"=",
"'transaction: %s\\n'",
"%",
"transactionid",
"return",
"\"SEND\\ndestination: %s\\n%s\\n%s\\x00\\n\"",
"%"... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | Frame.setCmd | Check the cmd is valid, FrameError will be raised if its not. | lib/stomper/stomp_10.py | def setCmd(self, cmd):
"""Check the cmd is valid, FrameError will be raised if its not."""
cmd = cmd.upper()
if cmd not in VALID_COMMANDS:
raise FrameError("The cmd '%s' is not valid! It must be one of '%s' (STOMP v%s)." % (
cmd, VALID_COMMANDS, STOMP_VERSION)
... | def setCmd(self, cmd):
"""Check the cmd is valid, FrameError will be raised if its not."""
cmd = cmd.upper()
if cmd not in VALID_COMMANDS:
raise FrameError("The cmd '%s' is not valid! It must be one of '%s' (STOMP v%s)." % (
cmd, VALID_COMMANDS, STOMP_VERSION)
... | [
"Check",
"the",
"cmd",
"is",
"valid",
"FrameError",
"will",
"be",
"raised",
"if",
"its",
"not",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_10.py#L119-L127 | [
"def",
"setCmd",
"(",
"self",
",",
"cmd",
")",
":",
"cmd",
"=",
"cmd",
".",
"upper",
"(",
")",
"if",
"cmd",
"not",
"in",
"VALID_COMMANDS",
":",
"raise",
"FrameError",
"(",
"\"The cmd '%s' is not valid! It must be one of '%s' (STOMP v%s).\"",
"%",
"(",
"cmd",
"... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | Frame.pack | Called to create a STOMP message from the internal values. | lib/stomper/stomp_10.py | def pack(self):
"""Called to create a STOMP message from the internal values.
"""
headers = ''.join(
['%s:%s\n' % (f, v) for f, v in sorted(self.headers.items())]
)
stomp_message = "%s\n%s\n%s%s\n" % (self._cmd, headers, self.body, NULL)
# import pprint
# ... | def pack(self):
"""Called to create a STOMP message from the internal values.
"""
headers = ''.join(
['%s:%s\n' % (f, v) for f, v in sorted(self.headers.items())]
)
stomp_message = "%s\n%s\n%s%s\n" % (self._cmd, headers, self.body, NULL)
# import pprint
# ... | [
"Called",
"to",
"create",
"a",
"STOMP",
"message",
"from",
"the",
"internal",
"values",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_10.py#L131-L142 | [
"def",
"pack",
"(",
"self",
")",
":",
"headers",
"=",
"''",
".",
"join",
"(",
"[",
"'%s:%s\\n'",
"%",
"(",
"f",
",",
"v",
")",
"for",
"f",
",",
"v",
"in",
"sorted",
"(",
"self",
".",
"headers",
".",
"items",
"(",
")",
")",
"]",
")",
"stomp_me... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | Frame.unpack | Called to extract a STOMP message into this instance.
message:
This is a text string representing a valid
STOMP (v1.0) message.
This method uses unpack_frame(...) to extract the
information, before it is assigned internally.
retuned:
The result of t... | lib/stomper/stomp_10.py | def unpack(self, message):
"""Called to extract a STOMP message into this instance.
message:
This is a text string representing a valid
STOMP (v1.0) message.
This method uses unpack_frame(...) to extract the
information, before it is assigned internally.
... | def unpack(self, message):
"""Called to extract a STOMP message into this instance.
message:
This is a text string representing a valid
STOMP (v1.0) message.
This method uses unpack_frame(...) to extract the
information, before it is assigned internally.
... | [
"Called",
"to",
"extract",
"a",
"STOMP",
"message",
"into",
"this",
"instance",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_10.py#L145-L171 | [
"def",
"unpack",
"(",
"self",
",",
"message",
")",
":",
"if",
"not",
"message",
":",
"raise",
"FrameError",
"(",
"\"Unpack error! The given message isn't valid '%s'!\"",
"%",
"message",
")",
"msg",
"=",
"unpack_frame",
"(",
"message",
")",
"self",
".",
"cmd",
... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | Engine.react | Called to provide a response to a message if needed.
msg:
This is a dictionary as returned by unpack_frame(...)
or it can be a straight STOMP message. This function
will attempt to determine which an deal with it.
returned:
A message to return or an empt... | lib/stomper/stomp_10.py | def react(self, msg):
"""Called to provide a response to a message if needed.
msg:
This is a dictionary as returned by unpack_frame(...)
or it can be a straight STOMP message. This function
will attempt to determine which an deal with it.
returned:
... | def react(self, msg):
"""Called to provide a response to a message if needed.
msg:
This is a dictionary as returned by unpack_frame(...)
or it can be a straight STOMP message. This function
will attempt to determine which an deal with it.
returned:
... | [
"Called",
"to",
"provide",
"a",
"response",
"to",
"a",
"message",
"if",
"needed",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_10.py#L403-L430 | [
"def",
"react",
"(",
"self",
",",
"msg",
")",
":",
"returned",
"=",
"\"\"",
"# If its not a string assume its a dict.",
"mtype",
"=",
"type",
"(",
"msg",
")",
"if",
"mtype",
"in",
"stringTypes",
":",
"msg",
"=",
"unpack_frame",
"(",
"msg",
")",
"elif",
"mt... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | Engine.error | Called to handle an error message received from the server.
This method just logs the error message
returned:
NO_RESPONSE_NEEDED | lib/stomper/stomp_10.py | def error(self, msg):
"""Called to handle an error message received from the server.
This method just logs the error message
returned:
NO_RESPONSE_NEEDED
"""
body = msg['body'].replace(NULL, '')
brief_msg = ""
if 'message' in msg['headers']:
... | def error(self, msg):
"""Called to handle an error message received from the server.
This method just logs the error message
returned:
NO_RESPONSE_NEEDED
"""
body = msg['body'].replace(NULL, '')
brief_msg = ""
if 'message' in msg['headers']:
... | [
"Called",
"to",
"handle",
"an",
"error",
"message",
"received",
"from",
"the",
"server",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_10.py#L469-L490 | [
"def",
"error",
"(",
"self",
",",
"msg",
")",
":",
"body",
"=",
"msg",
"[",
"'body'",
"]",
".",
"replace",
"(",
"NULL",
",",
"''",
")",
"brief_msg",
"=",
"\"\"",
"if",
"'message'",
"in",
"msg",
"[",
"'headers'",
"]",
":",
"brief_msg",
"=",
"msg",
... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | Engine.receipt | Called to handle a receipt message received from the server.
This method just logs the receipt message
returned:
NO_RESPONSE_NEEDED | lib/stomper/stomp_10.py | def receipt(self, msg):
"""Called to handle a receipt message received from the server.
This method just logs the receipt message
returned:
NO_RESPONSE_NEEDED
"""
body = msg['body'].replace(NULL, '')
brief_msg = ""
if 'receipt-id' in msg['headers']... | def receipt(self, msg):
"""Called to handle a receipt message received from the server.
This method just logs the receipt message
returned:
NO_RESPONSE_NEEDED
"""
body = msg['body'].replace(NULL, '')
brief_msg = ""
if 'receipt-id' in msg['headers']... | [
"Called",
"to",
"handle",
"a",
"receipt",
"message",
"received",
"from",
"the",
"server",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/stomp_10.py#L493-L514 | [
"def",
"receipt",
"(",
"self",
",",
"msg",
")",
":",
"body",
"=",
"msg",
"[",
"'body'",
"]",
".",
"replace",
"(",
"NULL",
",",
"''",
")",
"brief_msg",
"=",
"\"\"",
"if",
"'receipt-id'",
"in",
"msg",
"[",
"'headers'",
"]",
":",
"brief_msg",
"=",
"ms... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
train | log_init | Set up a logger that catches all channels and logs it to stdout.
This is used to set up logging when testing. | lib/stomper/utils.py | def log_init(level):
"""Set up a logger that catches all channels and logs it to stdout.
This is used to set up logging when testing.
"""
log = logging.getLogger()
hdlr = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s')
hdlr.se... | def log_init(level):
"""Set up a logger that catches all channels and logs it to stdout.
This is used to set up logging when testing.
"""
log = logging.getLogger()
hdlr = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s')
hdlr.se... | [
"Set",
"up",
"a",
"logger",
"that",
"catches",
"all",
"channels",
"and",
"logs",
"it",
"to",
"stdout",
".",
"This",
"is",
"used",
"to",
"set",
"up",
"logging",
"when",
"testing",
"."
] | oisinmulvihill/stomper | python | https://github.com/oisinmulvihill/stomper/blob/842ed2353a4ddd638d35929ae5b7b70eb298305c/lib/stomper/utils.py#L11-L22 | [
"def",
"log_init",
"(",
"level",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
")",
"hdlr",
"=",
"logging",
".",
"StreamHandler",
"(",
")",
"formatter",
"=",
"logging",
".",
"Formatter",
"(",
"'%(asctime)s %(name)s %(levelname)s %(message)s'",
")",
"... | 842ed2353a4ddd638d35929ae5b7b70eb298305c |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.