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 | krbContext.init_with_keytab | Initialize credential cache with keytab | krbcontext/context.py | def init_with_keytab(self):
"""Initialize credential cache with keytab"""
creds_opts = {
'usage': 'initiate',
'name': self._cleaned_options['principal'],
}
store = {}
if self._cleaned_options['keytab'] != DEFAULT_KEYTAB:
store['client_keytab']... | def init_with_keytab(self):
"""Initialize credential cache with keytab"""
creds_opts = {
'usage': 'initiate',
'name': self._cleaned_options['principal'],
}
store = {}
if self._cleaned_options['keytab'] != DEFAULT_KEYTAB:
store['client_keytab']... | [
"Initialize",
"credential",
"cache",
"with",
"keytab"
] | krbcontext/python-krbcontext | python | https://github.com/krbcontext/python-krbcontext/blob/9dc93765a4723fa04c2ca57125294d422a6356cd/krbcontext/context.py#L150-L183 | [
"def",
"init_with_keytab",
"(",
"self",
")",
":",
"creds_opts",
"=",
"{",
"'usage'",
":",
"'initiate'",
",",
"'name'",
":",
"self",
".",
"_cleaned_options",
"[",
"'principal'",
"]",
",",
"}",
"store",
"=",
"{",
"}",
"if",
"self",
".",
"_cleaned_options",
... | 9dc93765a4723fa04c2ca57125294d422a6356cd |
train | krbContext.init_with_password | Initialize credential cache with password
**Causion:** once you enter password from command line, or pass it to
API directly, the given password is not encrypted always. Although
getting credential with password works, from security point of view, it
is strongly recommended **NOT** use ... | krbcontext/context.py | def init_with_password(self):
"""Initialize credential cache with password
**Causion:** once you enter password from command line, or pass it to
API directly, the given password is not encrypted always. Although
getting credential with password works, from security point of view, it
... | def init_with_password(self):
"""Initialize credential cache with password
**Causion:** once you enter password from command line, or pass it to
API directly, the given password is not encrypted always. Although
getting credential with password works, from security point of view, it
... | [
"Initialize",
"credential",
"cache",
"with",
"password"
] | krbcontext/python-krbcontext | python | https://github.com/krbcontext/python-krbcontext/blob/9dc93765a4723fa04c2ca57125294d422a6356cd/krbcontext/context.py#L185-L240 | [
"def",
"init_with_password",
"(",
"self",
")",
":",
"creds_opts",
"=",
"{",
"'usage'",
":",
"'initiate'",
",",
"'name'",
":",
"self",
".",
"_cleaned_options",
"[",
"'principal'",
"]",
",",
"}",
"if",
"self",
".",
"_cleaned_options",
"[",
"'ccache'",
"]",
"... | 9dc93765a4723fa04c2ca57125294d422a6356cd |
train | krbContext._prepare_context | Prepare context
Initialize credential cache with keytab or password according to
``using_keytab`` parameter. Then, ``KRB5CCNAME`` is set properly so
that Kerberos library called in current context is able to get
credential from correct cache.
Internal use only. | krbcontext/context.py | def _prepare_context(self):
"""Prepare context
Initialize credential cache with keytab or password according to
``using_keytab`` parameter. Then, ``KRB5CCNAME`` is set properly so
that Kerberos library called in current context is able to get
credential from correct cache.
... | def _prepare_context(self):
"""Prepare context
Initialize credential cache with keytab or password according to
``using_keytab`` parameter. Then, ``KRB5CCNAME`` is set properly so
that Kerberos library called in current context is able to get
credential from correct cache.
... | [
"Prepare",
"context"
] | krbcontext/python-krbcontext | python | https://github.com/krbcontext/python-krbcontext/blob/9dc93765a4723fa04c2ca57125294d422a6356cd/krbcontext/context.py#L242-L273 | [
"def",
"_prepare_context",
"(",
"self",
")",
":",
"ccache",
"=",
"self",
".",
"_cleaned_options",
"[",
"'ccache'",
"]",
"# Whatever there is KRB5CCNAME was set in current process,",
"# original_krb5ccname will contain current value even if None if",
"# that variable wasn't set, and w... | 9dc93765a4723fa04c2ca57125294d422a6356cd |
train | _SearchState.templates | Generate a dictionary with template names and file paths. | invenio_search/ext.py | def templates(self):
"""Generate a dictionary with template names and file paths."""
templates = {}
result = []
if self.entry_point_group_templates:
result = self.load_entry_point_group_templates(
self.entry_point_group_templates) or []
for template i... | def templates(self):
"""Generate a dictionary with template names and file paths."""
templates = {}
result = []
if self.entry_point_group_templates:
result = self.load_entry_point_group_templates(
self.entry_point_group_templates) or []
for template i... | [
"Generate",
"a",
"dictionary",
"with",
"template",
"names",
"and",
"file",
"paths",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L71-L83 | [
"def",
"templates",
"(",
"self",
")",
":",
"templates",
"=",
"{",
"}",
"result",
"=",
"[",
"]",
"if",
"self",
".",
"entry_point_group_templates",
":",
"result",
"=",
"self",
".",
"load_entry_point_group_templates",
"(",
"self",
".",
"entry_point_group_templates"... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | _SearchState.register_mappings | Register mappings from a package under given alias.
:param alias: The alias.
:param package_name: The package name. | invenio_search/ext.py | def register_mappings(self, alias, package_name):
"""Register mappings from a package under given alias.
:param alias: The alias.
:param package_name: The package name.
"""
# For backwards compatibility, we also allow for ES2 mappings to be
# placed at the root level of ... | def register_mappings(self, alias, package_name):
"""Register mappings from a package under given alias.
:param alias: The alias.
:param package_name: The package name.
"""
# For backwards compatibility, we also allow for ES2 mappings to be
# placed at the root level of ... | [
"Register",
"mappings",
"from",
"a",
"package",
"under",
"given",
"alias",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L85-L145 | [
"def",
"register_mappings",
"(",
"self",
",",
"alias",
",",
"package_name",
")",
":",
"# For backwards compatibility, we also allow for ES2 mappings to be",
"# placed at the root level of the specified package path, and not in",
"# the `<package-path>/v2` directory.",
"if",
"ES_VERSION",... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | _SearchState.register_templates | Register templates from the provided directory.
:param directory: The templates directory. | invenio_search/ext.py | def register_templates(self, directory):
"""Register templates from the provided directory.
:param directory: The templates directory.
"""
try:
resource_listdir(directory, 'v{}'.format(ES_VERSION[0]))
directory = '{}/v{}'.format(directory, ES_VERSION[0])
... | def register_templates(self, directory):
"""Register templates from the provided directory.
:param directory: The templates directory.
"""
try:
resource_listdir(directory, 'v{}'.format(ES_VERSION[0]))
directory = '{}/v{}'.format(directory, ES_VERSION[0])
... | [
"Register",
"templates",
"from",
"the",
"provided",
"directory",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L147-L190 | [
"def",
"register_templates",
"(",
"self",
",",
"directory",
")",
":",
"try",
":",
"resource_listdir",
"(",
"directory",
",",
"'v{}'",
".",
"format",
"(",
"ES_VERSION",
"[",
"0",
"]",
")",
")",
"directory",
"=",
"'{}/v{}'",
".",
"format",
"(",
"directory",
... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | _SearchState.load_entry_point_group_mappings | Load actions from an entry point group. | invenio_search/ext.py | def load_entry_point_group_mappings(self, entry_point_group_mappings):
"""Load actions from an entry point group."""
for ep in iter_entry_points(group=entry_point_group_mappings):
self.register_mappings(ep.name, ep.module_name) | def load_entry_point_group_mappings(self, entry_point_group_mappings):
"""Load actions from an entry point group."""
for ep in iter_entry_points(group=entry_point_group_mappings):
self.register_mappings(ep.name, ep.module_name) | [
"Load",
"actions",
"from",
"an",
"entry",
"point",
"group",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L192-L195 | [
"def",
"load_entry_point_group_mappings",
"(",
"self",
",",
"entry_point_group_mappings",
")",
":",
"for",
"ep",
"in",
"iter_entry_points",
"(",
"group",
"=",
"entry_point_group_mappings",
")",
":",
"self",
".",
"register_mappings",
"(",
"ep",
".",
"name",
",",
"e... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | _SearchState.load_entry_point_group_templates | Load actions from an entry point group. | invenio_search/ext.py | def load_entry_point_group_templates(self, entry_point_group_templates):
"""Load actions from an entry point group."""
result = []
for ep in iter_entry_points(group=entry_point_group_templates):
with self.app.app_context():
for template_dir in ep.load()():
... | def load_entry_point_group_templates(self, entry_point_group_templates):
"""Load actions from an entry point group."""
result = []
for ep in iter_entry_points(group=entry_point_group_templates):
with self.app.app_context():
for template_dir in ep.load()():
... | [
"Load",
"actions",
"from",
"an",
"entry",
"point",
"group",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L197-L204 | [
"def",
"load_entry_point_group_templates",
"(",
"self",
",",
"entry_point_group_templates",
")",
":",
"result",
"=",
"[",
"]",
"for",
"ep",
"in",
"iter_entry_points",
"(",
"group",
"=",
"entry_point_group_templates",
")",
":",
"with",
"self",
".",
"app",
".",
"a... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | _SearchState._client_builder | Build Elasticsearch client. | invenio_search/ext.py | def _client_builder(self):
"""Build Elasticsearch client."""
client_config = self.app.config.get('SEARCH_CLIENT_CONFIG') or {}
client_config.setdefault(
'hosts', self.app.config.get('SEARCH_ELASTIC_HOSTS'))
client_config.setdefault('connection_class', RequestsHttpConnection)
... | def _client_builder(self):
"""Build Elasticsearch client."""
client_config = self.app.config.get('SEARCH_CLIENT_CONFIG') or {}
client_config.setdefault(
'hosts', self.app.config.get('SEARCH_ELASTIC_HOSTS'))
client_config.setdefault('connection_class', RequestsHttpConnection)
... | [
"Build",
"Elasticsearch",
"client",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L206-L212 | [
"def",
"_client_builder",
"(",
"self",
")",
":",
"client_config",
"=",
"self",
".",
"app",
".",
"config",
".",
"get",
"(",
"'SEARCH_CLIENT_CONFIG'",
")",
"or",
"{",
"}",
"client_config",
".",
"setdefault",
"(",
"'hosts'",
",",
"self",
".",
"app",
".",
"c... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | _SearchState.client | Return client for current application. | invenio_search/ext.py | def client(self):
"""Return client for current application."""
if self._client is None:
self._client = self._client_builder()
return self._client | def client(self):
"""Return client for current application."""
if self._client is None:
self._client = self._client_builder()
return self._client | [
"Return",
"client",
"for",
"current",
"application",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L215-L219 | [
"def",
"client",
"(",
"self",
")",
":",
"if",
"self",
".",
"_client",
"is",
"None",
":",
"self",
".",
"_client",
"=",
"self",
".",
"_client_builder",
"(",
")",
"return",
"self",
".",
"_client"
] | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | _SearchState.flush_and_refresh | Flush and refresh one or more indices.
.. warning::
Do not call this method unless you know what you are doing. This
method is only intended to be called during tests. | invenio_search/ext.py | def flush_and_refresh(self, index):
"""Flush and refresh one or more indices.
.. warning::
Do not call this method unless you know what you are doing. This
method is only intended to be called during tests.
"""
self.client.indices.flush(wait_if_ongoing=True, index... | def flush_and_refresh(self, index):
"""Flush and refresh one or more indices.
.. warning::
Do not call this method unless you know what you are doing. This
method is only intended to be called during tests.
"""
self.client.indices.flush(wait_if_ongoing=True, index... | [
"Flush",
"and",
"refresh",
"one",
"or",
"more",
"indices",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L221-L233 | [
"def",
"flush_and_refresh",
"(",
"self",
",",
"index",
")",
":",
"self",
".",
"client",
".",
"indices",
".",
"flush",
"(",
"wait_if_ongoing",
"=",
"True",
",",
"index",
"=",
"index",
")",
"self",
".",
"client",
".",
"indices",
".",
"refresh",
"(",
"ind... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | _SearchState.cluster_version | Get version of Elasticsearch running on the cluster. | invenio_search/ext.py | def cluster_version(self):
"""Get version of Elasticsearch running on the cluster."""
versionstr = self.client.info()['version']['number']
return [int(x) for x in versionstr.split('.')] | def cluster_version(self):
"""Get version of Elasticsearch running on the cluster."""
versionstr = self.client.info()['version']['number']
return [int(x) for x in versionstr.split('.')] | [
"Get",
"version",
"of",
"Elasticsearch",
"running",
"on",
"the",
"cluster",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L236-L239 | [
"def",
"cluster_version",
"(",
"self",
")",
":",
"versionstr",
"=",
"self",
".",
"client",
".",
"info",
"(",
")",
"[",
"'version'",
"]",
"[",
"'number'",
"]",
"return",
"[",
"int",
"(",
"x",
")",
"for",
"x",
"in",
"versionstr",
".",
"split",
"(",
"... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | _SearchState.active_aliases | Get a filtered list of aliases based on configuration.
Returns aliases and their mappings that are defined in the
`SEARCH_MAPPINGS` config variable. If the `SEARCH_MAPPINGS` is set to
`None` (the default), all aliases are included. | invenio_search/ext.py | def active_aliases(self):
"""Get a filtered list of aliases based on configuration.
Returns aliases and their mappings that are defined in the
`SEARCH_MAPPINGS` config variable. If the `SEARCH_MAPPINGS` is set to
`None` (the default), all aliases are included.
"""
whitel... | def active_aliases(self):
"""Get a filtered list of aliases based on configuration.
Returns aliases and their mappings that are defined in the
`SEARCH_MAPPINGS` config variable. If the `SEARCH_MAPPINGS` is set to
`None` (the default), all aliases are included.
"""
whitel... | [
"Get",
"a",
"filtered",
"list",
"of",
"aliases",
"based",
"on",
"configuration",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L242-L254 | [
"def",
"active_aliases",
"(",
"self",
")",
":",
"whitelisted_aliases",
"=",
"self",
".",
"app",
".",
"config",
".",
"get",
"(",
"'SEARCH_MAPPINGS'",
")",
"if",
"whitelisted_aliases",
"is",
"None",
":",
"return",
"self",
".",
"aliases",
"else",
":",
"return",... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | _SearchState.create | Yield tuple with created index name and responses from a client. | invenio_search/ext.py | def create(self, ignore=None):
"""Yield tuple with created index name and responses from a client."""
ignore = ignore or []
def _create(tree_or_filename, alias=None):
"""Create indices and aliases by walking DFS."""
# Iterate over aliases:
for name, value in ... | def create(self, ignore=None):
"""Yield tuple with created index name and responses from a client."""
ignore = ignore or []
def _create(tree_or_filename, alias=None):
"""Create indices and aliases by walking DFS."""
# Iterate over aliases:
for name, value in ... | [
"Yield",
"tuple",
"with",
"created",
"index",
"name",
"and",
"responses",
"from",
"a",
"client",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L256-L283 | [
"def",
"create",
"(",
"self",
",",
"ignore",
"=",
"None",
")",
":",
"ignore",
"=",
"ignore",
"or",
"[",
"]",
"def",
"_create",
"(",
"tree_or_filename",
",",
"alias",
"=",
"None",
")",
":",
"\"\"\"Create indices and aliases by walking DFS.\"\"\"",
"# Iterate over... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | _SearchState.put_templates | Yield tuple with registered template and response from client. | invenio_search/ext.py | def put_templates(self, ignore=None):
"""Yield tuple with registered template and response from client."""
ignore = ignore or []
def _replace_prefix(template_path, body):
"""Replace index prefix in template request body."""
pattern = '__SEARCH_INDEX_PREFIX__'
... | def put_templates(self, ignore=None):
"""Yield tuple with registered template and response from client."""
ignore = ignore or []
def _replace_prefix(template_path, body):
"""Replace index prefix in template request body."""
pattern = '__SEARCH_INDEX_PREFIX__'
... | [
"Yield",
"tuple",
"with",
"registered",
"template",
"and",
"response",
"from",
"client",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L285-L314 | [
"def",
"put_templates",
"(",
"self",
",",
"ignore",
"=",
"None",
")",
":",
"ignore",
"=",
"ignore",
"or",
"[",
"]",
"def",
"_replace_prefix",
"(",
"template_path",
",",
"body",
")",
":",
"\"\"\"Replace index prefix in template request body.\"\"\"",
"pattern",
"=",... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | _SearchState.delete | Yield tuple with deleted index name and responses from a client. | invenio_search/ext.py | def delete(self, ignore=None):
"""Yield tuple with deleted index name and responses from a client."""
ignore = ignore or []
def _delete(tree_or_filename, alias=None):
"""Delete indexes and aliases by walking DFS."""
if alias:
yield alias, self.client.indi... | def delete(self, ignore=None):
"""Yield tuple with deleted index name and responses from a client."""
ignore = ignore or []
def _delete(tree_or_filename, alias=None):
"""Delete indexes and aliases by walking DFS."""
if alias:
yield alias, self.client.indi... | [
"Yield",
"tuple",
"with",
"deleted",
"index",
"name",
"and",
"responses",
"from",
"a",
"client",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L316-L341 | [
"def",
"delete",
"(",
"self",
",",
"ignore",
"=",
"None",
")",
":",
"ignore",
"=",
"ignore",
"or",
"[",
"]",
"def",
"_delete",
"(",
"tree_or_filename",
",",
"alias",
"=",
"None",
")",
":",
"\"\"\"Delete indexes and aliases by walking DFS.\"\"\"",
"if",
"alias"... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | InvenioSearch.init_app | Flask application initialization.
:param app: An instance of :class:`~flask.app.Flask`. | invenio_search/ext.py | def init_app(self, app,
entry_point_group_mappings='invenio_search.mappings',
entry_point_group_templates='invenio_search.templates',
**kwargs):
"""Flask application initialization.
:param app: An instance of :class:`~flask.app.Flask`.
"""
... | def init_app(self, app,
entry_point_group_mappings='invenio_search.mappings',
entry_point_group_templates='invenio_search.templates',
**kwargs):
"""Flask application initialization.
:param app: An instance of :class:`~flask.app.Flask`.
"""
... | [
"Flask",
"application",
"initialization",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L357-L375 | [
"def",
"init_app",
"(",
"self",
",",
"app",
",",
"entry_point_group_mappings",
"=",
"'invenio_search.mappings'",
",",
"entry_point_group_templates",
"=",
"'invenio_search.templates'",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"init_config",
"(",
"app",
")",
... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | main | Start the poor_consumer. | example/poor_consumer.py | def main():
"""Start the poor_consumer."""
try:
opts, args = getopt.getopt(sys.argv[1:], "h:v", ["help", "nack=",
"servers=", "queues="])
except getopt.GetoptError as err:
print str(err)
usage()
sys.exit()
# defaults
nack = 0.0
... | def main():
"""Start the poor_consumer."""
try:
opts, args = getopt.getopt(sys.argv[1:], "h:v", ["help", "nack=",
"servers=", "queues="])
except getopt.GetoptError as err:
print str(err)
usage()
sys.exit()
# defaults
nack = 0.0
... | [
"Start",
"the",
"poor_consumer",
"."
] | ybrs/pydisque | python | https://github.com/ybrs/pydisque/blob/ea5ce1576b66398c1cce32cad0f15709b1ea8df8/example/poor_consumer.py#L27-L78 | [
"def",
"main",
"(",
")",
":",
"try",
":",
"opts",
",",
"args",
"=",
"getopt",
".",
"getopt",
"(",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
",",
"\"h:v\"",
",",
"[",
"\"help\"",
",",
"\"nack=\"",
",",
"\"servers=\"",
",",
"\"queues=\"",
"]",
")",
"... | ea5ce1576b66398c1cce32cad0f15709b1ea8df8 |
train | Client.connect | Connect to one of the Disque nodes.
You can get current connection with connected_node property
:returns: nothing | pydisque/client.py | def connect(self):
"""
Connect to one of the Disque nodes.
You can get current connection with connected_node property
:returns: nothing
"""
self.connected_node = None
for i, node in self.nodes.items():
host, port = i.split(':')
port = i... | def connect(self):
"""
Connect to one of the Disque nodes.
You can get current connection with connected_node property
:returns: nothing
"""
self.connected_node = None
for i, node in self.nodes.items():
host, port = i.split(':')
port = i... | [
"Connect",
"to",
"one",
"of",
"the",
"Disque",
"nodes",
"."
] | ybrs/pydisque | python | https://github.com/ybrs/pydisque/blob/ea5ce1576b66398c1cce32cad0f15709b1ea8df8/pydisque/client.py#L117-L143 | [
"def",
"connect",
"(",
"self",
")",
":",
"self",
".",
"connected_node",
"=",
"None",
"for",
"i",
",",
"node",
"in",
"self",
".",
"nodes",
".",
"items",
"(",
")",
":",
"host",
",",
"port",
"=",
"i",
".",
"split",
"(",
"':'",
")",
"port",
"=",
"i... | ea5ce1576b66398c1cce32cad0f15709b1ea8df8 |
train | Client.execute_command | Execute a command on the connected server. | pydisque/client.py | def execute_command(self, *args, **kwargs):
"""Execute a command on the connected server."""
try:
return self.get_connection().execute_command(*args, **kwargs)
except ConnectionError as e:
logger.warn('trying to reconnect')
self.connect()
logger.wa... | def execute_command(self, *args, **kwargs):
"""Execute a command on the connected server."""
try:
return self.get_connection().execute_command(*args, **kwargs)
except ConnectionError as e:
logger.warn('trying to reconnect')
self.connect()
logger.wa... | [
"Execute",
"a",
"command",
"on",
"the",
"connected",
"server",
"."
] | ybrs/pydisque | python | https://github.com/ybrs/pydisque/blob/ea5ce1576b66398c1cce32cad0f15709b1ea8df8/pydisque/client.py#L157-L165 | [
"def",
"execute_command",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"self",
".",
"get_connection",
"(",
")",
".",
"execute_command",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"except",
"ConnectionErro... | ea5ce1576b66398c1cce32cad0f15709b1ea8df8 |
train | Client.add_job | Add a job to a queue.
ADDJOB queue_name job <ms-timeout> [REPLICATE <count>] [DELAY <sec>]
[RETRY <sec>] [TTL <sec>] [MAXLEN <count>] [ASYNC]
:param queue_name: is the name of the queue, any string, basically.
:param job: is a string representing the job.
:param timeout: is... | pydisque/client.py | def add_job(self, queue_name, job, timeout=200, replicate=None, delay=None,
retry=None, ttl=None, maxlen=None, asynchronous=None):
"""
Add a job to a queue.
ADDJOB queue_name job <ms-timeout> [REPLICATE <count>] [DELAY <sec>]
[RETRY <sec>] [TTL <sec>] [MAXLEN <count>... | def add_job(self, queue_name, job, timeout=200, replicate=None, delay=None,
retry=None, ttl=None, maxlen=None, asynchronous=None):
"""
Add a job to a queue.
ADDJOB queue_name job <ms-timeout> [REPLICATE <count>] [DELAY <sec>]
[RETRY <sec>] [TTL <sec>] [MAXLEN <count>... | [
"Add",
"a",
"job",
"to",
"a",
"queue",
"."
] | ybrs/pydisque | python | https://github.com/ybrs/pydisque/blob/ea5ce1576b66398c1cce32cad0f15709b1ea8df8/pydisque/client.py#L182-L235 | [
"def",
"add_job",
"(",
"self",
",",
"queue_name",
",",
"job",
",",
"timeout",
"=",
"200",
",",
"replicate",
"=",
"None",
",",
"delay",
"=",
"None",
",",
"retry",
"=",
"None",
",",
"ttl",
"=",
"None",
",",
"maxlen",
"=",
"None",
",",
"asynchronous",
... | ea5ce1576b66398c1cce32cad0f15709b1ea8df8 |
train | Client.get_job | Return some number of jobs from specified queues.
GETJOB [NOHANG] [TIMEOUT <ms-timeout>] [COUNT <count>] [WITHCOUNTERS] FROM
queue1 queue2 ... queueN
:param queues: name of queues
:returns: list of tuple(job_id, queue_name, job), tuple(job_id, queue_name, job, nacks, additional_de... | pydisque/client.py | def get_job(self, queues, timeout=None, count=None, nohang=False, withcounters=False):
"""
Return some number of jobs from specified queues.
GETJOB [NOHANG] [TIMEOUT <ms-timeout>] [COUNT <count>] [WITHCOUNTERS] FROM
queue1 queue2 ... queueN
:param queues: name of queues
... | def get_job(self, queues, timeout=None, count=None, nohang=False, withcounters=False):
"""
Return some number of jobs from specified queues.
GETJOB [NOHANG] [TIMEOUT <ms-timeout>] [COUNT <count>] [WITHCOUNTERS] FROM
queue1 queue2 ... queueN
:param queues: name of queues
... | [
"Return",
"some",
"number",
"of",
"jobs",
"from",
"specified",
"queues",
"."
] | ybrs/pydisque | python | https://github.com/ybrs/pydisque/blob/ea5ce1576b66398c1cce32cad0f15709b1ea8df8/pydisque/client.py#L237-L271 | [
"def",
"get_job",
"(",
"self",
",",
"queues",
",",
"timeout",
"=",
"None",
",",
"count",
"=",
"None",
",",
"nohang",
"=",
"False",
",",
"withcounters",
"=",
"False",
")",
":",
"assert",
"queues",
"command",
"=",
"[",
"'GETJOB'",
"]",
"if",
"nohang",
... | ea5ce1576b66398c1cce32cad0f15709b1ea8df8 |
train | Client.qstat | Return the status of the queue (currently unimplemented).
Future support / testing of QSTAT support in Disque
QSTAT <qname>
Return produced ... consumed ... idle ... sources [...] ctime ... | pydisque/client.py | def qstat(self, queue_name, return_dict=False):
"""
Return the status of the queue (currently unimplemented).
Future support / testing of QSTAT support in Disque
QSTAT <qname>
Return produced ... consumed ... idle ... sources [...] ctime ...
"""
rtn = self.exec... | def qstat(self, queue_name, return_dict=False):
"""
Return the status of the queue (currently unimplemented).
Future support / testing of QSTAT support in Disque
QSTAT <qname>
Return produced ... consumed ... idle ... sources [...] ctime ...
"""
rtn = self.exec... | [
"Return",
"the",
"status",
"of",
"the",
"queue",
"(",
"currently",
"unimplemented",
")",
"."
] | ybrs/pydisque | python | https://github.com/ybrs/pydisque/blob/ea5ce1576b66398c1cce32cad0f15709b1ea8df8/pydisque/client.py#L333-L349 | [
"def",
"qstat",
"(",
"self",
",",
"queue_name",
",",
"return_dict",
"=",
"False",
")",
":",
"rtn",
"=",
"self",
".",
"execute_command",
"(",
"'QSTAT'",
",",
"queue_name",
")",
"if",
"return_dict",
":",
"grouped",
"=",
"self",
".",
"_grouper",
"(",
"rtn",... | ea5ce1576b66398c1cce32cad0f15709b1ea8df8 |
train | Client.show | Describe the job.
:param job_id: | pydisque/client.py | def show(self, job_id, return_dict=False):
"""
Describe the job.
:param job_id:
"""
rtn = self.execute_command('SHOW', job_id)
if return_dict:
grouped = self._grouper(rtn, 2)
rtn = dict((a, b) for a, b in grouped)
return rtn | def show(self, job_id, return_dict=False):
"""
Describe the job.
:param job_id:
"""
rtn = self.execute_command('SHOW', job_id)
if return_dict:
grouped = self._grouper(rtn, 2)
rtn = dict((a, b) for a, b in grouped)
return rtn | [
"Describe",
"the",
"job",
"."
] | ybrs/pydisque | python | https://github.com/ybrs/pydisque/blob/ea5ce1576b66398c1cce32cad0f15709b1ea8df8/pydisque/client.py#L402-L415 | [
"def",
"show",
"(",
"self",
",",
"job_id",
",",
"return_dict",
"=",
"False",
")",
":",
"rtn",
"=",
"self",
".",
"execute_command",
"(",
"'SHOW'",
",",
"job_id",
")",
"if",
"return_dict",
":",
"grouped",
"=",
"self",
".",
"_grouper",
"(",
"rtn",
",",
... | ea5ce1576b66398c1cce32cad0f15709b1ea8df8 |
train | Client.pause | Pause a queue.
Unfortunately, the PAUSE keywords are mostly reserved words in Python,
so I've been a little creative in the function variable names. Open
to suggestions to change it (canardleteer)
:param queue_name: The job queue we are modifying.
:param kw_in: pause the queue ... | pydisque/client.py | def pause(self, queue_name, kw_in=None, kw_out=None, kw_all=None,
kw_none=None, kw_state=None, kw_bcast=None):
"""
Pause a queue.
Unfortunately, the PAUSE keywords are mostly reserved words in Python,
so I've been a little creative in the function variable names. Open
... | def pause(self, queue_name, kw_in=None, kw_out=None, kw_all=None,
kw_none=None, kw_state=None, kw_bcast=None):
"""
Pause a queue.
Unfortunately, the PAUSE keywords are mostly reserved words in Python,
so I've been a little creative in the function variable names. Open
... | [
"Pause",
"a",
"queue",
"."
] | ybrs/pydisque | python | https://github.com/ybrs/pydisque/blob/ea5ce1576b66398c1cce32cad0f15709b1ea8df8/pydisque/client.py#L417-L451 | [
"def",
"pause",
"(",
"self",
",",
"queue_name",
",",
"kw_in",
"=",
"None",
",",
"kw_out",
"=",
"None",
",",
"kw_all",
"=",
"None",
",",
"kw_none",
"=",
"None",
",",
"kw_state",
"=",
"None",
",",
"kw_bcast",
"=",
"None",
")",
":",
"command",
"=",
"[... | ea5ce1576b66398c1cce32cad0f15709b1ea8df8 |
train | Client.qscan | Iterate all the existing queues in the local node.
:param count: An hint about how much work to do per iteration.
:param busyloop: Block and return all the elements in a busy loop.
:param minlen: Don't return elements with less than count jobs queued.
:param maxlen: Don't return element... | pydisque/client.py | def qscan(self, cursor=0, count=None, busyloop=None, minlen=None,
maxlen=None, importrate=None):
"""
Iterate all the existing queues in the local node.
:param count: An hint about how much work to do per iteration.
:param busyloop: Block and return all the elements in a bu... | def qscan(self, cursor=0, count=None, busyloop=None, minlen=None,
maxlen=None, importrate=None):
"""
Iterate all the existing queues in the local node.
:param count: An hint about how much work to do per iteration.
:param busyloop: Block and return all the elements in a bu... | [
"Iterate",
"all",
"the",
"existing",
"queues",
"in",
"the",
"local",
"node",
"."
] | ybrs/pydisque | python | https://github.com/ybrs/pydisque/blob/ea5ce1576b66398c1cce32cad0f15709b1ea8df8/pydisque/client.py#L453-L477 | [
"def",
"qscan",
"(",
"self",
",",
"cursor",
"=",
"0",
",",
"count",
"=",
"None",
",",
"busyloop",
"=",
"None",
",",
"minlen",
"=",
"None",
",",
"maxlen",
"=",
"None",
",",
"importrate",
"=",
"None",
")",
":",
"command",
"=",
"[",
"\"QSCAN\"",
",",
... | ea5ce1576b66398c1cce32cad0f15709b1ea8df8 |
train | Client.jscan | Iterate all the existing jobs in the local node.
:param count: An hint about how much work to do per iteration.
:param busyloop: Block and return all the elements in a busy loop.
:param queue: Return only jobs in the specified queue.
:param state: Must be a list - Return jobs in the spe... | pydisque/client.py | def jscan(self, cursor=0, count=None, busyloop=None, queue=None,
state=None, reply=None):
"""Iterate all the existing jobs in the local node.
:param count: An hint about how much work to do per iteration.
:param busyloop: Block and return all the elements in a busy loop.
:... | def jscan(self, cursor=0, count=None, busyloop=None, queue=None,
state=None, reply=None):
"""Iterate all the existing jobs in the local node.
:param count: An hint about how much work to do per iteration.
:param busyloop: Block and return all the elements in a busy loop.
:... | [
"Iterate",
"all",
"the",
"existing",
"jobs",
"in",
"the",
"local",
"node",
"."
] | ybrs/pydisque | python | https://github.com/ybrs/pydisque/blob/ea5ce1576b66398c1cce32cad0f15709b1ea8df8/pydisque/client.py#L479-L505 | [
"def",
"jscan",
"(",
"self",
",",
"cursor",
"=",
"0",
",",
"count",
"=",
"None",
",",
"busyloop",
"=",
"None",
",",
"queue",
"=",
"None",
",",
"state",
"=",
"None",
",",
"reply",
"=",
"None",
")",
":",
"command",
"=",
"[",
"\"JSCAN\"",
",",
"curs... | ea5ce1576b66398c1cce32cad0f15709b1ea8df8 |
train | build_index_name | Build an index name from parts.
:param parts: Parts that should be combined to make an index name. | invenio_search/utils.py | def build_index_name(app, *parts):
"""Build an index name from parts.
:param parts: Parts that should be combined to make an index name.
"""
base_index = os.path.splitext(
'-'.join([part for part in parts if part])
)[0]
return prefix_index(app=app, index=base_index) | def build_index_name(app, *parts):
"""Build an index name from parts.
:param parts: Parts that should be combined to make an index name.
"""
base_index = os.path.splitext(
'-'.join([part for part in parts if part])
)[0]
return prefix_index(app=app, index=base_index) | [
"Build",
"an",
"index",
"name",
"from",
"parts",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/utils.py#L27-L36 | [
"def",
"build_index_name",
"(",
"app",
",",
"*",
"parts",
")",
":",
"base_index",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"'-'",
".",
"join",
"(",
"[",
"part",
"for",
"part",
"in",
"parts",
"if",
"part",
"]",
")",
")",
"[",
"0",
"]",
"retur... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | schema_to_index | Get index/doc_type given a schema URL.
:param schema: The schema name
:param index_names: A list of index name.
:returns: A tuple containing (index, doc_type). | invenio_search/utils.py | def schema_to_index(schema, index_names=None):
"""Get index/doc_type given a schema URL.
:param schema: The schema name
:param index_names: A list of index name.
:returns: A tuple containing (index, doc_type).
"""
parts = schema.split('/')
doc_type = os.path.splitext(parts[-1])
if doc_... | def schema_to_index(schema, index_names=None):
"""Get index/doc_type given a schema URL.
:param schema: The schema name
:param index_names: A list of index name.
:returns: A tuple containing (index, doc_type).
"""
parts = schema.split('/')
doc_type = os.path.splitext(parts[-1])
if doc_... | [
"Get",
"index",
"/",
"doc_type",
"given",
"a",
"schema",
"URL",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/utils.py#L39-L60 | [
"def",
"schema_to_index",
"(",
"schema",
",",
"index_names",
"=",
"None",
")",
":",
"parts",
"=",
"schema",
".",
"split",
"(",
"'/'",
")",
"doc_type",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"parts",
"[",
"-",
"1",
"]",
")",
"if",
"doc_type",
... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | es_version_check | Decorator to check Elasticsearch version. | invenio_search/cli.py | def es_version_check(f):
"""Decorator to check Elasticsearch version."""
@wraps(f)
def inner(*args, **kwargs):
cluster_ver = current_search.cluster_version[0]
client_ver = ES_VERSION[0]
if cluster_ver != client_ver:
raise click.ClickException(
'Elasticsear... | def es_version_check(f):
"""Decorator to check Elasticsearch version."""
@wraps(f)
def inner(*args, **kwargs):
cluster_ver = current_search.cluster_version[0]
client_ver = ES_VERSION[0]
if cluster_ver != client_ver:
raise click.ClickException(
'Elasticsear... | [
"Decorator",
"to",
"check",
"Elasticsearch",
"version",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/cli.py#L30-L45 | [
"def",
"es_version_check",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"inner",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"cluster_ver",
"=",
"current_search",
".",
"cluster_version",
"[",
"0",
"]",
"client_ver",
"=",
"ES_VERSION... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | init | Initialize registered aliases and mappings. | invenio_search/cli.py | def init(force):
"""Initialize registered aliases and mappings."""
click.secho('Creating indexes...', fg='green', bold=True, file=sys.stderr)
with click.progressbar(
current_search.create(ignore=[400] if force else None),
length=current_search.number_of_indexes) as bar:
for n... | def init(force):
"""Initialize registered aliases and mappings."""
click.secho('Creating indexes...', fg='green', bold=True, file=sys.stderr)
with click.progressbar(
current_search.create(ignore=[400] if force else None),
length=current_search.number_of_indexes) as bar:
for n... | [
"Initialize",
"registered",
"aliases",
"and",
"mappings",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/cli.py#L68-L81 | [
"def",
"init",
"(",
"force",
")",
":",
"click",
".",
"secho",
"(",
"'Creating indexes...'",
",",
"fg",
"=",
"'green'",
",",
"bold",
"=",
"True",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"with",
"click",
".",
"progressbar",
"(",
"current_search",
".... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | destroy | Destroy all indexes. | invenio_search/cli.py | def destroy(force):
"""Destroy all indexes."""
click.secho('Destroying indexes...', fg='red', bold=True, file=sys.stderr)
with click.progressbar(
current_search.delete(ignore=[400, 404] if force else None),
length=current_search.number_of_indexes) as bar:
for name, response i... | def destroy(force):
"""Destroy all indexes."""
click.secho('Destroying indexes...', fg='red', bold=True, file=sys.stderr)
with click.progressbar(
current_search.delete(ignore=[400, 404] if force else None),
length=current_search.number_of_indexes) as bar:
for name, response i... | [
"Destroy",
"all",
"indexes",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/cli.py#L91-L98 | [
"def",
"destroy",
"(",
"force",
")",
":",
"click",
".",
"secho",
"(",
"'Destroying indexes...'",
",",
"fg",
"=",
"'red'",
",",
"bold",
"=",
"True",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"with",
"click",
".",
"progressbar",
"(",
"current_search",
... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | create | Create a new index. | invenio_search/cli.py | def create(index_name, body, force, verbose):
"""Create a new index."""
result = current_search_client.indices.create(
index=index_name,
body=json.load(body),
ignore=[400] if force else None,
)
if verbose:
click.echo(json.dumps(result)) | def create(index_name, body, force, verbose):
"""Create a new index."""
result = current_search_client.indices.create(
index=index_name,
body=json.load(body),
ignore=[400] if force else None,
)
if verbose:
click.echo(json.dumps(result)) | [
"Create",
"a",
"new",
"index",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/cli.py#L108-L116 | [
"def",
"create",
"(",
"index_name",
",",
"body",
",",
"force",
",",
"verbose",
")",
":",
"result",
"=",
"current_search_client",
".",
"indices",
".",
"create",
"(",
"index",
"=",
"index_name",
",",
"body",
"=",
"json",
".",
"load",
"(",
"body",
")",
",... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | list_cmd | List indices. | invenio_search/cli.py | def list_cmd(only_active, only_aliases, verbose):
"""List indices."""
def _tree_print(d, rec_list=None, verbose=False, indent=2):
# Note that on every recursion rec_list is copied,
# which might not be very effective for very deep dictionaries.
rec_list = rec_list or []
for idx, ... | def list_cmd(only_active, only_aliases, verbose):
"""List indices."""
def _tree_print(d, rec_list=None, verbose=False, indent=2):
# Note that on every recursion rec_list is copied,
# which might not be very effective for very deep dictionaries.
rec_list = rec_list or []
for idx, ... | [
"List",
"indices",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/cli.py#L124-L153 | [
"def",
"list_cmd",
"(",
"only_active",
",",
"only_aliases",
",",
"verbose",
")",
":",
"def",
"_tree_print",
"(",
"d",
",",
"rec_list",
"=",
"None",
",",
"verbose",
"=",
"False",
",",
"indent",
"=",
"2",
")",
":",
"# Note that on every recursion rec_list is cop... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | delete | Delete index by its name. | invenio_search/cli.py | def delete(index_name, force, verbose):
"""Delete index by its name."""
result = current_search_client.indices.delete(
index=index_name,
ignore=[400, 404] if force else None,
)
if verbose:
click.echo(json.dumps(result)) | def delete(index_name, force, verbose):
"""Delete index by its name."""
result = current_search_client.indices.delete(
index=index_name,
ignore=[400, 404] if force else None,
)
if verbose:
click.echo(json.dumps(result)) | [
"Delete",
"index",
"by",
"its",
"name",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/cli.py#L165-L172 | [
"def",
"delete",
"(",
"index_name",
",",
"force",
",",
"verbose",
")",
":",
"result",
"=",
"current_search_client",
".",
"indices",
".",
"delete",
"(",
"index",
"=",
"index_name",
",",
"ignore",
"=",
"[",
"400",
",",
"404",
"]",
"if",
"force",
"else",
... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | put | Index input data. | invenio_search/cli.py | def put(index_name, doc_type, identifier, body, force, verbose):
"""Index input data."""
result = current_search_client.index(
index=index_name,
doc_type=doc_type or index_name,
id=identifier,
body=json.load(body),
op_type='index' if force or identifier is None else 'crea... | def put(index_name, doc_type, identifier, body, force, verbose):
"""Index input data."""
result = current_search_client.index(
index=index_name,
doc_type=doc_type or index_name,
id=identifier,
body=json.load(body),
op_type='index' if force or identifier is None else 'crea... | [
"Index",
"input",
"data",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/cli.py#L184-L194 | [
"def",
"put",
"(",
"index_name",
",",
"doc_type",
",",
"identifier",
",",
"body",
",",
"force",
",",
"verbose",
")",
":",
"result",
"=",
"current_search_client",
".",
"index",
"(",
"index",
"=",
"index_name",
",",
"doc_type",
"=",
"doc_type",
"or",
"index_... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | RecordsSearch.get_records | Return records by their identifiers.
:param ids: A list of record identifier.
:returns: A list of records. | invenio_search/api.py | def get_records(self, ids):
"""Return records by their identifiers.
:param ids: A list of record identifier.
:returns: A list of records.
"""
return self.query(Ids(values=[str(id_) for id_ in ids])) | def get_records(self, ids):
"""Return records by their identifiers.
:param ids: A list of record identifier.
:returns: A list of records.
"""
return self.query(Ids(values=[str(id_) for id_ in ids])) | [
"Return",
"records",
"by",
"their",
"identifiers",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/api.py#L120-L126 | [
"def",
"get_records",
"(",
"self",
",",
"ids",
")",
":",
"return",
"self",
".",
"query",
"(",
"Ids",
"(",
"values",
"=",
"[",
"str",
"(",
"id_",
")",
"for",
"id_",
"in",
"ids",
"]",
")",
")"
] | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | RecordsSearch.faceted_search | Return faceted search instance with defaults set.
:param query: Elastic DSL query object (``Q``).
:param filters: Dictionary with selected facet values.
:param search: An instance of ``Search`` class. (default: ``cls()``). | invenio_search/api.py | def faceted_search(cls, query=None, filters=None, search=None):
"""Return faceted search instance with defaults set.
:param query: Elastic DSL query object (``Q``).
:param filters: Dictionary with selected facet values.
:param search: An instance of ``Search`` class. (default: ``cls()``... | def faceted_search(cls, query=None, filters=None, search=None):
"""Return faceted search instance with defaults set.
:param query: Elastic DSL query object (``Q``).
:param filters: Dictionary with selected facet values.
:param search: An instance of ``Search`` class. (default: ``cls()``... | [
"Return",
"faceted",
"search",
"instance",
"with",
"defaults",
"set",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/api.py#L129-L155 | [
"def",
"faceted_search",
"(",
"cls",
",",
"query",
"=",
"None",
",",
"filters",
"=",
"None",
",",
"search",
"=",
"None",
")",
":",
"search_",
"=",
"search",
"or",
"cls",
"(",
")",
"class",
"RecordsFacetedSearch",
"(",
"FacetedSearch",
")",
":",
"\"\"\"Pa... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | RecordsSearch.with_preference_param | Add the preference param to the ES request and return a new Search.
The preference param avoids the bouncing effect with multiple
replicas, documented on ES documentation.
See: https://www.elastic.co/guide/en/elasticsearch/guide/current
/_search_options.html#_preference for more informa... | invenio_search/api.py | def with_preference_param(self):
"""Add the preference param to the ES request and return a new Search.
The preference param avoids the bouncing effect with multiple
replicas, documented on ES documentation.
See: https://www.elastic.co/guide/en/elasticsearch/guide/current
/_sear... | def with_preference_param(self):
"""Add the preference param to the ES request and return a new Search.
The preference param avoids the bouncing effect with multiple
replicas, documented on ES documentation.
See: https://www.elastic.co/guide/en/elasticsearch/guide/current
/_sear... | [
"Add",
"the",
"preference",
"param",
"to",
"the",
"ES",
"request",
"and",
"return",
"a",
"new",
"Search",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/api.py#L157-L168 | [
"def",
"with_preference_param",
"(",
"self",
")",
":",
"user_hash",
"=",
"self",
".",
"_get_user_hash",
"(",
")",
"if",
"user_hash",
":",
"return",
"self",
".",
"params",
"(",
"preference",
"=",
"user_hash",
")",
"return",
"self"
] | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | RecordsSearch._get_user_agent | Retrieve the request's User-Agent, if available.
Taken from Flask Login utils.py. | invenio_search/api.py | def _get_user_agent(self):
"""Retrieve the request's User-Agent, if available.
Taken from Flask Login utils.py.
"""
user_agent = request.headers.get('User-Agent')
if user_agent:
user_agent = user_agent.encode('utf-8')
return user_agent or '' | def _get_user_agent(self):
"""Retrieve the request's User-Agent, if available.
Taken from Flask Login utils.py.
"""
user_agent = request.headers.get('User-Agent')
if user_agent:
user_agent = user_agent.encode('utf-8')
return user_agent or '' | [
"Retrieve",
"the",
"request",
"s",
"User",
"-",
"Agent",
"if",
"available",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/api.py#L170-L178 | [
"def",
"_get_user_agent",
"(",
"self",
")",
":",
"user_agent",
"=",
"request",
".",
"headers",
".",
"get",
"(",
"'User-Agent'",
")",
"if",
"user_agent",
":",
"user_agent",
"=",
"user_agent",
".",
"encode",
"(",
"'utf-8'",
")",
"return",
"user_agent",
"or",
... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | RecordsSearch._get_user_hash | Calculate a digest based on request's User-Agent and IP address. | invenio_search/api.py | def _get_user_hash(self):
"""Calculate a digest based on request's User-Agent and IP address."""
if request:
user_hash = '{ip}-{ua}'.format(ip=request.remote_addr,
ua=self._get_user_agent())
alg = hashlib.md5()
alg.update(use... | def _get_user_hash(self):
"""Calculate a digest based on request's User-Agent and IP address."""
if request:
user_hash = '{ip}-{ua}'.format(ip=request.remote_addr,
ua=self._get_user_agent())
alg = hashlib.md5()
alg.update(use... | [
"Calculate",
"a",
"digest",
"based",
"on",
"request",
"s",
"User",
"-",
"Agent",
"and",
"IP",
"address",
"."
] | inveniosoftware/invenio-search | python | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/api.py#L180-L188 | [
"def",
"_get_user_hash",
"(",
"self",
")",
":",
"if",
"request",
":",
"user_hash",
"=",
"'{ip}-{ua}'",
".",
"format",
"(",
"ip",
"=",
"request",
".",
"remote_addr",
",",
"ua",
"=",
"self",
".",
"_get_user_agent",
"(",
")",
")",
"alg",
"=",
"hashlib",
"... | 19c073d608d4c811f1c5aecb6622402d39715228 |
train | beautify | Beautify JSON string or file.
Keyword arguments:
:param filename: use its contents as json string instead of
json_str param.
:param json_str: json string to be beautified. | src/migration/utils.py | def beautify(filename=None, json_str=None):
"""Beautify JSON string or file.
Keyword arguments:
:param filename: use its contents as json string instead of
json_str param.
:param json_str: json string to be beautified.
"""
if filename is not None:
with open(filename) as json_file:
... | def beautify(filename=None, json_str=None):
"""Beautify JSON string or file.
Keyword arguments:
:param filename: use its contents as json string instead of
json_str param.
:param json_str: json string to be beautified.
"""
if filename is not None:
with open(filename) as json_file:
... | [
"Beautify",
"JSON",
"string",
"or",
"file",
"."
] | chaoss/grimoirelab-sigils | python | https://github.com/chaoss/grimoirelab-sigils/blob/33d395195acb316287143a535a2c6e4009bf0528/src/migration/utils.py#L26-L38 | [
"def",
"beautify",
"(",
"filename",
"=",
"None",
",",
"json_str",
"=",
"None",
")",
":",
"if",
"filename",
"is",
"not",
"None",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"json_file",
":",
"json_str",
"=",
"json",
".",
"load",
"(",
"json_file",
... | 33d395195acb316287143a535a2c6e4009bf0528 |
train | replace | Replace strings giving some info on where
the replacement was done | src/migration/utils.py | def replace(pretty, old_str, new_str):
""" Replace strings giving some info on where
the replacement was done
"""
out_str = ''
line_number = 1
changes = 0
for line in pretty.splitlines(keepends=True):
new_line = line.replace(old_str, new_str)
if line.find(old_str) != -1:
... | def replace(pretty, old_str, new_str):
""" Replace strings giving some info on where
the replacement was done
"""
out_str = ''
line_number = 1
changes = 0
for line in pretty.splitlines(keepends=True):
new_line = line.replace(old_str, new_str)
if line.find(old_str) != -1:
... | [
"Replace",
"strings",
"giving",
"some",
"info",
"on",
"where",
"the",
"replacement",
"was",
"done"
] | chaoss/grimoirelab-sigils | python | https://github.com/chaoss/grimoirelab-sigils/blob/33d395195acb316287143a535a2c6e4009bf0528/src/migration/utils.py#L40-L58 | [
"def",
"replace",
"(",
"pretty",
",",
"old_str",
",",
"new_str",
")",
":",
"out_str",
"=",
"''",
"line_number",
"=",
"1",
"changes",
"=",
"0",
"for",
"line",
"in",
"pretty",
".",
"splitlines",
"(",
"keepends",
"=",
"True",
")",
":",
"new_line",
"=",
... | 33d395195acb316287143a535a2c6e4009bf0528 |
train | receive_connection | Wait for and then return a connected socket..
Opens a TCP connection on port 8080, and waits for a single client. | examples/obtain_refresh_token.py | def receive_connection():
"""Wait for and then return a connected socket..
Opens a TCP connection on port 8080, and waits for a single client.
"""
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.bind(("localhost", 8... | def receive_connection():
"""Wait for and then return a connected socket..
Opens a TCP connection on port 8080, and waits for a single client.
"""
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.bind(("localhost", 8... | [
"Wait",
"for",
"and",
"then",
"return",
"a",
"connected",
"socket",
".."
] | praw-dev/prawcore | python | https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/examples/obtain_refresh_token.py#L19-L31 | [
"def",
"receive_connection",
"(",
")",
":",
"server",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_STREAM",
")",
"server",
".",
"setsockopt",
"(",
"socket",
".",
"SOL_SOCKET",
",",
"socket",
".",
"SO_REUSEADDR",
",... | b16ae88a1f2bf98095ed6fe64851cb7add7ed752 |
train | send_message | Send message to client and close the connection. | examples/obtain_refresh_token.py | def send_message(client, message):
"""Send message to client and close the connection."""
print(message)
client.send("HTTP/1.1 200 OK\r\n\r\n{}".format(message).encode("utf-8"))
client.close() | def send_message(client, message):
"""Send message to client and close the connection."""
print(message)
client.send("HTTP/1.1 200 OK\r\n\r\n{}".format(message).encode("utf-8"))
client.close() | [
"Send",
"message",
"to",
"client",
"and",
"close",
"the",
"connection",
"."
] | praw-dev/prawcore | python | https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/examples/obtain_refresh_token.py#L34-L38 | [
"def",
"send_message",
"(",
"client",
",",
"message",
")",
":",
"print",
"(",
"message",
")",
"client",
".",
"send",
"(",
"\"HTTP/1.1 200 OK\\r\\n\\r\\n{}\"",
".",
"format",
"(",
"message",
")",
".",
"encode",
"(",
"\"utf-8\"",
")",
")",
"client",
".",
"cl... | b16ae88a1f2bf98095ed6fe64851cb7add7ed752 |
train | main | Provide the program's entry point when directly executed. | examples/obtain_refresh_token.py | def main():
"""Provide the program's entry point when directly executed."""
if len(sys.argv) < 2:
print("Usage: {} SCOPE...".format(sys.argv[0]))
return 1
authenticator = prawcore.TrustedAuthenticator(
prawcore.Requestor("prawcore_refresh_token_example"),
os.environ["PRAWCOR... | def main():
"""Provide the program's entry point when directly executed."""
if len(sys.argv) < 2:
print("Usage: {} SCOPE...".format(sys.argv[0]))
return 1
authenticator = prawcore.TrustedAuthenticator(
prawcore.Requestor("prawcore_refresh_token_example"),
os.environ["PRAWCOR... | [
"Provide",
"the",
"program",
"s",
"entry",
"point",
"when",
"directly",
"executed",
"."
] | praw-dev/prawcore | python | https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/examples/obtain_refresh_token.py#L41-L82 | [
"def",
"main",
"(",
")",
":",
"if",
"len",
"(",
"sys",
".",
"argv",
")",
"<",
"2",
":",
"print",
"(",
"\"Usage: {} SCOPE...\"",
".",
"format",
"(",
"sys",
".",
"argv",
"[",
"0",
"]",
")",
")",
"return",
"1",
"authenticator",
"=",
"prawcore",
".",
... | b16ae88a1f2bf98095ed6fe64851cb7add7ed752 |
train | watch | Quick wrapper for using the Watcher.
:param logger_name: name of logger to watch
:param level: minimum log level to show (default INFO)
:param out: where to send output (default stdout)
:return: Watcher instance | neobolt/diagnostics.py | def watch(logger_name, level=DEBUG, out=stdout):
""" Quick wrapper for using the Watcher.
:param logger_name: name of logger to watch
:param level: minimum log level to show (default INFO)
:param out: where to send output (default stdout)
:return: Watcher instance
"""
watcher = Watcher(logg... | def watch(logger_name, level=DEBUG, out=stdout):
""" Quick wrapper for using the Watcher.
:param logger_name: name of logger to watch
:param level: minimum log level to show (default INFO)
:param out: where to send output (default stdout)
:return: Watcher instance
"""
watcher = Watcher(logg... | [
"Quick",
"wrapper",
"for",
"using",
"the",
"Watcher",
"."
] | neo4j-drivers/neobolt | python | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/diagnostics.py#L80-L90 | [
"def",
"watch",
"(",
"logger_name",
",",
"level",
"=",
"DEBUG",
",",
"out",
"=",
"stdout",
")",
":",
"watcher",
"=",
"Watcher",
"(",
"logger_name",
")",
"watcher",
".",
"watch",
"(",
"level",
",",
"out",
")",
"return",
"watcher"
] | 724569d76e85777c4f5e30e8d0a18116bda4d8cd |
train | get_user_agent | Obtain the default user agent string sent to the server after
a successful handshake. | neobolt/meta.py | def get_user_agent():
""" Obtain the default user agent string sent to the server after
a successful handshake.
"""
from sys import platform, version_info
template = "neobolt/{} Python/{}.{}.{}-{}-{} ({})"
fields = (version,) + tuple(version_info) + (platform,)
return template.format(*fields... | def get_user_agent():
""" Obtain the default user agent string sent to the server after
a successful handshake.
"""
from sys import platform, version_info
template = "neobolt/{} Python/{}.{}.{}-{}-{} ({})"
fields = (version,) + tuple(version_info) + (platform,)
return template.format(*fields... | [
"Obtain",
"the",
"default",
"user",
"agent",
"string",
"sent",
"to",
"the",
"server",
"after",
"a",
"successful",
"handshake",
"."
] | neo4j-drivers/neobolt | python | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/meta.py#L26-L33 | [
"def",
"get_user_agent",
"(",
")",
":",
"from",
"sys",
"import",
"platform",
",",
"version_info",
"template",
"=",
"\"neobolt/{} Python/{}.{}.{}-{}-{} ({})\"",
"fields",
"=",
"(",
"version",
",",
")",
"+",
"tuple",
"(",
"version_info",
")",
"+",
"(",
"platform",... | 724569d76e85777c4f5e30e8d0a18116bda4d8cd |
train | import_best | Import the best available module,
with C preferred to pure Python. | neobolt/meta.py | def import_best(c_module, py_module):
""" Import the best available module,
with C preferred to pure Python.
"""
from importlib import import_module
from os import getenv
pure_python = getenv("PURE_PYTHON", "")
if pure_python:
return import_module(py_module)
else:
try:
... | def import_best(c_module, py_module):
""" Import the best available module,
with C preferred to pure Python.
"""
from importlib import import_module
from os import getenv
pure_python = getenv("PURE_PYTHON", "")
if pure_python:
return import_module(py_module)
else:
try:
... | [
"Import",
"the",
"best",
"available",
"module",
"with",
"C",
"preferred",
"to",
"pure",
"Python",
"."
] | neo4j-drivers/neobolt | python | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/meta.py#L58-L71 | [
"def",
"import_best",
"(",
"c_module",
",",
"py_module",
")",
":",
"from",
"importlib",
"import",
"import_module",
"from",
"os",
"import",
"getenv",
"pure_python",
"=",
"getenv",
"(",
"\"PURE_PYTHON\"",
",",
"\"\"",
")",
"if",
"pure_python",
":",
"return",
"im... | 724569d76e85777c4f5e30e8d0a18116bda4d8cd |
train | PackStreamHydrator.hydrate | Convert PackStream values into native values. | neobolt/types/__init__.py | def hydrate(self, values):
""" Convert PackStream values into native values.
"""
def hydrate_(obj):
if isinstance(obj, Structure):
try:
f = self.hydration_functions[obj.tag]
except KeyError:
# If we don't recogn... | def hydrate(self, values):
""" Convert PackStream values into native values.
"""
def hydrate_(obj):
if isinstance(obj, Structure):
try:
f = self.hydration_functions[obj.tag]
except KeyError:
# If we don't recogn... | [
"Convert",
"PackStream",
"values",
"into",
"native",
"values",
"."
] | neo4j-drivers/neobolt | python | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/types/__init__.py#L97-L117 | [
"def",
"hydrate",
"(",
"self",
",",
"values",
")",
":",
"def",
"hydrate_",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"Structure",
")",
":",
"try",
":",
"f",
"=",
"self",
".",
"hydration_functions",
"[",
"obj",
".",
"tag",
"]",
"exc... | 724569d76e85777c4f5e30e8d0a18116bda4d8cd |
train | BaseAuthenticator.authorize_url | Return the URL used out-of-band to grant access to your application.
:param duration: Either ``permanent`` or ``temporary``. ``temporary``
authorizations generate access tokens that last only 1
hour. ``permanent`` authorizations additionally generate a refresh
token that can... | prawcore/auth.py | def authorize_url(self, duration, scopes, state, implicit=False):
"""Return the URL used out-of-band to grant access to your application.
:param duration: Either ``permanent`` or ``temporary``. ``temporary``
authorizations generate access tokens that last only 1
hour. ``permanen... | def authorize_url(self, duration, scopes, state, implicit=False):
"""Return the URL used out-of-band to grant access to your application.
:param duration: Either ``permanent`` or ``temporary``. ``temporary``
authorizations generate access tokens that last only 1
hour. ``permanen... | [
"Return",
"the",
"URL",
"used",
"out",
"-",
"of",
"-",
"band",
"to",
"grant",
"access",
"to",
"your",
"application",
"."
] | praw-dev/prawcore | python | https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/auth.py#L35-L75 | [
"def",
"authorize_url",
"(",
"self",
",",
"duration",
",",
"scopes",
",",
"state",
",",
"implicit",
"=",
"False",
")",
":",
"if",
"self",
".",
"redirect_uri",
"is",
"None",
":",
"raise",
"InvalidInvocation",
"(",
"\"redirect URI not provided\"",
")",
"if",
"... | b16ae88a1f2bf98095ed6fe64851cb7add7ed752 |
train | BaseAuthenticator.revoke_token | Ask Reddit to revoke the provided token.
:param token: The access or refresh token to revoke.
:param token_type: (Optional) When provided, hint to Reddit what the
token type is for a possible efficiency gain. The value can be
either ``access_token`` or ``refresh_token``. | prawcore/auth.py | def revoke_token(self, token, token_type=None):
"""Ask Reddit to revoke the provided token.
:param token: The access or refresh token to revoke.
:param token_type: (Optional) When provided, hint to Reddit what the
token type is for a possible efficiency gain. The value can be
... | def revoke_token(self, token, token_type=None):
"""Ask Reddit to revoke the provided token.
:param token: The access or refresh token to revoke.
:param token_type: (Optional) When provided, hint to Reddit what the
token type is for a possible efficiency gain. The value can be
... | [
"Ask",
"Reddit",
"to",
"revoke",
"the",
"provided",
"token",
"."
] | praw-dev/prawcore | python | https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/auth.py#L77-L90 | [
"def",
"revoke_token",
"(",
"self",
",",
"token",
",",
"token_type",
"=",
"None",
")",
":",
"data",
"=",
"{",
"\"token\"",
":",
"token",
"}",
"if",
"token_type",
"is",
"not",
"None",
":",
"data",
"[",
"\"token_type_hint\"",
"]",
"=",
"token_type",
"url",... | b16ae88a1f2bf98095ed6fe64851cb7add7ed752 |
train | BaseAuthorizer.revoke | Revoke the current Authorization. | prawcore/auth.py | def revoke(self):
"""Revoke the current Authorization."""
if self.access_token is None:
raise InvalidInvocation("no token available to revoke")
self._authenticator.revoke_token(self.access_token, "access_token")
self._clear_access_token() | def revoke(self):
"""Revoke the current Authorization."""
if self.access_token is None:
raise InvalidInvocation("no token available to revoke")
self._authenticator.revoke_token(self.access_token, "access_token")
self._clear_access_token() | [
"Revoke",
"the",
"current",
"Authorization",
"."
] | praw-dev/prawcore | python | https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/auth.py#L184-L190 | [
"def",
"revoke",
"(",
"self",
")",
":",
"if",
"self",
".",
"access_token",
"is",
"None",
":",
"raise",
"InvalidInvocation",
"(",
"\"no token available to revoke\"",
")",
"self",
".",
"_authenticator",
".",
"revoke_token",
"(",
"self",
".",
"access_token",
",",
... | b16ae88a1f2bf98095ed6fe64851cb7add7ed752 |
train | Authorizer.authorize | Obtain and set authorization tokens based on ``code``.
:param code: The code obtained by an out-of-band authorization request
to Reddit. | prawcore/auth.py | def authorize(self, code):
"""Obtain and set authorization tokens based on ``code``.
:param code: The code obtained by an out-of-band authorization request
to Reddit.
"""
if self._authenticator.redirect_uri is None:
raise InvalidInvocation("redirect URI not prov... | def authorize(self, code):
"""Obtain and set authorization tokens based on ``code``.
:param code: The code obtained by an out-of-band authorization request
to Reddit.
"""
if self._authenticator.redirect_uri is None:
raise InvalidInvocation("redirect URI not prov... | [
"Obtain",
"and",
"set",
"authorization",
"tokens",
"based",
"on",
"code",
"."
] | praw-dev/prawcore | python | https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/auth.py#L210-L223 | [
"def",
"authorize",
"(",
"self",
",",
"code",
")",
":",
"if",
"self",
".",
"_authenticator",
".",
"redirect_uri",
"is",
"None",
":",
"raise",
"InvalidInvocation",
"(",
"\"redirect URI not provided\"",
")",
"self",
".",
"_request_token",
"(",
"code",
"=",
"code... | b16ae88a1f2bf98095ed6fe64851cb7add7ed752 |
train | Authorizer.refresh | Obtain a new access token from the refresh_token. | prawcore/auth.py | def refresh(self):
"""Obtain a new access token from the refresh_token."""
if self.refresh_token is None:
raise InvalidInvocation("refresh token not provided")
self._request_token(
grant_type="refresh_token", refresh_token=self.refresh_token
) | def refresh(self):
"""Obtain a new access token from the refresh_token."""
if self.refresh_token is None:
raise InvalidInvocation("refresh token not provided")
self._request_token(
grant_type="refresh_token", refresh_token=self.refresh_token
) | [
"Obtain",
"a",
"new",
"access",
"token",
"from",
"the",
"refresh_token",
"."
] | praw-dev/prawcore | python | https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/auth.py#L225-L231 | [
"def",
"refresh",
"(",
"self",
")",
":",
"if",
"self",
".",
"refresh_token",
"is",
"None",
":",
"raise",
"InvalidInvocation",
"(",
"\"refresh token not provided\"",
")",
"self",
".",
"_request_token",
"(",
"grant_type",
"=",
"\"refresh_token\"",
",",
"refresh_toke... | b16ae88a1f2bf98095ed6fe64851cb7add7ed752 |
train | Authorizer.revoke | Revoke the current Authorization.
:param only_access: (Optional) When explicitly set to True, do not
evict the refresh token if one is set.
Revoking a refresh token will in-turn revoke all access tokens
associated with that authorization. | prawcore/auth.py | def revoke(self, only_access=False):
"""Revoke the current Authorization.
:param only_access: (Optional) When explicitly set to True, do not
evict the refresh token if one is set.
Revoking a refresh token will in-turn revoke all access tokens
associated with that authorizat... | def revoke(self, only_access=False):
"""Revoke the current Authorization.
:param only_access: (Optional) When explicitly set to True, do not
evict the refresh token if one is set.
Revoking a refresh token will in-turn revoke all access tokens
associated with that authorizat... | [
"Revoke",
"the",
"current",
"Authorization",
"."
] | praw-dev/prawcore | python | https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/auth.py#L233-L250 | [
"def",
"revoke",
"(",
"self",
",",
"only_access",
"=",
"False",
")",
":",
"if",
"only_access",
"or",
"self",
".",
"refresh_token",
"is",
"None",
":",
"super",
"(",
"Authorizer",
",",
"self",
")",
".",
"revoke",
"(",
")",
"else",
":",
"self",
".",
"_a... | b16ae88a1f2bf98095ed6fe64851cb7add7ed752 |
train | DeviceIDAuthorizer.refresh | Obtain a new access token. | prawcore/auth.py | def refresh(self):
"""Obtain a new access token."""
grant_type = "https://oauth.reddit.com/grants/installed_client"
self._request_token(grant_type=grant_type, device_id=self._device_id) | def refresh(self):
"""Obtain a new access token."""
grant_type = "https://oauth.reddit.com/grants/installed_client"
self._request_token(grant_type=grant_type, device_id=self._device_id) | [
"Obtain",
"a",
"new",
"access",
"token",
"."
] | praw-dev/prawcore | python | https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/auth.py#L275-L278 | [
"def",
"refresh",
"(",
"self",
")",
":",
"grant_type",
"=",
"\"https://oauth.reddit.com/grants/installed_client\"",
"self",
".",
"_request_token",
"(",
"grant_type",
"=",
"grant_type",
",",
"device_id",
"=",
"self",
".",
"_device_id",
")"
] | b16ae88a1f2bf98095ed6fe64851cb7add7ed752 |
train | ScriptAuthorizer.refresh | Obtain a new personal-use script type access token. | prawcore/auth.py | def refresh(self):
"""Obtain a new personal-use script type access token."""
self._request_token(
grant_type="password",
username=self._username,
password=self._password,
) | def refresh(self):
"""Obtain a new personal-use script type access token."""
self._request_token(
grant_type="password",
username=self._username,
password=self._password,
) | [
"Obtain",
"a",
"new",
"personal",
"-",
"use",
"script",
"type",
"access",
"token",
"."
] | praw-dev/prawcore | python | https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/auth.py#L347-L353 | [
"def",
"refresh",
"(",
"self",
")",
":",
"self",
".",
"_request_token",
"(",
"grant_type",
"=",
"\"password\"",
",",
"username",
"=",
"self",
".",
"_username",
",",
"password",
"=",
"self",
".",
"_password",
",",
")"
] | b16ae88a1f2bf98095ed6fe64851cb7add7ed752 |
train | Requestor.request | Issue the HTTP request capturing any errors that may occur. | prawcore/requestor.py | def request(self, *args, **kwargs):
"""Issue the HTTP request capturing any errors that may occur."""
try:
return self._http.request(*args, timeout=TIMEOUT, **kwargs)
except Exception as exc:
raise RequestException(exc, args, kwargs) | def request(self, *args, **kwargs):
"""Issue the HTTP request capturing any errors that may occur."""
try:
return self._http.request(*args, timeout=TIMEOUT, **kwargs)
except Exception as exc:
raise RequestException(exc, args, kwargs) | [
"Issue",
"the",
"HTTP",
"request",
"capturing",
"any",
"errors",
"that",
"may",
"occur",
"."
] | praw-dev/prawcore | python | https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/requestor.py#L50-L55 | [
"def",
"request",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"self",
".",
"_http",
".",
"request",
"(",
"*",
"args",
",",
"timeout",
"=",
"TIMEOUT",
",",
"*",
"*",
"kwargs",
")",
"except",
"Exception",
... | b16ae88a1f2bf98095ed6fe64851cb7add7ed752 |
train | _hangul_char_to_jamo | Return a 3-tuple of lead, vowel, and tail jamo characters.
Note: Non-Hangul characters are echoed back. | jamo/jamo.py | def _hangul_char_to_jamo(syllable):
"""Return a 3-tuple of lead, vowel, and tail jamo characters.
Note: Non-Hangul characters are echoed back.
"""
if is_hangul_char(syllable):
rem = ord(syllable) - _JAMO_OFFSET
tail = rem % 28
vowel = 1 + ((rem - tail) % 588) // 28
lead =... | def _hangul_char_to_jamo(syllable):
"""Return a 3-tuple of lead, vowel, and tail jamo characters.
Note: Non-Hangul characters are echoed back.
"""
if is_hangul_char(syllable):
rem = ord(syllable) - _JAMO_OFFSET
tail = rem % 28
vowel = 1 + ((rem - tail) % 588) // 28
lead =... | [
"Return",
"a",
"3",
"-",
"tuple",
"of",
"lead",
"vowel",
"and",
"tail",
"jamo",
"characters",
".",
"Note",
":",
"Non",
"-",
"Hangul",
"characters",
"are",
"echoed",
"back",
"."
] | JDongian/python-jamo | python | https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L54-L71 | [
"def",
"_hangul_char_to_jamo",
"(",
"syllable",
")",
":",
"if",
"is_hangul_char",
"(",
"syllable",
")",
":",
"rem",
"=",
"ord",
"(",
"syllable",
")",
"-",
"_JAMO_OFFSET",
"tail",
"=",
"rem",
"%",
"28",
"vowel",
"=",
"1",
"+",
"(",
"(",
"rem",
"-",
"t... | d087a9f5f52f066fb933ad1da8e9915703374c9a |
train | _jamo_to_hangul_char | Return the Hangul character for the given jamo characters. | jamo/jamo.py | def _jamo_to_hangul_char(lead, vowel, tail=0):
"""Return the Hangul character for the given jamo characters.
"""
lead = ord(lead) - _JAMO_LEAD_OFFSET
vowel = ord(vowel) - _JAMO_VOWEL_OFFSET
tail = ord(tail) - _JAMO_TAIL_OFFSET if tail else 0
return chr(tail + (vowel - 1) * 28 + (lead - 1) * 588 ... | def _jamo_to_hangul_char(lead, vowel, tail=0):
"""Return the Hangul character for the given jamo characters.
"""
lead = ord(lead) - _JAMO_LEAD_OFFSET
vowel = ord(vowel) - _JAMO_VOWEL_OFFSET
tail = ord(tail) - _JAMO_TAIL_OFFSET if tail else 0
return chr(tail + (vowel - 1) * 28 + (lead - 1) * 588 ... | [
"Return",
"the",
"Hangul",
"character",
"for",
"the",
"given",
"jamo",
"characters",
"."
] | JDongian/python-jamo | python | https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L74-L80 | [
"def",
"_jamo_to_hangul_char",
"(",
"lead",
",",
"vowel",
",",
"tail",
"=",
"0",
")",
":",
"lead",
"=",
"ord",
"(",
"lead",
")",
"-",
"_JAMO_LEAD_OFFSET",
"vowel",
"=",
"ord",
"(",
"vowel",
")",
"-",
"_JAMO_VOWEL_OFFSET",
"tail",
"=",
"ord",
"(",
"tail... | d087a9f5f52f066fb933ad1da8e9915703374c9a |
train | _get_unicode_name | Fetch the unicode name for jamo characters. | jamo/jamo.py | def _get_unicode_name(char):
"""Fetch the unicode name for jamo characters.
"""
if char not in _JAMO_TO_NAME.keys() and char not in _HCJ_TO_NAME.keys():
raise InvalidJamoError("Not jamo or nameless jamo character", char)
else:
if is_hcj(char):
return _HCJ_TO_NAME[char]
... | def _get_unicode_name(char):
"""Fetch the unicode name for jamo characters.
"""
if char not in _JAMO_TO_NAME.keys() and char not in _HCJ_TO_NAME.keys():
raise InvalidJamoError("Not jamo or nameless jamo character", char)
else:
if is_hcj(char):
return _HCJ_TO_NAME[char]
... | [
"Fetch",
"the",
"unicode",
"name",
"for",
"jamo",
"characters",
"."
] | JDongian/python-jamo | python | https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L93-L101 | [
"def",
"_get_unicode_name",
"(",
"char",
")",
":",
"if",
"char",
"not",
"in",
"_JAMO_TO_NAME",
".",
"keys",
"(",
")",
"and",
"char",
"not",
"in",
"_HCJ_TO_NAME",
".",
"keys",
"(",
")",
":",
"raise",
"InvalidJamoError",
"(",
"\"Not jamo or nameless jamo charact... | d087a9f5f52f066fb933ad1da8e9915703374c9a |
train | is_jamo | Test if a single character is a jamo character.
Valid jamo includes all modern and archaic jamo, as well as all HCJ.
Non-assigned code points are invalid. | jamo/jamo.py | def is_jamo(character):
"""Test if a single character is a jamo character.
Valid jamo includes all modern and archaic jamo, as well as all HCJ.
Non-assigned code points are invalid.
"""
code = ord(character)
return 0x1100 <= code <= 0x11FF or\
0xA960 <= code <= 0xA97C or\
0xD7B0 ... | def is_jamo(character):
"""Test if a single character is a jamo character.
Valid jamo includes all modern and archaic jamo, as well as all HCJ.
Non-assigned code points are invalid.
"""
code = ord(character)
return 0x1100 <= code <= 0x11FF or\
0xA960 <= code <= 0xA97C or\
0xD7B0 ... | [
"Test",
"if",
"a",
"single",
"character",
"is",
"a",
"jamo",
"character",
".",
"Valid",
"jamo",
"includes",
"all",
"modern",
"and",
"archaic",
"jamo",
"as",
"well",
"as",
"all",
"HCJ",
".",
"Non",
"-",
"assigned",
"code",
"points",
"are",
"invalid",
"."
... | JDongian/python-jamo | python | https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L104-L113 | [
"def",
"is_jamo",
"(",
"character",
")",
":",
"code",
"=",
"ord",
"(",
"character",
")",
"return",
"0x1100",
"<=",
"code",
"<=",
"0x11FF",
"or",
"0xA960",
"<=",
"code",
"<=",
"0xA97C",
"or",
"0xD7B0",
"<=",
"code",
"<=",
"0xD7C6",
"or",
"0xD7CB",
"<=",... | d087a9f5f52f066fb933ad1da8e9915703374c9a |
train | is_jamo_modern | Test if a single character is a modern jamo character.
Modern jamo includes all U+11xx jamo in addition to HCJ in modern usage,
as defined in Unicode 7.0.
WARNING: U+1160 is NOT considered a modern jamo character, but it is listed
under 'Medial Vowels' in the Unicode 7.0 spec. | jamo/jamo.py | def is_jamo_modern(character):
"""Test if a single character is a modern jamo character.
Modern jamo includes all U+11xx jamo in addition to HCJ in modern usage,
as defined in Unicode 7.0.
WARNING: U+1160 is NOT considered a modern jamo character, but it is listed
under 'Medial Vowels' in the Unicod... | def is_jamo_modern(character):
"""Test if a single character is a modern jamo character.
Modern jamo includes all U+11xx jamo in addition to HCJ in modern usage,
as defined in Unicode 7.0.
WARNING: U+1160 is NOT considered a modern jamo character, but it is listed
under 'Medial Vowels' in the Unicod... | [
"Test",
"if",
"a",
"single",
"character",
"is",
"a",
"modern",
"jamo",
"character",
".",
"Modern",
"jamo",
"includes",
"all",
"U",
"+",
"11xx",
"jamo",
"in",
"addition",
"to",
"HCJ",
"in",
"modern",
"usage",
"as",
"defined",
"in",
"Unicode",
"7",
".",
... | JDongian/python-jamo | python | https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L116-L127 | [
"def",
"is_jamo_modern",
"(",
"character",
")",
":",
"code",
"=",
"ord",
"(",
"character",
")",
"return",
"0x1100",
"<=",
"code",
"<=",
"0x1112",
"or",
"0x1161",
"<=",
"code",
"<=",
"0x1175",
"or",
"0x11A8",
"<=",
"code",
"<=",
"0x11C2",
"or",
"is_hcj_mo... | d087a9f5f52f066fb933ad1da8e9915703374c9a |
train | is_jamo_compound | Test if a single character is a compound, i.e., a consonant
cluster, double consonant, or dipthong. | jamo/jamo.py | def is_jamo_compound(character):
"""Test if a single character is a compound, i.e., a consonant
cluster, double consonant, or dipthong.
"""
if len(character) != 1:
return False
# Consider instead:
# raise TypeError('is_jamo_compound() expected a single character')
if is_jamo(... | def is_jamo_compound(character):
"""Test if a single character is a compound, i.e., a consonant
cluster, double consonant, or dipthong.
"""
if len(character) != 1:
return False
# Consider instead:
# raise TypeError('is_jamo_compound() expected a single character')
if is_jamo(... | [
"Test",
"if",
"a",
"single",
"character",
"is",
"a",
"compound",
"i",
".",
"e",
".",
"a",
"consonant",
"cluster",
"double",
"consonant",
"or",
"dipthong",
"."
] | JDongian/python-jamo | python | https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L155-L165 | [
"def",
"is_jamo_compound",
"(",
"character",
")",
":",
"if",
"len",
"(",
"character",
")",
"!=",
"1",
":",
"return",
"False",
"# Consider instead:",
"# raise TypeError('is_jamo_compound() expected a single character')",
"if",
"is_jamo",
"(",
"character",
")",
":",
"re... | d087a9f5f52f066fb933ad1da8e9915703374c9a |
train | get_jamo_class | Determine if a jamo character is a lead, vowel, or tail.
Integers and U+11xx characters are valid arguments. HCJ consonants are not
valid here.
get_jamo_class should return the class ["lead" | "vowel" | "tail"] of a
given character or integer.
Note: jamo class directly corresponds to the Unicode 7... | jamo/jamo.py | def get_jamo_class(jamo):
"""Determine if a jamo character is a lead, vowel, or tail.
Integers and U+11xx characters are valid arguments. HCJ consonants are not
valid here.
get_jamo_class should return the class ["lead" | "vowel" | "tail"] of a
given character or integer.
Note: jamo class dire... | def get_jamo_class(jamo):
"""Determine if a jamo character is a lead, vowel, or tail.
Integers and U+11xx characters are valid arguments. HCJ consonants are not
valid here.
get_jamo_class should return the class ["lead" | "vowel" | "tail"] of a
given character or integer.
Note: jamo class dire... | [
"Determine",
"if",
"a",
"jamo",
"character",
"is",
"a",
"lead",
"vowel",
"or",
"tail",
".",
"Integers",
"and",
"U",
"+",
"11xx",
"characters",
"are",
"valid",
"arguments",
".",
"HCJ",
"consonants",
"are",
"not",
"valid",
"here",
"."
] | JDongian/python-jamo | python | https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L168-L188 | [
"def",
"get_jamo_class",
"(",
"jamo",
")",
":",
"# TODO: Perhaps raise a separate error for U+3xxx jamo.",
"if",
"jamo",
"in",
"JAMO_LEADS",
"or",
"jamo",
"==",
"chr",
"(",
"0x115F",
")",
":",
"return",
"\"lead\"",
"if",
"jamo",
"in",
"JAMO_VOWELS",
"or",
"jamo",
... | d087a9f5f52f066fb933ad1da8e9915703374c9a |
train | hcj_to_jamo | Convert a HCJ character to a jamo character.
Arguments may be single characters along with the desired jamo class
(lead, vowel, tail). Non-mappable input will raise an InvalidJamoError. | jamo/jamo.py | def hcj_to_jamo(hcj_char, position="vowel"):
"""Convert a HCJ character to a jamo character.
Arguments may be single characters along with the desired jamo class
(lead, vowel, tail). Non-mappable input will raise an InvalidJamoError.
"""
if position == "lead":
jamo_class = "CHOSEONG"
eli... | def hcj_to_jamo(hcj_char, position="vowel"):
"""Convert a HCJ character to a jamo character.
Arguments may be single characters along with the desired jamo class
(lead, vowel, tail). Non-mappable input will raise an InvalidJamoError.
"""
if position == "lead":
jamo_class = "CHOSEONG"
eli... | [
"Convert",
"a",
"HCJ",
"character",
"to",
"a",
"jamo",
"character",
".",
"Arguments",
"may",
"be",
"single",
"characters",
"along",
"with",
"the",
"desired",
"jamo",
"class",
"(",
"lead",
"vowel",
"tail",
")",
".",
"Non",
"-",
"mappable",
"input",
"will",
... | JDongian/python-jamo | python | https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L216-L235 | [
"def",
"hcj_to_jamo",
"(",
"hcj_char",
",",
"position",
"=",
"\"vowel\"",
")",
":",
"if",
"position",
"==",
"\"lead\"",
":",
"jamo_class",
"=",
"\"CHOSEONG\"",
"elif",
"position",
"==",
"\"vowel\"",
":",
"jamo_class",
"=",
"\"JUNGSEONG\"",
"elif",
"position",
... | d087a9f5f52f066fb933ad1da8e9915703374c9a |
train | hangul_to_jamo | Convert a string of Hangul to jamo.
Arguments may be iterables of characters.
hangul_to_jamo should split every Hangul character into U+11xx jamo
characters for any given string. Non-hangul characters are not changed.
hangul_to_jamo is the generator version of h2j, the string version. | jamo/jamo.py | def hangul_to_jamo(hangul_string):
"""Convert a string of Hangul to jamo.
Arguments may be iterables of characters.
hangul_to_jamo should split every Hangul character into U+11xx jamo
characters for any given string. Non-hangul characters are not changed.
hangul_to_jamo is the generator version of... | def hangul_to_jamo(hangul_string):
"""Convert a string of Hangul to jamo.
Arguments may be iterables of characters.
hangul_to_jamo should split every Hangul character into U+11xx jamo
characters for any given string. Non-hangul characters are not changed.
hangul_to_jamo is the generator version of... | [
"Convert",
"a",
"string",
"of",
"Hangul",
"to",
"jamo",
".",
"Arguments",
"may",
"be",
"iterables",
"of",
"characters",
"."
] | JDongian/python-jamo | python | https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L245-L256 | [
"def",
"hangul_to_jamo",
"(",
"hangul_string",
")",
":",
"return",
"(",
"_",
"for",
"_",
"in",
"chain",
".",
"from_iterable",
"(",
"_hangul_char_to_jamo",
"(",
"_",
")",
"for",
"_",
"in",
"hangul_string",
")",
")"
] | d087a9f5f52f066fb933ad1da8e9915703374c9a |
train | jamo_to_hangul | Return the Hangul character for the given jamo input.
Integers corresponding to U+11xx jamo codepoints, U+11xx jamo characters,
or HCJ are valid inputs.
Outputs a one-character Hangul string.
This function is identical to j2h. | jamo/jamo.py | def jamo_to_hangul(lead, vowel, tail=''):
"""Return the Hangul character for the given jamo input.
Integers corresponding to U+11xx jamo codepoints, U+11xx jamo characters,
or HCJ are valid inputs.
Outputs a one-character Hangul string.
This function is identical to j2h.
"""
# Internally, ... | def jamo_to_hangul(lead, vowel, tail=''):
"""Return the Hangul character for the given jamo input.
Integers corresponding to U+11xx jamo codepoints, U+11xx jamo characters,
or HCJ are valid inputs.
Outputs a one-character Hangul string.
This function is identical to j2h.
"""
# Internally, ... | [
"Return",
"the",
"Hangul",
"character",
"for",
"the",
"given",
"jamo",
"input",
".",
"Integers",
"corresponding",
"to",
"U",
"+",
"11xx",
"jamo",
"codepoints",
"U",
"+",
"11xx",
"jamo",
"characters",
"or",
"HCJ",
"are",
"valid",
"inputs",
"."
] | JDongian/python-jamo | python | https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L271-L295 | [
"def",
"jamo_to_hangul",
"(",
"lead",
",",
"vowel",
",",
"tail",
"=",
"''",
")",
":",
"# Internally, we convert everything to a jamo char,",
"# then pass it to _jamo_to_hangul_char",
"lead",
"=",
"hcj_to_jamo",
"(",
"lead",
",",
"\"lead\"",
")",
"vowel",
"=",
"hcj_to_... | d087a9f5f52f066fb933ad1da8e9915703374c9a |
train | decompose_jamo | Return a tuple of jamo character constituents of a compound.
Note: Non-compound characters are echoed back.
WARNING: Archaic jamo compounds will raise NotImplementedError. | jamo/jamo.py | def decompose_jamo(compound):
"""Return a tuple of jamo character constituents of a compound.
Note: Non-compound characters are echoed back.
WARNING: Archaic jamo compounds will raise NotImplementedError.
"""
if len(compound) != 1:
raise TypeError("decompose_jamo() expects a single characte... | def decompose_jamo(compound):
"""Return a tuple of jamo character constituents of a compound.
Note: Non-compound characters are echoed back.
WARNING: Archaic jamo compounds will raise NotImplementedError.
"""
if len(compound) != 1:
raise TypeError("decompose_jamo() expects a single characte... | [
"Return",
"a",
"tuple",
"of",
"jamo",
"character",
"constituents",
"of",
"a",
"compound",
".",
"Note",
":",
"Non",
"-",
"compound",
"characters",
"are",
"echoed",
"back",
"."
] | JDongian/python-jamo | python | https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L310-L325 | [
"def",
"decompose_jamo",
"(",
"compound",
")",
":",
"if",
"len",
"(",
"compound",
")",
"!=",
"1",
":",
"raise",
"TypeError",
"(",
"\"decompose_jamo() expects a single character,\"",
",",
"\"but received\"",
",",
"type",
"(",
"compound",
")",
",",
"\"length\"",
"... | d087a9f5f52f066fb933ad1da8e9915703374c9a |
train | compose_jamo | Return the compound jamo for the given jamo input.
Integers corresponding to U+11xx jamo codepoints, U+11xx jamo
characters, or HCJ are valid inputs.
Outputs a one-character jamo string. | jamo/jamo.py | def compose_jamo(*parts):
"""Return the compound jamo for the given jamo input.
Integers corresponding to U+11xx jamo codepoints, U+11xx jamo
characters, or HCJ are valid inputs.
Outputs a one-character jamo string.
"""
# Internally, we convert everything to a jamo char,
# then pass it to _... | def compose_jamo(*parts):
"""Return the compound jamo for the given jamo input.
Integers corresponding to U+11xx jamo codepoints, U+11xx jamo
characters, or HCJ are valid inputs.
Outputs a one-character jamo string.
"""
# Internally, we convert everything to a jamo char,
# then pass it to _... | [
"Return",
"the",
"compound",
"jamo",
"for",
"the",
"given",
"jamo",
"input",
".",
"Integers",
"corresponding",
"to",
"U",
"+",
"11xx",
"jamo",
"codepoints",
"U",
"+",
"11xx",
"jamo",
"characters",
"or",
"HCJ",
"are",
"valid",
"inputs",
"."
] | JDongian/python-jamo | python | https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L328-L350 | [
"def",
"compose_jamo",
"(",
"*",
"parts",
")",
":",
"# Internally, we convert everything to a jamo char,",
"# then pass it to _jamo_to_hangul_char",
"# NOTE: Relies on hcj_to_jamo not strictly requiring \"position\" arg.",
"for",
"p",
"in",
"parts",
":",
"if",
"not",
"(",
"type",... | d087a9f5f52f066fb933ad1da8e9915703374c9a |
train | synth_hangul | Convert jamo characters in a string into hcj as much as possible. | jamo/jamo.py | def synth_hangul(string):
"""Convert jamo characters in a string into hcj as much as possible."""
raise NotImplementedError
return ''.join([''.join(''.join(jamo_to_hcj(_)) for _ in string)]) | def synth_hangul(string):
"""Convert jamo characters in a string into hcj as much as possible."""
raise NotImplementedError
return ''.join([''.join(''.join(jamo_to_hcj(_)) for _ in string)]) | [
"Convert",
"jamo",
"characters",
"in",
"a",
"string",
"into",
"hcj",
"as",
"much",
"as",
"possible",
"."
] | JDongian/python-jamo | python | https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L353-L356 | [
"def",
"synth_hangul",
"(",
"string",
")",
":",
"raise",
"NotImplementedError",
"return",
"''",
".",
"join",
"(",
"[",
"''",
".",
"join",
"(",
"''",
".",
"join",
"(",
"jamo_to_hcj",
"(",
"_",
")",
")",
"for",
"_",
"in",
"string",
")",
"]",
")"
] | d087a9f5f52f066fb933ad1da8e9915703374c9a |
train | authorization_error_class | Return an exception instance that maps to the OAuth Error.
:param response: The HTTP response containing a www-authenticate error. | prawcore/util.py | def authorization_error_class(response):
"""Return an exception instance that maps to the OAuth Error.
:param response: The HTTP response containing a www-authenticate error.
"""
message = response.headers.get("www-authenticate")
if message:
error = message.replace('"', "").rsplit("=", 1)[... | def authorization_error_class(response):
"""Return an exception instance that maps to the OAuth Error.
:param response: The HTTP response containing a www-authenticate error.
"""
message = response.headers.get("www-authenticate")
if message:
error = message.replace('"', "").rsplit("=", 1)[... | [
"Return",
"an",
"exception",
"instance",
"that",
"maps",
"to",
"the",
"OAuth",
"Error",
"."
] | praw-dev/prawcore | python | https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/util.py#L12-L23 | [
"def",
"authorization_error_class",
"(",
"response",
")",
":",
"message",
"=",
"response",
".",
"headers",
".",
"get",
"(",
"\"www-authenticate\"",
")",
"if",
"message",
":",
"error",
"=",
"message",
".",
"replace",
"(",
"'\"'",
",",
"\"\"",
")",
".",
"rsp... | b16ae88a1f2bf98095ed6fe64851cb7add7ed752 |
train | _last_bookmark | Return the latest of two bookmarks by looking for the maximum
integer value following the last colon in the bookmark string. | neobolt/impl/python/direct.py | def _last_bookmark(b0, b1):
""" Return the latest of two bookmarks by looking for the maximum
integer value following the last colon in the bookmark string.
"""
n = [None, None]
_, _, n[0] = b0.rpartition(":")
_, _, n[1] = b1.rpartition(":")
for i in range(2):
try:
n[i] =... | def _last_bookmark(b0, b1):
""" Return the latest of two bookmarks by looking for the maximum
integer value following the last colon in the bookmark string.
"""
n = [None, None]
_, _, n[0] = b0.rpartition(":")
_, _, n[1] = b1.rpartition(":")
for i in range(2):
try:
n[i] =... | [
"Return",
"the",
"latest",
"of",
"two",
"bookmarks",
"by",
"looking",
"for",
"the",
"maximum",
"integer",
"value",
"following",
"the",
"last",
"colon",
"in",
"the",
"bookmark",
"string",
"."
] | neo4j-drivers/neobolt | python | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L705-L717 | [
"def",
"_last_bookmark",
"(",
"b0",
",",
"b1",
")",
":",
"n",
"=",
"[",
"None",
",",
"None",
"]",
"_",
",",
"_",
",",
"n",
"[",
"0",
"]",
"=",
"b0",
".",
"rpartition",
"(",
"\":\"",
")",
"_",
",",
"_",
",",
"n",
"[",
"1",
"]",
"=",
"b1",
... | 724569d76e85777c4f5e30e8d0a18116bda4d8cd |
train | last_bookmark | The bookmark returned by the last :class:`.Transaction`. | neobolt/impl/python/direct.py | def last_bookmark(bookmarks):
""" The bookmark returned by the last :class:`.Transaction`.
"""
last = None
for bookmark in bookmarks:
if last is None:
last = bookmark
else:
last = _last_bookmark(last, bookmark)
return last | def last_bookmark(bookmarks):
""" The bookmark returned by the last :class:`.Transaction`.
"""
last = None
for bookmark in bookmarks:
if last is None:
last = bookmark
else:
last = _last_bookmark(last, bookmark)
return last | [
"The",
"bookmark",
"returned",
"by",
"the",
"last",
":",
"class",
":",
".",
"Transaction",
"."
] | neo4j-drivers/neobolt | python | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L721-L730 | [
"def",
"last_bookmark",
"(",
"bookmarks",
")",
":",
"last",
"=",
"None",
"for",
"bookmark",
"in",
"bookmarks",
":",
"if",
"last",
"is",
"None",
":",
"last",
"=",
"bookmark",
"else",
":",
"last",
"=",
"_last_bookmark",
"(",
"last",
",",
"bookmark",
")",
... | 724569d76e85777c4f5e30e8d0a18116bda4d8cd |
train | connect | Connect and perform a handshake and return a valid Connection object, assuming
a protocol version can be agreed. | neobolt/impl/python/direct.py | def connect(address, **config):
""" Connect and perform a handshake and return a valid Connection object, assuming
a protocol version can be agreed.
"""
ssl_context = make_ssl_context(**config)
last_error = None
# Establish a connection to the host and port specified
# Catches refused connec... | def connect(address, **config):
""" Connect and perform a handshake and return a valid Connection object, assuming
a protocol version can be agreed.
"""
ssl_context = make_ssl_context(**config)
last_error = None
# Establish a connection to the host and port specified
# Catches refused connec... | [
"Connect",
"and",
"perform",
"a",
"handshake",
"and",
"return",
"a",
"valid",
"Connection",
"object",
"assuming",
"a",
"protocol",
"version",
"can",
"be",
"agreed",
"."
] | neo4j-drivers/neobolt | python | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L858-L884 | [
"def",
"connect",
"(",
"address",
",",
"*",
"*",
"config",
")",
":",
"ssl_context",
"=",
"make_ssl_context",
"(",
"*",
"*",
"config",
")",
"last_error",
"=",
"None",
"# Establish a connection to the host and port specified",
"# Catches refused connections see:",
"# http... | 724569d76e85777c4f5e30e8d0a18116bda4d8cd |
train | Connection._append | Add a message to the outgoing queue.
:arg signature: the signature of the message
:arg fields: the fields of the message as a tuple
:arg response: a response object to handle callbacks | neobolt/impl/python/direct.py | def _append(self, signature, fields=(), response=None):
""" Add a message to the outgoing queue.
:arg signature: the signature of the message
:arg fields: the fields of the message as a tuple
:arg response: a response object to handle callbacks
"""
self.packer.pack_struc... | def _append(self, signature, fields=(), response=None):
""" Add a message to the outgoing queue.
:arg signature: the signature of the message
:arg fields: the fields of the message as a tuple
:arg response: a response object to handle callbacks
"""
self.packer.pack_struc... | [
"Add",
"a",
"message",
"to",
"the",
"outgoing",
"queue",
"."
] | neo4j-drivers/neobolt | python | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L288-L298 | [
"def",
"_append",
"(",
"self",
",",
"signature",
",",
"fields",
"=",
"(",
")",
",",
"response",
"=",
"None",
")",
":",
"self",
".",
"packer",
".",
"pack_struct",
"(",
"signature",
",",
"fields",
")",
"self",
".",
"output_buffer",
".",
"chunk",
"(",
"... | 724569d76e85777c4f5e30e8d0a18116bda4d8cd |
train | Connection.reset | Add a RESET message to the outgoing queue, send
it and consume all remaining messages. | neobolt/impl/python/direct.py | def reset(self):
""" Add a RESET message to the outgoing queue, send
it and consume all remaining messages.
"""
def fail(metadata):
raise ProtocolError("RESET failed %r" % metadata)
log_debug("[#%04X] C: RESET", self.local_port)
self._append(b"\x0F", respon... | def reset(self):
""" Add a RESET message to the outgoing queue, send
it and consume all remaining messages.
"""
def fail(metadata):
raise ProtocolError("RESET failed %r" % metadata)
log_debug("[#%04X] C: RESET", self.local_port)
self._append(b"\x0F", respon... | [
"Add",
"a",
"RESET",
"message",
"to",
"the",
"outgoing",
"queue",
"send",
"it",
"and",
"consume",
"all",
"remaining",
"messages",
"."
] | neo4j-drivers/neobolt | python | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L300-L310 | [
"def",
"reset",
"(",
"self",
")",
":",
"def",
"fail",
"(",
"metadata",
")",
":",
"raise",
"ProtocolError",
"(",
"\"RESET failed %r\"",
"%",
"metadata",
")",
"log_debug",
"(",
"\"[#%04X] C: RESET\"",
",",
"self",
".",
"local_port",
")",
"self",
".",
"_append... | 724569d76e85777c4f5e30e8d0a18116bda4d8cd |
train | Connection._send | Send all queued messages to the server. | neobolt/impl/python/direct.py | def _send(self):
""" Send all queued messages to the server.
"""
data = self.output_buffer.view()
if not data:
return
if self.closed():
raise self.Error("Failed to write to closed connection {!r}".format(self.server.address))
if self.defunct():
... | def _send(self):
""" Send all queued messages to the server.
"""
data = self.output_buffer.view()
if not data:
return
if self.closed():
raise self.Error("Failed to write to closed connection {!r}".format(self.server.address))
if self.defunct():
... | [
"Send",
"all",
"queued",
"messages",
"to",
"the",
"server",
"."
] | neo4j-drivers/neobolt | python | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L320-L331 | [
"def",
"_send",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"output_buffer",
".",
"view",
"(",
")",
"if",
"not",
"data",
":",
"return",
"if",
"self",
".",
"closed",
"(",
")",
":",
"raise",
"self",
".",
"Error",
"(",
"\"Failed to write to closed co... | 724569d76e85777c4f5e30e8d0a18116bda4d8cd |
train | Connection._fetch | Receive at least one message from the server, if available.
:return: 2-tuple of number of detail messages and number of summary messages fetched | neobolt/impl/python/direct.py | def _fetch(self):
""" Receive at least one message from the server, if available.
:return: 2-tuple of number of detail messages and number of summary messages fetched
"""
if self.closed():
raise self.Error("Failed to read from closed connection {!r}".format(self.server.addre... | def _fetch(self):
""" Receive at least one message from the server, if available.
:return: 2-tuple of number of detail messages and number of summary messages fetched
"""
if self.closed():
raise self.Error("Failed to read from closed connection {!r}".format(self.server.addre... | [
"Receive",
"at",
"least",
"one",
"message",
"from",
"the",
"server",
"if",
"available",
"."
] | neo4j-drivers/neobolt | python | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L341-L381 | [
"def",
"_fetch",
"(",
"self",
")",
":",
"if",
"self",
".",
"closed",
"(",
")",
":",
"raise",
"self",
".",
"Error",
"(",
"\"Failed to read from closed connection {!r}\"",
".",
"format",
"(",
"self",
".",
"server",
".",
"address",
")",
")",
"if",
"self",
"... | 724569d76e85777c4f5e30e8d0a18116bda4d8cd |
train | Connection.sync | Send and fetch all outstanding messages.
:return: 2-tuple of number of detail messages and number of summary messages fetched | neobolt/impl/python/direct.py | def sync(self):
""" Send and fetch all outstanding messages.
:return: 2-tuple of number of detail messages and number of summary messages fetched
"""
self.send()
detail_count = summary_count = 0
while self.responses:
response = self.responses[0]
w... | def sync(self):
""" Send and fetch all outstanding messages.
:return: 2-tuple of number of detail messages and number of summary messages fetched
"""
self.send()
detail_count = summary_count = 0
while self.responses:
response = self.responses[0]
w... | [
"Send",
"and",
"fetch",
"all",
"outstanding",
"messages",
"."
] | neo4j-drivers/neobolt | python | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L431-L444 | [
"def",
"sync",
"(",
"self",
")",
":",
"self",
".",
"send",
"(",
")",
"detail_count",
"=",
"summary_count",
"=",
"0",
"while",
"self",
".",
"responses",
":",
"response",
"=",
"self",
".",
"responses",
"[",
"0",
"]",
"while",
"not",
"response",
".",
"c... | 724569d76e85777c4f5e30e8d0a18116bda4d8cd |
train | Connection.close | Close the connection. | neobolt/impl/python/direct.py | def close(self):
""" Close the connection.
"""
if not self._closed:
if self.protocol_version >= 3:
log_debug("[#%04X] C: GOODBYE", self.local_port)
self._append(b"\x02", ())
try:
self.send()
except S... | def close(self):
""" Close the connection.
"""
if not self._closed:
if self.protocol_version >= 3:
log_debug("[#%04X] C: GOODBYE", self.local_port)
self._append(b"\x02", ())
try:
self.send()
except S... | [
"Close",
"the",
"connection",
"."
] | neo4j-drivers/neobolt | python | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L446-L463 | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_closed",
":",
"if",
"self",
".",
"protocol_version",
">=",
"3",
":",
"log_debug",
"(",
"\"[#%04X] C: GOODBYE\"",
",",
"self",
".",
"local_port",
")",
"self",
".",
"_append",
"(",
"b\"\\x... | 724569d76e85777c4f5e30e8d0a18116bda4d8cd |
train | AbstractConnectionPool.acquire_direct | Acquire a connection to a given address from the pool.
The address supplied should always be an IP address, not
a host name.
This method is thread safe. | neobolt/impl/python/direct.py | def acquire_direct(self, address):
""" Acquire a connection to a given address from the pool.
The address supplied should always be an IP address, not
a host name.
This method is thread safe.
"""
if self.closed():
raise ServiceUnavailable("Connection pool clo... | def acquire_direct(self, address):
""" Acquire a connection to a given address from the pool.
The address supplied should always be an IP address, not
a host name.
This method is thread safe.
"""
if self.closed():
raise ServiceUnavailable("Connection pool clo... | [
"Acquire",
"a",
"connection",
"to",
"a",
"given",
"address",
"from",
"the",
"pool",
".",
"The",
"address",
"supplied",
"should",
"always",
"be",
"an",
"IP",
"address",
"not",
"a",
"host",
"name",
"."
] | neo4j-drivers/neobolt | python | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L492-L543 | [
"def",
"acquire_direct",
"(",
"self",
",",
"address",
")",
":",
"if",
"self",
".",
"closed",
"(",
")",
":",
"raise",
"ServiceUnavailable",
"(",
"\"Connection pool closed\"",
")",
"with",
"self",
".",
"lock",
":",
"try",
":",
"connections",
"=",
"self",
"."... | 724569d76e85777c4f5e30e8d0a18116bda4d8cd |
train | AbstractConnectionPool.release | Release a connection back into the pool.
This method is thread safe. | neobolt/impl/python/direct.py | def release(self, connection):
""" Release a connection back into the pool.
This method is thread safe.
"""
with self.lock:
connection.in_use = False
self.cond.notify_all() | def release(self, connection):
""" Release a connection back into the pool.
This method is thread safe.
"""
with self.lock:
connection.in_use = False
self.cond.notify_all() | [
"Release",
"a",
"connection",
"back",
"into",
"the",
"pool",
".",
"This",
"method",
"is",
"thread",
"safe",
"."
] | neo4j-drivers/neobolt | python | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L551-L557 | [
"def",
"release",
"(",
"self",
",",
"connection",
")",
":",
"with",
"self",
".",
"lock",
":",
"connection",
".",
"in_use",
"=",
"False",
"self",
".",
"cond",
".",
"notify_all",
"(",
")"
] | 724569d76e85777c4f5e30e8d0a18116bda4d8cd |
train | AbstractConnectionPool.in_use_connection_count | Count the number of connections currently in use to a given
address. | neobolt/impl/python/direct.py | def in_use_connection_count(self, address):
""" Count the number of connections currently in use to a given
address.
"""
try:
connections = self.connections[address]
except KeyError:
return 0
else:
return sum(1 if connection.in_use else... | def in_use_connection_count(self, address):
""" Count the number of connections currently in use to a given
address.
"""
try:
connections = self.connections[address]
except KeyError:
return 0
else:
return sum(1 if connection.in_use else... | [
"Count",
"the",
"number",
"of",
"connections",
"currently",
"in",
"use",
"to",
"a",
"given",
"address",
"."
] | neo4j-drivers/neobolt | python | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L559-L568 | [
"def",
"in_use_connection_count",
"(",
"self",
",",
"address",
")",
":",
"try",
":",
"connections",
"=",
"self",
".",
"connections",
"[",
"address",
"]",
"except",
"KeyError",
":",
"return",
"0",
"else",
":",
"return",
"sum",
"(",
"1",
"if",
"connection",
... | 724569d76e85777c4f5e30e8d0a18116bda4d8cd |
train | AbstractConnectionPool.deactivate | Deactivate an address from the connection pool, if present, closing
all idle connection to that address | neobolt/impl/python/direct.py | def deactivate(self, address):
""" Deactivate an address from the connection pool, if present, closing
all idle connection to that address
"""
with self.lock:
try:
connections = self.connections[address]
except KeyError: # already removed from the ... | def deactivate(self, address):
""" Deactivate an address from the connection pool, if present, closing
all idle connection to that address
"""
with self.lock:
try:
connections = self.connections[address]
except KeyError: # already removed from the ... | [
"Deactivate",
"an",
"address",
"from",
"the",
"connection",
"pool",
"if",
"present",
"closing",
"all",
"idle",
"connection",
"to",
"that",
"address"
] | neo4j-drivers/neobolt | python | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L570-L587 | [
"def",
"deactivate",
"(",
"self",
",",
"address",
")",
":",
"with",
"self",
".",
"lock",
":",
"try",
":",
"connections",
"=",
"self",
".",
"connections",
"[",
"address",
"]",
"except",
"KeyError",
":",
"# already removed from the connection pool",
"return",
"f... | 724569d76e85777c4f5e30e8d0a18116bda4d8cd |
train | AbstractConnectionPool.remove | Remove an address from the connection pool, if present, closing
all connections to that address. | neobolt/impl/python/direct.py | def remove(self, address):
""" Remove an address from the connection pool, if present, closing
all connections to that address.
"""
with self.lock:
for connection in self.connections.pop(address, ()):
try:
connection.close()
... | def remove(self, address):
""" Remove an address from the connection pool, if present, closing
all connections to that address.
"""
with self.lock:
for connection in self.connections.pop(address, ()):
try:
connection.close()
... | [
"Remove",
"an",
"address",
"from",
"the",
"connection",
"pool",
"if",
"present",
"closing",
"all",
"connections",
"to",
"that",
"address",
"."
] | neo4j-drivers/neobolt | python | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L589-L598 | [
"def",
"remove",
"(",
"self",
",",
"address",
")",
":",
"with",
"self",
".",
"lock",
":",
"for",
"connection",
"in",
"self",
".",
"connections",
".",
"pop",
"(",
"address",
",",
"(",
")",
")",
":",
"try",
":",
"connection",
".",
"close",
"(",
")",
... | 724569d76e85777c4f5e30e8d0a18116bda4d8cd |
train | AbstractConnectionPool.close | Close all connections and empty the pool.
This method is thread safe. | neobolt/impl/python/direct.py | def close(self):
""" Close all connections and empty the pool.
This method is thread safe.
"""
if self._closed:
return
try:
with self.lock:
if not self._closed:
self._closed = True
for address in list... | def close(self):
""" Close all connections and empty the pool.
This method is thread safe.
"""
if self._closed:
return
try:
with self.lock:
if not self._closed:
self._closed = True
for address in list... | [
"Close",
"all",
"connections",
"and",
"empty",
"the",
"pool",
".",
"This",
"method",
"is",
"thread",
"safe",
"."
] | neo4j-drivers/neobolt | python | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L600-L613 | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_closed",
":",
"return",
"try",
":",
"with",
"self",
".",
"lock",
":",
"if",
"not",
"self",
".",
"_closed",
":",
"self",
".",
"_closed",
"=",
"True",
"for",
"address",
"in",
"list",
"(",
... | 724569d76e85777c4f5e30e8d0a18116bda4d8cd |
train | Response.on_records | Called when one or more RECORD messages have been received. | neobolt/impl/python/direct.py | def on_records(self, records):
""" Called when one or more RECORD messages have been received.
"""
handler = self.handlers.get("on_records")
if callable(handler):
handler(records) | def on_records(self, records):
""" Called when one or more RECORD messages have been received.
"""
handler = self.handlers.get("on_records")
if callable(handler):
handler(records) | [
"Called",
"when",
"one",
"or",
"more",
"RECORD",
"messages",
"have",
"been",
"received",
"."
] | neo4j-drivers/neobolt | python | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L648-L653 | [
"def",
"on_records",
"(",
"self",
",",
"records",
")",
":",
"handler",
"=",
"self",
".",
"handlers",
".",
"get",
"(",
"\"on_records\"",
")",
"if",
"callable",
"(",
"handler",
")",
":",
"handler",
"(",
"records",
")"
] | 724569d76e85777c4f5e30e8d0a18116bda4d8cd |
train | Response.on_success | Called when a SUCCESS message has been received. | neobolt/impl/python/direct.py | def on_success(self, metadata):
""" Called when a SUCCESS message has been received.
"""
handler = self.handlers.get("on_success")
if callable(handler):
handler(metadata)
handler = self.handlers.get("on_summary")
if callable(handler):
handler() | def on_success(self, metadata):
""" Called when a SUCCESS message has been received.
"""
handler = self.handlers.get("on_success")
if callable(handler):
handler(metadata)
handler = self.handlers.get("on_summary")
if callable(handler):
handler() | [
"Called",
"when",
"a",
"SUCCESS",
"message",
"has",
"been",
"received",
"."
] | neo4j-drivers/neobolt | python | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L655-L663 | [
"def",
"on_success",
"(",
"self",
",",
"metadata",
")",
":",
"handler",
"=",
"self",
".",
"handlers",
".",
"get",
"(",
"\"on_success\"",
")",
"if",
"callable",
"(",
"handler",
")",
":",
"handler",
"(",
"metadata",
")",
"handler",
"=",
"self",
".",
"han... | 724569d76e85777c4f5e30e8d0a18116bda4d8cd |
train | Response.on_failure | Called when a FAILURE message has been received. | neobolt/impl/python/direct.py | def on_failure(self, metadata):
""" Called when a FAILURE message has been received.
"""
self.connection.reset()
handler = self.handlers.get("on_failure")
if callable(handler):
handler(metadata)
handler = self.handlers.get("on_summary")
if callable(han... | def on_failure(self, metadata):
""" Called when a FAILURE message has been received.
"""
self.connection.reset()
handler = self.handlers.get("on_failure")
if callable(handler):
handler(metadata)
handler = self.handlers.get("on_summary")
if callable(han... | [
"Called",
"when",
"a",
"FAILURE",
"message",
"has",
"been",
"received",
"."
] | neo4j-drivers/neobolt | python | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L665-L675 | [
"def",
"on_failure",
"(",
"self",
",",
"metadata",
")",
":",
"self",
".",
"connection",
".",
"reset",
"(",
")",
"handler",
"=",
"self",
".",
"handlers",
".",
"get",
"(",
"\"on_failure\"",
")",
"if",
"callable",
"(",
"handler",
")",
":",
"handler",
"(",... | 724569d76e85777c4f5e30e8d0a18116bda4d8cd |
train | Response.on_ignored | Called when an IGNORED message has been received. | neobolt/impl/python/direct.py | def on_ignored(self, metadata=None):
""" Called when an IGNORED message has been received.
"""
handler = self.handlers.get("on_ignored")
if callable(handler):
handler(metadata)
handler = self.handlers.get("on_summary")
if callable(handler):
handler... | def on_ignored(self, metadata=None):
""" Called when an IGNORED message has been received.
"""
handler = self.handlers.get("on_ignored")
if callable(handler):
handler(metadata)
handler = self.handlers.get("on_summary")
if callable(handler):
handler... | [
"Called",
"when",
"an",
"IGNORED",
"message",
"has",
"been",
"received",
"."
] | neo4j-drivers/neobolt | python | https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/direct.py#L677-L685 | [
"def",
"on_ignored",
"(",
"self",
",",
"metadata",
"=",
"None",
")",
":",
"handler",
"=",
"self",
".",
"handlers",
".",
"get",
"(",
"\"on_ignored\"",
")",
"if",
"callable",
"(",
"handler",
")",
":",
"handler",
"(",
"metadata",
")",
"handler",
"=",
"sel... | 724569d76e85777c4f5e30e8d0a18116bda4d8cd |
train | cached_property | A replacement for the property decorator that will only compute the
attribute's value on the first call and serve a cached copy from
then on. | hnmp.py | def cached_property(prop):
"""
A replacement for the property decorator that will only compute the
attribute's value on the first call and serve a cached copy from
then on.
"""
def cache_wrapper(self):
if not hasattr(self, "_cache"):
self._cache = {}
if prop.__name__ ... | def cached_property(prop):
"""
A replacement for the property decorator that will only compute the
attribute's value on the first call and serve a cached copy from
then on.
"""
def cache_wrapper(self):
if not hasattr(self, "_cache"):
self._cache = {}
if prop.__name__ ... | [
"A",
"replacement",
"for",
"the",
"property",
"decorator",
"that",
"will",
"only",
"compute",
"the",
"attribute",
"s",
"value",
"on",
"the",
"first",
"call",
"and",
"serve",
"a",
"cached",
"copy",
"from",
"then",
"on",
"."
] | trehn/hnmp | python | https://github.com/trehn/hnmp/blob/a21f9e73c96a35bff2354894031c4788ad4ed2f0/hnmp.py#L47-L62 | [
"def",
"cached_property",
"(",
"prop",
")",
":",
"def",
"cache_wrapper",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"_cache\"",
")",
":",
"self",
".",
"_cache",
"=",
"{",
"}",
"if",
"prop",
".",
"__name__",
"not",
"in",
"self"... | a21f9e73c96a35bff2354894031c4788ad4ed2f0 |
train | _convert_value_to_native | Converts pysnmp objects into native Python objects. | hnmp.py | def _convert_value_to_native(value):
"""
Converts pysnmp objects into native Python objects.
"""
if isinstance(value, Counter32):
return int(value.prettyPrint())
if isinstance(value, Counter64):
return int(value.prettyPrint())
if isinstance(value, Gauge32):
return int(val... | def _convert_value_to_native(value):
"""
Converts pysnmp objects into native Python objects.
"""
if isinstance(value, Counter32):
return int(value.prettyPrint())
if isinstance(value, Counter64):
return int(value.prettyPrint())
if isinstance(value, Gauge32):
return int(val... | [
"Converts",
"pysnmp",
"objects",
"into",
"native",
"Python",
"objects",
"."
] | trehn/hnmp | python | https://github.com/trehn/hnmp/blob/a21f9e73c96a35bff2354894031c4788ad4ed2f0/hnmp.py#L65-L90 | [
"def",
"_convert_value_to_native",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"Counter32",
")",
":",
"return",
"int",
"(",
"value",
".",
"prettyPrint",
"(",
")",
")",
"if",
"isinstance",
"(",
"value",
",",
"Counter64",
")",
":",
"retu... | a21f9e73c96a35bff2354894031c4788ad4ed2f0 |
train | SNMP.get | Get a single OID value. | hnmp.py | def get(self, oid):
"""
Get a single OID value.
"""
snmpsecurity = self._get_snmp_security()
try:
engine_error, pdu_error, pdu_error_index, objects = self._cmdgen.getCmd(
snmpsecurity,
cmdgen.UdpTransportTarget((self.host, self.port), ... | def get(self, oid):
"""
Get a single OID value.
"""
snmpsecurity = self._get_snmp_security()
try:
engine_error, pdu_error, pdu_error_index, objects = self._cmdgen.getCmd(
snmpsecurity,
cmdgen.UdpTransportTarget((self.host, self.port), ... | [
"Get",
"a",
"single",
"OID",
"value",
"."
] | trehn/hnmp | python | https://github.com/trehn/hnmp/blob/a21f9e73c96a35bff2354894031c4788ad4ed2f0/hnmp.py#L178-L201 | [
"def",
"get",
"(",
"self",
",",
"oid",
")",
":",
"snmpsecurity",
"=",
"self",
".",
"_get_snmp_security",
"(",
")",
"try",
":",
"engine_error",
",",
"pdu_error",
",",
"pdu_error_index",
",",
"objects",
"=",
"self",
".",
"_cmdgen",
".",
"getCmd",
"(",
"snm... | a21f9e73c96a35bff2354894031c4788ad4ed2f0 |
train | SNMP.set | Sets a single OID value. If you do not pass value_type hnmp will
try to guess the correct type. Autodetection is supported for:
* int and float (as Integer, fractional part will be discarded)
* IPv4 address (as IpAddress)
* str (as OctetString)
Unfortunately, pysnmp does not su... | hnmp.py | def set(self, oid, value, value_type=None):
"""
Sets a single OID value. If you do not pass value_type hnmp will
try to guess the correct type. Autodetection is supported for:
* int and float (as Integer, fractional part will be discarded)
* IPv4 address (as IpAddress)
*... | def set(self, oid, value, value_type=None):
"""
Sets a single OID value. If you do not pass value_type hnmp will
try to guess the correct type. Autodetection is supported for:
* int and float (as Integer, fractional part will be discarded)
* IPv4 address (as IpAddress)
*... | [
"Sets",
"a",
"single",
"OID",
"value",
".",
"If",
"you",
"do",
"not",
"pass",
"value_type",
"hnmp",
"will",
"try",
"to",
"guess",
"the",
"correct",
"type",
".",
"Autodetection",
"is",
"supported",
"for",
":"
] | trehn/hnmp | python | https://github.com/trehn/hnmp/blob/a21f9e73c96a35bff2354894031c4788ad4ed2f0/hnmp.py#L203-L257 | [
"def",
"set",
"(",
"self",
",",
"oid",
",",
"value",
",",
"value_type",
"=",
"None",
")",
":",
"snmpsecurity",
"=",
"self",
".",
"_get_snmp_security",
"(",
")",
"if",
"value_type",
"is",
"None",
":",
"if",
"isinstance",
"(",
"value",
",",
"int",
")",
... | a21f9e73c96a35bff2354894031c4788ad4ed2f0 |
train | SNMP.table | Get a table of values with the given OID prefix. | hnmp.py | def table(self, oid, columns=None, column_value_mapping=None, non_repeaters=0,
max_repetitions=20, fetch_all_columns=True):
"""
Get a table of values with the given OID prefix.
"""
snmpsecurity = self._get_snmp_security()
base_oid = oid.strip(".")
if not fe... | def table(self, oid, columns=None, column_value_mapping=None, non_repeaters=0,
max_repetitions=20, fetch_all_columns=True):
"""
Get a table of values with the given OID prefix.
"""
snmpsecurity = self._get_snmp_security()
base_oid = oid.strip(".")
if not fe... | [
"Get",
"a",
"table",
"of",
"values",
"with",
"the",
"given",
"OID",
"prefix",
"."
] | trehn/hnmp | python | https://github.com/trehn/hnmp/blob/a21f9e73c96a35bff2354894031c4788ad4ed2f0/hnmp.py#L259-L317 | [
"def",
"table",
"(",
"self",
",",
"oid",
",",
"columns",
"=",
"None",
",",
"column_value_mapping",
"=",
"None",
",",
"non_repeaters",
"=",
"0",
",",
"max_repetitions",
"=",
"20",
",",
"fetch_all_columns",
"=",
"True",
")",
":",
"snmpsecurity",
"=",
"self",... | a21f9e73c96a35bff2354894031c4788ad4ed2f0 |
train | get_parser | Load parser for command line arguments.
It parses argv/input into args variable. | auto_py_torrent/auto_py_torrent.py | def get_parser():
"""Load parser for command line arguments.
It parses argv/input into args variable.
"""
desc = Colors.LIGHTBLUE + textwrap.dedent(
'''\
Welcome to
_ _ _
__ _ _ _| |_ ___ _ __ ... | def get_parser():
"""Load parser for command line arguments.
It parses argv/input into args variable.
"""
desc = Colors.LIGHTBLUE + textwrap.dedent(
'''\
Welcome to
_ _ _
__ _ _ _| |_ ___ _ __ ... | [
"Load",
"parser",
"for",
"command",
"line",
"arguments",
"."
] | ocslegna/auto_py_torrent | python | https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L98-L174 | [
"def",
"get_parser",
"(",
")",
":",
"desc",
"=",
"Colors",
".",
"LIGHTBLUE",
"+",
"textwrap",
".",
"dedent",
"(",
"'''\\\n Welcome to\n _ _ _\n __ _ _ _| |_ ___ _ __ _ _ | |_ ___ _ _... | 32761fe18b3112e6e3754da863488b50929fcc41 |
train | insert | Insert args values into instance variables. | auto_py_torrent/auto_py_torrent.py | def insert(args):
"""Insert args values into instance variables."""
string_search = args.str_search
mode_search = MODES[args.mode]
page = list(TORRENTS[args.torr_page].keys())[0]
key_search = TORRENTS[args.torr_page][page]['key_search']
torrent_page = TORRENTS[args.torr_page][page]['page']
d... | def insert(args):
"""Insert args values into instance variables."""
string_search = args.str_search
mode_search = MODES[args.mode]
page = list(TORRENTS[args.torr_page].keys())[0]
key_search = TORRENTS[args.torr_page][page]['key_search']
torrent_page = TORRENTS[args.torr_page][page]['page']
d... | [
"Insert",
"args",
"values",
"into",
"instance",
"variables",
"."
] | ocslegna/auto_py_torrent | python | https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L579-L588 | [
"def",
"insert",
"(",
"args",
")",
":",
"string_search",
"=",
"args",
".",
"str_search",
"mode_search",
"=",
"MODES",
"[",
"args",
".",
"mode",
"]",
"page",
"=",
"list",
"(",
"TORRENTS",
"[",
"args",
".",
"torr_page",
"]",
".",
"keys",
"(",
")",
")",... | 32761fe18b3112e6e3754da863488b50929fcc41 |
train | run_it | Search and download torrents until the user says it so. | auto_py_torrent/auto_py_torrent.py | def run_it():
"""Search and download torrents until the user says it so."""
initialize()
parser = get_parser()
args = None
first_parse = True
while(True):
if first_parse is True:
first_parse = False
args = parser.parse_args()
else:
print(textwr... | def run_it():
"""Search and download torrents until the user says it so."""
initialize()
parser = get_parser()
args = None
first_parse = True
while(True):
if first_parse is True:
first_parse = False
args = parser.parse_args()
else:
print(textwr... | [
"Search",
"and",
"download",
"torrents",
"until",
"the",
"user",
"says",
"it",
"so",
"."
] | ocslegna/auto_py_torrent | python | https://github.com/ocslegna/auto_py_torrent/blob/32761fe18b3112e6e3754da863488b50929fcc41/auto_py_torrent/auto_py_torrent.py#L596-L636 | [
"def",
"run_it",
"(",
")",
":",
"initialize",
"(",
")",
"parser",
"=",
"get_parser",
"(",
")",
"args",
"=",
"None",
"first_parse",
"=",
"True",
"while",
"(",
"True",
")",
":",
"if",
"first_parse",
"is",
"True",
":",
"first_parse",
"=",
"False",
"args",... | 32761fe18b3112e6e3754da863488b50929fcc41 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.