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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test | cli_auth | Authenticates and then outputs the resulting information.
See :py:mod:`swiftly.cli.auth` for context usage information.
See :py:class:`CLIAuth` for more information. | swiftly/cli/auth.py | def cli_auth(context):
"""
Authenticates and then outputs the resulting information.
See :py:mod:`swiftly.cli.auth` for context usage information.
See :py:class:`CLIAuth` for more information.
"""
with context.io_manager.with_stdout() as fp:
with context.client_manager.with_client() as... | def cli_auth(context):
"""
Authenticates and then outputs the resulting information.
See :py:mod:`swiftly.cli.auth` for context usage information.
See :py:class:`CLIAuth` for more information.
"""
with context.io_manager.with_stdout() as fp:
with context.client_manager.with_client() as... | [
"Authenticates",
"and",
"then",
"outputs",
"the",
"resulting",
"information",
"."
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/cli/auth.py#L32-L83 | [
"def",
"cli_auth",
"(",
"context",
")",
":",
"with",
"context",
".",
"io_manager",
".",
"with_stdout",
"(",
")",
"as",
"fp",
":",
"with",
"context",
".",
"client_manager",
".",
"with_client",
"(",
")",
"as",
"client",
":",
"info",
"=",
"[",
"]",
"clien... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | generate_temp_url | Returns a TempURL good for the given request method, url, and
number of seconds from now, signed by the given key. | swiftly/client/utils.py | def generate_temp_url(method, url, seconds, key):
"""
Returns a TempURL good for the given request method, url, and
number of seconds from now, signed by the given key.
"""
method = method.upper()
base_url, object_path = url.split('/v1/')
object_path = '/v1/' + object_path
expires = int(... | def generate_temp_url(method, url, seconds, key):
"""
Returns a TempURL good for the given request method, url, and
number of seconds from now, signed by the given key.
"""
method = method.upper()
base_url, object_path = url.split('/v1/')
object_path = '/v1/' + object_path
expires = int(... | [
"Returns",
"a",
"TempURL",
"good",
"for",
"the",
"given",
"request",
"method",
"url",
"and",
"number",
"of",
"seconds",
"from",
"now",
"signed",
"by",
"the",
"given",
"key",
"."
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/client/utils.py#L26-L38 | [
"def",
"generate_temp_url",
"(",
"method",
",",
"url",
",",
"seconds",
",",
"key",
")",
":",
"method",
"=",
"method",
".",
"upper",
"(",
")",
"base_url",
",",
"object_path",
"=",
"url",
".",
"split",
"(",
"'/v1/'",
")",
"object_path",
"=",
"'/v1/'",
"+... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | quote | Much like parse.quote in that it returns a URL encoded string
for the given value, protecting the safe characters; but this
version also ensures the value is UTF-8 encoded. | swiftly/client/utils.py | def quote(value, safe='/:'):
"""
Much like parse.quote in that it returns a URL encoded string
for the given value, protecting the safe characters; but this
version also ensures the value is UTF-8 encoded.
"""
if isinstance(value, six.text_type):
value = value.encode('utf8')
elif not... | def quote(value, safe='/:'):
"""
Much like parse.quote in that it returns a URL encoded string
for the given value, protecting the safe characters; but this
version also ensures the value is UTF-8 encoded.
"""
if isinstance(value, six.text_type):
value = value.encode('utf8')
elif not... | [
"Much",
"like",
"parse",
".",
"quote",
"in",
"that",
"it",
"returns",
"a",
"URL",
"encoded",
"string",
"for",
"the",
"given",
"value",
"protecting",
"the",
"safe",
"characters",
";",
"but",
"this",
"version",
"also",
"ensures",
"the",
"value",
"is",
"UTF",... | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/client/utils.py#L57-L67 | [
"def",
"quote",
"(",
"value",
",",
"safe",
"=",
"'/:'",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"six",
".",
"text_type",
")",
":",
"value",
"=",
"value",
".",
"encode",
"(",
"'utf8'",
")",
"elif",
"not",
"isinstance",
"(",
"value",
",",
"s... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | headers_to_dict | Converts a sequence of (name, value) tuples into a dict where if
a given name occurs more than once its value in the dict will be
a list of values. | swiftly/client/utils.py | def headers_to_dict(headers):
"""
Converts a sequence of (name, value) tuples into a dict where if
a given name occurs more than once its value in the dict will be
a list of values.
"""
hdrs = {}
for h, v in headers:
h = h.lower()
if h in hdrs:
if isinstance(hdrs[... | def headers_to_dict(headers):
"""
Converts a sequence of (name, value) tuples into a dict where if
a given name occurs more than once its value in the dict will be
a list of values.
"""
hdrs = {}
for h, v in headers:
h = h.lower()
if h in hdrs:
if isinstance(hdrs[... | [
"Converts",
"a",
"sequence",
"of",
"(",
"name",
"value",
")",
"tuples",
"into",
"a",
"dict",
"where",
"if",
"a",
"given",
"name",
"occurs",
"more",
"than",
"once",
"its",
"value",
"in",
"the",
"dict",
"will",
"be",
"a",
"list",
"of",
"values",
"."
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/client/utils.py#L70-L86 | [
"def",
"headers_to_dict",
"(",
"headers",
")",
":",
"hdrs",
"=",
"{",
"}",
"for",
"h",
",",
"v",
"in",
"headers",
":",
"h",
"=",
"h",
".",
"lower",
"(",
")",
"if",
"h",
"in",
"hdrs",
":",
"if",
"isinstance",
"(",
"hdrs",
"[",
"h",
"]",
",",
"... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | cli_fordo | Issues commands for each item in an account or container listing.
See :py:mod:`swiftly.cli.fordo` for context usage information.
See :py:class:`CLIForDo` for more information. | swiftly/cli/fordo.py | def cli_fordo(context, path=None):
"""
Issues commands for each item in an account or container listing.
See :py:mod:`swiftly.cli.fordo` for context usage information.
See :py:class:`CLIForDo` for more information.
"""
path = path.lstrip('/') if path else None
if path and '/' in path:
... | def cli_fordo(context, path=None):
"""
Issues commands for each item in an account or container listing.
See :py:mod:`swiftly.cli.fordo` for context usage information.
See :py:class:`CLIForDo` for more information.
"""
path = path.lstrip('/') if path else None
if path and '/' in path:
... | [
"Issues",
"commands",
"for",
"each",
"item",
"in",
"an",
"account",
"or",
"container",
"listing",
"."
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/cli/fordo.py#L71-L138 | [
"def",
"cli_fordo",
"(",
"context",
",",
"path",
"=",
"None",
")",
":",
"path",
"=",
"path",
".",
"lstrip",
"(",
"'/'",
")",
"if",
"path",
"else",
"None",
"if",
"path",
"and",
"'/'",
"in",
"path",
":",
"raise",
"ReturnCode",
"(",
"'path must be an empt... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | ClientManager.get_client | Obtains a client for use, whether an existing unused client
or a brand new one if none are available. | swiftly/client/manager.py | def get_client(self):
"""
Obtains a client for use, whether an existing unused client
or a brand new one if none are available.
"""
client = None
try:
client = self.clients.get(block=False)
except queue.Empty:
pass
if not client:
... | def get_client(self):
"""
Obtains a client for use, whether an existing unused client
or a brand new one if none are available.
"""
client = None
try:
client = self.clients.get(block=False)
except queue.Empty:
pass
if not client:
... | [
"Obtains",
"a",
"client",
"for",
"use",
"whether",
"an",
"existing",
"unused",
"client",
"or",
"a",
"brand",
"new",
"one",
"if",
"none",
"are",
"available",
"."
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/client/manager.py#L41-L57 | [
"def",
"get_client",
"(",
"self",
")",
":",
"client",
"=",
"None",
"try",
":",
"client",
"=",
"self",
".",
"clients",
".",
"get",
"(",
"block",
"=",
"False",
")",
"except",
"queue",
".",
"Empty",
":",
"pass",
"if",
"not",
"client",
":",
"self",
"."... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | cli_head | Performs a HEAD on the item (account, container, or object).
See :py:mod:`swiftly.cli.head` for context usage information.
See :py:class:`CLIHead` for more information. | swiftly/cli/head.py | def cli_head(context, path=None):
"""
Performs a HEAD on the item (account, container, or object).
See :py:mod:`swiftly.cli.head` for context usage information.
See :py:class:`CLIHead` for more information.
"""
path = path.lstrip('/') if path else None
with context.client_manager.with_clie... | def cli_head(context, path=None):
"""
Performs a HEAD on the item (account, container, or object).
See :py:mod:`swiftly.cli.head` for context usage information.
See :py:class:`CLIHead` for more information.
"""
path = path.lstrip('/') if path else None
with context.client_manager.with_clie... | [
"Performs",
"a",
"HEAD",
"on",
"the",
"item",
"(",
"account",
"container",
"or",
"object",
")",
"."
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/cli/head.py#L42-L82 | [
"def",
"cli_head",
"(",
"context",
",",
"path",
"=",
"None",
")",
":",
"path",
"=",
"path",
".",
"lstrip",
"(",
"'/'",
")",
"if",
"path",
"else",
"None",
"with",
"context",
".",
"client_manager",
".",
"with_client",
"(",
")",
"as",
"client",
":",
"if... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | aes_encrypt | Generator that encrypts a content stream using AES 256 in CBC
mode.
:param key: Any string to use as the encryption key.
:param stdin: Where to read the contents from.
:param preamble: str to yield initially useful for providing a
hint for future readers as to the algorithm in use.
:param c... | swiftly/dencrypt.py | def aes_encrypt(key, stdin, preamble=None, chunk_size=65536,
content_length=None):
"""
Generator that encrypts a content stream using AES 256 in CBC
mode.
:param key: Any string to use as the encryption key.
:param stdin: Where to read the contents from.
:param preamble: str to ... | def aes_encrypt(key, stdin, preamble=None, chunk_size=65536,
content_length=None):
"""
Generator that encrypts a content stream using AES 256 in CBC
mode.
:param key: Any string to use as the encryption key.
:param stdin: Where to read the contents from.
:param preamble: str to ... | [
"Generator",
"that",
"encrypts",
"a",
"content",
"stream",
"using",
"AES",
"256",
"in",
"CBC",
"mode",
"."
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/dencrypt.py#L35-L99 | [
"def",
"aes_encrypt",
"(",
"key",
",",
"stdin",
",",
"preamble",
"=",
"None",
",",
"chunk_size",
"=",
"65536",
",",
"content_length",
"=",
"None",
")",
":",
"if",
"not",
"AES256CBC_Support",
":",
"raise",
"Exception",
"(",
"'AES256CBC not supported; likely pycry... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | aes_decrypt | Generator that decrypts a content stream using AES 256 in CBC
mode.
:param key: Any string to use as the decryption key.
:param stdin: Where to read the encrypted data from.
:param chunk_size: Largest amount to read at once. | swiftly/dencrypt.py | def aes_decrypt(key, stdin, chunk_size=65536):
"""
Generator that decrypts a content stream using AES 256 in CBC
mode.
:param key: Any string to use as the decryption key.
:param stdin: Where to read the encrypted data from.
:param chunk_size: Largest amount to read at once.
"""
if not ... | def aes_decrypt(key, stdin, chunk_size=65536):
"""
Generator that decrypts a content stream using AES 256 in CBC
mode.
:param key: Any string to use as the decryption key.
:param stdin: Where to read the encrypted data from.
:param chunk_size: Largest amount to read at once.
"""
if not ... | [
"Generator",
"that",
"decrypts",
"a",
"content",
"stream",
"using",
"AES",
"256",
"in",
"CBC",
"mode",
"."
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/dencrypt.py#L102-L143 | [
"def",
"aes_decrypt",
"(",
"key",
",",
"stdin",
",",
"chunk_size",
"=",
"65536",
")",
":",
"if",
"not",
"AES256CBC_Support",
":",
"raise",
"Exception",
"(",
"'AES256CBC not supported; likely pycrypto is not installed'",
")",
"# Always use 256-bit key",
"key",
"=",
"ha... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | cli_put_directory_structure | Performs PUTs rooted at the path using a directory structure
pointed to by context.input\_.
See :py:mod:`swiftly.cli.put` for context usage information.
See :py:class:`CLIPut` for more information. | swiftly/cli/put.py | def cli_put_directory_structure(context, path):
"""
Performs PUTs rooted at the path using a directory structure
pointed to by context.input\_.
See :py:mod:`swiftly.cli.put` for context usage information.
See :py:class:`CLIPut` for more information.
"""
if not context.input_:
raise... | def cli_put_directory_structure(context, path):
"""
Performs PUTs rooted at the path using a directory structure
pointed to by context.input\_.
See :py:mod:`swiftly.cli.put` for context usage information.
See :py:class:`CLIPut` for more information.
"""
if not context.input_:
raise... | [
"Performs",
"PUTs",
"rooted",
"at",
"the",
"path",
"using",
"a",
"directory",
"structure",
"pointed",
"to",
"by",
"context",
".",
"input",
"\\",
"_",
"."
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/cli/put.py#L64-L130 | [
"def",
"cli_put_directory_structure",
"(",
"context",
",",
"path",
")",
":",
"if",
"not",
"context",
".",
"input_",
":",
"raise",
"ReturnCode",
"(",
"'called cli_put_directory_structure without context.input_ set'",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | cli_put_account | Performs a PUT on the account.
See :py:mod:`swiftly.cli.put` for context usage information.
See :py:class:`CLIPut` for more information. | swiftly/cli/put.py | def cli_put_account(context):
"""
Performs a PUT on the account.
See :py:mod:`swiftly.cli.put` for context usage information.
See :py:class:`CLIPut` for more information.
"""
body = None
if context.input_:
if context.input_ == '-':
body = context.io_manager.get_stdin()
... | def cli_put_account(context):
"""
Performs a PUT on the account.
See :py:mod:`swiftly.cli.put` for context usage information.
See :py:class:`CLIPut` for more information.
"""
body = None
if context.input_:
if context.input_ == '-':
body = context.io_manager.get_stdin()
... | [
"Performs",
"a",
"PUT",
"on",
"the",
"account",
"."
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/cli/put.py#L133-L154 | [
"def",
"cli_put_account",
"(",
"context",
")",
":",
"body",
"=",
"None",
"if",
"context",
".",
"input_",
":",
"if",
"context",
".",
"input_",
"==",
"'-'",
":",
"body",
"=",
"context",
".",
"io_manager",
".",
"get_stdin",
"(",
")",
"else",
":",
"body",
... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | cli_put_container | Performs a PUT on the container.
See :py:mod:`swiftly.cli.put` for context usage information.
See :py:class:`CLIPut` for more information. | swiftly/cli/put.py | def cli_put_container(context, path):
"""
Performs a PUT on the container.
See :py:mod:`swiftly.cli.put` for context usage information.
See :py:class:`CLIPut` for more information.
"""
path = path.rstrip('/')
if '/' in path:
raise ReturnCode('called cli_put_container with object %r... | def cli_put_container(context, path):
"""
Performs a PUT on the container.
See :py:mod:`swiftly.cli.put` for context usage information.
See :py:class:`CLIPut` for more information.
"""
path = path.rstrip('/')
if '/' in path:
raise ReturnCode('called cli_put_container with object %r... | [
"Performs",
"a",
"PUT",
"on",
"the",
"container",
"."
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/cli/put.py#L157-L182 | [
"def",
"cli_put_container",
"(",
"context",
",",
"path",
")",
":",
"path",
"=",
"path",
".",
"rstrip",
"(",
"'/'",
")",
"if",
"'/'",
"in",
"path",
":",
"raise",
"ReturnCode",
"(",
"'called cli_put_container with object %r'",
"%",
"path",
")",
"body",
"=",
... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | cli_put_object | Performs a PUT on the object.
See :py:mod:`swiftly.cli.put` for context usage information.
See :py:class:`CLIPut` for more information. | swiftly/cli/put.py | def cli_put_object(context, path):
"""
Performs a PUT on the object.
See :py:mod:`swiftly.cli.put` for context usage information.
See :py:class:`CLIPut` for more information.
"""
if context.different and context.encrypt:
raise ReturnCode(
'context.different will not work pr... | def cli_put_object(context, path):
"""
Performs a PUT on the object.
See :py:mod:`swiftly.cli.put` for context usage information.
See :py:class:`CLIPut` for more information.
"""
if context.different and context.encrypt:
raise ReturnCode(
'context.different will not work pr... | [
"Performs",
"a",
"PUT",
"on",
"the",
"object",
"."
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/cli/put.py#L185-L365 | [
"def",
"cli_put_object",
"(",
"context",
",",
"path",
")",
":",
"if",
"context",
".",
"different",
"and",
"context",
".",
"encrypt",
":",
"raise",
"ReturnCode",
"(",
"'context.different will not work properly with context.encrypt '",
"'since encryption may change the object... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | cli_put | Performs a PUT on the item (account, container, or object).
See :py:mod:`swiftly.cli.put` for context usage information.
See :py:class:`CLIPut` for more information. | swiftly/cli/put.py | def cli_put(context, path):
"""
Performs a PUT on the item (account, container, or object).
See :py:mod:`swiftly.cli.put` for context usage information.
See :py:class:`CLIPut` for more information.
"""
path = path.lstrip('/') if path else ''
if context.input_ and os.path.isdir(context.inpu... | def cli_put(context, path):
"""
Performs a PUT on the item (account, container, or object).
See :py:mod:`swiftly.cli.put` for context usage information.
See :py:class:`CLIPut` for more information.
"""
path = path.lstrip('/') if path else ''
if context.input_ and os.path.isdir(context.inpu... | [
"Performs",
"a",
"PUT",
"on",
"the",
"item",
"(",
"account",
"container",
"or",
"object",
")",
"."
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/cli/put.py#L368-L384 | [
"def",
"cli_put",
"(",
"context",
",",
"path",
")",
":",
"path",
"=",
"path",
".",
"lstrip",
"(",
"'/'",
")",
"if",
"path",
"else",
"''",
"if",
"context",
".",
"input_",
"and",
"os",
".",
"path",
".",
"isdir",
"(",
"context",
".",
"input_",
")",
... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | _get_manifest_body | Returns body for manifest file and modifies put_headers.
path2info is a dict like {"path": (size, etag)} | swiftly/cli/put.py | def _get_manifest_body(context, prefix, path2info, put_headers):
"""
Returns body for manifest file and modifies put_headers.
path2info is a dict like {"path": (size, etag)}
"""
if context.static_segments:
body = json.dumps([
{'path': '/' + p, 'size_bytes': s, 'etag': e}
... | def _get_manifest_body(context, prefix, path2info, put_headers):
"""
Returns body for manifest file and modifies put_headers.
path2info is a dict like {"path": (size, etag)}
"""
if context.static_segments:
body = json.dumps([
{'path': '/' + p, 'size_bytes': s, 'etag': e}
... | [
"Returns",
"body",
"for",
"manifest",
"file",
"and",
"modifies",
"put_headers",
"."
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/cli/put.py#L394-L412 | [
"def",
"_get_manifest_body",
"(",
"context",
",",
"prefix",
",",
"path2info",
",",
"put_headers",
")",
":",
"if",
"context",
".",
"static_segments",
":",
"body",
"=",
"json",
".",
"dumps",
"(",
"[",
"{",
"'path'",
":",
"'/'",
"+",
"p",
",",
"'size_bytes'... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | _create_container | Creates container for segments of file with `path` | swiftly/cli/put.py | def _create_container(context, path, l_mtime, size):
"""
Creates container for segments of file with `path`
"""
new_context = context.copy()
new_context.input_ = None
new_context.headers = None
new_context.query = None
container = path.split('/', 1)[0] + '_segments'
cli_put_container... | def _create_container(context, path, l_mtime, size):
"""
Creates container for segments of file with `path`
"""
new_context = context.copy()
new_context.input_ = None
new_context.headers = None
new_context.query = None
container = path.split('/', 1)[0] + '_segments'
cli_put_container... | [
"Creates",
"container",
"for",
"segments",
"of",
"file",
"with",
"path"
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/cli/put.py#L415-L428 | [
"def",
"_create_container",
"(",
"context",
",",
"path",
",",
"l_mtime",
",",
"size",
")",
":",
"new_context",
"=",
"context",
".",
"copy",
"(",
")",
"new_context",
".",
"input_",
"=",
"None",
"new_context",
".",
"headers",
"=",
"None",
"new_context",
".",... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | cli_tempurl | Generates a TempURL and sends that to the context.io_manager's
stdout.
See :py:mod:`swiftly.cli.tempurl` for context usage information.
See :py:class:`CLITempURL` for more information.
:param context: The :py:class:`swiftly.cli.context.CLIContext` to
use.
:param method: The method for the... | swiftly/cli/tempurl.py | def cli_tempurl(context, method, path, seconds=None, use_container=False):
"""
Generates a TempURL and sends that to the context.io_manager's
stdout.
See :py:mod:`swiftly.cli.tempurl` for context usage information.
See :py:class:`CLITempURL` for more information.
:param context: The :py:class... | def cli_tempurl(context, method, path, seconds=None, use_container=False):
"""
Generates a TempURL and sends that to the context.io_manager's
stdout.
See :py:mod:`swiftly.cli.tempurl` for context usage information.
See :py:class:`CLITempURL` for more information.
:param context: The :py:class... | [
"Generates",
"a",
"TempURL",
"and",
"sends",
"that",
"to",
"the",
"context",
".",
"io_manager",
"s",
"stdout",
"."
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/cli/tempurl.py#L32-L81 | [
"def",
"cli_tempurl",
"(",
"context",
",",
"method",
",",
"path",
",",
"seconds",
"=",
"None",
",",
"use_container",
"=",
"False",
")",
":",
"with",
"contextlib",
".",
"nested",
"(",
"context",
".",
"io_manager",
".",
"with_stdout",
"(",
")",
",",
"conte... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | StandardClient.auth | See :py:func:`swiftly.client.client.Client.auth` | swiftly/client/standardclient.py | def auth(self):
"""
See :py:func:`swiftly.client.client.Client.auth`
"""
self.reset()
if not self.auth_url:
raise ValueError('No Auth URL has been provided.')
funcs = []
if self.auth_methods:
for method in self.auth_methods.split(','):
... | def auth(self):
"""
See :py:func:`swiftly.client.client.Client.auth`
"""
self.reset()
if not self.auth_url:
raise ValueError('No Auth URL has been provided.')
funcs = []
if self.auth_methods:
for method in self.auth_methods.split(','):
... | [
"See",
":",
"py",
":",
"func",
":",
"swiftly",
".",
"client",
".",
"client",
".",
"Client",
".",
"auth"
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/client/standardclient.py#L222-L250 | [
"def",
"auth",
"(",
"self",
")",
":",
"self",
".",
"reset",
"(",
")",
"if",
"not",
"self",
".",
"auth_url",
":",
"raise",
"ValueError",
"(",
"'No Auth URL has been provided.'",
")",
"funcs",
"=",
"[",
"]",
"if",
"self",
".",
"auth_methods",
":",
"for",
... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | StandardClient.request | See :py:func:`swiftly.client.client.Client.request` | swiftly/client/standardclient.py | def request(self, method, path, contents, headers, decode_json=False,
stream=False, query=None, cdn=False):
"""
See :py:func:`swiftly.client.client.Client.request`
"""
if query:
path += '?' + '&'.join(
('%s=%s' % (quote(k), quote(v)) if v else ... | def request(self, method, path, contents, headers, decode_json=False,
stream=False, query=None, cdn=False):
"""
See :py:func:`swiftly.client.client.Client.request`
"""
if query:
path += '?' + '&'.join(
('%s=%s' % (quote(k), quote(v)) if v else ... | [
"See",
":",
"py",
":",
"func",
":",
"swiftly",
".",
"client",
".",
"client",
".",
"Client",
".",
"request"
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/client/standardclient.py#L464-L608 | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"path",
",",
"contents",
",",
"headers",
",",
"decode_json",
"=",
"False",
",",
"stream",
"=",
"False",
",",
"query",
"=",
"None",
",",
"cdn",
"=",
"False",
")",
":",
"if",
"query",
":",
"path",
"+... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | StandardClient.reset | See :py:func:`swiftly.client.client.Client.reset` | swiftly/client/standardclient.py | def reset(self):
"""
See :py:func:`swiftly.client.client.Client.reset`
"""
for conn in (self.storage_conn, self.cdn_conn):
if conn:
try:
conn.close()
except Exception:
pass
self.storage_conn = Non... | def reset(self):
"""
See :py:func:`swiftly.client.client.Client.reset`
"""
for conn in (self.storage_conn, self.cdn_conn):
if conn:
try:
conn.close()
except Exception:
pass
self.storage_conn = Non... | [
"See",
":",
"py",
":",
"func",
":",
"swiftly",
".",
"client",
".",
"client",
".",
"Client",
".",
"reset"
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/client/standardclient.py#L610-L621 | [
"def",
"reset",
"(",
"self",
")",
":",
"for",
"conn",
"in",
"(",
"self",
".",
"storage_conn",
",",
"self",
".",
"cdn_conn",
")",
":",
"if",
"conn",
":",
"try",
":",
"conn",
".",
"close",
"(",
")",
"except",
"Exception",
":",
"pass",
"self",
".",
... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | StandardClient.get_account_hash | See :py:func:`swiftly.client.client.Client.get_account_hash` | swiftly/client/standardclient.py | def get_account_hash(self):
"""
See :py:func:`swiftly.client.client.Client.get_account_hash`
"""
if not(self.storage_url or self.storage_path):
self.auth()
return (self.storage_url or self.storage_path).rsplit('/', 1)[1] | def get_account_hash(self):
"""
See :py:func:`swiftly.client.client.Client.get_account_hash`
"""
if not(self.storage_url or self.storage_path):
self.auth()
return (self.storage_url or self.storage_path).rsplit('/', 1)[1] | [
"See",
":",
"py",
":",
"func",
":",
"swiftly",
".",
"client",
".",
"client",
".",
"Client",
".",
"get_account_hash"
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/client/standardclient.py#L623-L629 | [
"def",
"get_account_hash",
"(",
"self",
")",
":",
"if",
"not",
"(",
"self",
".",
"storage_url",
"or",
"self",
".",
"storage_path",
")",
":",
"self",
".",
"auth",
"(",
")",
"return",
"(",
"self",
".",
"storage_url",
"or",
"self",
".",
"storage_path",
")... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | cli_trans | Translates any information that can be determined from the
x_trans_id and sends that to the context.io_manager's stdout.
See :py:mod:`swiftly.cli.trans` for context usage information.
See :py:class:`CLITrans` for more information. | swiftly/cli/trans.py | def cli_trans(context, x_trans_id):
"""
Translates any information that can be determined from the
x_trans_id and sends that to the context.io_manager's stdout.
See :py:mod:`swiftly.cli.trans` for context usage information.
See :py:class:`CLITrans` for more information.
"""
with context.io... | def cli_trans(context, x_trans_id):
"""
Translates any information that can be determined from the
x_trans_id and sends that to the context.io_manager's stdout.
See :py:mod:`swiftly.cli.trans` for context usage information.
See :py:class:`CLITrans` for more information.
"""
with context.io... | [
"Translates",
"any",
"information",
"that",
"can",
"be",
"determined",
"from",
"the",
"x_trans_id",
"and",
"sends",
"that",
"to",
"the",
"context",
".",
"io_manager",
"s",
"stdout",
"."
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/cli/trans.py#L31-L55 | [
"def",
"cli_trans",
"(",
"context",
",",
"x_trans_id",
")",
":",
"with",
"context",
".",
"io_manager",
".",
"with_stdout",
"(",
")",
"as",
"fp",
":",
"trans_time",
"=",
"get_trans_id_time",
"(",
"x_trans_id",
")",
"trans_info",
"=",
"x_trans_id",
"[",
"34",
... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | cli_help | Outputs help information.
See :py:mod:`swiftly.cli.help` for context usage information.
See :py:class:`CLIHelp` for more information.
:param context: The :py:class:`swiftly.cli.context.CLIContext` to
use.
:param command_name: The command_name to output help information
for, or set to ... | swiftly/cli/help.py | def cli_help(context, command_name, general_parser, command_parsers):
"""
Outputs help information.
See :py:mod:`swiftly.cli.help` for context usage information.
See :py:class:`CLIHelp` for more information.
:param context: The :py:class:`swiftly.cli.context.CLIContext` to
use.
:param... | def cli_help(context, command_name, general_parser, command_parsers):
"""
Outputs help information.
See :py:mod:`swiftly.cli.help` for context usage information.
See :py:class:`CLIHelp` for more information.
:param context: The :py:class:`swiftly.cli.context.CLIContext` to
use.
:param... | [
"Outputs",
"help",
"information",
"."
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/cli/help.py#L28-L55 | [
"def",
"cli_help",
"(",
"context",
",",
"command_name",
",",
"general_parser",
",",
"command_parsers",
")",
":",
"if",
"command_name",
"==",
"'for'",
":",
"command_name",
"=",
"'fordo'",
"with",
"context",
".",
"io_manager",
".",
"with_stdout",
"(",
")",
"as",... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | FileLikeIter.read | read([size]) -> read at most size bytes, returned as a string.
If the size argument is negative or omitted, read until EOF is reached.
Notice that when in non-blocking mode, less data than what was
requested may be returned, even if no size parameter was given. | swiftly/filelikeiter.py | def read(self, size=-1):
"""
read([size]) -> read at most size bytes, returned as a string.
If the size argument is negative or omitted, read until EOF is reached.
Notice that when in non-blocking mode, less data than what was
requested may be returned, even if no size parameter... | def read(self, size=-1):
"""
read([size]) -> read at most size bytes, returned as a string.
If the size argument is negative or omitted, read until EOF is reached.
Notice that when in non-blocking mode, less data than what was
requested may be returned, even if no size parameter... | [
"read",
"(",
"[",
"size",
"]",
")",
"-",
">",
"read",
"at",
"most",
"size",
"bytes",
"returned",
"as",
"a",
"string",
"."
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/filelikeiter.py#L58-L87 | [
"def",
"read",
"(",
"self",
",",
"size",
"=",
"-",
"1",
")",
":",
"if",
"self",
".",
"left",
"is",
"not",
"None",
":",
"size",
"=",
"min",
"(",
"size",
",",
"self",
".",
"left",
")",
"if",
"self",
".",
"closed",
":",
"raise",
"ValueError",
"(",... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | FileLikeIter.readline | readline([size]) -> next line from the file, as a string.
Retain newline. A non-negative size argument limits the maximum
number of bytes to return (an incomplete line may be returned then).
Return an empty string at EOF. | swiftly/filelikeiter.py | def readline(self, size=-1):
"""
readline([size]) -> next line from the file, as a string.
Retain newline. A non-negative size argument limits the maximum
number of bytes to return (an incomplete line may be returned then).
Return an empty string at EOF.
"""
if ... | def readline(self, size=-1):
"""
readline([size]) -> next line from the file, as a string.
Retain newline. A non-negative size argument limits the maximum
number of bytes to return (an incomplete line may be returned then).
Return an empty string at EOF.
"""
if ... | [
"readline",
"(",
"[",
"size",
"]",
")",
"-",
">",
"next",
"line",
"from",
"the",
"file",
"as",
"a",
"string",
"."
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/filelikeiter.py#L89-L115 | [
"def",
"readline",
"(",
"self",
",",
"size",
"=",
"-",
"1",
")",
":",
"if",
"self",
".",
"closed",
":",
"raise",
"ValueError",
"(",
"'I/O operation on closed file'",
")",
"data",
"=",
"''",
"while",
"'\\n'",
"not",
"in",
"data",
"and",
"(",
"size",
"<"... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | FileLikeIter.readlines | readlines([size]) -> list of strings, each a line from the file.
Call readline() repeatedly and return a list of the lines so read.
The optional size argument, if given, is an approximate bound on the
total number of bytes in the lines returned. | swiftly/filelikeiter.py | def readlines(self, sizehint=-1):
"""
readlines([size]) -> list of strings, each a line from the file.
Call readline() repeatedly and return a list of the lines so read.
The optional size argument, if given, is an approximate bound on the
total number of bytes in the lines retur... | def readlines(self, sizehint=-1):
"""
readlines([size]) -> list of strings, each a line from the file.
Call readline() repeatedly and return a list of the lines so read.
The optional size argument, if given, is an approximate bound on the
total number of bytes in the lines retur... | [
"readlines",
"(",
"[",
"size",
"]",
")",
"-",
">",
"list",
"of",
"strings",
"each",
"a",
"line",
"from",
"the",
"file",
"."
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/filelikeiter.py#L117-L137 | [
"def",
"readlines",
"(",
"self",
",",
"sizehint",
"=",
"-",
"1",
")",
":",
"if",
"self",
".",
"closed",
":",
"raise",
"ValueError",
"(",
"'I/O operation on closed file'",
")",
"lines",
"=",
"[",
"]",
"while",
"True",
":",
"line",
"=",
"self",
".",
"rea... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | FileLikeIter.is_empty | Check whether the "file" is empty reading the single byte. | swiftly/filelikeiter.py | def is_empty(self):
"""
Check whether the "file" is empty reading the single byte.
"""
something = self.read(1)
if something:
if self.buf:
self.buf = something + self.buf
else:
self.buf = something
return False
... | def is_empty(self):
"""
Check whether the "file" is empty reading the single byte.
"""
something = self.read(1)
if something:
if self.buf:
self.buf = something + self.buf
else:
self.buf = something
return False
... | [
"Check",
"whether",
"the",
"file",
"is",
"empty",
"reading",
"the",
"single",
"byte",
"."
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/filelikeiter.py#L139-L151 | [
"def",
"is_empty",
"(",
"self",
")",
":",
"something",
"=",
"self",
".",
"read",
"(",
"1",
")",
"if",
"something",
":",
"if",
"self",
".",
"buf",
":",
"self",
".",
"buf",
"=",
"something",
"+",
"self",
".",
"buf",
"else",
":",
"self",
".",
"buf",... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | cli_encrypt | Encrypts context.io_manager's stdin and sends that to
context.io_manager's stdout.
This can be useful to encrypt to disk before attempting to
upload, allowing uploads retries and segmented encrypted objects.
See :py:mod:`swiftly.cli.encrypt` for context usage information.
See :py:class:`CLIEncryp... | swiftly/cli/encrypt.py | def cli_encrypt(context, key):
"""
Encrypts context.io_manager's stdin and sends that to
context.io_manager's stdout.
This can be useful to encrypt to disk before attempting to
upload, allowing uploads retries and segmented encrypted objects.
See :py:mod:`swiftly.cli.encrypt` for context usage... | def cli_encrypt(context, key):
"""
Encrypts context.io_manager's stdin and sends that to
context.io_manager's stdout.
This can be useful to encrypt to disk before attempting to
upload, allowing uploads retries and segmented encrypted objects.
See :py:mod:`swiftly.cli.encrypt` for context usage... | [
"Encrypts",
"context",
".",
"io_manager",
"s",
"stdin",
"and",
"sends",
"that",
"to",
"context",
".",
"io_manager",
"s",
"stdout",
"."
] | gholt/swiftly | python | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/cli/encrypt.py#L31-L47 | [
"def",
"cli_encrypt",
"(",
"context",
",",
"key",
")",
":",
"with",
"context",
".",
"io_manager",
".",
"with_stdout",
"(",
")",
"as",
"stdout",
":",
"with",
"context",
".",
"io_manager",
".",
"with_stdin",
"(",
")",
"as",
"stdin",
":",
"for",
"chunk",
... | 5bcc1c65323b1caf1f85adbefd9fc4988c072149 |
test | get_build_commits | Determine the value for BUILD_COMMITS from the app and repository
config. Resolves the previous BUILD_ALL_COMMITS = True/False option
to BUILD_COMMITS = 'ALL'/'LAST' respectively. | leeroy/github.py | def get_build_commits(app, repo_config):
"""
Determine the value for BUILD_COMMITS from the app and repository
config. Resolves the previous BUILD_ALL_COMMITS = True/False option
to BUILD_COMMITS = 'ALL'/'LAST' respectively.
"""
build_commits = repo_config.get("build_commits")
build_all_comm... | def get_build_commits(app, repo_config):
"""
Determine the value for BUILD_COMMITS from the app and repository
config. Resolves the previous BUILD_ALL_COMMITS = True/False option
to BUILD_COMMITS = 'ALL'/'LAST' respectively.
"""
build_commits = repo_config.get("build_commits")
build_all_comm... | [
"Determine",
"the",
"value",
"for",
"BUILD_COMMITS",
"from",
"the",
"app",
"and",
"repository",
"config",
".",
"Resolves",
"the",
"previous",
"BUILD_ALL_COMMITS",
"=",
"True",
"/",
"False",
"option",
"to",
"BUILD_COMMITS",
"=",
"ALL",
"/",
"LAST",
"respectively"... | litl/leeroy | python | https://github.com/litl/leeroy/blob/ab6565a3b63e9103d8c011d9c62a9c0ad589b051/leeroy/github.py#L71-L92 | [
"def",
"get_build_commits",
"(",
"app",
",",
"repo_config",
")",
":",
"build_commits",
"=",
"repo_config",
".",
"get",
"(",
"\"build_commits\"",
")",
"build_all_commits",
"=",
"repo_config",
".",
"get",
"(",
"\"build_all_commits\"",
",",
"app",
".",
"config",
".... | ab6565a3b63e9103d8c011d9c62a9c0ad589b051 |
test | get_status | Gets the status of a commit.
.. note::
``repo_name`` might not ever be anything other than
``repo_config['github_repo']``.
:param app: Flask app for leeroy
:param repo_config: configuration for the repo
:param repo_name: The name of the owner/repo
:param sha: SHA for the status we ... | leeroy/github.py | def get_status(app, repo_config, repo_name, sha):
"""Gets the status of a commit.
.. note::
``repo_name`` might not ever be anything other than
``repo_config['github_repo']``.
:param app: Flask app for leeroy
:param repo_config: configuration for the repo
:param repo_name: The name... | def get_status(app, repo_config, repo_name, sha):
"""Gets the status of a commit.
.. note::
``repo_name`` might not ever be anything other than
``repo_config['github_repo']``.
:param app: Flask app for leeroy
:param repo_config: configuration for the repo
:param repo_name: The name... | [
"Gets",
"the",
"status",
"of",
"a",
"commit",
"."
] | litl/leeroy | python | https://github.com/litl/leeroy/blob/ab6565a3b63e9103d8c011d9c62a9c0ad589b051/leeroy/github.py#L155-L175 | [
"def",
"get_status",
"(",
"app",
",",
"repo_config",
",",
"repo_name",
",",
"sha",
")",
":",
"url",
"=",
"get_api_url",
"(",
"app",
",",
"repo_config",
",",
"github_status_url",
")",
".",
"format",
"(",
"repo_name",
"=",
"repo_name",
",",
"sha",
"=",
"sh... | ab6565a3b63e9103d8c011d9c62a9c0ad589b051 |
test | get_pull_request | Data for a given pull request.
:param app: Flask app
:param repo_config: dict with ``github_repo`` key
:param pull_request: the pull request number | leeroy/github.py | def get_pull_request(app, repo_config, pull_request):
"""Data for a given pull request.
:param app: Flask app
:param repo_config: dict with ``github_repo`` key
:param pull_request: the pull request number
"""
response = get_api_response(
app, repo_config,
"/repos/{{repo_name}}/p... | def get_pull_request(app, repo_config, pull_request):
"""Data for a given pull request.
:param app: Flask app
:param repo_config: dict with ``github_repo`` key
:param pull_request: the pull request number
"""
response = get_api_response(
app, repo_config,
"/repos/{{repo_name}}/p... | [
"Data",
"for",
"a",
"given",
"pull",
"request",
"."
] | litl/leeroy | python | https://github.com/litl/leeroy/blob/ab6565a3b63e9103d8c011d9c62a9c0ad589b051/leeroy/github.py#L236-L248 | [
"def",
"get_pull_request",
"(",
"app",
",",
"repo_config",
",",
"pull_request",
")",
":",
"response",
"=",
"get_api_response",
"(",
"app",
",",
"repo_config",
",",
"\"/repos/{{repo_name}}/pulls/{0}\"",
".",
"format",
"(",
"pull_request",
")",
")",
"if",
"not",
"... | ab6565a3b63e9103d8c011d9c62a9c0ad589b051 |
test | get_pull_requests | Last 30 pull requests from a repository.
:param app: Flask app
:param repo_config: dict with ``github_repo`` key
:returns: id for a pull request | leeroy/github.py | def get_pull_requests(app, repo_config):
"""Last 30 pull requests from a repository.
:param app: Flask app
:param repo_config: dict with ``github_repo`` key
:returns: id for a pull request
"""
response = get_api_response(app, repo_config, "/repos/{repo_name}/pulls")
if not response.ok:
... | def get_pull_requests(app, repo_config):
"""Last 30 pull requests from a repository.
:param app: Flask app
:param repo_config: dict with ``github_repo`` key
:returns: id for a pull request
"""
response = get_api_response(app, repo_config, "/repos/{repo_name}/pulls")
if not response.ok:
... | [
"Last",
"30",
"pull",
"requests",
"from",
"a",
"repository",
"."
] | litl/leeroy | python | https://github.com/litl/leeroy/blob/ab6565a3b63e9103d8c011d9c62a9c0ad589b051/leeroy/github.py#L251-L262 | [
"def",
"get_pull_requests",
"(",
"app",
",",
"repo_config",
")",
":",
"response",
"=",
"get_api_response",
"(",
"app",
",",
"repo_config",
",",
"\"/repos/{repo_name}/pulls\"",
")",
"if",
"not",
"response",
".",
"ok",
":",
"raise",
"Exception",
"(",
"\"Unable to ... | ab6565a3b63e9103d8c011d9c62a9c0ad589b051 |
test | Plugin.write | Write obj in elasticsearch.
:param obj: value to be written in elasticsearch.
:param resource_id: id for the resource.
:return: id of the transaction. | oceandb_elasticsearch_driver/plugin.py | def write(self, obj, resource_id=None):
"""Write obj in elasticsearch.
:param obj: value to be written in elasticsearch.
:param resource_id: id for the resource.
:return: id of the transaction.
"""
self.logger.debug('elasticsearch::write::{}'.format(resource_id))
... | def write(self, obj, resource_id=None):
"""Write obj in elasticsearch.
:param obj: value to be written in elasticsearch.
:param resource_id: id for the resource.
:return: id of the transaction.
"""
self.logger.debug('elasticsearch::write::{}'.format(resource_id))
... | [
"Write",
"obj",
"in",
"elasticsearch",
".",
":",
"param",
"obj",
":",
"value",
"to",
"be",
"written",
"in",
"elasticsearch",
".",
":",
"param",
"resource_id",
":",
"id",
"for",
"the",
"resource",
".",
":",
"return",
":",
"id",
"of",
"the",
"transaction",... | oceanprotocol/oceandb-elasticsearch-driver | python | https://github.com/oceanprotocol/oceandb-elasticsearch-driver/blob/11901e8396252b9dbb70fd48debcfa82f1dd1ff2/oceandb_elasticsearch_driver/plugin.py#L33-L54 | [
"def",
"write",
"(",
"self",
",",
"obj",
",",
"resource_id",
"=",
"None",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'elasticsearch::write::{}'",
".",
"format",
"(",
"resource_id",
")",
")",
"if",
"resource_id",
"is",
"not",
"None",
":",
"if",
... | 11901e8396252b9dbb70fd48debcfa82f1dd1ff2 |
test | Plugin.read | Read object in elasticsearch using the resource_id.
:param resource_id: id of the object to be read.
:return: object value from elasticsearch. | oceandb_elasticsearch_driver/plugin.py | def read(self, resource_id):
"""Read object in elasticsearch using the resource_id.
:param resource_id: id of the object to be read.
:return: object value from elasticsearch.
"""
self.logger.debug('elasticsearch::read::{}'.format(resource_id))
return self.driver._es.get(
... | def read(self, resource_id):
"""Read object in elasticsearch using the resource_id.
:param resource_id: id of the object to be read.
:return: object value from elasticsearch.
"""
self.logger.debug('elasticsearch::read::{}'.format(resource_id))
return self.driver._es.get(
... | [
"Read",
"object",
"in",
"elasticsearch",
"using",
"the",
"resource_id",
".",
":",
"param",
"resource_id",
":",
"id",
"of",
"the",
"object",
"to",
"be",
"read",
".",
":",
"return",
":",
"object",
"value",
"from",
"elasticsearch",
"."
] | oceanprotocol/oceandb-elasticsearch-driver | python | https://github.com/oceanprotocol/oceandb-elasticsearch-driver/blob/11901e8396252b9dbb70fd48debcfa82f1dd1ff2/oceandb_elasticsearch_driver/plugin.py#L56-L66 | [
"def",
"read",
"(",
"self",
",",
"resource_id",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'elasticsearch::read::{}'",
".",
"format",
"(",
"resource_id",
")",
")",
"return",
"self",
".",
"driver",
".",
"_es",
".",
"get",
"(",
"index",
"=",
"s... | 11901e8396252b9dbb70fd48debcfa82f1dd1ff2 |
test | Plugin.update | Update object in elasticsearch using the resource_id.
:param metadata: new metadata for the transaction.
:param resource_id: id of the object to be updated.
:return: id of the object. | oceandb_elasticsearch_driver/plugin.py | def update(self, obj, resource_id):
"""Update object in elasticsearch using the resource_id.
:param metadata: new metadata for the transaction.
:param resource_id: id of the object to be updated.
:return: id of the object.
"""
self.logger.debug('elasticsearch::update::{}'... | def update(self, obj, resource_id):
"""Update object in elasticsearch using the resource_id.
:param metadata: new metadata for the transaction.
:param resource_id: id of the object to be updated.
:return: id of the object.
"""
self.logger.debug('elasticsearch::update::{}'... | [
"Update",
"object",
"in",
"elasticsearch",
"using",
"the",
"resource_id",
".",
":",
"param",
"metadata",
":",
"new",
"metadata",
"for",
"the",
"transaction",
".",
":",
"param",
"resource_id",
":",
"id",
"of",
"the",
"object",
"to",
"be",
"updated",
".",
":... | oceanprotocol/oceandb-elasticsearch-driver | python | https://github.com/oceanprotocol/oceandb-elasticsearch-driver/blob/11901e8396252b9dbb70fd48debcfa82f1dd1ff2/oceandb_elasticsearch_driver/plugin.py#L68-L81 | [
"def",
"update",
"(",
"self",
",",
"obj",
",",
"resource_id",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'elasticsearch::update::{}'",
".",
"format",
"(",
"resource_id",
")",
")",
"return",
"self",
".",
"driver",
".",
"_es",
".",
"index",
"(",
... | 11901e8396252b9dbb70fd48debcfa82f1dd1ff2 |
test | Plugin.delete | Delete an object from elasticsearch.
:param resource_id: id of the object to be deleted.
:return: | oceandb_elasticsearch_driver/plugin.py | def delete(self, resource_id):
"""Delete an object from elasticsearch.
:param resource_id: id of the object to be deleted.
:return:
"""
self.logger.debug('elasticsearch::delete::{}'.format(resource_id))
if self.driver._es.exists(
index=self.driver._index,
... | def delete(self, resource_id):
"""Delete an object from elasticsearch.
:param resource_id: id of the object to be deleted.
:return:
"""
self.logger.debug('elasticsearch::delete::{}'.format(resource_id))
if self.driver._es.exists(
index=self.driver._index,
... | [
"Delete",
"an",
"object",
"from",
"elasticsearch",
".",
":",
"param",
"resource_id",
":",
"id",
"of",
"the",
"object",
"to",
"be",
"deleted",
".",
":",
"return",
":"
] | oceanprotocol/oceandb-elasticsearch-driver | python | https://github.com/oceanprotocol/oceandb-elasticsearch-driver/blob/11901e8396252b9dbb70fd48debcfa82f1dd1ff2/oceandb_elasticsearch_driver/plugin.py#L83-L99 | [
"def",
"delete",
"(",
"self",
",",
"resource_id",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'elasticsearch::delete::{}'",
".",
"format",
"(",
"resource_id",
")",
")",
"if",
"self",
".",
"driver",
".",
"_es",
".",
"exists",
"(",
"index",
"=",
... | 11901e8396252b9dbb70fd48debcfa82f1dd1ff2 |
test | Plugin.list | List all the objects saved elasticsearch.
:param search_from: start offset of objects to return.
:param search_to: last offset of objects to return.
:param limit: max number of values to be returned.
:return: list with transactions. | oceandb_elasticsearch_driver/plugin.py | def list(self, search_from=None, search_to=None, limit=None):
"""List all the objects saved elasticsearch.
:param search_from: start offset of objects to return.
:param search_to: last offset of objects to return.
:param limit: max number of values to be returned.
:return: li... | def list(self, search_from=None, search_to=None, limit=None):
"""List all the objects saved elasticsearch.
:param search_from: start offset of objects to return.
:param search_to: last offset of objects to return.
:param limit: max number of values to be returned.
:return: li... | [
"List",
"all",
"the",
"objects",
"saved",
"elasticsearch",
".",
":",
"param",
"search_from",
":",
"start",
"offset",
"of",
"objects",
"to",
"return",
".",
":",
"param",
"search_to",
":",
"last",
"offset",
"of",
"objects",
"to",
"return",
".",
":",
"param",... | oceanprotocol/oceandb-elasticsearch-driver | python | https://github.com/oceanprotocol/oceandb-elasticsearch-driver/blob/11901e8396252b9dbb70fd48debcfa82f1dd1ff2/oceandb_elasticsearch_driver/plugin.py#L101-L134 | [
"def",
"list",
"(",
"self",
",",
"search_from",
"=",
"None",
",",
"search_to",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'elasticsearch::list'",
")",
"body",
"=",
"{",
"'sort'",
":",
"[",
"{",
"\"_id... | 11901e8396252b9dbb70fd48debcfa82f1dd1ff2 |
test | Plugin.query | Query elasticsearch for objects.
:param search_model: object of QueryModel.
:return: list of objects that match the query. | oceandb_elasticsearch_driver/plugin.py | def query(self, search_model: QueryModel):
"""Query elasticsearch for objects.
:param search_model: object of QueryModel.
:return: list of objects that match the query.
"""
query_parsed = query_parser(search_model.query)
self.logger.debug(f'elasticsearch::query::{query_pa... | def query(self, search_model: QueryModel):
"""Query elasticsearch for objects.
:param search_model: object of QueryModel.
:return: list of objects that match the query.
"""
query_parsed = query_parser(search_model.query)
self.logger.debug(f'elasticsearch::query::{query_pa... | [
"Query",
"elasticsearch",
"for",
"objects",
".",
":",
"param",
"search_model",
":",
"object",
"of",
"QueryModel",
".",
":",
"return",
":",
"list",
"of",
"objects",
"that",
"match",
"the",
"query",
"."
] | oceanprotocol/oceandb-elasticsearch-driver | python | https://github.com/oceanprotocol/oceandb-elasticsearch-driver/blob/11901e8396252b9dbb70fd48debcfa82f1dd1ff2/oceandb_elasticsearch_driver/plugin.py#L136-L170 | [
"def",
"query",
"(",
"self",
",",
"search_model",
":",
"QueryModel",
")",
":",
"query_parsed",
"=",
"query_parser",
"(",
"search_model",
".",
"query",
")",
"self",
".",
"logger",
".",
"debug",
"(",
"f'elasticsearch::query::{query_parsed[0]}'",
")",
"if",
"search... | 11901e8396252b9dbb70fd48debcfa82f1dd1ff2 |
test | Plugin.text_query | Query elasticsearch for objects.
:param search_model: object of FullTextModel
:return: list of objects that match the query. | oceandb_elasticsearch_driver/plugin.py | def text_query(self, search_model: FullTextModel):
"""Query elasticsearch for objects.
:param search_model: object of FullTextModel
:return: list of objects that match the query.
"""
self.logger.debug('elasticsearch::text_query::{}'.format(search_model.text))
if search_mo... | def text_query(self, search_model: FullTextModel):
"""Query elasticsearch for objects.
:param search_model: object of FullTextModel
:return: list of objects that match the query.
"""
self.logger.debug('elasticsearch::text_query::{}'.format(search_model.text))
if search_mo... | [
"Query",
"elasticsearch",
"for",
"objects",
".",
":",
"param",
"search_model",
":",
"object",
"of",
"FullTextModel",
":",
"return",
":",
"list",
"of",
"objects",
"that",
"match",
"the",
"query",
"."
] | oceanprotocol/oceandb-elasticsearch-driver | python | https://github.com/oceanprotocol/oceandb-elasticsearch-driver/blob/11901e8396252b9dbb70fd48debcfa82f1dd1ff2/oceandb_elasticsearch_driver/plugin.py#L172-L199 | [
"def",
"text_query",
"(",
"self",
",",
"search_model",
":",
"FullTextModel",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'elasticsearch::text_query::{}'",
".",
"format",
"(",
"search_model",
".",
"text",
")",
")",
"if",
"search_model",
".",
"sort",
... | 11901e8396252b9dbb70fd48debcfa82f1dd1ff2 |
test | Migration.forwards | Write your forwards methods here. | hero_slider/south_migrations/0003_set_existing_slideritems_to_be_published.py | def forwards(self, orm):
"Write your forwards methods here."
# Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
for title in orm['hero_slider.SliderItemTitle'].objects.all():
title.is_published = True
title.save() | def forwards(self, orm):
"Write your forwards methods here."
# Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
for title in orm['hero_slider.SliderItemTitle'].objects.all():
title.is_published = True
title.save() | [
"Write",
"your",
"forwards",
"methods",
"here",
"."
] | bitlabstudio/django-hero-slider | python | https://github.com/bitlabstudio/django-hero-slider/blob/8153b3eece76c47210a266c2edb660725c34a56e/hero_slider/south_migrations/0003_set_existing_slideritems_to_be_published.py#L10-L15 | [
"def",
"forwards",
"(",
"self",
",",
"orm",
")",
":",
"# Note: Remember to use orm['appname.ModelName'] rather than \"from appname.models...\"",
"for",
"title",
"in",
"orm",
"[",
"'hero_slider.SliderItemTitle'",
"]",
".",
"objects",
".",
"all",
"(",
")",
":",
"title",
... | 8153b3eece76c47210a266c2edb660725c34a56e |
test | get_slider_items | Returns the published slider items. | hero_slider/templatetags/hero_slider_tags.py | def get_slider_items(context, amount=None):
"""Returns the published slider items."""
req = context.get('request')
qs = SliderItem.objects.published(req).order_by('position')
if amount:
qs = qs[:amount]
return qs | def get_slider_items(context, amount=None):
"""Returns the published slider items."""
req = context.get('request')
qs = SliderItem.objects.published(req).order_by('position')
if amount:
qs = qs[:amount]
return qs | [
"Returns",
"the",
"published",
"slider",
"items",
"."
] | bitlabstudio/django-hero-slider | python | https://github.com/bitlabstudio/django-hero-slider/blob/8153b3eece76c47210a266c2edb660725c34a56e/hero_slider/templatetags/hero_slider_tags.py#L11-L17 | [
"def",
"get_slider_items",
"(",
"context",
",",
"amount",
"=",
"None",
")",
":",
"req",
"=",
"context",
".",
"get",
"(",
"'request'",
")",
"qs",
"=",
"SliderItem",
".",
"objects",
".",
"published",
"(",
"req",
")",
".",
"order_by",
"(",
"'position'",
"... | 8153b3eece76c47210a266c2edb660725c34a56e |
test | render_hero_slider | Renders the hero slider. | hero_slider/templatetags/hero_slider_tags.py | def render_hero_slider(context):
"""
Renders the hero slider.
"""
req = context.get('request')
qs = SliderItem.objects.published(req).order_by('position')
return {
'slider_items': qs,
} | def render_hero_slider(context):
"""
Renders the hero slider.
"""
req = context.get('request')
qs = SliderItem.objects.published(req).order_by('position')
return {
'slider_items': qs,
} | [
"Renders",
"the",
"hero",
"slider",
"."
] | bitlabstudio/django-hero-slider | python | https://github.com/bitlabstudio/django-hero-slider/blob/8153b3eece76c47210a266c2edb660725c34a56e/hero_slider/templatetags/hero_slider_tags.py#L21-L30 | [
"def",
"render_hero_slider",
"(",
"context",
")",
":",
"req",
"=",
"context",
".",
"get",
"(",
"'request'",
")",
"qs",
"=",
"SliderItem",
".",
"objects",
".",
"published",
"(",
"req",
")",
".",
"order_by",
"(",
"'position'",
")",
"return",
"{",
"'slider_... | 8153b3eece76c47210a266c2edb660725c34a56e |
test | RWLock.reader_acquire | Acquire the lock to read | arthur/utils.py | def reader_acquire(self):
"""Acquire the lock to read"""
self._order_mutex.acquire()
self._readers_mutex.acquire()
if self._readers == 0:
self._access_mutex.acquire()
self._readers += 1
self._order_mutex.release()
self._readers_mutex.release() | def reader_acquire(self):
"""Acquire the lock to read"""
self._order_mutex.acquire()
self._readers_mutex.acquire()
if self._readers == 0:
self._access_mutex.acquire()
self._readers += 1
self._order_mutex.release()
self._readers_mutex.release() | [
"Acquire",
"the",
"lock",
"to",
"read"
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/utils.py#L45-L56 | [
"def",
"reader_acquire",
"(",
"self",
")",
":",
"self",
".",
"_order_mutex",
".",
"acquire",
"(",
")",
"self",
".",
"_readers_mutex",
".",
"acquire",
"(",
")",
"if",
"self",
".",
"_readers",
"==",
"0",
":",
"self",
".",
"_access_mutex",
".",
"acquire",
... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | RWLock.reader_release | Release the lock after reading | arthur/utils.py | def reader_release(self):
"""Release the lock after reading"""
self._readers_mutex.acquire()
self._readers -= 1
if self._readers == 0:
self._access_mutex.release()
self._readers_mutex.release() | def reader_release(self):
"""Release the lock after reading"""
self._readers_mutex.acquire()
self._readers -= 1
if self._readers == 0:
self._access_mutex.release()
self._readers_mutex.release() | [
"Release",
"the",
"lock",
"after",
"reading"
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/utils.py#L58-L67 | [
"def",
"reader_release",
"(",
"self",
")",
":",
"self",
".",
"_readers_mutex",
".",
"acquire",
"(",
")",
"self",
".",
"_readers",
"-=",
"1",
"if",
"self",
".",
"_readers",
"==",
"0",
":",
"self",
".",
"_access_mutex",
".",
"release",
"(",
")",
"self",
... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | RWLock.writer_acquire | Acquire the lock to write | arthur/utils.py | def writer_acquire(self):
"""Acquire the lock to write"""
self._order_mutex.acquire()
self._access_mutex.acquire()
self._order_mutex.release() | def writer_acquire(self):
"""Acquire the lock to write"""
self._order_mutex.acquire()
self._access_mutex.acquire()
self._order_mutex.release() | [
"Acquire",
"the",
"lock",
"to",
"write"
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/utils.py#L69-L74 | [
"def",
"writer_acquire",
"(",
"self",
")",
":",
"self",
".",
"_order_mutex",
".",
"acquire",
"(",
")",
"self",
".",
"_access_mutex",
".",
"acquire",
"(",
")",
"self",
".",
"_order_mutex",
".",
"release",
"(",
")"
] | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | TaskRegistry.add | Add a task to the registry.
This method adds task using `task_id` as identifier. If a task
with the same identifier already exists on the registry, a
`AlreadyExistsError` exception will be raised.
:param task_id: identifier of the task to add
:param backend: backend used to fet... | arthur/tasks.py | def add(self, task_id, backend, category, backend_args,
archiving_cfg=None, scheduling_cfg=None):
"""Add a task to the registry.
This method adds task using `task_id` as identifier. If a task
with the same identifier already exists on the registry, a
`AlreadyExistsError` exc... | def add(self, task_id, backend, category, backend_args,
archiving_cfg=None, scheduling_cfg=None):
"""Add a task to the registry.
This method adds task using `task_id` as identifier. If a task
with the same identifier already exists on the registry, a
`AlreadyExistsError` exc... | [
"Add",
"a",
"task",
"to",
"the",
"registry",
"."
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/tasks.py#L102-L137 | [
"def",
"add",
"(",
"self",
",",
"task_id",
",",
"backend",
",",
"category",
",",
"backend_args",
",",
"archiving_cfg",
"=",
"None",
",",
"scheduling_cfg",
"=",
"None",
")",
":",
"self",
".",
"_rwlock",
".",
"writer_acquire",
"(",
")",
"if",
"task_id",
"i... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | TaskRegistry.remove | Remove a task from the registry.
To remove it, pass its identifier with `taks_id` parameter.
When the identifier is not found, a `NotFoundError` exception
is raised.
:param task_id: identifier of the task to remove
:raises NotFoundError: raised when the given task identifier
... | arthur/tasks.py | def remove(self, task_id):
"""Remove a task from the registry.
To remove it, pass its identifier with `taks_id` parameter.
When the identifier is not found, a `NotFoundError` exception
is raised.
:param task_id: identifier of the task to remove
:raises NotFoundError: r... | def remove(self, task_id):
"""Remove a task from the registry.
To remove it, pass its identifier with `taks_id` parameter.
When the identifier is not found, a `NotFoundError` exception
is raised.
:param task_id: identifier of the task to remove
:raises NotFoundError: r... | [
"Remove",
"a",
"task",
"from",
"the",
"registry",
"."
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/tasks.py#L139-L159 | [
"def",
"remove",
"(",
"self",
",",
"task_id",
")",
":",
"try",
":",
"self",
".",
"_rwlock",
".",
"writer_acquire",
"(",
")",
"del",
"self",
".",
"_tasks",
"[",
"task_id",
"]",
"except",
"KeyError",
":",
"raise",
"NotFoundError",
"(",
"element",
"=",
"s... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | TaskRegistry.get | Get a task from the registry.
Retrieve a task from the registry using its task identifier. When
the task does not exist, a `NotFoundError` exception will be
raised.
:param task_id: task identifier
:returns: a task object
:raises NotFoundError: raised when the requeste... | arthur/tasks.py | def get(self, task_id):
"""Get a task from the registry.
Retrieve a task from the registry using its task identifier. When
the task does not exist, a `NotFoundError` exception will be
raised.
:param task_id: task identifier
:returns: a task object
:raises NotF... | def get(self, task_id):
"""Get a task from the registry.
Retrieve a task from the registry using its task identifier. When
the task does not exist, a `NotFoundError` exception will be
raised.
:param task_id: task identifier
:returns: a task object
:raises NotF... | [
"Get",
"a",
"task",
"from",
"the",
"registry",
"."
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/tasks.py#L161-L183 | [
"def",
"get",
"(",
"self",
",",
"task_id",
")",
":",
"try",
":",
"self",
".",
"_rwlock",
".",
"reader_acquire",
"(",
")",
"task",
"=",
"self",
".",
"_tasks",
"[",
"task_id",
"]",
"except",
"KeyError",
":",
"raise",
"NotFoundError",
"(",
"element",
"=",... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | TaskRegistry.tasks | Get the list of tasks | arthur/tasks.py | def tasks(self):
"""Get the list of tasks"""
self._rwlock.reader_acquire()
tl = [v for v in self._tasks.values()]
tl.sort(key=lambda x: x.task_id)
self._rwlock.reader_release()
return tl | def tasks(self):
"""Get the list of tasks"""
self._rwlock.reader_acquire()
tl = [v for v in self._tasks.values()]
tl.sort(key=lambda x: x.task_id)
self._rwlock.reader_release()
return tl | [
"Get",
"the",
"list",
"of",
"tasks"
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/tasks.py#L186-L194 | [
"def",
"tasks",
"(",
"self",
")",
":",
"self",
".",
"_rwlock",
".",
"reader_acquire",
"(",
")",
"tl",
"=",
"[",
"v",
"for",
"v",
"in",
"self",
".",
"_tasks",
".",
"values",
"(",
")",
"]",
"tl",
".",
"sort",
"(",
"key",
"=",
"lambda",
"x",
":",
... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | _TaskConfig.to_dict | Returns a dict with the representation of this task configuration object. | arthur/tasks.py | def to_dict(self):
"""Returns a dict with the representation of this task configuration object."""
properties = find_class_properties(self.__class__)
config = {
name: self.__getattribute__(name) for name, _ in properties
}
return config | def to_dict(self):
"""Returns a dict with the representation of this task configuration object."""
properties = find_class_properties(self.__class__)
config = {
name: self.__getattribute__(name) for name, _ in properties
}
return config | [
"Returns",
"a",
"dict",
"with",
"the",
"representation",
"of",
"this",
"task",
"configuration",
"object",
"."
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/tasks.py#L214-L221 | [
"def",
"to_dict",
"(",
"self",
")",
":",
"properties",
"=",
"find_class_properties",
"(",
"self",
".",
"__class__",
")",
"config",
"=",
"{",
"name",
":",
"self",
".",
"__getattribute__",
"(",
"name",
")",
"for",
"name",
",",
"_",
"in",
"properties",
"}",... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | _TaskConfig.from_dict | Create an configuration object from a dictionary.
Key,value pairs will be used to initialize a task configuration
object. If 'config' contains invalid configuration parameters
a `ValueError` exception will be raised.
:param config: dictionary used to create an instance of this object
... | arthur/tasks.py | def from_dict(cls, config):
"""Create an configuration object from a dictionary.
Key,value pairs will be used to initialize a task configuration
object. If 'config' contains invalid configuration parameters
a `ValueError` exception will be raised.
:param config: dictionary used... | def from_dict(cls, config):
"""Create an configuration object from a dictionary.
Key,value pairs will be used to initialize a task configuration
object. If 'config' contains invalid configuration parameters
a `ValueError` exception will be raised.
:param config: dictionary used... | [
"Create",
"an",
"configuration",
"object",
"from",
"a",
"dictionary",
"."
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/tasks.py#L224-L246 | [
"def",
"from_dict",
"(",
"cls",
",",
"config",
")",
":",
"try",
":",
"obj",
"=",
"cls",
"(",
"*",
"*",
"config",
")",
"except",
"TypeError",
"as",
"e",
":",
"m",
"=",
"cls",
".",
"KW_ARGS_ERROR_REGEX",
".",
"match",
"(",
"str",
"(",
"e",
")",
")"... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | metadata | Add metadata to an item.
Decorator that adds metadata to Perceval items such as the
identifier of the job that generated it or the version of
the system. The contents from the original item will
be stored under the 'data' keyword.
Take into account that this function only can be called from
a ... | arthur/jobs.py | def metadata(func):
"""Add metadata to an item.
Decorator that adds metadata to Perceval items such as the
identifier of the job that generated it or the version of
the system. The contents from the original item will
be stored under the 'data' keyword.
Take into account that this function onl... | def metadata(func):
"""Add metadata to an item.
Decorator that adds metadata to Perceval items such as the
identifier of the job that generated it or the version of
the system. The contents from the original item will
be stored under the 'data' keyword.
Take into account that this function onl... | [
"Add",
"metadata",
"to",
"an",
"item",
"."
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/jobs.py#L46-L64 | [
"def",
"metadata",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"decorator",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"item",
"in",
"func",
"(",
"self",
",",
"*",
"args",
",",
"... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | execute_perceval_job | Execute a Perceval job on RQ.
The items fetched during the process will be stored in a
Redis queue named `queue`.
Setting the parameter `archive_path`, raw data will be stored
with the archive manager. The contents from the archive can
be retrieved setting the pameter `fetch_from_archive` to `True... | arthur/jobs.py | def execute_perceval_job(backend, backend_args, qitems, task_id, category,
archive_args=None, max_retries=MAX_JOB_RETRIES):
"""Execute a Perceval job on RQ.
The items fetched during the process will be stored in a
Redis queue named `queue`.
Setting the parameter `archive_path`... | def execute_perceval_job(backend, backend_args, qitems, task_id, category,
archive_args=None, max_retries=MAX_JOB_RETRIES):
"""Execute a Perceval job on RQ.
The items fetched during the process will be stored in a
Redis queue named `queue`.
Setting the parameter `archive_path`... | [
"Execute",
"a",
"Perceval",
"job",
"on",
"RQ",
"."
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/jobs.py#L244-L315 | [
"def",
"execute_perceval_job",
"(",
"backend",
",",
"backend_args",
",",
"qitems",
",",
"task_id",
",",
"category",
",",
"archive_args",
"=",
"None",
",",
"max_retries",
"=",
"MAX_JOB_RETRIES",
")",
":",
"rq_job",
"=",
"rq",
".",
"get_current_job",
"(",
")",
... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | PercevalJob.initialize_archive_manager | Initialize the archive manager.
:param archive_path: path where the archive manager is located | arthur/jobs.py | def initialize_archive_manager(self, archive_path):
"""Initialize the archive manager.
:param archive_path: path where the archive manager is located
"""
if archive_path == "":
raise ValueError("Archive manager path cannot be empty")
if archive_path:
sel... | def initialize_archive_manager(self, archive_path):
"""Initialize the archive manager.
:param archive_path: path where the archive manager is located
"""
if archive_path == "":
raise ValueError("Archive manager path cannot be empty")
if archive_path:
sel... | [
"Initialize",
"the",
"archive",
"manager",
"."
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/jobs.py#L135-L144 | [
"def",
"initialize_archive_manager",
"(",
"self",
",",
"archive_path",
")",
":",
"if",
"archive_path",
"==",
"\"\"",
":",
"raise",
"ValueError",
"(",
"\"Archive manager path cannot be empty\"",
")",
"if",
"archive_path",
":",
"self",
".",
"archive_manager",
"=",
"pe... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | PercevalJob.run | Run the backend with the given parameters.
The method will run the backend assigned to this job,
storing the fetched items in a Redis queue. The ongoing
status of the job, can be accessed through the property
`result`. When `resume` is set, the job will start from
the last execu... | arthur/jobs.py | def run(self, backend_args, archive_args=None, resume=False):
"""Run the backend with the given parameters.
The method will run the backend assigned to this job,
storing the fetched items in a Redis queue. The ongoing
status of the job, can be accessed through the property
`resu... | def run(self, backend_args, archive_args=None, resume=False):
"""Run the backend with the given parameters.
The method will run the backend assigned to this job,
storing the fetched items in a Redis queue. The ongoing
status of the job, can be accessed through the property
`resu... | [
"Run",
"the",
"backend",
"with",
"the",
"given",
"parameters",
"."
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/jobs.py#L146-L198 | [
"def",
"run",
"(",
"self",
",",
"backend_args",
",",
"archive_args",
"=",
"None",
",",
"resume",
"=",
"False",
")",
":",
"args",
"=",
"backend_args",
".",
"copy",
"(",
")",
"if",
"archive_args",
":",
"self",
".",
"initialize_archive_manager",
"(",
"archive... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | PercevalJob._execute | Execute a backend of Perceval.
Run the backend of Perceval assigned to this job using the
given arguments. It will raise an `AttributeError` when any of
the required parameters to run the backend are not found.
Other exceptions related to the execution of the backend
will be rai... | arthur/jobs.py | def _execute(self, backend_args, archive_args):
"""Execute a backend of Perceval.
Run the backend of Perceval assigned to this job using the
given arguments. It will raise an `AttributeError` when any of
the required parameters to run the backend are not found.
Other exceptions ... | def _execute(self, backend_args, archive_args):
"""Execute a backend of Perceval.
Run the backend of Perceval assigned to this job using the
given arguments. It will raise an `AttributeError` when any of
the required parameters to run the backend are not found.
Other exceptions ... | [
"Execute",
"a",
"backend",
"of",
"Perceval",
"."
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/jobs.py#L211-L241 | [
"def",
"_execute",
"(",
"self",
",",
"backend_args",
",",
"archive_args",
")",
":",
"if",
"not",
"archive_args",
"or",
"not",
"archive_args",
"[",
"'fetch_from_archive'",
"]",
":",
"return",
"perceval",
".",
"backend",
".",
"fetch",
"(",
"self",
".",
"_bklas... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | ElasticItemsWriter.create_index | Configure the index to work with | arthur/writers.py | def create_index(idx_url, clean=False):
"""Configure the index to work with"""
try:
r = requests.get(idx_url)
except requests.exceptions.ConnectionError:
cause = "Error connecting to Elastic Search (index: %s)" % idx_url
raise ElasticSearchError(cause=cause)
... | def create_index(idx_url, clean=False):
"""Configure the index to work with"""
try:
r = requests.get(idx_url)
except requests.exceptions.ConnectionError:
cause = "Error connecting to Elastic Search (index: %s)" % idx_url
raise ElasticSearchError(cause=cause)
... | [
"Configure",
"the",
"index",
"to",
"work",
"with"
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/writers.py#L124-L150 | [
"def",
"create_index",
"(",
"idx_url",
",",
"clean",
"=",
"False",
")",
":",
"try",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"idx_url",
")",
"except",
"requests",
".",
"exceptions",
".",
"ConnectionError",
":",
"cause",
"=",
"\"Error connecting to Elastic... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | ElasticItemsWriter.create_mapping | Create a mapping | arthur/writers.py | def create_mapping(idx_url, mapping):
"""Create a mapping"""
mapping_url = idx_url + '/items/_mapping'
mapping = json.dumps(mapping)
try:
r = requests.put(mapping_url, data=mapping,
headers={'Content-Type': 'application/json'})
except re... | def create_mapping(idx_url, mapping):
"""Create a mapping"""
mapping_url = idx_url + '/items/_mapping'
mapping = json.dumps(mapping)
try:
r = requests.put(mapping_url, data=mapping,
headers={'Content-Type': 'application/json'})
except re... | [
"Create",
"a",
"mapping"
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/writers.py#L153-L175 | [
"def",
"create_mapping",
"(",
"idx_url",
",",
"mapping",
")",
":",
"mapping_url",
"=",
"idx_url",
"+",
"'/items/_mapping'",
"mapping",
"=",
"json",
".",
"dumps",
"(",
"mapping",
")",
"try",
":",
"r",
"=",
"requests",
".",
"put",
"(",
"mapping_url",
",",
... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | json_encoder | Custom JSON encoder handler | arthur/server.py | def json_encoder(*args, **kwargs):
"""Custom JSON encoder handler"""
obj = cherrypy.serving.request._json_inner_handler(*args, **kwargs)
for chunk in JSONEncoder().iterencode(obj):
yield chunk.encode('utf-8') | def json_encoder(*args, **kwargs):
"""Custom JSON encoder handler"""
obj = cherrypy.serving.request._json_inner_handler(*args, **kwargs)
for chunk in JSONEncoder().iterencode(obj):
yield chunk.encode('utf-8') | [
"Custom",
"JSON",
"encoder",
"handler"
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/server.py#L39-L45 | [
"def",
"json_encoder",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"obj",
"=",
"cherrypy",
".",
"serving",
".",
"request",
".",
"_json_inner_handler",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"for",
"chunk",
"in",
"JSONEncoder",
"(",
... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | ArthurServer.write_items | Write items to the queue
:param writer: the writer object
:param items_generator: items to be written in the queue | arthur/server.py | def write_items(cls, writer, items_generator):
"""Write items to the queue
:param writer: the writer object
:param items_generator: items to be written in the queue
"""
while True:
items = items_generator()
writer.write(items)
time.sleep(1) | def write_items(cls, writer, items_generator):
"""Write items to the queue
:param writer: the writer object
:param items_generator: items to be written in the queue
"""
while True:
items = items_generator()
writer.write(items)
time.sleep(1) | [
"Write",
"items",
"to",
"the",
"queue"
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/server.py#L73-L82 | [
"def",
"write_items",
"(",
"cls",
",",
"writer",
",",
"items_generator",
")",
":",
"while",
"True",
":",
"items",
"=",
"items_generator",
"(",
")",
"writer",
".",
"write",
"(",
"items",
")",
"time",
".",
"sleep",
"(",
"1",
")"
] | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | ArthurServer.add | Add tasks | arthur/server.py | def add(self):
"""Add tasks"""
payload = cherrypy.request.json
logger.debug("Reading tasks...")
for task_data in payload['tasks']:
try:
category = task_data['category']
backend_args = task_data['backend_args']
archive_args = t... | def add(self):
"""Add tasks"""
payload = cherrypy.request.json
logger.debug("Reading tasks...")
for task_data in payload['tasks']:
try:
category = task_data['category']
backend_args = task_data['backend_args']
archive_args = t... | [
"Add",
"tasks"
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/server.py#L86-L115 | [
"def",
"add",
"(",
"self",
")",
":",
"payload",
"=",
"cherrypy",
".",
"request",
".",
"json",
"logger",
".",
"debug",
"(",
"\"Reading tasks...\"",
")",
"for",
"task_data",
"in",
"payload",
"[",
"'tasks'",
"]",
":",
"try",
":",
"category",
"=",
"task_data... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | ArthurServer.remove | Remove tasks | arthur/server.py | def remove(self):
"""Remove tasks"""
payload = cherrypy.request.json
logger.debug("Reading tasks to remove...")
task_ids = {}
for task_data in payload['tasks']:
task_id = task_data['task_id']
removed = super().remove_task(task_id)
task_ids[t... | def remove(self):
"""Remove tasks"""
payload = cherrypy.request.json
logger.debug("Reading tasks to remove...")
task_ids = {}
for task_data in payload['tasks']:
task_id = task_data['task_id']
removed = super().remove_task(task_id)
task_ids[t... | [
"Remove",
"tasks"
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/server.py#L120-L135 | [
"def",
"remove",
"(",
"self",
")",
":",
"payload",
"=",
"cherrypy",
".",
"request",
".",
"json",
"logger",
".",
"debug",
"(",
"\"Reading tasks to remove...\"",
")",
"task_ids",
"=",
"{",
"}",
"for",
"task_data",
"in",
"payload",
"[",
"'tasks'",
"]",
":",
... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | ArthurServer.tasks | List tasks | arthur/server.py | def tasks(self):
"""List tasks"""
logger.debug("API 'tasks' method called")
result = [task.to_dict() for task in self._tasks.tasks]
result = {'tasks': result}
logger.debug("Tasks registry read")
return result | def tasks(self):
"""List tasks"""
logger.debug("API 'tasks' method called")
result = [task.to_dict() for task in self._tasks.tasks]
result = {'tasks': result}
logger.debug("Tasks registry read")
return result | [
"List",
"tasks"
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/server.py#L139-L149 | [
"def",
"tasks",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"API 'tasks' method called\"",
")",
"result",
"=",
"[",
"task",
".",
"to_dict",
"(",
")",
"for",
"task",
"in",
"self",
".",
"_tasks",
".",
"tasks",
"]",
"result",
"=",
"{",
"'tasks'"... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | Arthur.add_task | Add and schedule a task.
:param task_id: id of the task
:param backend: name of the backend
:param category: category of the items to fecth
:param backend_args: args needed to initialize the backend
:param archive_args: args needed to initialize the archive
:param sched_... | arthur/arthur.py | def add_task(self, task_id, backend, category, backend_args,
archive_args=None, sched_args=None):
"""Add and schedule a task.
:param task_id: id of the task
:param backend: name of the backend
:param category: category of the items to fecth
:param backend_args: ... | def add_task(self, task_id, backend, category, backend_args,
archive_args=None, sched_args=None):
"""Add and schedule a task.
:param task_id: id of the task
:param backend: name of the backend
:param category: category of the items to fecth
:param backend_args: ... | [
"Add",
"and",
"schedule",
"a",
"task",
"."
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/arthur.py#L61-L90 | [
"def",
"add_task",
"(",
"self",
",",
"task_id",
",",
"backend",
",",
"category",
",",
"backend_args",
",",
"archive_args",
"=",
"None",
",",
"sched_args",
"=",
"None",
")",
":",
"try",
":",
"archiving_cfg",
"=",
"self",
".",
"__parse_archive_args",
"(",
"a... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | Arthur.remove_task | Remove and cancel a task.
:param task_id: id of the task to be removed | arthur/arthur.py | def remove_task(self, task_id):
"""Remove and cancel a task.
:param task_id: id of the task to be removed
"""
try:
self._scheduler.cancel_task(task_id)
except NotFoundError as e:
logger.info("Cannot cancel %s task because it does not exist.",
... | def remove_task(self, task_id):
"""Remove and cancel a task.
:param task_id: id of the task to be removed
"""
try:
self._scheduler.cancel_task(task_id)
except NotFoundError as e:
logger.info("Cannot cancel %s task because it does not exist.",
... | [
"Remove",
"and",
"cancel",
"a",
"task",
"."
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/arthur.py#L92-L104 | [
"def",
"remove_task",
"(",
"self",
",",
"task_id",
")",
":",
"try",
":",
"self",
".",
"_scheduler",
".",
"cancel_task",
"(",
"task_id",
")",
"except",
"NotFoundError",
"as",
"e",
":",
"logger",
".",
"info",
"(",
"\"Cannot cancel %s task because it does not exist... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | Arthur.items | Get the items fetched by the jobs. | arthur/arthur.py | def items(self):
"""Get the items fetched by the jobs."""
# Get and remove queued items in an atomic transaction
pipe = self.conn.pipeline()
pipe.lrange(Q_STORAGE_ITEMS, 0, -1)
pipe.ltrim(Q_STORAGE_ITEMS, 1, 0)
items = pipe.execute()[0]
for item in items:
... | def items(self):
"""Get the items fetched by the jobs."""
# Get and remove queued items in an atomic transaction
pipe = self.conn.pipeline()
pipe.lrange(Q_STORAGE_ITEMS, 0, -1)
pipe.ltrim(Q_STORAGE_ITEMS, 1, 0)
items = pipe.execute()[0]
for item in items:
... | [
"Get",
"the",
"items",
"fetched",
"by",
"the",
"jobs",
"."
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/arthur.py#L106-L117 | [
"def",
"items",
"(",
"self",
")",
":",
"# Get and remove queued items in an atomic transaction",
"pipe",
"=",
"self",
".",
"conn",
".",
"pipeline",
"(",
")",
"pipe",
".",
"lrange",
"(",
"Q_STORAGE_ITEMS",
",",
"0",
",",
"-",
"1",
")",
"pipe",
".",
"ltrim",
... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | Arthur.__validate_args | Check that the task arguments received are valid | arthur/arthur.py | def __validate_args(task_id, backend, category, backend_args):
"""Check that the task arguments received are valid"""
if not task_id or task_id.strip() == "":
msg = "Missing task_id for task"
raise ValueError(msg)
if not backend or backend.strip() == "":
msg... | def __validate_args(task_id, backend, category, backend_args):
"""Check that the task arguments received are valid"""
if not task_id or task_id.strip() == "":
msg = "Missing task_id for task"
raise ValueError(msg)
if not backend or backend.strip() == "":
msg... | [
"Check",
"that",
"the",
"task",
"arguments",
"received",
"are",
"valid"
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/arthur.py#L120-L137 | [
"def",
"__validate_args",
"(",
"task_id",
",",
"backend",
",",
"category",
",",
"backend_args",
")",
":",
"if",
"not",
"task_id",
"or",
"task_id",
".",
"strip",
"(",
")",
"==",
"\"\"",
":",
"msg",
"=",
"\"Missing task_id for task\"",
"raise",
"ValueError",
"... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | Arthur.__parse_archive_args | Parse the archive arguments of a task | arthur/arthur.py | def __parse_archive_args(self, archive_args):
"""Parse the archive arguments of a task"""
if not archive_args:
return None
archiving_args = copy.deepcopy(archive_args)
if self.archive_path:
archiving_args['archive_path'] = self.archive_path
else:
... | def __parse_archive_args(self, archive_args):
"""Parse the archive arguments of a task"""
if not archive_args:
return None
archiving_args = copy.deepcopy(archive_args)
if self.archive_path:
archiving_args['archive_path'] = self.archive_path
else:
... | [
"Parse",
"the",
"archive",
"arguments",
"of",
"a",
"task"
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/arthur.py#L139-L152 | [
"def",
"__parse_archive_args",
"(",
"self",
",",
"archive_args",
")",
":",
"if",
"not",
"archive_args",
":",
"return",
"None",
"archiving_args",
"=",
"copy",
".",
"deepcopy",
"(",
"archive_args",
")",
"if",
"self",
".",
"archive_path",
":",
"archiving_args",
"... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | ArthurWorker.perform_job | Custom method to execute a job and notify of its result
:param job: Job object
:param queue: the queue containing the object | arthur/worker.py | def perform_job(self, job, queue):
"""Custom method to execute a job and notify of its result
:param job: Job object
:param queue: the queue containing the object
"""
result = super().perform_job(job, queue)
job_status = job.get_status()
job_result = job.return... | def perform_job(self, job, queue):
"""Custom method to execute a job and notify of its result
:param job: Job object
:param queue: the queue containing the object
"""
result = super().perform_job(job, queue)
job_status = job.get_status()
job_result = job.return... | [
"Custom",
"method",
"to",
"execute",
"a",
"job",
"and",
"notify",
"of",
"its",
"result"
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/worker.py#L50-L71 | [
"def",
"perform_job",
"(",
"self",
",",
"job",
",",
"queue",
")",
":",
"result",
"=",
"super",
"(",
")",
".",
"perform_job",
"(",
"job",
",",
"queue",
")",
"job_status",
"=",
"job",
".",
"get_status",
"(",
")",
"job_result",
"=",
"job",
".",
"return_... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | _JobScheduler.schedule_job_task | Schedule a job in the given queue. | arthur/scheduler.py | def schedule_job_task(self, queue_id, task_id, job_args, delay=0):
"""Schedule a job in the given queue."""
self._rwlock.writer_acquire()
job_id = self._generate_job_id(task_id)
event = self._scheduler.enter(delay, 1, self._enqueue_job,
argument=(... | def schedule_job_task(self, queue_id, task_id, job_args, delay=0):
"""Schedule a job in the given queue."""
self._rwlock.writer_acquire()
job_id = self._generate_job_id(task_id)
event = self._scheduler.enter(delay, 1, self._enqueue_job,
argument=(... | [
"Schedule",
"a",
"job",
"in",
"the",
"given",
"queue",
"."
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/scheduler.py#L117-L134 | [
"def",
"schedule_job_task",
"(",
"self",
",",
"queue_id",
",",
"task_id",
",",
"job_args",
",",
"delay",
"=",
"0",
")",
":",
"self",
".",
"_rwlock",
".",
"writer_acquire",
"(",
")",
"job_id",
"=",
"self",
".",
"_generate_job_id",
"(",
"task_id",
")",
"ev... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | _JobScheduler.cancel_job_task | Cancel the job related to the given task. | arthur/scheduler.py | def cancel_job_task(self, task_id):
"""Cancel the job related to the given task."""
try:
self._rwlock.writer_acquire()
job_id = self._tasks.get(task_id, None)
if job_id:
self._cancel_job(job_id)
else:
logger.warning("Task... | def cancel_job_task(self, task_id):
"""Cancel the job related to the given task."""
try:
self._rwlock.writer_acquire()
job_id = self._tasks.get(task_id, None)
if job_id:
self._cancel_job(job_id)
else:
logger.warning("Task... | [
"Cancel",
"the",
"job",
"related",
"to",
"the",
"given",
"task",
"."
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/scheduler.py#L136-L150 | [
"def",
"cancel_job_task",
"(",
"self",
",",
"task_id",
")",
":",
"try",
":",
"self",
".",
"_rwlock",
".",
"writer_acquire",
"(",
")",
"job_id",
"=",
"self",
".",
"_tasks",
".",
"get",
"(",
"task_id",
",",
"None",
")",
"if",
"job_id",
":",
"self",
"."... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | _JobListener.run | Run thread to listen for jobs and reschedule successful ones. | arthur/scheduler.py | def run(self):
"""Run thread to listen for jobs and reschedule successful ones."""
try:
self.listen()
except Exception as e:
logger.critical("JobListener instence crashed. Error: %s", str(e))
logger.critical(traceback.format_exc()) | def run(self):
"""Run thread to listen for jobs and reschedule successful ones."""
try:
self.listen()
except Exception as e:
logger.critical("JobListener instence crashed. Error: %s", str(e))
logger.critical(traceback.format_exc()) | [
"Run",
"thread",
"to",
"listen",
"for",
"jobs",
"and",
"reschedule",
"successful",
"ones",
"."
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/scheduler.py#L211-L218 | [
"def",
"run",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"listen",
"(",
")",
"except",
"Exception",
"as",
"e",
":",
"logger",
".",
"critical",
"(",
"\"JobListener instence crashed. Error: %s\"",
",",
"str",
"(",
"e",
")",
")",
"logger",
".",
"critic... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | _JobListener.listen | Listen for completed jobs and reschedule successful ones. | arthur/scheduler.py | def listen(self):
"""Listen for completed jobs and reschedule successful ones."""
pubsub = self.conn.pubsub()
pubsub.subscribe(self.pubsub_channel)
logger.debug("Listening on channel %s", self.pubsub_channel)
for msg in pubsub.listen():
logger.debug("New message re... | def listen(self):
"""Listen for completed jobs and reschedule successful ones."""
pubsub = self.conn.pubsub()
pubsub.subscribe(self.pubsub_channel)
logger.debug("Listening on channel %s", self.pubsub_channel)
for msg in pubsub.listen():
logger.debug("New message re... | [
"Listen",
"for",
"completed",
"jobs",
"and",
"reschedule",
"successful",
"ones",
"."
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/scheduler.py#L220-L251 | [
"def",
"listen",
"(",
"self",
")",
":",
"pubsub",
"=",
"self",
".",
"conn",
".",
"pubsub",
"(",
")",
"pubsub",
".",
"subscribe",
"(",
"self",
".",
"pubsub_channel",
")",
"logger",
".",
"debug",
"(",
"\"Listening on channel %s\"",
",",
"self",
".",
"pubsu... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | Scheduler.schedule | Start scheduling jobs. | arthur/scheduler.py | def schedule(self):
"""Start scheduling jobs."""
if self.async_mode:
self._scheduler.start()
self._listener.start()
else:
self._scheduler.schedule() | def schedule(self):
"""Start scheduling jobs."""
if self.async_mode:
self._scheduler.start()
self._listener.start()
else:
self._scheduler.schedule() | [
"Start",
"scheduling",
"jobs",
"."
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/scheduler.py#L280-L287 | [
"def",
"schedule",
"(",
"self",
")",
":",
"if",
"self",
".",
"async_mode",
":",
"self",
".",
"_scheduler",
".",
"start",
"(",
")",
"self",
".",
"_listener",
".",
"start",
"(",
")",
"else",
":",
"self",
".",
"_scheduler",
".",
"schedule",
"(",
")"
] | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | Scheduler.schedule_task | Schedule a task.
:param task_id: identifier of the task to schedule
:raises NotFoundError: raised when the requested task is not
found in the registry | arthur/scheduler.py | def schedule_task(self, task_id):
"""Schedule a task.
:param task_id: identifier of the task to schedule
:raises NotFoundError: raised when the requested task is not
found in the registry
"""
task = self.registry.get(task_id)
job_args = self._build_job_argu... | def schedule_task(self, task_id):
"""Schedule a task.
:param task_id: identifier of the task to schedule
:raises NotFoundError: raised when the requested task is not
found in the registry
"""
task = self.registry.get(task_id)
job_args = self._build_job_argu... | [
"Schedule",
"a",
"task",
"."
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/scheduler.py#L289-L312 | [
"def",
"schedule_task",
"(",
"self",
",",
"task_id",
")",
":",
"task",
"=",
"self",
".",
"registry",
".",
"get",
"(",
"task_id",
")",
"job_args",
"=",
"self",
".",
"_build_job_arguments",
"(",
"task",
")",
"archiving_cfg",
"=",
"task",
".",
"archiving_cfg"... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | Scheduler.cancel_task | Cancel or 'un-schedule' a task.
:param task_id: identifier of the task to cancel
:raises NotFoundError: raised when the requested task is not
found in the registry | arthur/scheduler.py | def cancel_task(self, task_id):
"""Cancel or 'un-schedule' a task.
:param task_id: identifier of the task to cancel
:raises NotFoundError: raised when the requested task is not
found in the registry
"""
self.registry.remove(task_id)
self._scheduler.cancel_jo... | def cancel_task(self, task_id):
"""Cancel or 'un-schedule' a task.
:param task_id: identifier of the task to cancel
:raises NotFoundError: raised when the requested task is not
found in the registry
"""
self.registry.remove(task_id)
self._scheduler.cancel_jo... | [
"Cancel",
"or",
"un",
"-",
"schedule",
"a",
"task",
"."
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/scheduler.py#L314-L325 | [
"def",
"cancel_task",
"(",
"self",
",",
"task_id",
")",
":",
"self",
".",
"registry",
".",
"remove",
"(",
"task_id",
")",
"self",
".",
"_scheduler",
".",
"cancel_job_task",
"(",
"task_id",
")",
"logger",
".",
"info",
"(",
"\"Task %s canceled\"",
",",
"task... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | Scheduler._handle_successful_job | Handle successufl jobs | arthur/scheduler.py | def _handle_successful_job(self, job):
"""Handle successufl jobs"""
result = job.result
task_id = job.kwargs['task_id']
try:
task = self.registry.get(task_id)
except NotFoundError:
logger.warning("Task %s not found; related job #%s will not be reschedule... | def _handle_successful_job(self, job):
"""Handle successufl jobs"""
result = job.result
task_id = job.kwargs['task_id']
try:
task = self.registry.get(task_id)
except NotFoundError:
logger.warning("Task %s not found; related job #%s will not be reschedule... | [
"Handle",
"successufl",
"jobs"
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/scheduler.py#L327-L359 | [
"def",
"_handle_successful_job",
"(",
"self",
",",
"job",
")",
":",
"result",
"=",
"job",
".",
"result",
"task_id",
"=",
"job",
".",
"kwargs",
"[",
"'task_id'",
"]",
"try",
":",
"task",
"=",
"self",
".",
"registry",
".",
"get",
"(",
"task_id",
")",
"... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | Scheduler._handle_failed_job | Handle failed jobs | arthur/scheduler.py | def _handle_failed_job(self, job):
"""Handle failed jobs"""
task_id = job.kwargs['task_id']
logger.error("Job #%s (task: %s) failed; cancelled",
job.id, task_id) | def _handle_failed_job(self, job):
"""Handle failed jobs"""
task_id = job.kwargs['task_id']
logger.error("Job #%s (task: %s) failed; cancelled",
job.id, task_id) | [
"Handle",
"failed",
"jobs"
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/scheduler.py#L361-L366 | [
"def",
"_handle_failed_job",
"(",
"self",
",",
"job",
")",
":",
"task_id",
"=",
"job",
".",
"kwargs",
"[",
"'task_id'",
"]",
"logger",
".",
"error",
"(",
"\"Job #%s (task: %s) failed; cancelled\"",
",",
"job",
".",
"id",
",",
"task_id",
")"
] | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | Scheduler._build_job_arguments | Build the set of arguments required for running a job | arthur/scheduler.py | def _build_job_arguments(task):
"""Build the set of arguments required for running a job"""
job_args = {}
job_args['qitems'] = Q_STORAGE_ITEMS
job_args['task_id'] = task.task_id
# Backend parameters
job_args['backend'] = task.backend
backend_args = copy.deepcopy... | def _build_job_arguments(task):
"""Build the set of arguments required for running a job"""
job_args = {}
job_args['qitems'] = Q_STORAGE_ITEMS
job_args['task_id'] = task.task_id
# Backend parameters
job_args['backend'] = task.backend
backend_args = copy.deepcopy... | [
"Build",
"the",
"set",
"of",
"arguments",
"required",
"for",
"running",
"a",
"job"
] | chaoss/grimoirelab-kingarthur | python | https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/scheduler.py#L369-L399 | [
"def",
"_build_job_arguments",
"(",
"task",
")",
":",
"job_args",
"=",
"{",
"}",
"job_args",
"[",
"'qitems'",
"]",
"=",
"Q_STORAGE_ITEMS",
"job_args",
"[",
"'task_id'",
"]",
"=",
"task",
".",
"task_id",
"# Backend parameters",
"job_args",
"[",
"'backend'",
"]"... | 9d6a638bee68d5e5c511f045eeebf06340fd3252 |
test | get_secret | Gets contents of secret file
:param secret_name: The name of the secret present in BANANAS_SECRETS_DIR
:param default: Default value to return if no secret was found
:return: The secret or default if not found | bananas/secrets.py | def get_secret(secret_name, default=None):
"""
Gets contents of secret file
:param secret_name: The name of the secret present in BANANAS_SECRETS_DIR
:param default: Default value to return if no secret was found
:return: The secret or default if not found
"""
secrets_dir = get_secrets_dir(... | def get_secret(secret_name, default=None):
"""
Gets contents of secret file
:param secret_name: The name of the secret present in BANANAS_SECRETS_DIR
:param default: Default value to return if no secret was found
:return: The secret or default if not found
"""
secrets_dir = get_secrets_dir(... | [
"Gets",
"contents",
"of",
"secret",
"file"
] | 5monkeys/django-bananas | python | https://github.com/5monkeys/django-bananas/blob/cfd318c737f6c4580036c13d2acf32bca96654bf/bananas/secrets.py#L8-L22 | [
"def",
"get_secret",
"(",
"secret_name",
",",
"default",
"=",
"None",
")",
":",
"secrets_dir",
"=",
"get_secrets_dir",
"(",
")",
"secret_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"secrets_dir",
",",
"secret_name",
")",
"try",
":",
"with",
"open",
... | cfd318c737f6c4580036c13d2acf32bca96654bf |
test | register | Register the API view class in the bananas router.
:param BananasAPI view: | bananas/admin/api/router.py | def register(view): # Type[BananasAPI]
"""
Register the API view class in the bananas router.
:param BananasAPI view:
"""
meta = view.get_admin_meta()
prefix = meta.basename.replace(".", "/")
router.register(prefix, view, meta.basename) | def register(view): # Type[BananasAPI]
"""
Register the API view class in the bananas router.
:param BananasAPI view:
"""
meta = view.get_admin_meta()
prefix = meta.basename.replace(".", "/")
router.register(prefix, view, meta.basename) | [
"Register",
"the",
"API",
"view",
"class",
"in",
"the",
"bananas",
"router",
"."
] | 5monkeys/django-bananas | python | https://github.com/5monkeys/django-bananas/blob/cfd318c737f6c4580036c13d2acf32bca96654bf/bananas/admin/api/router.py#L6-L14 | [
"def",
"register",
"(",
"view",
")",
":",
"# Type[BananasAPI]",
"meta",
"=",
"view",
".",
"get_admin_meta",
"(",
")",
"prefix",
"=",
"meta",
".",
"basename",
".",
"replace",
"(",
"\".\"",
",",
"\"/\"",
")",
"router",
".",
"register",
"(",
"prefix",
",",
... | cfd318c737f6c4580036c13d2acf32bca96654bf |
test | register | Register a generic class based view wrapped with ModelAdmin and fake model
:param view: The AdminView to register.
:param admin_site: The AdminSite to register the view on.
Defaults to bananas.admin.ExtendedAdminSite.
:param admin_class: The ModelAdmin class to use for eg. permissions.
Defa... | bananas/admin/extension.py | def register(view=None, *, admin_site=None, admin_class=ModelAdminView):
"""
Register a generic class based view wrapped with ModelAdmin and fake model
:param view: The AdminView to register.
:param admin_site: The AdminSite to register the view on.
Defaults to bananas.admin.ExtendedAdminSite.
... | def register(view=None, *, admin_site=None, admin_class=ModelAdminView):
"""
Register a generic class based view wrapped with ModelAdmin and fake model
:param view: The AdminView to register.
:param admin_site: The AdminSite to register the view on.
Defaults to bananas.admin.ExtendedAdminSite.
... | [
"Register",
"a",
"generic",
"class",
"based",
"view",
"wrapped",
"with",
"ModelAdmin",
"and",
"fake",
"model"
] | 5monkeys/django-bananas | python | https://github.com/5monkeys/django-bananas/blob/cfd318c737f6c4580036c13d2acf32bca96654bf/bananas/admin/extension.py#L144-L221 | [
"def",
"register",
"(",
"view",
"=",
"None",
",",
"*",
",",
"admin_site",
"=",
"None",
",",
"admin_class",
"=",
"ModelAdminView",
")",
":",
"if",
"not",
"admin_site",
":",
"admin_site",
"=",
"site",
"def",
"wrapped",
"(",
"inner_view",
")",
":",
"module"... | cfd318c737f6c4580036c13d2acf32bca96654bf |
test | BananasAPI.reverse_action | Extended DRF with fallback to requested namespace if request.version is missing | bananas/admin/api/mixins.py | def reverse_action(self, url_name, *args, **kwargs):
"""
Extended DRF with fallback to requested namespace if request.version is missing
"""
if self.request and not self.request.version:
return reverse(self.get_url_name(url_name), *args, **kwargs)
return super().reve... | def reverse_action(self, url_name, *args, **kwargs):
"""
Extended DRF with fallback to requested namespace if request.version is missing
"""
if self.request and not self.request.version:
return reverse(self.get_url_name(url_name), *args, **kwargs)
return super().reve... | [
"Extended",
"DRF",
"with",
"fallback",
"to",
"requested",
"namespace",
"if",
"request",
".",
"version",
"is",
"missing"
] | 5monkeys/django-bananas | python | https://github.com/5monkeys/django-bananas/blob/cfd318c737f6c4580036c13d2acf32bca96654bf/bananas/admin/api/mixins.py#L69-L76 | [
"def",
"reverse_action",
"(",
"self",
",",
"url_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"request",
"and",
"not",
"self",
".",
"request",
".",
"version",
":",
"return",
"reverse",
"(",
"self",
".",
"get_url_name",
... | cfd318c737f6c4580036c13d2acf32bca96654bf |
test | BananasAPI.get_url_name | Get full namespaced url name to use for reverse() | bananas/admin/api/mixins.py | def get_url_name(self, action_url_name="list"):
"""
Get full namespaced url name to use for reverse()
"""
url_name = "{}-{}".format(self.basename, action_url_name)
namespace = self.request.resolver_match.namespace
if namespace:
url_name = "{}:{}".format(names... | def get_url_name(self, action_url_name="list"):
"""
Get full namespaced url name to use for reverse()
"""
url_name = "{}-{}".format(self.basename, action_url_name)
namespace = self.request.resolver_match.namespace
if namespace:
url_name = "{}:{}".format(names... | [
"Get",
"full",
"namespaced",
"url",
"name",
"to",
"use",
"for",
"reverse",
"()"
] | 5monkeys/django-bananas | python | https://github.com/5monkeys/django-bananas/blob/cfd318c737f6c4580036c13d2acf32bca96654bf/bananas/admin/api/mixins.py#L78-L88 | [
"def",
"get_url_name",
"(",
"self",
",",
"action_url_name",
"=",
"\"list\"",
")",
":",
"url_name",
"=",
"\"{}-{}\"",
".",
"format",
"(",
"self",
".",
"basename",
",",
"action_url_name",
")",
"namespace",
"=",
"self",
".",
"request",
".",
"resolver_match",
".... | cfd318c737f6c4580036c13d2acf32bca96654bf |
test | BananasAPI.get_view_name | Get or generate human readable view name.
Extended version from DRF to support usage from both class and instance. | bananas/admin/api/mixins.py | def get_view_name(self, respect_name=True):
"""
Get or generate human readable view name.
Extended version from DRF to support usage from both class and instance.
"""
if isinstance(self, type):
view = self
else:
view = self.__class__
# Nam... | def get_view_name(self, respect_name=True):
"""
Get or generate human readable view name.
Extended version from DRF to support usage from both class and instance.
"""
if isinstance(self, type):
view = self
else:
view = self.__class__
# Nam... | [
"Get",
"or",
"generate",
"human",
"readable",
"view",
"name",
".",
"Extended",
"version",
"from",
"DRF",
"to",
"support",
"usage",
"from",
"both",
"class",
"and",
"instance",
"."
] | 5monkeys/django-bananas | python | https://github.com/5monkeys/django-bananas/blob/cfd318c737f6c4580036c13d2acf32bca96654bf/bananas/admin/api/mixins.py#L90-L116 | [
"def",
"get_view_name",
"(",
"self",
",",
"respect_name",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"self",
",",
"type",
")",
":",
"view",
"=",
"self",
"else",
":",
"view",
"=",
"self",
".",
"__class__",
"# Name may be set by some Views, such as a ViewSe... | cfd318c737f6c4580036c13d2acf32bca96654bf |
test | get_version | Derives a PEP386-compliant version number from VERSION. | bananas/__init__.py | def get_version(version=None):
"""Derives a PEP386-compliant version number from VERSION."""
if version is None:
version = VERSION
assert len(version) == 5
assert version[3] in ("alpha", "beta", "rc", "final")
# Now build the two parts of the version number:
# main = X.Y[.Z]
# sub =... | def get_version(version=None):
"""Derives a PEP386-compliant version number from VERSION."""
if version is None:
version = VERSION
assert len(version) == 5
assert version[3] in ("alpha", "beta", "rc", "final")
# Now build the two parts of the version number:
# main = X.Y[.Z]
# sub =... | [
"Derives",
"a",
"PEP386",
"-",
"compliant",
"version",
"number",
"from",
"VERSION",
"."
] | 5monkeys/django-bananas | python | https://github.com/5monkeys/django-bananas/blob/cfd318c737f6c4580036c13d2acf32bca96654bf/bananas/__init__.py#L4-L24 | [
"def",
"get_version",
"(",
"version",
"=",
"None",
")",
":",
"if",
"version",
"is",
"None",
":",
"version",
"=",
"VERSION",
"assert",
"len",
"(",
"version",
")",
"==",
"5",
"assert",
"version",
"[",
"3",
"]",
"in",
"(",
"\"alpha\"",
",",
"\"beta\"",
... | cfd318c737f6c4580036c13d2acf32bca96654bf |
test | BananasSwaggerSchema.get_summary_and_description | Compat: drf-yasg 1.12+ | bananas/admin/api/schemas/yasg.py | def get_summary_and_description(self):
"""
Compat: drf-yasg 1.12+
"""
summary = self.get_summary()
_, description = super().get_summary_and_description()
return summary, description | def get_summary_and_description(self):
"""
Compat: drf-yasg 1.12+
"""
summary = self.get_summary()
_, description = super().get_summary_and_description()
return summary, description | [
"Compat",
":",
"drf",
"-",
"yasg",
"1",
".",
"12",
"+"
] | 5monkeys/django-bananas | python | https://github.com/5monkeys/django-bananas/blob/cfd318c737f6c4580036c13d2acf32bca96654bf/bananas/admin/api/schemas/yasg.py#L37-L43 | [
"def",
"get_summary_and_description",
"(",
"self",
")",
":",
"summary",
"=",
"self",
".",
"get_summary",
"(",
")",
"_",
",",
"description",
"=",
"super",
"(",
")",
".",
"get_summary_and_description",
"(",
")",
"return",
"summary",
",",
"description"
] | cfd318c737f6c4580036c13d2acf32bca96654bf |
test | BananasSwaggerSchema.get_summary | Compat: drf-yasg 1.11 | bananas/admin/api/schemas/yasg.py | def get_summary(self):
"""
Compat: drf-yasg 1.11
"""
title = None
method_name = getattr(self.view, "action", self.method.lower())
action = getattr(self.view, method_name, None)
action_kwargs = getattr(action, "kwargs", None)
if action_kwargs:
... | def get_summary(self):
"""
Compat: drf-yasg 1.11
"""
title = None
method_name = getattr(self.view, "action", self.method.lower())
action = getattr(self.view, method_name, None)
action_kwargs = getattr(action, "kwargs", None)
if action_kwargs:
... | [
"Compat",
":",
"drf",
"-",
"yasg",
"1",
".",
"11"
] | 5monkeys/django-bananas | python | https://github.com/5monkeys/django-bananas/blob/cfd318c737f6c4580036c13d2acf32bca96654bf/bananas/admin/api/schemas/yasg.py#L45-L76 | [
"def",
"get_summary",
"(",
"self",
")",
":",
"title",
"=",
"None",
"method_name",
"=",
"getattr",
"(",
"self",
".",
"view",
",",
"\"action\"",
",",
"self",
".",
"method",
".",
"lower",
"(",
")",
")",
"action",
"=",
"getattr",
"(",
"self",
".",
"view"... | cfd318c737f6c4580036c13d2acf32bca96654bf |
test | BananasVersioning.get_versioned_viewname | Prefix viewname with full namespace bananas:vX.Y: | bananas/admin/api/versioning.py | def get_versioned_viewname(self, viewname, request):
"""
Prefix viewname with full namespace bananas:vX.Y:
"""
namespace = request.resolver_match.namespace
if namespace:
viewname = "{}:{}".format(namespace, viewname)
return viewname | def get_versioned_viewname(self, viewname, request):
"""
Prefix viewname with full namespace bananas:vX.Y:
"""
namespace = request.resolver_match.namespace
if namespace:
viewname = "{}:{}".format(namespace, viewname)
return viewname | [
"Prefix",
"viewname",
"with",
"full",
"namespace",
"bananas",
":",
"vX",
".",
"Y",
":"
] | 5monkeys/django-bananas | python | https://github.com/5monkeys/django-bananas/blob/cfd318c737f6c4580036c13d2acf32bca96654bf/bananas/admin/api/versioning.py#L14-L22 | [
"def",
"get_versioned_viewname",
"(",
"self",
",",
"viewname",
",",
"request",
")",
":",
"namespace",
"=",
"request",
".",
"resolver_match",
".",
"namespace",
"if",
"namespace",
":",
"viewname",
"=",
"\"{}:{}\"",
".",
"format",
"(",
"namespace",
",",
"viewname... | cfd318c737f6c4580036c13d2acf32bca96654bf |
test | resolve | Get engine or raise exception, resolves Alias-instances to a sibling target.
:param cursor: The object so search in
:param key: The key to get
:return: The object found | bananas/url.py | def resolve(cursor, key):
"""
Get engine or raise exception, resolves Alias-instances to a sibling target.
:param cursor: The object so search in
:param key: The key to get
:return: The object found
"""
try:
result = cursor[key]
# Resolve alias
if isinstance(result,... | def resolve(cursor, key):
"""
Get engine or raise exception, resolves Alias-instances to a sibling target.
:param cursor: The object so search in
:param key: The key to get
:return: The object found
"""
try:
result = cursor[key]
# Resolve alias
if isinstance(result,... | [
"Get",
"engine",
"or",
"raise",
"exception",
"resolves",
"Alias",
"-",
"instances",
"to",
"a",
"sibling",
"target",
"."
] | 5monkeys/django-bananas | python | https://github.com/5monkeys/django-bananas/blob/cfd318c737f6c4580036c13d2acf32bca96654bf/bananas/url.py#L72-L89 | [
"def",
"resolve",
"(",
"cursor",
",",
"key",
")",
":",
"try",
":",
"result",
"=",
"cursor",
"[",
"key",
"]",
"# Resolve alias",
"if",
"isinstance",
"(",
"result",
",",
"Alias",
")",
":",
"result",
"=",
"cursor",
"[",
"result",
".",
"target",
"]",
"re... | cfd318c737f6c4580036c13d2acf32bca96654bf |
test | get_engine | Perform a lookup in _ENGINE_MAPPING using engine_string.
:param scheme: '+'-separated string Maximum of 2 parts,
i.e "postgres+psycopg" is OK, "postgres+psycopg2+postgis" is NOT OK.
:return: Engine string | bananas/url.py | def get_engine(scheme):
"""
Perform a lookup in _ENGINE_MAPPING using engine_string.
:param scheme: '+'-separated string Maximum of 2 parts,
i.e "postgres+psycopg" is OK, "postgres+psycopg2+postgis" is NOT OK.
:return: Engine string
"""
path = scheme.split("+")
first, rest = path[0], pa... | def get_engine(scheme):
"""
Perform a lookup in _ENGINE_MAPPING using engine_string.
:param scheme: '+'-separated string Maximum of 2 parts,
i.e "postgres+psycopg" is OK, "postgres+psycopg2+postgis" is NOT OK.
:return: Engine string
"""
path = scheme.split("+")
first, rest = path[0], pa... | [
"Perform",
"a",
"lookup",
"in",
"_ENGINE_MAPPING",
"using",
"engine_string",
"."
] | 5monkeys/django-bananas | python | https://github.com/5monkeys/django-bananas/blob/cfd318c737f6c4580036c13d2acf32bca96654bf/bananas/url.py#L92-L134 | [
"def",
"get_engine",
"(",
"scheme",
")",
":",
"path",
"=",
"scheme",
".",
"split",
"(",
"\"+\"",
")",
"first",
",",
"rest",
"=",
"path",
"[",
"0",
"]",
",",
"path",
"[",
"1",
":",
"]",
"second",
"=",
"rest",
"[",
"0",
"]",
"if",
"rest",
"else",... | cfd318c737f6c4580036c13d2acf32bca96654bf |
test | parse_path | Get database name and database schema from path.
:param path: "/"-delimited path, parsed as
"/<database name>/<database schema>"
:return: tuple with (database or None, schema or None) | bananas/url.py | def parse_path(path):
"""
Get database name and database schema from path.
:param path: "/"-delimited path, parsed as
"/<database name>/<database schema>"
:return: tuple with (database or None, schema or None)
"""
if path is None:
raise ValueError("path must be a string")
part... | def parse_path(path):
"""
Get database name and database schema from path.
:param path: "/"-delimited path, parsed as
"/<database name>/<database schema>"
:return: tuple with (database or None, schema or None)
"""
if path is None:
raise ValueError("path must be a string")
part... | [
"Get",
"database",
"name",
"and",
"database",
"schema",
"from",
"path",
"."
] | 5monkeys/django-bananas | python | https://github.com/5monkeys/django-bananas/blob/cfd318c737f6c4580036c13d2acf32bca96654bf/bananas/url.py#L143-L159 | [
"def",
"parse_path",
"(",
"path",
")",
":",
"if",
"path",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"path must be a string\"",
")",
"parts",
"=",
"path",
".",
"strip",
"(",
"\"/\"",
")",
".",
"split",
"(",
"\"/\"",
")",
"database",
"=",
"unquote_p... | cfd318c737f6c4580036c13d2acf32bca96654bf |
test | database_conf_from_url | Return a django-style database configuration based on ``url``.
:param url: Database URL
:return: Django-style database configuration dict
Example:
>>> conf = database_conf_from_url(
... 'pgsql://joar:hunter2@5monkeys.se:4242/tweets/tweetschema'
... '?hello=world')
>>> sorted(conf.i... | bananas/url.py | def database_conf_from_url(url):
"""
Return a django-style database configuration based on ``url``.
:param url: Database URL
:return: Django-style database configuration dict
Example:
>>> conf = database_conf_from_url(
... 'pgsql://joar:hunter2@5monkeys.se:4242/tweets/tweetschema'
... | def database_conf_from_url(url):
"""
Return a django-style database configuration based on ``url``.
:param url: Database URL
:return: Django-style database configuration dict
Example:
>>> conf = database_conf_from_url(
... 'pgsql://joar:hunter2@5monkeys.se:4242/tweets/tweetschema'
... | [
"Return",
"a",
"django",
"-",
"style",
"database",
"configuration",
"based",
"on",
"url",
"."
] | 5monkeys/django-bananas | python | https://github.com/5monkeys/django-bananas/blob/cfd318c737f6c4580036c13d2acf32bca96654bf/bananas/url.py#L162-L183 | [
"def",
"database_conf_from_url",
"(",
"url",
")",
":",
"return",
"{",
"key",
".",
"upper",
"(",
")",
":",
"val",
"for",
"key",
",",
"val",
"in",
"parse_database_url",
"(",
"url",
")",
".",
"_asdict",
"(",
")",
".",
"items",
"(",
")",
"}"
] | cfd318c737f6c4580036c13d2acf32bca96654bf |
test | parse_database_url | Parse a database URL and return a DatabaseInfo named tuple.
:param url: Database URL
:return: DatabaseInfo instance
Example:
>>> conf = parse_database_url(
... 'pgsql://joar:hunter2@5monkeys.se:4242/tweets/tweetschema'
... '?hello=world')
>>> conf # doctest: +NORMALIZE_WHITESPACE
... | bananas/url.py | def parse_database_url(url):
"""
Parse a database URL and return a DatabaseInfo named tuple.
:param url: Database URL
:return: DatabaseInfo instance
Example:
>>> conf = parse_database_url(
... 'pgsql://joar:hunter2@5monkeys.se:4242/tweets/tweetschema'
... '?hello=world')
>>... | def parse_database_url(url):
"""
Parse a database URL and return a DatabaseInfo named tuple.
:param url: Database URL
:return: DatabaseInfo instance
Example:
>>> conf = parse_database_url(
... 'pgsql://joar:hunter2@5monkeys.se:4242/tweets/tweetschema'
... '?hello=world')
>>... | [
"Parse",
"a",
"database",
"URL",
"and",
"return",
"a",
"DatabaseInfo",
"named",
"tuple",
"."
] | 5monkeys/django-bananas | python | https://github.com/5monkeys/django-bananas/blob/cfd318c737f6c4580036c13d2acf32bca96654bf/bananas/url.py#L186-L233 | [
"def",
"parse_database_url",
"(",
"url",
")",
":",
"if",
"url",
"==",
"\"sqlite://:memory:\"",
":",
"raise",
"Exception",
"(",
"'Your url is \"sqlite://:memory:\", if you want '",
"'an sqlite memory database, just use \"sqlite://\"'",
")",
"url_parts",
"=",
"urlsplit",
"(",
... | cfd318c737f6c4580036c13d2acf32bca96654bf |
test | LoginAPI.create | Log in django staff user | bananas/admin/api/views.py | def create(self, request):
"""
Log in django staff user
"""
# TODO: Decorate api with sensitive post parameters as Django admin do?
# from django.utils.decorators import method_decorator
# from django.views.decorators.debug import sensitive_post_parameters
# sensi... | def create(self, request):
"""
Log in django staff user
"""
# TODO: Decorate api with sensitive post parameters as Django admin do?
# from django.utils.decorators import method_decorator
# from django.views.decorators.debug import sensitive_post_parameters
# sensi... | [
"Log",
"in",
"django",
"staff",
"user"
] | 5monkeys/django-bananas | python | https://github.com/5monkeys/django-bananas/blob/cfd318c737f6c4580036c13d2acf32bca96654bf/bananas/admin/api/views.py#L40-L57 | [
"def",
"create",
"(",
"self",
",",
"request",
")",
":",
"# TODO: Decorate api with sensitive post parameters as Django admin do?",
"# from django.utils.decorators import method_decorator",
"# from django.views.decorators.debug import sensitive_post_parameters",
"# sensitive_post_parameters_m =... | cfd318c737f6c4580036c13d2acf32bca96654bf |
test | MeAPI.list | Retrieve logged in user info | bananas/admin/api/views.py | def list(self, request):
"""
Retrieve logged in user info
"""
serializer = self.get_serializer(request.user)
return Response(serializer.data, status=status.HTTP_200_OK) | def list(self, request):
"""
Retrieve logged in user info
"""
serializer = self.get_serializer(request.user)
return Response(serializer.data, status=status.HTTP_200_OK) | [
"Retrieve",
"logged",
"in",
"user",
"info"
] | 5monkeys/django-bananas | python | https://github.com/5monkeys/django-bananas/blob/cfd318c737f6c4580036c13d2acf32bca96654bf/bananas/admin/api/views.py#L85-L90 | [
"def",
"list",
"(",
"self",
",",
"request",
")",
":",
"serializer",
"=",
"self",
".",
"get_serializer",
"(",
"request",
".",
"user",
")",
"return",
"Response",
"(",
"serializer",
".",
"data",
",",
"status",
"=",
"status",
".",
"HTTP_200_OK",
")"
] | cfd318c737f6c4580036c13d2acf32bca96654bf |
test | ChangePasswordAPI.create | Change password for logged in django staff user | bananas/admin/api/views.py | def create(self, request):
"""
Change password for logged in django staff user
"""
# TODO: Decorate api with sensitive post parameters as Django admin do?
password_form = PasswordChangeForm(request.user, data=request.data)
if not password_form.is_valid():
ra... | def create(self, request):
"""
Change password for logged in django staff user
"""
# TODO: Decorate api with sensitive post parameters as Django admin do?
password_form = PasswordChangeForm(request.user, data=request.data)
if not password_form.is_valid():
ra... | [
"Change",
"password",
"for",
"logged",
"in",
"django",
"staff",
"user"
] | 5monkeys/django-bananas | python | https://github.com/5monkeys/django-bananas/blob/cfd318c737f6c4580036c13d2acf32bca96654bf/bananas/admin/api/views.py#L103-L117 | [
"def",
"create",
"(",
"self",
",",
"request",
")",
":",
"# TODO: Decorate api with sensitive post parameters as Django admin do?",
"password_form",
"=",
"PasswordChangeForm",
"(",
"request",
".",
"user",
",",
"data",
"=",
"request",
".",
"data",
")",
"if",
"not",
"p... | cfd318c737f6c4580036c13d2acf32bca96654bf |
test | UserDetailsSerializer.build_url_field | This is needed due to DRF's model serializer uses the queryset to build url name
# TODO: Move this to own serializer mixin or fix problem elsewhere? | example/example/api.py | def build_url_field(self, field_name, model_class):
"""
This is needed due to DRF's model serializer uses the queryset to build url name
# TODO: Move this to own serializer mixin or fix problem elsewhere?
"""
field, kwargs = super().build_url_field(field_name, model_class)
... | def build_url_field(self, field_name, model_class):
"""
This is needed due to DRF's model serializer uses the queryset to build url name
# TODO: Move this to own serializer mixin or fix problem elsewhere?
"""
field, kwargs = super().build_url_field(field_name, model_class)
... | [
"This",
"is",
"needed",
"due",
"to",
"DRF",
"s",
"model",
"serializer",
"uses",
"the",
"queryset",
"to",
"build",
"url",
"name"
] | 5monkeys/django-bananas | python | https://github.com/5monkeys/django-bananas/blob/cfd318c737f6c4580036c13d2acf32bca96654bf/example/example/api.py#L25-L36 | [
"def",
"build_url_field",
"(",
"self",
",",
"field_name",
",",
"model_class",
")",
":",
"field",
",",
"kwargs",
"=",
"super",
"(",
")",
".",
"build_url_field",
"(",
"field_name",
",",
"model_class",
")",
"view",
"=",
"self",
".",
"root",
".",
"context",
... | cfd318c737f6c4580036c13d2acf32bca96654bf |
test | parse_bool | Parse string to bool.
:param str value: String value to parse as bool
:return bool: | bananas/environment.py | def parse_bool(value):
"""
Parse string to bool.
:param str value: String value to parse as bool
:return bool:
"""
boolean = parse_str(value).capitalize()
if boolean in ("True", "Yes", "On", "1"):
return True
elif boolean in ("False", "No", "Off", "0"):
return False
... | def parse_bool(value):
"""
Parse string to bool.
:param str value: String value to parse as bool
:return bool:
"""
boolean = parse_str(value).capitalize()
if boolean in ("True", "Yes", "On", "1"):
return True
elif boolean in ("False", "No", "Off", "0"):
return False
... | [
"Parse",
"string",
"to",
"bool",
"."
] | 5monkeys/django-bananas | python | https://github.com/5monkeys/django-bananas/blob/cfd318c737f6c4580036c13d2acf32bca96654bf/bananas/environment.py#L40-L54 | [
"def",
"parse_bool",
"(",
"value",
")",
":",
"boolean",
"=",
"parse_str",
"(",
"value",
")",
".",
"capitalize",
"(",
")",
"if",
"boolean",
"in",
"(",
"\"True\"",
",",
"\"Yes\"",
",",
"\"On\"",
",",
"\"1\"",
")",
":",
"return",
"True",
"elif",
"boolean"... | cfd318c737f6c4580036c13d2acf32bca96654bf |
test | parse_int | Parse numeric string to int. Supports oct formatted string.
:param str value: String value to parse as int
:return int: | bananas/environment.py | def parse_int(value):
"""
Parse numeric string to int. Supports oct formatted string.
:param str value: String value to parse as int
:return int:
"""
value = parse_str(value=value)
if value.startswith("0"):
return int(value.lstrip("0o"), 8)
else:
return int(value) | def parse_int(value):
"""
Parse numeric string to int. Supports oct formatted string.
:param str value: String value to parse as int
:return int:
"""
value = parse_str(value=value)
if value.startswith("0"):
return int(value.lstrip("0o"), 8)
else:
return int(value) | [
"Parse",
"numeric",
"string",
"to",
"int",
".",
"Supports",
"oct",
"formatted",
"string",
"."
] | 5monkeys/django-bananas | python | https://github.com/5monkeys/django-bananas/blob/cfd318c737f6c4580036c13d2acf32bca96654bf/bananas/environment.py#L57-L68 | [
"def",
"parse_int",
"(",
"value",
")",
":",
"value",
"=",
"parse_str",
"(",
"value",
"=",
"value",
")",
"if",
"value",
".",
"startswith",
"(",
"\"0\"",
")",
":",
"return",
"int",
"(",
"value",
".",
"lstrip",
"(",
"\"0o\"",
")",
",",
"8",
")",
"else... | cfd318c737f6c4580036c13d2acf32bca96654bf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.