partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | make_handler | Make a handler for authorized and disconnect callbacks.
:param f: Callable or an import path to a callable | invenio_oauthclient/handlers.py | def make_handler(f, remote, with_response=True):
"""Make a handler for authorized and disconnect callbacks.
:param f: Callable or an import path to a callable
"""
if isinstance(f, six.string_types):
f = import_string(f)
@wraps(f)
def inner(*args, **kwargs):
if with_response:
... | def make_handler(f, remote, with_response=True):
"""Make a handler for authorized and disconnect callbacks.
:param f: Callable or an import path to a callable
"""
if isinstance(f, six.string_types):
f = import_string(f)
@wraps(f)
def inner(*args, **kwargs):
if with_response:
... | [
"Make",
"a",
"handler",
"for",
"authorized",
"and",
"disconnect",
"callbacks",
"."
] | inveniosoftware/invenio-oauthclient | python | https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/handlers.py#L480-L494 | [
"def",
"make_handler",
"(",
"f",
",",
"remote",
",",
"with_response",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"f",
",",
"six",
".",
"string_types",
")",
":",
"f",
"=",
"import_string",
"(",
"f",
")",
"@",
"wraps",
"(",
"f",
")",
"def",
"inn... | 2500dc6935738107617aeade79e050d7608004bb |
train | _enable_lock | The decorator for ensuring thread-safe when current cache instance is concurrent status. | common_cache/__init__.py | def _enable_lock(func):
"""
The decorator for ensuring thread-safe when current cache instance is concurrent status.
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
self = args[0]
if self.is_concurrent:
only_read = kwargs.get('only_read')
if only_rea... | def _enable_lock(func):
"""
The decorator for ensuring thread-safe when current cache instance is concurrent status.
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
self = args[0]
if self.is_concurrent:
only_read = kwargs.get('only_read')
if only_rea... | [
"The",
"decorator",
"for",
"ensuring",
"thread",
"-",
"safe",
"when",
"current",
"cache",
"instance",
"is",
"concurrent",
"status",
"."
] | SylvanasSun/python-common-cache | python | https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L18-L40 | [
"def",
"_enable_lock",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
"=",
"args",
"[",
"0",
"]",
"if",
"self",
".",
"is_concurrent",
":",
"o... | f113eb3cd751eed5ab5373e8610a31a444220cf8 |
train | _enable_cleanup | Execute cleanup operation when the decorated function completed. | common_cache/__init__.py | def _enable_cleanup(func):
"""
Execute cleanup operation when the decorated function completed.
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
self = args[0]
result = func(*args, **kwargs)
self.cleanup(self)
return result
return wrapper | def _enable_cleanup(func):
"""
Execute cleanup operation when the decorated function completed.
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
self = args[0]
result = func(*args, **kwargs)
self.cleanup(self)
return result
return wrapper | [
"Execute",
"cleanup",
"operation",
"when",
"the",
"decorated",
"function",
"completed",
"."
] | SylvanasSun/python-common-cache | python | https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L43-L55 | [
"def",
"_enable_cleanup",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
"=",
"args",
"[",
"0",
"]",
"result",
"=",
"func",
"(",
"*",
"args",... | f113eb3cd751eed5ab5373e8610a31a444220cf8 |
train | _enable_thread_pool | Use thread pool for executing a task if self.enable_thread_pool is True.
Return an instance of future when flag is_async is True otherwise will to
block waiting for the result until timeout then returns the result. | common_cache/__init__.py | def _enable_thread_pool(func):
"""
Use thread pool for executing a task if self.enable_thread_pool is True.
Return an instance of future when flag is_async is True otherwise will to
block waiting for the result until timeout then returns the result.
"""
@functools.wraps(func)
def wrapper(*... | def _enable_thread_pool(func):
"""
Use thread pool for executing a task if self.enable_thread_pool is True.
Return an instance of future when flag is_async is True otherwise will to
block waiting for the result until timeout then returns the result.
"""
@functools.wraps(func)
def wrapper(*... | [
"Use",
"thread",
"pool",
"for",
"executing",
"a",
"task",
"if",
"self",
".",
"enable_thread_pool",
"is",
"True",
"."
] | SylvanasSun/python-common-cache | python | https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L58-L86 | [
"def",
"_enable_thread_pool",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
"=",
"args",
"[",
"0",
"]",
"if",
"self",
".",
"enable_thread_pool",... | f113eb3cd751eed5ab5373e8610a31a444220cf8 |
train | Cache.clear | >>> cache = Cache(log_level=logging.WARNING)
>>> cache.put('a', 0)
>>> cache.put('b', 1)
>>> cache.size()
2
>>> cache.clear()
>>> cache.size()
0 | common_cache/__init__.py | def clear(self, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> cache.put('a', 0)
>>> cache.put('b', 1)
>>> cache.size()
2
>>> cache.clear()
>>> cache.size()
0
"""
self.cache_items.clear()
self.total_a... | def clear(self, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> cache.put('a', 0)
>>> cache.put('b', 1)
>>> cache.size()
2
>>> cache.clear()
>>> cache.size()
0
"""
self.cache_items.clear()
self.total_a... | [
">>>",
"cache",
"=",
"Cache",
"(",
"log_level",
"=",
"logging",
".",
"WARNING",
")",
">>>",
"cache",
".",
"put",
"(",
"a",
"0",
")",
">>>",
"cache",
".",
"put",
"(",
"b",
"1",
")",
">>>",
"cache",
".",
"size",
"()",
"2",
">>>",
"cache",
".",
"c... | SylvanasSun/python-common-cache | python | https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L338-L351 | [
"def",
"clear",
"(",
"self",
",",
"only_read",
"=",
"False",
")",
":",
"self",
".",
"cache_items",
".",
"clear",
"(",
")",
"self",
".",
"total_access_count",
"=",
"0",
"self",
".",
"logger",
".",
"debug",
"(",
"'Cache clear operation is completed'",
")"
] | f113eb3cd751eed5ab5373e8610a31a444220cf8 |
train | Cache.replace_evict_func | >>> cache = Cache(log_level=logging.WARNING)
>>> def evict(dict, evict_number=10): pass
>>> cache.replace_evict_func(evict)
True
>>> def evict_b(dict): pass
>>> cache.replace_evict_func(evict_b)
False
>>> def evict_c(dict, a, b): pass
>>> cache.replace_evi... | common_cache/__init__.py | def replace_evict_func(self, func, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> def evict(dict, evict_number=10): pass
>>> cache.replace_evict_func(evict)
True
>>> def evict_b(dict): pass
>>> cache.replace_evict_func(evict_b)
Fals... | def replace_evict_func(self, func, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> def evict(dict, evict_number=10): pass
>>> cache.replace_evict_func(evict)
True
>>> def evict_b(dict): pass
>>> cache.replace_evict_func(evict_b)
Fals... | [
">>>",
"cache",
"=",
"Cache",
"(",
"log_level",
"=",
"logging",
".",
"WARNING",
")",
">>>",
"def",
"evict",
"(",
"dict",
"evict_number",
"=",
"10",
")",
":",
"pass",
">>>",
"cache",
".",
"replace_evict_func",
"(",
"evict",
")",
"True",
">>>",
"def",
"e... | SylvanasSun/python-common-cache | python | https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L355-L371 | [
"def",
"replace_evict_func",
"(",
"self",
",",
"func",
",",
"only_read",
"=",
"False",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"'Replace the evict function %s ---> %s'",
"%",
"(",
"get_function_signature",
"(",
"self",
".",
"evict_func",
")",
",",
"... | f113eb3cd751eed5ab5373e8610a31a444220cf8 |
train | Cache.replace_cleanup_func | >>> cache = Cache(log_level=logging.WARNING)
>>> def cleanup(self): pass
>>> cache.replace_cleanup_func(cleanup)
True
>>> def cleanup_b(self, other): pass
>>> cache.replace_cleanup_func(cleanup_b)
False | common_cache/__init__.py | def replace_cleanup_func(self, func, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> def cleanup(self): pass
>>> cache.replace_cleanup_func(cleanup)
True
>>> def cleanup_b(self, other): pass
>>> cache.replace_cleanup_func(cleanup_b)
... | def replace_cleanup_func(self, func, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> def cleanup(self): pass
>>> cache.replace_cleanup_func(cleanup)
True
>>> def cleanup_b(self, other): pass
>>> cache.replace_cleanup_func(cleanup_b)
... | [
">>>",
"cache",
"=",
"Cache",
"(",
"log_level",
"=",
"logging",
".",
"WARNING",
")",
">>>",
"def",
"cleanup",
"(",
"self",
")",
":",
"pass",
">>>",
"cache",
".",
"replace_cleanup_func",
"(",
"cleanup",
")",
"True",
">>>",
"def",
"cleanup_b",
"(",
"self",... | SylvanasSun/python-common-cache | python | https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L375-L388 | [
"def",
"replace_cleanup_func",
"(",
"self",
",",
"func",
",",
"only_read",
"=",
"False",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"'Replace the cleanup function %s ---> %s'",
"%",
"(",
"get_function_signature",
"(",
"self",
".",
"cleanup",
")",
",",
... | f113eb3cd751eed5ab5373e8610a31a444220cf8 |
train | Cache.with_cache_loader | >>> cache = Cache(log_level=logging.WARNING)
>>> def cache_loader(key): pass
>>> cache.with_cache_loader(cache_loader)
True
>>> def cache_loader_b(key, value): pass
>>> cache.with_cache_loader(cache_loader_b)
False | common_cache/__init__.py | def with_cache_loader(self, func, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> def cache_loader(key): pass
>>> cache.with_cache_loader(cache_loader)
True
>>> def cache_loader_b(key, value): pass
>>> cache.with_cache_loader(cache_loader_b)... | def with_cache_loader(self, func, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> def cache_loader(key): pass
>>> cache.with_cache_loader(cache_loader)
True
>>> def cache_loader_b(key, value): pass
>>> cache.with_cache_loader(cache_loader_b)... | [
">>>",
"cache",
"=",
"Cache",
"(",
"log_level",
"=",
"logging",
".",
"WARNING",
")",
">>>",
"def",
"cache_loader",
"(",
"key",
")",
":",
"pass",
">>>",
"cache",
".",
"with_cache_loader",
"(",
"cache_loader",
")",
"True",
">>>",
"def",
"cache_loader_b",
"("... | SylvanasSun/python-common-cache | python | https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L392-L404 | [
"def",
"with_cache_loader",
"(",
"self",
",",
"func",
",",
"only_read",
"=",
"False",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"'Enabled cache loader %s'",
"%",
"get_function_signature",
"(",
"func",
")",
")",
"self",
".",
"cache_loader",
"=",
"fun... | f113eb3cd751eed5ab5373e8610a31a444220cf8 |
train | Cache.with_cache_writer | >>> cache = Cache(log_level=logging.WARNING)
>>> def cache_writer(key): pass
>>> cache.with_cache_writer(cache_writer)
False
>>> def cache_writer(key, value): pass
>>> cache.with_cache_writer(cache_writer)
True | common_cache/__init__.py | def with_cache_writer(self, func, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> def cache_writer(key): pass
>>> cache.with_cache_writer(cache_writer)
False
>>> def cache_writer(key, value): pass
>>> cache.with_cache_writer(cache_writer)
... | def with_cache_writer(self, func, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> def cache_writer(key): pass
>>> cache.with_cache_writer(cache_writer)
False
>>> def cache_writer(key, value): pass
>>> cache.with_cache_writer(cache_writer)
... | [
">>>",
"cache",
"=",
"Cache",
"(",
"log_level",
"=",
"logging",
".",
"WARNING",
")",
">>>",
"def",
"cache_writer",
"(",
"key",
")",
":",
"pass",
">>>",
"cache",
".",
"with_cache_writer",
"(",
"cache_writer",
")",
"False",
">>>",
"def",
"cache_writer",
"(",... | SylvanasSun/python-common-cache | python | https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L408-L420 | [
"def",
"with_cache_writer",
"(",
"self",
",",
"func",
",",
"only_read",
"=",
"False",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"'Enabled cache writer %s'",
"%",
"get_function_signature",
"(",
"func",
")",
")",
"self",
".",
"cache_writer",
"=",
"fun... | f113eb3cd751eed5ab5373e8610a31a444220cf8 |
train | Cache.stop_regularly_cleanup | >>> cache = Cache(log_level=logging.WARNING)
>>> cache.stop_regularly_cleanup()
True
>>> cache.stop_regularly_cleanup()
False | common_cache/__init__.py | def stop_regularly_cleanup(self, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> cache.stop_regularly_cleanup()
True
>>> cache.stop_regularly_cleanup()
False
"""
if hasattr(self, 'cleanup_supervisor') and self.cleanup_supervisor is n... | def stop_regularly_cleanup(self, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> cache.stop_regularly_cleanup()
True
>>> cache.stop_regularly_cleanup()
False
"""
if hasattr(self, 'cleanup_supervisor') and self.cleanup_supervisor is n... | [
">>>",
"cache",
"=",
"Cache",
"(",
"log_level",
"=",
"logging",
".",
"WARNING",
")",
">>>",
"cache",
".",
"stop_regularly_cleanup",
"()",
"True",
">>>",
"cache",
".",
"stop_regularly_cleanup",
"()",
"False"
] | SylvanasSun/python-common-cache | python | https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L423-L438 | [
"def",
"stop_regularly_cleanup",
"(",
"self",
",",
"only_read",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'cleanup_supervisor'",
")",
"and",
"self",
".",
"cleanup_supervisor",
"is",
"not",
"None",
":",
"self",
".",
"cleanup_supervisor",
".",
... | f113eb3cd751eed5ab5373e8610a31a444220cf8 |
train | Cache.start_regularly_cleanup | >>> cache = Cache(regularly_cleanup=False, log_level=logging.ERROR)
>>> cache.start_regularly_cleanup()
True
>>> cache.start_regularly_cleanup()
False | common_cache/__init__.py | def start_regularly_cleanup(self, regularly_cleanup_interval=None, only_read=False):
"""
>>> cache = Cache(regularly_cleanup=False, log_level=logging.ERROR)
>>> cache.start_regularly_cleanup()
True
>>> cache.start_regularly_cleanup()
False
"""
if not hasat... | def start_regularly_cleanup(self, regularly_cleanup_interval=None, only_read=False):
"""
>>> cache = Cache(regularly_cleanup=False, log_level=logging.ERROR)
>>> cache.start_regularly_cleanup()
True
>>> cache.start_regularly_cleanup()
False
"""
if not hasat... | [
">>>",
"cache",
"=",
"Cache",
"(",
"regularly_cleanup",
"=",
"False",
"log_level",
"=",
"logging",
".",
"ERROR",
")",
">>>",
"cache",
".",
"start_regularly_cleanup",
"()",
"True",
">>>",
"cache",
".",
"start_regularly_cleanup",
"()",
"False"
] | SylvanasSun/python-common-cache | python | https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L441-L460 | [
"def",
"start_regularly_cleanup",
"(",
"self",
",",
"regularly_cleanup_interval",
"=",
"None",
",",
"only_read",
"=",
"False",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'cleanup_supervisor'",
")",
"or",
"self",
".",
"cleanup_supervisor",
"is",
"None",... | f113eb3cd751eed5ab5373e8610a31a444220cf8 |
train | Cache.with_thread_pool | >>> cache = Cache(enable_thread_pool=False, log_level=logging.ERROR)
>>> cache.with_thread_pool()
True
>>> cache.with_thread_pool()
False | common_cache/__init__.py | def with_thread_pool(self, init_func=None, only_read=False):
"""
>>> cache = Cache(enable_thread_pool=False, log_level=logging.ERROR)
>>> cache.with_thread_pool()
True
>>> cache.with_thread_pool()
False
"""
if not hasattr(self, 'thread_pool') or self.threa... | def with_thread_pool(self, init_func=None, only_read=False):
"""
>>> cache = Cache(enable_thread_pool=False, log_level=logging.ERROR)
>>> cache.with_thread_pool()
True
>>> cache.with_thread_pool()
False
"""
if not hasattr(self, 'thread_pool') or self.threa... | [
">>>",
"cache",
"=",
"Cache",
"(",
"enable_thread_pool",
"=",
"False",
"log_level",
"=",
"logging",
".",
"ERROR",
")",
">>>",
"cache",
".",
"with_thread_pool",
"()",
"True",
">>>",
"cache",
".",
"with_thread_pool",
"()",
"False"
] | SylvanasSun/python-common-cache | python | https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L463-L481 | [
"def",
"with_thread_pool",
"(",
"self",
",",
"init_func",
"=",
"None",
",",
"only_read",
"=",
"False",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'thread_pool'",
")",
"or",
"self",
".",
"thread_pool",
"is",
"None",
":",
"if",
"init_func",
"is",... | f113eb3cd751eed5ab5373e8610a31a444220cf8 |
train | Cache.unable_thread_pool | >>> cache = Cache(log_level=logging.WARNING)
>>> cache.unable_thread_pool()
True
>>> cache.unable_thread_pool()
False | common_cache/__init__.py | def unable_thread_pool(self, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> cache.unable_thread_pool()
True
>>> cache.unable_thread_pool()
False
"""
if self.enable_thread_pool and hasattr(self, 'thread_pool') and self.thread_pool is... | def unable_thread_pool(self, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> cache.unable_thread_pool()
True
>>> cache.unable_thread_pool()
False
"""
if self.enable_thread_pool and hasattr(self, 'thread_pool') and self.thread_pool is... | [
">>>",
"cache",
"=",
"Cache",
"(",
"log_level",
"=",
"logging",
".",
"WARNING",
")",
">>>",
"cache",
".",
"unable_thread_pool",
"()",
"True",
">>>",
"cache",
".",
"unable_thread_pool",
"()",
"False"
] | SylvanasSun/python-common-cache | python | https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L484-L500 | [
"def",
"unable_thread_pool",
"(",
"self",
",",
"only_read",
"=",
"False",
")",
":",
"if",
"self",
".",
"enable_thread_pool",
"and",
"hasattr",
"(",
"self",
",",
"'thread_pool'",
")",
"and",
"self",
".",
"thread_pool",
"is",
"not",
"None",
":",
"self",
".",... | f113eb3cd751eed5ab5373e8610a31a444220cf8 |
train | Cache.shutdown_thread_pool | >>> cache = Cache(log_level=logging.WARNING)
>>> cache.shutdown_thread_pool()
True
>>> cache.unable_thread_pool()
True
>>> cache.shutdown_thread_pool()
False | common_cache/__init__.py | def shutdown_thread_pool(self, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> cache.shutdown_thread_pool()
True
>>> cache.unable_thread_pool()
True
>>> cache.shutdown_thread_pool()
False
"""
if self.enable_thread_poo... | def shutdown_thread_pool(self, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> cache.shutdown_thread_pool()
True
>>> cache.unable_thread_pool()
True
>>> cache.shutdown_thread_pool()
False
"""
if self.enable_thread_poo... | [
">>>",
"cache",
"=",
"Cache",
"(",
"log_level",
"=",
"logging",
".",
"WARNING",
")",
">>>",
"cache",
".",
"shutdown_thread_pool",
"()",
"True",
">>>",
"cache",
".",
"unable_thread_pool",
"()",
"True",
">>>",
"cache",
".",
"shutdown_thread_pool",
"()",
"False"
... | SylvanasSun/python-common-cache | python | https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L503-L518 | [
"def",
"shutdown_thread_pool",
"(",
"self",
",",
"only_read",
"=",
"False",
")",
":",
"if",
"self",
".",
"enable_thread_pool",
"and",
"hasattr",
"(",
"self",
",",
"'thread_pool'",
")",
"and",
"self",
".",
"thread_pool",
"is",
"not",
"None",
":",
"self",
".... | f113eb3cd751eed5ab5373e8610a31a444220cf8 |
train | Cache.set_capacity | >>> cache = Cache(log_level=logging.WARNING)
>>> cache.set_capacity(100)
>>> cache.capacity
100
>>> cache.set_capacity('haha')
>>> cache.capacity
100 | common_cache/__init__.py | def set_capacity(self, new_capacity, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> cache.set_capacity(100)
>>> cache.capacity
100
>>> cache.set_capacity('haha')
>>> cache.capacity
100
"""
if not isinstance(new_capac... | def set_capacity(self, new_capacity, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> cache.set_capacity(100)
>>> cache.capacity
100
>>> cache.set_capacity('haha')
>>> cache.capacity
100
"""
if not isinstance(new_capac... | [
">>>",
"cache",
"=",
"Cache",
"(",
"log_level",
"=",
"logging",
".",
"WARNING",
")",
">>>",
"cache",
".",
"set_capacity",
"(",
"100",
")",
">>>",
"cache",
".",
"capacity",
"100",
">>>",
"cache",
".",
"set_capacity",
"(",
"haha",
")",
">>>",
"cache",
".... | SylvanasSun/python-common-cache | python | https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L521-L534 | [
"def",
"set_capacity",
"(",
"self",
",",
"new_capacity",
",",
"only_read",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"new_capacity",
",",
"int",
")",
"or",
"new_capacity",
"<=",
"0",
":",
"self",
".",
"logger",
".",
"warning",
"(",
"'Parame... | f113eb3cd751eed5ab5373e8610a31a444220cf8 |
train | Cache.set_expire | >>> cache = Cache(log_level=logging.WARNING)
>>> cache.set_expire(40)
>>> cache.expire
40
>>> cache.set_expire('haha')
>>> cache.expire
40 | common_cache/__init__.py | def set_expire(self, new_expire, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> cache.set_expire(40)
>>> cache.expire
40
>>> cache.set_expire('haha')
>>> cache.expire
40
"""
if not isinstance(new_expire, int) or new_... | def set_expire(self, new_expire, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> cache.set_expire(40)
>>> cache.expire
40
>>> cache.set_expire('haha')
>>> cache.expire
40
"""
if not isinstance(new_expire, int) or new_... | [
">>>",
"cache",
"=",
"Cache",
"(",
"log_level",
"=",
"logging",
".",
"WARNING",
")",
">>>",
"cache",
".",
"set_expire",
"(",
"40",
")",
">>>",
"cache",
".",
"expire",
"40",
">>>",
"cache",
".",
"set_expire",
"(",
"haha",
")",
">>>",
"cache",
".",
"ex... | SylvanasSun/python-common-cache | python | https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L537-L550 | [
"def",
"set_expire",
"(",
"self",
",",
"new_expire",
",",
"only_read",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"new_expire",
",",
"int",
")",
"or",
"new_expire",
"<",
"0",
":",
"self",
".",
"logger",
".",
"warning",
"(",
"'Parameter new_e... | f113eb3cd751eed5ab5373e8610a31a444220cf8 |
train | Cache.set_evict_number | >>> cache = Cache(log_level=logging.WARNING)
>>> cache.set_evict_number(10)
>>> cache.evict_number
10
>>> cache.set_evict_number('haha')
>>> cache.evict_number
10 | common_cache/__init__.py | def set_evict_number(self, new_evict_number, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> cache.set_evict_number(10)
>>> cache.evict_number
10
>>> cache.set_evict_number('haha')
>>> cache.evict_number
10
"""
if not... | def set_evict_number(self, new_evict_number, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> cache.set_evict_number(10)
>>> cache.evict_number
10
>>> cache.set_evict_number('haha')
>>> cache.evict_number
10
"""
if not... | [
">>>",
"cache",
"=",
"Cache",
"(",
"log_level",
"=",
"logging",
".",
"WARNING",
")",
">>>",
"cache",
".",
"set_evict_number",
"(",
"10",
")",
">>>",
"cache",
".",
"evict_number",
"10",
">>>",
"cache",
".",
"set_evict_number",
"(",
"haha",
")",
">>>",
"ca... | SylvanasSun/python-common-cache | python | https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L553-L567 | [
"def",
"set_evict_number",
"(",
"self",
",",
"new_evict_number",
",",
"only_read",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"new_evict_number",
",",
"int",
")",
"or",
"new_evict_number",
"<=",
"0",
":",
"self",
".",
"logger",
".",
"warning",
... | f113eb3cd751eed5ab5373e8610a31a444220cf8 |
train | Cache.with_read_after_refresh_expire | >>> cache = Cache(log_level=logging.WARNING)
>>> cache.read_after_refresh_expire
True
>>> cache.with_read_after_refresh_expire(False)
>>> cache.read_after_refresh_expire
False
>>> cache.with_read_after_refresh_expire('haha')
>>> cache.read_after_refresh_expire
... | common_cache/__init__.py | def with_read_after_refresh_expire(self, flag, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> cache.read_after_refresh_expire
True
>>> cache.with_read_after_refresh_expire(False)
>>> cache.read_after_refresh_expire
False
>>> cache.w... | def with_read_after_refresh_expire(self, flag, only_read=False):
"""
>>> cache = Cache(log_level=logging.WARNING)
>>> cache.read_after_refresh_expire
True
>>> cache.with_read_after_refresh_expire(False)
>>> cache.read_after_refresh_expire
False
>>> cache.w... | [
">>>",
"cache",
"=",
"Cache",
"(",
"log_level",
"=",
"logging",
".",
"WARNING",
")",
">>>",
"cache",
".",
"read_after_refresh_expire",
"True",
">>>",
"cache",
".",
"with_read_after_refresh_expire",
"(",
"False",
")",
">>>",
"cache",
".",
"read_after_refresh_expire... | SylvanasSun/python-common-cache | python | https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L570-L585 | [
"def",
"with_read_after_refresh_expire",
"(",
"self",
",",
"flag",
",",
"only_read",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"flag",
",",
"bool",
")",
":",
"self",
".",
"logger",
".",
"warning",
"(",
"'Parameter flag %s must be boolean'",
"%",
... | f113eb3cd751eed5ab5373e8610a31a444220cf8 |
train | Cache.statistic_record | Returns a list that each element is a dictionary of the statistic info of the cache item. | common_cache/__init__.py | def statistic_record(self, desc=True, timeout=3, is_async=False, only_read=True, *keys):
"""
Returns a list that each element is a dictionary of the statistic info of the cache item.
"""
if len(keys) == 0:
records = self._generate_statistic_records()
else:
... | def statistic_record(self, desc=True, timeout=3, is_async=False, only_read=True, *keys):
"""
Returns a list that each element is a dictionary of the statistic info of the cache item.
"""
if len(keys) == 0:
records = self._generate_statistic_records()
else:
... | [
"Returns",
"a",
"list",
"that",
"each",
"element",
"is",
"a",
"dictionary",
"of",
"the",
"statistic",
"info",
"of",
"the",
"cache",
"item",
"."
] | SylvanasSun/python-common-cache | python | https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L589-L597 | [
"def",
"statistic_record",
"(",
"self",
",",
"desc",
"=",
"True",
",",
"timeout",
"=",
"3",
",",
"is_async",
"=",
"False",
",",
"only_read",
"=",
"True",
",",
"*",
"keys",
")",
":",
"if",
"len",
"(",
"keys",
")",
"==",
"0",
":",
"records",
"=",
"... | f113eb3cd751eed5ab5373e8610a31a444220cf8 |
train | Cache.access_cache | The decorator for simplifying of use cache, it supports auto-update
cache(if parameter auto_update is True), load cache from other level cache
system or data source and writes back the update result to the
other level cache system or data source if cache miss.
The parameter key assigns ... | common_cache/__init__.py | def access_cache(self, key=None, key_location_on_param=0, expire=None, auto_update=True,
cache_loader=None, cache_writer=None, timeout=1):
"""
The decorator for simplifying of use cache, it supports auto-update
cache(if parameter auto_update is True), load cache from other l... | def access_cache(self, key=None, key_location_on_param=0, expire=None, auto_update=True,
cache_loader=None, cache_writer=None, timeout=1):
"""
The decorator for simplifying of use cache, it supports auto-update
cache(if parameter auto_update is True), load cache from other l... | [
"The",
"decorator",
"for",
"simplifying",
"of",
"use",
"cache",
"it",
"supports",
"auto",
"-",
"update",
"cache",
"(",
"if",
"parameter",
"auto_update",
"is",
"True",
")",
"load",
"cache",
"from",
"other",
"level",
"cache",
"system",
"or",
"data",
"source",
... | SylvanasSun/python-common-cache | python | https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L612-L720 | [
"def",
"access_cache",
"(",
"self",
",",
"key",
"=",
"None",
",",
"key_location_on_param",
"=",
"0",
",",
"expire",
"=",
"None",
",",
"auto_update",
"=",
"True",
",",
"cache_loader",
"=",
"None",
",",
"cache_writer",
"=",
"None",
",",
"timeout",
"=",
"1"... | f113eb3cd751eed5ab5373e8610a31a444220cf8 |
train | Cache.get | Test:
>>> import time
>>> cache = Cache(expire=2)
>>> cache.put(key='a', value=0)
>>> cache.put(key='b', value=1)
>>> cache.put(key='c',value= 2)
>>> cache.get('a')
0
>>> cache.get('b')
1
>>> cache.get('c')
2
>>> cache.get(... | common_cache/__init__.py | def get(self, key, timeout=1, is_async=False, only_read=True):
"""
Test:
>>> import time
>>> cache = Cache(expire=2)
>>> cache.put(key='a', value=0)
>>> cache.put(key='b', value=1)
>>> cache.put(key='c',value= 2)
>>> cache.get('a')
0
>>> c... | def get(self, key, timeout=1, is_async=False, only_read=True):
"""
Test:
>>> import time
>>> cache = Cache(expire=2)
>>> cache.put(key='a', value=0)
>>> cache.put(key='b', value=1)
>>> cache.put(key='c',value= 2)
>>> cache.get('a')
0
>>> c... | [
"Test",
":"
] | SylvanasSun/python-common-cache | python | https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L725-L762 | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"timeout",
"=",
"1",
",",
"is_async",
"=",
"False",
",",
"only_read",
"=",
"True",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"cache_items",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'Cache it... | f113eb3cd751eed5ab5373e8610a31a444220cf8 |
train | Cache.put | Test:
>>> cache = Cache(expire=2)
>>> cache.put('a', 0)
>>> cache.get('a')
0
>>> cache.put('a', 1)
>>> cache.get('a')
1 | common_cache/__init__.py | def put(self, key, value, expire=None, timeout=1, is_async=True, only_read=False):
"""
Test:
>>> cache = Cache(expire=2)
>>> cache.put('a', 0)
>>> cache.get('a')
0
>>> cache.put('a', 1)
>>> cache.get('a')
1
"""
if key in self.cache... | def put(self, key, value, expire=None, timeout=1, is_async=True, only_read=False):
"""
Test:
>>> cache = Cache(expire=2)
>>> cache.put('a', 0)
>>> cache.get('a')
0
>>> cache.put('a', 1)
>>> cache.get('a')
1
"""
if key in self.cache... | [
"Test",
":"
] | SylvanasSun/python-common-cache | python | https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L767-L783 | [
"def",
"put",
"(",
"self",
",",
"key",
",",
"value",
",",
"expire",
"=",
"None",
",",
"timeout",
"=",
"1",
",",
"is_async",
"=",
"True",
",",
"only_read",
"=",
"False",
")",
":",
"if",
"key",
"in",
"self",
".",
"cache_items",
":",
"self",
".",
"c... | f113eb3cd751eed5ab5373e8610a31a444220cf8 |
train | Cache.pop | Test:
>>> cache = Cache(log_level=logging.WARNING)
>>> cache.put('a', 0)
>>> cache.pop('a')
0
>>> cache.pop('b') == None
True | common_cache/__init__.py | def pop(self, key, timeout=1, is_async=False, only_read=False):
"""
Test:
>>> cache = Cache(log_level=logging.WARNING)
>>> cache.put('a', 0)
>>> cache.pop('a')
0
>>> cache.pop('b') == None
True
"""
if key not in self.cache_items:
... | def pop(self, key, timeout=1, is_async=False, only_read=False):
"""
Test:
>>> cache = Cache(log_level=logging.WARNING)
>>> cache.put('a', 0)
>>> cache.pop('a')
0
>>> cache.pop('b') == None
True
"""
if key not in self.cache_items:
... | [
"Test",
":"
] | SylvanasSun/python-common-cache | python | https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L788-L801 | [
"def",
"pop",
"(",
"self",
",",
"key",
",",
"timeout",
"=",
"1",
",",
"is_async",
"=",
"False",
",",
"only_read",
"=",
"False",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"cache_items",
":",
"return",
"None",
"return",
"self",
".",
"cache_items... | f113eb3cd751eed5ab5373e8610a31a444220cf8 |
train | signature_unsafe | Not safe to use with secret keys or secret data.
See module docstring. This function should be used for testing only. | src/nano/ed25519_blake2.py | def signature_unsafe(m, sk, pk, hash_func=H):
"""
Not safe to use with secret keys or secret data.
See module docstring. This function should be used for testing only.
"""
h = hash_func(sk)
a = 2 ** (b - 2) + sum(2 ** i * bit(h, i) for i in range(3, b - 2))
r = Hint(bytearray([h[j] for j in... | def signature_unsafe(m, sk, pk, hash_func=H):
"""
Not safe to use with secret keys or secret data.
See module docstring. This function should be used for testing only.
"""
h = hash_func(sk)
a = 2 ** (b - 2) + sum(2 ** i * bit(h, i) for i in range(3, b - 2))
r = Hint(bytearray([h[j] for j in... | [
"Not",
"safe",
"to",
"use",
"with",
"secret",
"keys",
"or",
"secret",
"data",
".",
"See",
"module",
"docstring",
".",
"This",
"function",
"should",
"be",
"used",
"for",
"testing",
"only",
"."
] | dourvaris/nano-python | python | https://github.com/dourvaris/nano-python/blob/f26b8bc895b997067780f925049a70e82c0c2479/src/nano/ed25519_blake2.py#L214-L224 | [
"def",
"signature_unsafe",
"(",
"m",
",",
"sk",
",",
"pk",
",",
"hash_func",
"=",
"H",
")",
":",
"h",
"=",
"hash_func",
"(",
"sk",
")",
"a",
"=",
"2",
"**",
"(",
"b",
"-",
"2",
")",
"+",
"sum",
"(",
"2",
"**",
"i",
"*",
"bit",
"(",
"h",
"... | f26b8bc895b997067780f925049a70e82c0c2479 |
train | checkvalid | Not safe to use when any argument is secret.
See module docstring. This function should be used only for
verifying public signatures of public messages. | src/nano/ed25519_blake2.py | def checkvalid(s, m, pk):
"""
Not safe to use when any argument is secret.
See module docstring. This function should be used only for
verifying public signatures of public messages.
"""
if len(s) != b // 4:
raise ValueError("signature length is wrong")
if len(pk) != b // 8:
... | def checkvalid(s, m, pk):
"""
Not safe to use when any argument is secret.
See module docstring. This function should be used only for
verifying public signatures of public messages.
"""
if len(s) != b // 4:
raise ValueError("signature length is wrong")
if len(pk) != b // 8:
... | [
"Not",
"safe",
"to",
"use",
"when",
"any",
"argument",
"is",
"secret",
".",
"See",
"module",
"docstring",
".",
"This",
"function",
"should",
"be",
"used",
"only",
"for",
"verifying",
"public",
"signatures",
"of",
"public",
"messages",
"."
] | dourvaris/nano-python | python | https://github.com/dourvaris/nano-python/blob/f26b8bc895b997067780f925049a70e82c0c2479/src/nano/ed25519_blake2.py#L255-L285 | [
"def",
"checkvalid",
"(",
"s",
",",
"m",
",",
"pk",
")",
":",
"if",
"len",
"(",
"s",
")",
"!=",
"b",
"//",
"4",
":",
"raise",
"ValueError",
"(",
"\"signature length is wrong\"",
")",
"if",
"len",
"(",
"pk",
")",
"!=",
"b",
"//",
"8",
":",
"raise"... | f26b8bc895b997067780f925049a70e82c0c2479 |
train | upgrade | Upgrade database. | invenio_oauthclient/alembic/97bbc733896c_create_oauthclient_tables.py | def upgrade():
"""Upgrade database."""
op.create_table(
'oauthclient_remoteaccount',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('client_id', sa.String(length=255), nullable=False),
sa.Column(
'e... | def upgrade():
"""Upgrade database."""
op.create_table(
'oauthclient_remoteaccount',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('client_id', sa.String(length=255), nullable=False),
sa.Column(
'e... | [
"Upgrade",
"database",
"."
] | inveniosoftware/invenio-oauthclient | python | https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/alembic/97bbc733896c_create_oauthclient_tables.py#L23-L64 | [
"def",
"upgrade",
"(",
")",
":",
"op",
".",
"create_table",
"(",
"'oauthclient_remoteaccount'",
",",
"sa",
".",
"Column",
"(",
"'id'",
",",
"sa",
".",
"Integer",
"(",
")",
",",
"nullable",
"=",
"False",
")",
",",
"sa",
".",
"Column",
"(",
"'user_id'",
... | 2500dc6935738107617aeade79e050d7608004bb |
train | upgrade | Upgrade database. | invenio_oauthclient/alembic/bff1f190b9bd_add_timestamp_oauthclient.py | def upgrade():
"""Upgrade database."""
current_date = datetime.utcnow()
# Add 'created' and 'updated' columns to RemoteAccount
_add_created_updated_columns('oauthclient_remoteaccount', current_date)
# Add 'created' and 'updated' columns to RemoteToken
_add_created_updated_columns('oauthclient_... | def upgrade():
"""Upgrade database."""
current_date = datetime.utcnow()
# Add 'created' and 'updated' columns to RemoteAccount
_add_created_updated_columns('oauthclient_remoteaccount', current_date)
# Add 'created' and 'updated' columns to RemoteToken
_add_created_updated_columns('oauthclient_... | [
"Upgrade",
"database",
"."
] | inveniosoftware/invenio-oauthclient | python | https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/alembic/bff1f190b9bd_add_timestamp_oauthclient.py#L23-L34 | [
"def",
"upgrade",
"(",
")",
":",
"current_date",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"# Add 'created' and 'updated' columns to RemoteAccount",
"_add_created_updated_columns",
"(",
"'oauthclient_remoteaccount'",
",",
"current_date",
")",
"# Add 'created' and 'updated' colu... | 2500dc6935738107617aeade79e050d7608004bb |
train | downgrade | Downgrade database. | invenio_oauthclient/alembic/bff1f190b9bd_add_timestamp_oauthclient.py | def downgrade():
"""Downgrade database."""
# Remove 'created' and 'updated' columns
op.drop_column('oauthclient_remoteaccount', 'created')
op.drop_column('oauthclient_remoteaccount', 'updated')
op.drop_column('oauthclient_remotetoken', 'created')
op.drop_column('oauthclient_remotetoken', 'updat... | def downgrade():
"""Downgrade database."""
# Remove 'created' and 'updated' columns
op.drop_column('oauthclient_remoteaccount', 'created')
op.drop_column('oauthclient_remoteaccount', 'updated')
op.drop_column('oauthclient_remotetoken', 'created')
op.drop_column('oauthclient_remotetoken', 'updat... | [
"Downgrade",
"database",
"."
] | inveniosoftware/invenio-oauthclient | python | https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/alembic/bff1f190b9bd_add_timestamp_oauthclient.py#L37-L47 | [
"def",
"downgrade",
"(",
")",
":",
"# Remove 'created' and 'updated' columns",
"op",
".",
"drop_column",
"(",
"'oauthclient_remoteaccount'",
",",
"'created'",
")",
"op",
".",
"drop_column",
"(",
"'oauthclient_remoteaccount'",
",",
"'updated'",
")",
"op",
".",
"drop_co... | 2500dc6935738107617aeade79e050d7608004bb |
train | dict | Compatibility with NLTK.
Returns the cmudict lexicon as a dictionary, whose keys are
lowercase words and whose values are lists of pronunciations. | cmudict/__init__.py | def dict():
"""
Compatibility with NLTK.
Returns the cmudict lexicon as a dictionary, whose keys are
lowercase words and whose values are lists of pronunciations.
"""
default = defaultdict(list)
for key, value in entries():
default[key].append(value)
return default | def dict():
"""
Compatibility with NLTK.
Returns the cmudict lexicon as a dictionary, whose keys are
lowercase words and whose values are lists of pronunciations.
"""
default = defaultdict(list)
for key, value in entries():
default[key].append(value)
return default | [
"Compatibility",
"with",
"NLTK",
".",
"Returns",
"the",
"cmudict",
"lexicon",
"as",
"a",
"dictionary",
"whose",
"keys",
"are",
"lowercase",
"words",
"and",
"whose",
"values",
"are",
"lists",
"of",
"pronunciations",
"."
] | prosegrinder/python-cmudict | python | https://github.com/prosegrinder/python-cmudict/blob/e7af7ae9e923add04e14fa303ad44d5abd0cc20a/cmudict/__init__.py#L42-L51 | [
"def",
"dict",
"(",
")",
":",
"default",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"key",
",",
"value",
"in",
"entries",
"(",
")",
":",
"default",
"[",
"key",
"]",
".",
"append",
"(",
"value",
")",
"return",
"default"
] | e7af7ae9e923add04e14fa303ad44d5abd0cc20a |
train | symbols | Return a list of symbols. | cmudict/__init__.py | def symbols():
"""Return a list of symbols."""
symbols = []
for line in symbols_stream():
symbols.append(line.decode('utf-8').strip())
return symbols | def symbols():
"""Return a list of symbols."""
symbols = []
for line in symbols_stream():
symbols.append(line.decode('utf-8').strip())
return symbols | [
"Return",
"a",
"list",
"of",
"symbols",
"."
] | prosegrinder/python-cmudict | python | https://github.com/prosegrinder/python-cmudict/blob/e7af7ae9e923add04e14fa303ad44d5abd0cc20a/cmudict/__init__.py#L92-L97 | [
"def",
"symbols",
"(",
")",
":",
"symbols",
"=",
"[",
"]",
"for",
"line",
"in",
"symbols_stream",
"(",
")",
":",
"symbols",
".",
"append",
"(",
"line",
".",
"decode",
"(",
"'utf-8'",
")",
".",
"strip",
"(",
")",
")",
"return",
"symbols"
] | e7af7ae9e923add04e14fa303ad44d5abd0cc20a |
train | _inspect | (internal) Determines the type of a given ``object``. Discriminates between
``Piper``, ``Worker``, ``FunctionType`` and ``Iterable`` instances. It
returns a ``tuple`` of boolean variables i.e: (is_piper, is_worker,
is_function, is_iterable_of_pipers, is_iterable_of_workers,
is_iterable_of_functi... | src/papy/core.py | def _inspect(instance):
"""
(internal) Determines the type of a given ``object``. Discriminates between
``Piper``, ``Worker``, ``FunctionType`` and ``Iterable`` instances. It
returns a ``tuple`` of boolean variables i.e: (is_piper, is_worker,
is_function, is_iterable_of_pipers, is_iterable_of... | def _inspect(instance):
"""
(internal) Determines the type of a given ``object``. Discriminates between
``Piper``, ``Worker``, ``FunctionType`` and ``Iterable`` instances. It
returns a ``tuple`` of boolean variables i.e: (is_piper, is_worker,
is_function, is_iterable_of_pipers, is_iterable_of... | [
"(",
"internal",
")",
"Determines",
"the",
"type",
"of",
"a",
"given",
"object",
".",
"Discriminates",
"between",
"Piper",
"Worker",
"FunctionType",
"and",
"Iterable",
"instances",
".",
"It",
"returns",
"a",
"tuple",
"of",
"boolean",
"variables",
"i",
".",
"... | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L1414-L1433 | [
"def",
"_inspect",
"(",
"instance",
")",
":",
"is_piper",
"=",
"isinstance",
"(",
"instance",
",",
"Piper",
")",
"is_function",
"=",
"isinstance",
"(",
"instance",
",",
"FunctionType",
")",
"or",
"isbuiltin",
"(",
"instance",
")",
"is_worker",
"=",
"isinstan... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | _comp_task | (internal) Composes a sequence of functions in the global variable TASK. The
resulting composition is given the input "inbox" and arguments "args",
"kwargs". | src/papy/core.py | def _comp_task(inbox, args, kwargs):
"""
(internal) Composes a sequence of functions in the global variable TASK. The
resulting composition is given the input "inbox" and arguments "args",
"kwargs".
"""
# Note. this function uses a global variable which must be defined on the
# remote... | def _comp_task(inbox, args, kwargs):
"""
(internal) Composes a sequence of functions in the global variable TASK. The
resulting composition is given the input "inbox" and arguments "args",
"kwargs".
"""
# Note. this function uses a global variable which must be defined on the
# remote... | [
"(",
"internal",
")",
"Composes",
"a",
"sequence",
"of",
"functions",
"in",
"the",
"global",
"variable",
"TASK",
".",
"The",
"resulting",
"composition",
"is",
"given",
"the",
"input",
"inbox",
"and",
"arguments",
"args",
"kwargs",
"."
] | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L1436-L1447 | [
"def",
"_comp_task",
"(",
"inbox",
",",
"args",
",",
"kwargs",
")",
":",
"# Note. this function uses a global variable which must be defined on the ",
"# remote host.",
"for",
"func",
",",
"args",
",",
"kwargs",
"in",
"itertools",
".",
"izip",
"(",
"TASK",
",",
"arg... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Dagger.children_after_parents | Custom compare function. Returns ``1`` if the first ``Piper`` instance
is upstream of the second ``Piper`` instance, ``-1`` if the first
``Piper`` is downstream of the second ``Piper`` and ``0`` if the two
``Pipers`` are independent.
Arguments:
- piper1(``P... | src/papy/core.py | def children_after_parents(self, piper1, piper2):
"""
Custom compare function. Returns ``1`` if the first ``Piper`` instance
is upstream of the second ``Piper`` instance, ``-1`` if the first
``Piper`` is downstream of the second ``Piper`` and ``0`` if the two
``Pipers`` are in... | def children_after_parents(self, piper1, piper2):
"""
Custom compare function. Returns ``1`` if the first ``Piper`` instance
is upstream of the second ``Piper`` instance, ``-1`` if the first
``Piper`` is downstream of the second ``Piper`` and ``0`` if the two
``Pipers`` are in... | [
"Custom",
"compare",
"function",
".",
"Returns",
"1",
"if",
"the",
"first",
"Piper",
"instance",
"is",
"upstream",
"of",
"the",
"second",
"Piper",
"instance",
"-",
"1",
"if",
"the",
"first",
"Piper",
"is",
"downstream",
"of",
"the",
"second",
"Piper",
"and... | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L105-L123 | [
"def",
"children_after_parents",
"(",
"self",
",",
"piper1",
",",
"piper2",
")",
":",
"if",
"piper1",
"in",
"self",
"[",
"piper2",
"]",
".",
"deep_nodes",
"(",
")",
":",
"return",
"1",
"elif",
"piper2",
"in",
"self",
"[",
"piper1",
"]",
".",
"deep_node... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Dagger.resolve | Given a ``Piper`` instance or the ``id`` of the ``Piper``. Returns the
``Piper`` instance if it can be resolved else raises a ``DaggerError``
or returns ``False`` depending on the "forgive" argument.
Arguments:
- piper(``Piper`` or id(``Piper``)) a ``Piper`` instance or i... | src/papy/core.py | def resolve(self, piper, forgive=False):
"""
Given a ``Piper`` instance or the ``id`` of the ``Piper``. Returns the
``Piper`` instance if it can be resolved else raises a ``DaggerError``
or returns ``False`` depending on the "forgive" argument.
Arguments:
... | def resolve(self, piper, forgive=False):
"""
Given a ``Piper`` instance or the ``id`` of the ``Piper``. Returns the
``Piper`` instance if it can be resolved else raises a ``DaggerError``
or returns ``False`` depending on the "forgive" argument.
Arguments:
... | [
"Given",
"a",
"Piper",
"instance",
"or",
"the",
"id",
"of",
"the",
"Piper",
".",
"Returns",
"the",
"Piper",
"instance",
"if",
"it",
"can",
"be",
"resolved",
"else",
"raises",
"a",
"DaggerError",
"or",
"returns",
"False",
"depending",
"on",
"the",
"forgive"... | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L125-L156 | [
"def",
"resolve",
"(",
"self",
",",
"piper",
",",
"forgive",
"=",
"False",
")",
":",
"try",
":",
"if",
"piper",
"in",
"self",
":",
"resolved",
"=",
"piper",
"else",
":",
"resolved",
"=",
"[",
"p",
"for",
"p",
"in",
"self",
"if",
"id",
"(",
"p",
... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Dagger.connect | Connects ``Pipers`` in the order input -> output. See ``Piper.connect``.
According to the pipes (topology). If "datas" is given will connect the
input ``Pipers`` to the input data see: ``Dagger.connect_inputs``.
Argumensts:
- datas(sequence) [default: ``None``] valid ... | src/papy/core.py | def connect(self, datas=None):
"""
Connects ``Pipers`` in the order input -> output. See ``Piper.connect``.
According to the pipes (topology). If "datas" is given will connect the
input ``Pipers`` to the input data see: ``Dagger.connect_inputs``.
Argumensts:
... | def connect(self, datas=None):
"""
Connects ``Pipers`` in the order input -> output. See ``Piper.connect``.
According to the pipes (topology). If "datas" is given will connect the
input ``Pipers`` to the input data see: ``Dagger.connect_inputs``.
Argumensts:
... | [
"Connects",
"Pipers",
"in",
"the",
"order",
"input",
"-",
">",
"output",
".",
"See",
"Piper",
".",
"connect",
".",
"According",
"to",
"the",
"pipes",
"(",
"topology",
")",
".",
"If",
"datas",
"is",
"given",
"will",
"connect",
"the",
"input",
"Pipers",
... | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L158-L186 | [
"def",
"connect",
"(",
"self",
",",
"datas",
"=",
"None",
")",
":",
"# if data connect inputs",
"if",
"datas",
":",
"self",
".",
"connect_inputs",
"(",
"datas",
")",
"# connect the remaining pipers",
"postorder",
"=",
"self",
".",
"postorder",
"(",
")",
"self"... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Dagger.connect_inputs | Connects input ``Pipers`` to "datas" input data in the correct order
determined, by the ``Piper.ornament`` attribute and the ``Dagger._cmp``
function.
It is assumed that the input data is in the form of an iterator and
that all inputs have the same number of input items. A pipeline w... | src/papy/core.py | def connect_inputs(self, datas):
"""
Connects input ``Pipers`` to "datas" input data in the correct order
determined, by the ``Piper.ornament`` attribute and the ``Dagger._cmp``
function.
It is assumed that the input data is in the form of an iterator and
that all inp... | def connect_inputs(self, datas):
"""
Connects input ``Pipers`` to "datas" input data in the correct order
determined, by the ``Piper.ornament`` attribute and the ``Dagger._cmp``
function.
It is assumed that the input data is in the form of an iterator and
that all inp... | [
"Connects",
"input",
"Pipers",
"to",
"datas",
"input",
"data",
"in",
"the",
"correct",
"order",
"determined",
"by",
"the",
"Piper",
".",
"ornament",
"attribute",
"and",
"the",
"Dagger",
".",
"_cmp",
"function",
"."
] | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L188-L209 | [
"def",
"connect_inputs",
"(",
"self",
",",
"datas",
")",
":",
"start_pipers",
"=",
"self",
".",
"get_inputs",
"(",
")",
"self",
".",
"log",
".",
"debug",
"(",
"'%s trying to connect inputs in the order %s'",
"%",
"(",
"repr",
"(",
"self",
")",
",",
"repr",
... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Dagger.disconnect | Given the pipeline topology disconnects ``Pipers`` in the order output
-> input. This also disconnects inputs. See ``Dagger.connect``,
``Piper.connect`` and ``Piper.disconnect``. If "forced" is ``True``
``NuMap`` instances will be emptied.
Arguments:
- forced... | src/papy/core.py | def disconnect(self, forced=False):
"""
Given the pipeline topology disconnects ``Pipers`` in the order output
-> input. This also disconnects inputs. See ``Dagger.connect``,
``Piper.connect`` and ``Piper.disconnect``. If "forced" is ``True``
``NuMap`` instances will be emptied.... | def disconnect(self, forced=False):
"""
Given the pipeline topology disconnects ``Pipers`` in the order output
-> input. This also disconnects inputs. See ``Dagger.connect``,
``Piper.connect`` and ``Piper.disconnect``. If "forced" is ``True``
``NuMap`` instances will be emptied.... | [
"Given",
"the",
"pipeline",
"topology",
"disconnects",
"Pipers",
"in",
"the",
"order",
"output",
"-",
">",
"input",
".",
"This",
"also",
"disconnects",
"inputs",
".",
"See",
"Dagger",
".",
"connect",
"Piper",
".",
"connect",
"and",
"Piper",
".",
"disconnect"... | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L211-L232 | [
"def",
"disconnect",
"(",
"self",
",",
"forced",
"=",
"False",
")",
":",
"reversed_postorder",
"=",
"reversed",
"(",
"self",
".",
"postorder",
"(",
")",
")",
"self",
".",
"log",
".",
"debug",
"(",
"'%s trying to disconnect in the order %s'",
"%",
"(",
"repr"... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Dagger.start | Given the pipeline topology starts ``Pipers`` in the order input ->
output. See ``Piper.start``. ``Pipers`` instances are started in two
stages, which allows them to share ``NuMaps``. | src/papy/core.py | def start(self):
"""
Given the pipeline topology starts ``Pipers`` in the order input ->
output. See ``Piper.start``. ``Pipers`` instances are started in two
stages, which allows them to share ``NuMaps``.
"""
# top - > bottom of pipeline
pipers = self.p... | def start(self):
"""
Given the pipeline topology starts ``Pipers`` in the order input ->
output. See ``Piper.start``. ``Pipers`` instances are started in two
stages, which allows them to share ``NuMaps``.
"""
# top - > bottom of pipeline
pipers = self.p... | [
"Given",
"the",
"pipeline",
"topology",
"starts",
"Pipers",
"in",
"the",
"order",
"input",
"-",
">",
"output",
".",
"See",
"Piper",
".",
"start",
".",
"Pipers",
"instances",
"are",
"started",
"in",
"two",
"stages",
"which",
"allows",
"them",
"to",
"share",... | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L234-L247 | [
"def",
"start",
"(",
"self",
")",
":",
"# top - > bottom of pipeline",
"pipers",
"=",
"self",
".",
"postorder",
"(",
")",
"# ",
"for",
"piper",
"in",
"pipers",
":",
"piper",
".",
"start",
"(",
"stages",
"=",
"(",
"0",
",",
"1",
")",
")",
"for",
"pipe... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Dagger.stop | Stops the ``Pipers`` according to pipeline topology. | src/papy/core.py | def stop(self):
"""
Stops the ``Pipers`` according to pipeline topology.
"""
self.log.debug('%s begins stopping routine' % repr(self))
self.log.debug('%s triggers stopping in input pipers' % repr(self))
inputs = self.get_inputs()
for piper in inputs:
... | def stop(self):
"""
Stops the ``Pipers`` according to pipeline topology.
"""
self.log.debug('%s begins stopping routine' % repr(self))
self.log.debug('%s triggers stopping in input pipers' % repr(self))
inputs = self.get_inputs()
for piper in inputs:
... | [
"Stops",
"the",
"Pipers",
"according",
"to",
"pipeline",
"topology",
"."
] | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L249-L283 | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'%s begins stopping routine'",
"%",
"repr",
"(",
"self",
")",
")",
"self",
".",
"log",
".",
"debug",
"(",
"'%s triggers stopping in input pipers'",
"%",
"repr",
"(",
"self",
")",... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Dagger.get_inputs | Returns ``Piper`` instances, which are inputs to the pipeline i.e. have
no incoming pipes (outgoing dependency edges). | src/papy/core.py | def get_inputs(self):
"""
Returns ``Piper`` instances, which are inputs to the pipeline i.e. have
no incoming pipes (outgoing dependency edges).
"""
start_p = [p for p in self.postorder() if not self.outgoing_edges(p)]
self.log.debug('%s got input pipers %s' % ... | def get_inputs(self):
"""
Returns ``Piper`` instances, which are inputs to the pipeline i.e. have
no incoming pipes (outgoing dependency edges).
"""
start_p = [p for p in self.postorder() if not self.outgoing_edges(p)]
self.log.debug('%s got input pipers %s' % ... | [
"Returns",
"Piper",
"instances",
"which",
"are",
"inputs",
"to",
"the",
"pipeline",
"i",
".",
"e",
".",
"have",
"no",
"incoming",
"pipes",
"(",
"outgoing",
"dependency",
"edges",
")",
"."
] | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L285-L293 | [
"def",
"get_inputs",
"(",
"self",
")",
":",
"start_p",
"=",
"[",
"p",
"for",
"p",
"in",
"self",
".",
"postorder",
"(",
")",
"if",
"not",
"self",
".",
"outgoing_edges",
"(",
"p",
")",
"]",
"self",
".",
"log",
".",
"debug",
"(",
"'%s got input pipers %... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Dagger.get_outputs | Returns ``Piper`` instances, which are outputs to the pipeline i.e. have
no outgoing pipes (incoming dependency edges). | src/papy/core.py | def get_outputs(self):
"""
Returns ``Piper`` instances, which are outputs to the pipeline i.e. have
no outgoing pipes (incoming dependency edges).
"""
end_p = [p for p in self.postorder() if not self.incoming_edges(p)]
self.log.debug('%s got output pipers %s' % ... | def get_outputs(self):
"""
Returns ``Piper`` instances, which are outputs to the pipeline i.e. have
no outgoing pipes (incoming dependency edges).
"""
end_p = [p for p in self.postorder() if not self.incoming_edges(p)]
self.log.debug('%s got output pipers %s' % ... | [
"Returns",
"Piper",
"instances",
"which",
"are",
"outputs",
"to",
"the",
"pipeline",
"i",
".",
"e",
".",
"have",
"no",
"outgoing",
"pipes",
"(",
"incoming",
"dependency",
"edges",
")",
"."
] | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L295-L303 | [
"def",
"get_outputs",
"(",
"self",
")",
":",
"end_p",
"=",
"[",
"p",
"for",
"p",
"in",
"self",
".",
"postorder",
"(",
")",
"if",
"not",
"self",
".",
"incoming_edges",
"(",
"p",
")",
"]",
"self",
".",
"log",
".",
"debug",
"(",
"'%s got output pipers %... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Dagger.add_piper | Adds a ``Piper`` instance to this ``Dagger``, but only if the ``Piper``
is not already there. Optionally creates a new ``Piper`` if the "piper"
argument is valid for the ``Piper`` constructor. Returns a ``tuple``
(new_piper_created, piper_instance) indicating whether a new ``Piper``
ha... | src/papy/core.py | def add_piper(self, piper, xtra=None, create=True, branch=None):
"""
Adds a ``Piper`` instance to this ``Dagger``, but only if the ``Piper``
is not already there. Optionally creates a new ``Piper`` if the "piper"
argument is valid for the ``Piper`` constructor. Returns a ``tuple``
... | def add_piper(self, piper, xtra=None, create=True, branch=None):
"""
Adds a ``Piper`` instance to this ``Dagger``, but only if the ``Piper``
is not already there. Optionally creates a new ``Piper`` if the "piper"
argument is valid for the ``Piper`` constructor. Returns a ``tuple``
... | [
"Adds",
"a",
"Piper",
"instance",
"to",
"this",
"Dagger",
"but",
"only",
"if",
"the",
"Piper",
"is",
"not",
"already",
"there",
".",
"Optionally",
"creates",
"a",
"new",
"Piper",
"if",
"the",
"piper",
"argument",
"is",
"valid",
"for",
"the",
"Piper",
"co... | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L305-L344 | [
"def",
"add_piper",
"(",
"self",
",",
"piper",
",",
"xtra",
"=",
"None",
",",
"create",
"=",
"True",
",",
"branch",
"=",
"None",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'%s trying to add piper %s'",
"%",
"(",
"repr",
"(",
"self",
")",
",",
... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Dagger.del_piper | Removes a ``Piper`` from the ``Dagger`` instance.
Arguments:
- piper(``Piper`` or id(``Piper``)) ``Piper`` instance or ``Piper``
instance id.
- forced(bool) [default: ``False``] If "forced" is ``True``, will not
raise a ``DaggerError`` if the ``Piper`` ha... | src/papy/core.py | def del_piper(self, piper, forced=False):
"""
Removes a ``Piper`` from the ``Dagger`` instance.
Arguments:
- piper(``Piper`` or id(``Piper``)) ``Piper`` instance or ``Piper``
instance id.
- forced(bool) [default: ``False``] If "forced" is ``True``, wil... | def del_piper(self, piper, forced=False):
"""
Removes a ``Piper`` from the ``Dagger`` instance.
Arguments:
- piper(``Piper`` or id(``Piper``)) ``Piper`` instance or ``Piper``
instance id.
- forced(bool) [default: ``False``] If "forced" is ``True``, wil... | [
"Removes",
"a",
"Piper",
"from",
"the",
"Dagger",
"instance",
"."
] | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L346-L374 | [
"def",
"del_piper",
"(",
"self",
",",
"piper",
",",
"forced",
"=",
"False",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'%s trying to delete piper %s'",
"%",
"(",
"repr",
"(",
"self",
")",
",",
"repr",
"(",
"piper",
")",
")",
")",
"try",
":",
... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Dagger.add_pipe | Adds a pipe (A, ..., N) which is an N-``tuple`` tuple of ``Pipers``
instances. Adding a pipe means to add all the ``Pipers`` and connect
them in the specified left to right order.
The direction of the edges in the ``DictGraph`` is reversed compared to
the left to right data-f... | src/papy/core.py | def add_pipe(self, pipe, branch=None):
"""
Adds a pipe (A, ..., N) which is an N-``tuple`` tuple of ``Pipers``
instances. Adding a pipe means to add all the ``Pipers`` and connect
them in the specified left to right order.
The direction of the edges in the ``DictGraph`... | def add_pipe(self, pipe, branch=None):
"""
Adds a pipe (A, ..., N) which is an N-``tuple`` tuple of ``Pipers``
instances. Adding a pipe means to add all the ``Pipers`` and connect
them in the specified left to right order.
The direction of the edges in the ``DictGraph`... | [
"Adds",
"a",
"pipe",
"(",
"A",
"...",
"N",
")",
"which",
"is",
"an",
"N",
"-",
"tuple",
"tuple",
"of",
"Pipers",
"instances",
".",
"Adding",
"a",
"pipe",
"means",
"to",
"add",
"all",
"the",
"Pipers",
"and",
"connect",
"them",
"in",
"the",
"specified"... | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L376-L406 | [
"def",
"add_pipe",
"(",
"self",
",",
"pipe",
",",
"branch",
"=",
"None",
")",
":",
"#TODO: Check if consume/spawn/produce is right!",
"self",
".",
"log",
".",
"debug",
"(",
"'%s adding pipe: %s'",
"%",
"(",
"repr",
"(",
"self",
")",
",",
"repr",
"(",
"pipe",... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Dagger.del_pipe | Deletes a pipe (A, ..., N) which is an N-``tuple`` of ``Piper``
instances. Deleting a pipe means to delete all the connections between
``Pipers`` and to delete all the ``Pipers``. If "forced" is ``False``
only ``Pipers`` which are not used anymore (i.e. have not downstream
``Pipers``... | src/papy/core.py | def del_pipe(self, pipe, forced=False):
"""
Deletes a pipe (A, ..., N) which is an N-``tuple`` of ``Piper``
instances. Deleting a pipe means to delete all the connections between
``Pipers`` and to delete all the ``Pipers``. If "forced" is ``False``
only ``Pipers`` which are no... | def del_pipe(self, pipe, forced=False):
"""
Deletes a pipe (A, ..., N) which is an N-``tuple`` of ``Piper``
instances. Deleting a pipe means to delete all the connections between
``Pipers`` and to delete all the ``Pipers``. If "forced" is ``False``
only ``Pipers`` which are no... | [
"Deletes",
"a",
"pipe",
"(",
"A",
"...",
"N",
")",
"which",
"is",
"an",
"N",
"-",
"tuple",
"of",
"Piper",
"instances",
".",
"Deleting",
"a",
"pipe",
"means",
"to",
"delete",
"all",
"the",
"connections",
"between",
"Pipers",
"and",
"to",
"delete",
"all"... | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L408-L442 | [
"def",
"del_pipe",
"(",
"self",
",",
"pipe",
",",
"forced",
"=",
"False",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'%s removes pipe%s forced: %s'",
"%",
"(",
"repr",
"(",
"self",
")",
",",
"repr",
"(",
"pipe",
")",
",",
"forced",
")",
")",
... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Dagger.add_pipers | Adds a sequence of ``Pipers`` instances to the ``Dagger`` in the
specified order. Takes optional arguments for ``Dagger.add_piper``.
Arguments:
- pipers(sequence of valid ``add_piper`` arguments) Sequence of
``Pipers`` or valid ``Dagger.add_piper`` arguments to ... | src/papy/core.py | def add_pipers(self, pipers, *args, **kwargs):
"""
Adds a sequence of ``Pipers`` instances to the ``Dagger`` in the
specified order. Takes optional arguments for ``Dagger.add_piper``.
Arguments:
- pipers(sequence of valid ``add_piper`` arguments) Sequence of ... | def add_pipers(self, pipers, *args, **kwargs):
"""
Adds a sequence of ``Pipers`` instances to the ``Dagger`` in the
specified order. Takes optional arguments for ``Dagger.add_piper``.
Arguments:
- pipers(sequence of valid ``add_piper`` arguments) Sequence of ... | [
"Adds",
"a",
"sequence",
"of",
"Pipers",
"instances",
"to",
"the",
"Dagger",
"in",
"the",
"specified",
"order",
".",
"Takes",
"optional",
"arguments",
"for",
"Dagger",
".",
"add_piper",
".",
"Arguments",
":",
"-",
"pipers",
"(",
"sequence",
"of",
"valid",
... | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L444-L457 | [
"def",
"add_pipers",
"(",
"self",
",",
"pipers",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"piper",
"in",
"pipers",
":",
"self",
".",
"add_piper",
"(",
"piper",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Dagger.del_pipers | Deletes a sequence of ``Pipers`` instances from the ``Dagger`` in the
reverse of the specified order. Takes optional arguments for
``Dagger.del_piper``.
Arguments:
- pipers (sequence of valid ``del_piper`` arguments) Sequence of
``Pipers`` or valid ``Dag... | src/papy/core.py | def del_pipers(self, pipers, *args, **kwargs):
"""
Deletes a sequence of ``Pipers`` instances from the ``Dagger`` in the
reverse of the specified order. Takes optional arguments for
``Dagger.del_piper``.
Arguments:
- pipers (sequence of valid ``del_pi... | def del_pipers(self, pipers, *args, **kwargs):
"""
Deletes a sequence of ``Pipers`` instances from the ``Dagger`` in the
reverse of the specified order. Takes optional arguments for
``Dagger.del_piper``.
Arguments:
- pipers (sequence of valid ``del_pi... | [
"Deletes",
"a",
"sequence",
"of",
"Pipers",
"instances",
"from",
"the",
"Dagger",
"in",
"the",
"reverse",
"of",
"the",
"specified",
"order",
".",
"Takes",
"optional",
"arguments",
"for",
"Dagger",
".",
"del_piper",
".",
"Arguments",
":",
"-",
"pipers",
"(",
... | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L459-L474 | [
"def",
"del_pipers",
"(",
"self",
",",
"pipers",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"pipers",
".",
"reverse",
"(",
")",
"for",
"piper",
"in",
"pipers",
":",
"self",
".",
"del_piper",
"(",
"piper",
",",
"*",
"args",
",",
"*",
"*"... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Dagger.add_pipes | Adds a sequence of pipes to the ``Dagger`` in the specified order.
Takes optional arguments for ``Dagger.add_pipe``.
Arguments:
- pipes(sequence of valid ``add_pipe`` arguments) Sequence of pipes
or other valid ``Dagger.add_pipe`` arguments to be added to the
... | src/papy/core.py | def add_pipes(self, pipes, *args, **kwargs):
"""
Adds a sequence of pipes to the ``Dagger`` in the specified order.
Takes optional arguments for ``Dagger.add_pipe``.
Arguments:
- pipes(sequence of valid ``add_pipe`` arguments) Sequence of pipes
o... | def add_pipes(self, pipes, *args, **kwargs):
"""
Adds a sequence of pipes to the ``Dagger`` in the specified order.
Takes optional arguments for ``Dagger.add_pipe``.
Arguments:
- pipes(sequence of valid ``add_pipe`` arguments) Sequence of pipes
o... | [
"Adds",
"a",
"sequence",
"of",
"pipes",
"to",
"the",
"Dagger",
"in",
"the",
"specified",
"order",
".",
"Takes",
"optional",
"arguments",
"for",
"Dagger",
".",
"add_pipe",
".",
"Arguments",
":",
"-",
"pipes",
"(",
"sequence",
"of",
"valid",
"add_pipe",
"arg... | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L476-L490 | [
"def",
"add_pipes",
"(",
"self",
",",
"pipes",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"pipe",
"in",
"pipes",
":",
"self",
".",
"add_pipe",
"(",
"pipe",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Dagger.del_pipes | Deletes a sequence of pipes from the ``Dagger`` in the specified order.
Takes optional arguments for ``Dagger.del_pipe``.
Arguments:
- pipes(sequence of valid ``del_pipe`` arguments) Sequence of pipes or
other valid ``Dagger.del_pipe`` arguments to be removed fr... | src/papy/core.py | def del_pipes(self, pipes, *args, **kwargs):
"""
Deletes a sequence of pipes from the ``Dagger`` in the specified order.
Takes optional arguments for ``Dagger.del_pipe``.
Arguments:
- pipes(sequence of valid ``del_pipe`` arguments) Sequence of pipes or
... | def del_pipes(self, pipes, *args, **kwargs):
"""
Deletes a sequence of pipes from the ``Dagger`` in the specified order.
Takes optional arguments for ``Dagger.del_pipe``.
Arguments:
- pipes(sequence of valid ``del_pipe`` arguments) Sequence of pipes or
... | [
"Deletes",
"a",
"sequence",
"of",
"pipes",
"from",
"the",
"Dagger",
"in",
"the",
"specified",
"order",
".",
"Takes",
"optional",
"arguments",
"for",
"Dagger",
".",
"del_pipe",
".",
"Arguments",
":",
"-",
"pipes",
"(",
"sequence",
"of",
"valid",
"del_pipe",
... | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L492-L505 | [
"def",
"del_pipes",
"(",
"self",
",",
"pipes",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"pipe",
"in",
"pipes",
":",
"self",
".",
"del_pipe",
"(",
"pipe",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Plumber._finish | (internal) executes when last output piper raises ``StopIteration``. | src/papy/core.py | def _finish(self, ispausing):
"""
(internal) executes when last output piper raises ``StopIteration``.
"""
if ispausing:
self.log.debug('%s paused' % repr(self))
else:
self._finished.set()
self.log.debug('%s finished' % repr(self)) | def _finish(self, ispausing):
"""
(internal) executes when last output piper raises ``StopIteration``.
"""
if ispausing:
self.log.debug('%s paused' % repr(self))
else:
self._finished.set()
self.log.debug('%s finished' % repr(self)) | [
"(",
"internal",
")",
"executes",
"when",
"last",
"output",
"piper",
"raises",
"StopIteration",
"."
] | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L521-L529 | [
"def",
"_finish",
"(",
"self",
",",
"ispausing",
")",
":",
"if",
"ispausing",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'%s paused'",
"%",
"repr",
"(",
"self",
")",
")",
"else",
":",
"self",
".",
"_finished",
".",
"set",
"(",
")",
"self",
".",
... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Plumber._plunge | (internal) calls the next method of weaved tasks until they are finished
or The ``Plumber`` instance is stopped see: ``Dagger.chinkup``. | src/papy/core.py | def _plunge(tasks, pausing, finish):
"""
(internal) calls the next method of weaved tasks until they are finished
or The ``Plumber`` instance is stopped see: ``Dagger.chinkup``.
"""
# If no result received either not started or start & stop
# could have been called before... | def _plunge(tasks, pausing, finish):
"""
(internal) calls the next method of weaved tasks until they are finished
or The ``Plumber`` instance is stopped see: ``Dagger.chinkup``.
"""
# If no result received either not started or start & stop
# could have been called before... | [
"(",
"internal",
")",
"calls",
"the",
"next",
"method",
"of",
"weaved",
"tasks",
"until",
"they",
"are",
"finished",
"or",
"The",
"Plumber",
"instance",
"is",
"stopped",
"see",
":",
"Dagger",
".",
"chinkup",
"."
] | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L532-L546 | [
"def",
"_plunge",
"(",
"tasks",
",",
"pausing",
",",
"finish",
")",
":",
"# If no result received either not started or start & stop",
"# could have been called before the plunger thread",
"while",
"True",
":",
"if",
"pausing",
"(",
")",
":",
"tasks",
".",
"stop",
"(",
... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Plumber._code | (internal) generates imports, code and runtime calls to save a pipeline. | src/papy/core.py | def _code(self):
"""
(internal) generates imports, code and runtime calls to save a pipeline.
"""
icode, tcode = '', '' # imports, task code
icall, pcall = '', '' # imap calls, piper calls
tdone, idone = [], [] # task done, imap done
for piper in self:
... | def _code(self):
"""
(internal) generates imports, code and runtime calls to save a pipeline.
"""
icode, tcode = '', '' # imports, task code
icall, pcall = '', '' # imap calls, piper calls
tdone, idone = [], [] # task done, imap done
for piper in self:
... | [
"(",
"internal",
")",
"generates",
"imports",
"code",
"and",
"runtime",
"calls",
"to",
"save",
"a",
"pipeline",
"."
] | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L563-L602 | [
"def",
"_code",
"(",
"self",
")",
":",
"icode",
",",
"tcode",
"=",
"''",
",",
"''",
"# imports, task code",
"icall",
",",
"pcall",
"=",
"''",
",",
"''",
"# imap calls, piper calls",
"tdone",
",",
"idone",
"=",
"[",
"]",
",",
"[",
"]",
"# task done, imap ... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Plumber.save | Saves pipeline as a Python source code file.
Arguments:
- filename(``path``) Path to save the pipeline source code. | src/papy/core.py | def save(self, filename):
"""
Saves pipeline as a Python source code file.
Arguments:
- filename(``path``) Path to save the pipeline source code.
"""
handle = open(filename, 'wb')
handle.write(P_LAY % self._code())
handle.clo... | def save(self, filename):
"""
Saves pipeline as a Python source code file.
Arguments:
- filename(``path``) Path to save the pipeline source code.
"""
handle = open(filename, 'wb')
handle.write(P_LAY % self._code())
handle.clo... | [
"Saves",
"pipeline",
"as",
"a",
"Python",
"source",
"code",
"file",
".",
"Arguments",
":",
"-",
"filename",
"(",
"path",
")",
"Path",
"to",
"save",
"the",
"pipeline",
"source",
"code",
"."
] | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L618-L629 | [
"def",
"save",
"(",
"self",
",",
"filename",
")",
":",
"handle",
"=",
"open",
"(",
"filename",
",",
"'wb'",
")",
"handle",
".",
"write",
"(",
"P_LAY",
"%",
"self",
".",
"_code",
"(",
")",
")",
"handle",
".",
"close",
"(",
")"
] | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Plumber.load | Instanciates (loads) pipeline from a source code file.
Arguments:
- filename(``path``) location of the pipeline source code. | src/papy/core.py | def load(self, filename):
"""
Instanciates (loads) pipeline from a source code file.
Arguments:
- filename(``path``) location of the pipeline source code.
"""
dir_name = os.path.dirname(filename)
mod_name = os.path.basename(filename)... | def load(self, filename):
"""
Instanciates (loads) pipeline from a source code file.
Arguments:
- filename(``path``) location of the pipeline source code.
"""
dir_name = os.path.dirname(filename)
mod_name = os.path.basename(filename)... | [
"Instanciates",
"(",
"loads",
")",
"pipeline",
"from",
"a",
"source",
"code",
"file",
".",
"Arguments",
":",
"-",
"filename",
"(",
"path",
")",
"location",
"of",
"the",
"pipeline",
"source",
"code",
"."
] | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L631-L648 | [
"def",
"load",
"(",
"self",
",",
"filename",
")",
":",
"dir_name",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"filename",
")",
"mod_name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"filename",
")",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Plumber.start | Starts the pipeline by connecting the input ``Pipers`` of the pipeline
to the input data, connecting the pipeline and starting the ``NuMap``
instances.
The order of items in the "datas" argument sequence should correspond
to the order of the input ``Pipers`` defined by ``Dagge... | src/papy/core.py | def start(self, datas):
"""
Starts the pipeline by connecting the input ``Pipers`` of the pipeline
to the input data, connecting the pipeline and starting the ``NuMap``
instances.
The order of items in the "datas" argument sequence should correspond
to the orde... | def start(self, datas):
"""
Starts the pipeline by connecting the input ``Pipers`` of the pipeline
to the input data, connecting the pipeline and starting the ``NuMap``
instances.
The order of items in the "datas" argument sequence should correspond
to the orde... | [
"Starts",
"the",
"pipeline",
"by",
"connecting",
"the",
"input",
"Pipers",
"of",
"the",
"pipeline",
"to",
"the",
"input",
"data",
"connecting",
"the",
"pipeline",
"and",
"starting",
"the",
"NuMap",
"instances",
".",
"The",
"order",
"of",
"items",
"in",
"the"... | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L650-L692 | [
"def",
"start",
"(",
"self",
",",
"datas",
")",
":",
"if",
"not",
"self",
".",
"_started",
".",
"isSet",
"(",
")",
"and",
"not",
"self",
".",
"_running",
".",
"isSet",
"(",
")",
"and",
"not",
"self",
".",
"_pausing",
".",
"isSet",
"(",
")",
":",
... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Plumber.run | Executes a started pipeline by pulling results from it's output
``Pipers``. Processing nodes i.e. ``Pipers`` with the ``track``
attribute set ``True`` will have their returned results stored within
the ``Dagger.stats['pipers_tracked']`` dictionary. A running pipeline
can be paused. | src/papy/core.py | def run(self):
"""
Executes a started pipeline by pulling results from it's output
``Pipers``. Processing nodes i.e. ``Pipers`` with the ``track``
attribute set ``True`` will have their returned results stored within
the ``Dagger.stats['pipers_tracked']`` dictionary. A running... | def run(self):
"""
Executes a started pipeline by pulling results from it's output
``Pipers``. Processing nodes i.e. ``Pipers`` with the ``track``
attribute set ``True`` will have their returned results stored within
the ``Dagger.stats['pipers_tracked']`` dictionary. A running... | [
"Executes",
"a",
"started",
"pipeline",
"by",
"pulling",
"results",
"from",
"it",
"s",
"output",
"Pipers",
".",
"Processing",
"nodes",
"i",
".",
"e",
".",
"Pipers",
"with",
"the",
"track",
"attribute",
"set",
"True",
"will",
"have",
"their",
"returned",
"r... | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L694-L717 | [
"def",
"run",
"(",
"self",
")",
":",
"# remove non-block results for end tasks",
"if",
"self",
".",
"_started",
".",
"isSet",
"(",
")",
"and",
"not",
"self",
".",
"_running",
".",
"isSet",
"(",
")",
"and",
"not",
"self",
".",
"_pausing",
".",
"isSet",
"(... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Plumber.wait | Waits (blocks) until a running pipeline finishes.
Arguments:
- timeout(``int``) [default: ``None``] Specifies the timeout,
``RuntimeError`` will be raised. The default is to wait indefinetely
for the pipeline to finish. | src/papy/core.py | def wait(self, timeout=None):
"""
Waits (blocks) until a running pipeline finishes.
Arguments:
- timeout(``int``) [default: ``None``] Specifies the timeout,
``RuntimeError`` will be raised. The default is to wait indefinetely
for the pipeline ... | def wait(self, timeout=None):
"""
Waits (blocks) until a running pipeline finishes.
Arguments:
- timeout(``int``) [default: ``None``] Specifies the timeout,
``RuntimeError`` will be raised. The default is to wait indefinetely
for the pipeline ... | [
"Waits",
"(",
"blocks",
")",
"until",
"a",
"running",
"pipeline",
"finishes",
".",
"Arguments",
":",
"-",
"timeout",
"(",
"int",
")",
"[",
"default",
":",
"None",
"]",
"Specifies",
"the",
"timeout",
"RuntimeError",
"will",
"be",
"raised",
".",
"The",
"de... | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L719-L735 | [
"def",
"wait",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"self",
".",
"_started",
".",
"isSet",
"(",
")",
"and",
"self",
".",
"_running",
".",
"isSet",
"(",
")",
"and",
"not",
"self",
".",
"_pausing",
".",
"isSet",
"(",
")",
":",
... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Plumber.pause | Pauses a running pipeline. This will stop retrieving results from the
pipeline. Parallel parts of the pipeline will stop after the ``NuMap``
buffer is has been filled. A paused pipeline can be run or stopped. | src/papy/core.py | def pause(self):
"""
Pauses a running pipeline. This will stop retrieving results from the
pipeline. Parallel parts of the pipeline will stop after the ``NuMap``
buffer is has been filled. A paused pipeline can be run or stopped.
"""
# 1. stop the plumbing thr... | def pause(self):
"""
Pauses a running pipeline. This will stop retrieving results from the
pipeline. Parallel parts of the pipeline will stop after the ``NuMap``
buffer is has been filled. A paused pipeline can be run or stopped.
"""
# 1. stop the plumbing thr... | [
"Pauses",
"a",
"running",
"pipeline",
".",
"This",
"will",
"stop",
"retrieving",
"results",
"from",
"the",
"pipeline",
".",
"Parallel",
"parts",
"of",
"the",
"pipeline",
"will",
"stop",
"after",
"the",
"NuMap",
"buffer",
"is",
"has",
"been",
"filled",
".",
... | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L737-L755 | [
"def",
"pause",
"(",
"self",
")",
":",
"# 1. stop the plumbing thread by raising a StopIteration on a stride ",
"# boundary",
"if",
"self",
".",
"_started",
".",
"isSet",
"(",
")",
"and",
"self",
".",
"_running",
".",
"isSet",
"(",
")",
"and",
"not",
"self",
... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Plumber.stop | Stops a paused pipeline. This will a trigger a ``StopIteration`` in the
inputs of the pipeline. And retrieve the buffered results. This will
stop all ``Pipers`` and ``NuMaps``. Python will not terminate cleanly
if a pipeline is running or paused. | src/papy/core.py | def stop(self):
"""
Stops a paused pipeline. This will a trigger a ``StopIteration`` in the
inputs of the pipeline. And retrieve the buffered results. This will
stop all ``Pipers`` and ``NuMaps``. Python will not terminate cleanly
if a pipeline is running or paused.
... | def stop(self):
"""
Stops a paused pipeline. This will a trigger a ``StopIteration`` in the
inputs of the pipeline. And retrieve the buffered results. This will
stop all ``Pipers`` and ``NuMaps``. Python will not terminate cleanly
if a pipeline is running or paused.
... | [
"Stops",
"a",
"paused",
"pipeline",
".",
"This",
"will",
"a",
"trigger",
"a",
"StopIteration",
"in",
"the",
"inputs",
"of",
"the",
"pipeline",
".",
"And",
"retrieve",
"the",
"buffered",
"results",
".",
"This",
"will",
"stop",
"all",
"Pipers",
"and",
"NuMap... | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L757-L775 | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"self",
".",
"_started",
".",
"isSet",
"(",
")",
"and",
"not",
"self",
".",
"_running",
".",
"isSet",
"(",
")",
"and",
"not",
"self",
".",
"_pausing",
".",
"isSet",
"(",
")",
":",
"# stops the dagger",
"s... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Piper.start | Makes the ``Piper`` ready to return results. This involves starting the
the provided ``NuMap`` instance. If multiple ``Pipers`` share a
``NuMap`` instance the order in which these ``Pipers`` are started is
important. The valid order is upstream before downstream. The ``NuMap``
instan... | src/papy/core.py | def start(self, stages=None):
"""
Makes the ``Piper`` ready to return results. This involves starting the
the provided ``NuMap`` instance. If multiple ``Pipers`` share a
``NuMap`` instance the order in which these ``Pipers`` are started is
important. The valid order is upstrea... | def start(self, stages=None):
"""
Makes the ``Piper`` ready to return results. This involves starting the
the provided ``NuMap`` instance. If multiple ``Pipers`` share a
``NuMap`` instance the order in which these ``Pipers`` are started is
important. The valid order is upstrea... | [
"Makes",
"the",
"Piper",
"ready",
"to",
"return",
"results",
".",
"This",
"involves",
"starting",
"the",
"the",
"provided",
"NuMap",
"instance",
".",
"If",
"multiple",
"Pipers",
"share",
"a",
"NuMap",
"instance",
"the",
"order",
"in",
"which",
"these",
"Pipe... | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L925-L974 | [
"def",
"start",
"(",
"self",
",",
"stages",
"=",
"None",
")",
":",
"# defaults differ linear vs. parallel",
"stages",
"=",
"stages",
"or",
"(",
"(",
"0",
",",
")",
"if",
"self",
".",
"imap",
"is",
"imap",
"else",
"(",
"0",
",",
"1",
",",
"2",
")",
... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Piper.connect | Connects the ``Piper`` instance to its upstream ``Pipers`` that should
be given as a sequence. This connects this ``Piper.inbox`` with the
upstream ``Piper.outbox`` respecting any "consume", "spawn" and
"produce" arguments.
Arguments:
- inbox(sequence) seque... | src/papy/core.py | def connect(self, inbox):
"""
Connects the ``Piper`` instance to its upstream ``Pipers`` that should
be given as a sequence. This connects this ``Piper.inbox`` with the
upstream ``Piper.outbox`` respecting any "consume", "spawn" and
"produce" arguments.
Argumen... | def connect(self, inbox):
"""
Connects the ``Piper`` instance to its upstream ``Pipers`` that should
be given as a sequence. This connects this ``Piper.inbox`` with the
upstream ``Piper.outbox`` respecting any "consume", "spawn" and
"produce" arguments.
Argumen... | [
"Connects",
"the",
"Piper",
"instance",
"to",
"its",
"upstream",
"Pipers",
"that",
"should",
"be",
"given",
"as",
"a",
"sequence",
".",
"This",
"connects",
"this",
"Piper",
".",
"inbox",
"with",
"the",
"upstream",
"Piper",
".",
"outbox",
"respecting",
"any",... | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L977-L1052 | [
"def",
"connect",
"(",
"self",
",",
"inbox",
")",
":",
"if",
"self",
".",
"started",
":",
"self",
".",
"log",
".",
"error",
"(",
"'Piper %s is started and cannot connect to %s.'",
"%",
"(",
"self",
",",
"inbox",
")",
")",
"raise",
"PiperError",
"(",
"'Pipe... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Piper.stop | Attempts to cleanly stop the ``Piper`` instance. A ``Piper`` is
"started" if its ``NuMap`` instance is "started". Non-parallel
``Pipers`` do not have to be started or stopped. An ``NuMap`` instance
can be stopped by triggering its stopping procedure and retrieving
results from the ``... | src/papy/core.py | def stop(self, forced=False, **kwargs):
"""
Attempts to cleanly stop the ``Piper`` instance. A ``Piper`` is
"started" if its ``NuMap`` instance is "started". Non-parallel
``Pipers`` do not have to be started or stopped. An ``NuMap`` instance
can be stopped by triggering its st... | def stop(self, forced=False, **kwargs):
"""
Attempts to cleanly stop the ``Piper`` instance. A ``Piper`` is
"started" if its ``NuMap`` instance is "started". Non-parallel
``Pipers`` do not have to be started or stopped. An ``NuMap`` instance
can be stopped by triggering its st... | [
"Attempts",
"to",
"cleanly",
"stop",
"the",
"Piper",
"instance",
".",
"A",
"Piper",
"is",
"started",
"if",
"its",
"NuMap",
"instance",
"is",
"started",
".",
"Non",
"-",
"parallel",
"Pipers",
"do",
"not",
"have",
"to",
"be",
"started",
"or",
"stopped",
".... | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L1054-L1108 | [
"def",
"stop",
"(",
"self",
",",
"forced",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# ends valid only if forced specified.",
"if",
"not",
"self",
".",
"started",
":",
"self",
".",
"log",
".",
"error",
"(",
"'Piper %s has not yet been started.'",
"%",
... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Piper.disconnect | Disconnects the ``Piper`` instance from its upstream ``Pipers`` or
input data if the ``Piper`` is the input node of a pipeline.
Arguments:
- forced(``bool``) [default: ``False``] If ``True`` the ``Piper`` will
try to forcefully remove all tasks (including the spa... | src/papy/core.py | def disconnect(self, forced=False):
"""
Disconnects the ``Piper`` instance from its upstream ``Pipers`` or
input data if the ``Piper`` is the input node of a pipeline.
Arguments:
- forced(``bool``) [default: ``False``] If ``True`` the ``Piper`` will
... | def disconnect(self, forced=False):
"""
Disconnects the ``Piper`` instance from its upstream ``Pipers`` or
input data if the ``Piper`` is the input node of a pipeline.
Arguments:
- forced(``bool``) [default: ``False``] If ``True`` the ``Piper`` will
... | [
"Disconnects",
"the",
"Piper",
"instance",
"from",
"its",
"upstream",
"Pipers",
"or",
"input",
"data",
"if",
"the",
"Piper",
"is",
"the",
"input",
"node",
"of",
"a",
"pipeline",
".",
"Arguments",
":",
"-",
"forced",
"(",
"bool",
")",
"[",
"default",
":",... | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L1111-L1154 | [
"def",
"disconnect",
"(",
"self",
",",
"forced",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"connected",
":",
"self",
".",
"log",
".",
"error",
"(",
"'Piper %s is not connected and cannot be disconnected'",
"%",
"self",
")",
"raise",
"PiperError",
"(",
... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Piper.next | Returns the next result. If no result is availble within the specified
(during construction) "timeout" then a ``PiperError`` which wraps a
``TimeoutError`` is **returned**.
If the result is a ``WorkerError`` it is also wrapped in a
``PiperError`` and is returned or raised if "debug"... | src/papy/core.py | def next(self):
"""
Returns the next result. If no result is availble within the specified
(during construction) "timeout" then a ``PiperError`` which wraps a
``TimeoutError`` is **returned**.
If the result is a ``WorkerError`` it is also wrapped in a
``PiperError`` ... | def next(self):
"""
Returns the next result. If no result is availble within the specified
(during construction) "timeout" then a ``PiperError`` which wraps a
``TimeoutError`` is **returned**.
If the result is a ``WorkerError`` it is also wrapped in a
``PiperError`` ... | [
"Returns",
"the",
"next",
"result",
".",
"If",
"no",
"result",
"is",
"availble",
"within",
"the",
"specified",
"(",
"during",
"construction",
")",
"timeout",
"then",
"a",
"PiperError",
"which",
"wraps",
"a",
"TimeoutError",
"is",
"**",
"returned",
"**",
"."
... | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L1162-L1211 | [
"def",
"next",
"(",
"self",
")",
":",
"try",
":",
"next",
"=",
"self",
".",
"outbox",
".",
"next",
"(",
")",
"except",
"StopIteration",
",",
"excp",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Piper %s has processed all jobs (finished)'",
"%",
"self",
... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | Worker._inject | (internal) inject/replace all functions into a rpyc connection object. | src/papy/core.py | def _inject(self, conn):
"""
(internal) inject/replace all functions into a rpyc connection object.
"""
# provide PAPY_DEFAULTS remotely
# provide PAPY_RUNTIME remotely
if not 'PAPY_INJECTED' in conn.namespace:
_inject_func(get_defaults, conn)
... | def _inject(self, conn):
"""
(internal) inject/replace all functions into a rpyc connection object.
"""
# provide PAPY_DEFAULTS remotely
# provide PAPY_RUNTIME remotely
if not 'PAPY_INJECTED' in conn.namespace:
_inject_func(get_defaults, conn)
... | [
"(",
"internal",
")",
"inject",
"/",
"replace",
"all",
"functions",
"into",
"a",
"rpyc",
"connection",
"object",
"."
] | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L1345-L1373 | [
"def",
"_inject",
"(",
"self",
",",
"conn",
")",
":",
"# provide PAPY_DEFAULTS remotely",
"# provide PAPY_RUNTIME remotely",
"if",
"not",
"'PAPY_INJECTED'",
"in",
"conn",
".",
"namespace",
":",
"_inject_func",
"(",
"get_defaults",
",",
"conn",
")",
"_inject_func",
"... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | _Consume.next | Returns the next sequence of results, given stride and n. | src/papy/core.py | def next(self):
"""
Returns the next sequence of results, given stride and n.
"""
try:
results = self._stride_buffer.pop()
except (IndexError, AttributeError):
self._rebuffer()
results = self._stride_buffer.pop()
if not results... | def next(self):
"""
Returns the next sequence of results, given stride and n.
"""
try:
results = self._stride_buffer.pop()
except (IndexError, AttributeError):
self._rebuffer()
results = self._stride_buffer.pop()
if not results... | [
"Returns",
"the",
"next",
"sequence",
"of",
"results",
"given",
"stride",
"and",
"n",
"."
] | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L1490-L1502 | [
"def",
"next",
"(",
"self",
")",
":",
"try",
":",
"results",
"=",
"self",
".",
"_stride_buffer",
".",
"pop",
"(",
")",
"except",
"(",
"IndexError",
",",
"AttributeError",
")",
":",
"self",
".",
"_rebuffer",
"(",
")",
"results",
"=",
"self",
".",
"_st... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | _Chain.next | Returns the next result from the chained iterables given ``"stride"``. | src/papy/core.py | def next(self):
"""
Returns the next result from the chained iterables given ``"stride"``.
"""
if self.s:
self.s -= 1
else:
self.s = self.stride - 1
self.i = (self.i + 1) % self.l # new iterable
return self.iterables[self.i].ne... | def next(self):
"""
Returns the next result from the chained iterables given ``"stride"``.
"""
if self.s:
self.s -= 1
else:
self.s = self.stride - 1
self.i = (self.i + 1) % self.l # new iterable
return self.iterables[self.i].ne... | [
"Returns",
"the",
"next",
"result",
"from",
"the",
"chained",
"iterables",
"given",
"stride",
"."
] | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L1557-L1567 | [
"def",
"next",
"(",
"self",
")",
":",
"if",
"self",
".",
"s",
":",
"self",
".",
"s",
"-=",
"1",
"else",
":",
"self",
".",
"s",
"=",
"self",
".",
"stride",
"-",
"1",
"self",
".",
"i",
"=",
"(",
"self",
".",
"i",
"+",
"1",
")",
"%",
"self",... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | _Repeat._rebuffer | (very internal) refill the repeat buffer | src/papy/core.py | def _rebuffer(self):
"""
(very internal) refill the repeat buffer
"""
results = []
exceptions = []
for i in xrange(self.stride):
try:
results.append(self.iterable.next())
exceptions.append(False)
except Exception, ex... | def _rebuffer(self):
"""
(very internal) refill the repeat buffer
"""
results = []
exceptions = []
for i in xrange(self.stride):
try:
results.append(self.iterable.next())
exceptions.append(False)
except Exception, ex... | [
"(",
"very",
"internal",
")",
"refill",
"the",
"repeat",
"buffer"
] | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L1591-L1604 | [
"def",
"_rebuffer",
"(",
"self",
")",
":",
"results",
"=",
"[",
"]",
"exceptions",
"=",
"[",
"]",
"for",
"i",
"in",
"xrange",
"(",
"self",
".",
"stride",
")",
":",
"try",
":",
"results",
".",
"append",
"(",
"self",
".",
"iterable",
".",
"next",
"... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | _Repeat.next | (very internal) returns the next result, given ``"stride"`` and ``"n"``. | src/papy/core.py | def next(self):
"""
(very internal) returns the next result, given ``"stride"`` and ``"n"``.
"""
try:
res, excp = self._stride_buffer.next()
except (StopIteration, AttributeError):
try:
self._stride_buffer = izip(*self._repeat_buff... | def next(self):
"""
(very internal) returns the next result, given ``"stride"`` and ``"n"``.
"""
try:
res, excp = self._stride_buffer.next()
except (StopIteration, AttributeError):
try:
self._stride_buffer = izip(*self._repeat_buff... | [
"(",
"very",
"internal",
")",
"returns",
"the",
"next",
"result",
"given",
"stride",
"and",
"n",
"."
] | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L1606-L1623 | [
"def",
"next",
"(",
"self",
")",
":",
"try",
":",
"res",
",",
"excp",
"=",
"self",
".",
"_stride_buffer",
".",
"next",
"(",
")",
"except",
"(",
"StopIteration",
",",
"AttributeError",
")",
":",
"try",
":",
"self",
".",
"_stride_buffer",
"=",
"izip",
... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | _Produce._rebuffer | (internal) refill the repeat buffer | src/papy/core.py | def _rebuffer(self):
"""
(internal) refill the repeat buffer
"""
# collect a stride worth of results(result lists) or exceptions
results = []
exceptions = []
for i in xrange(self.stride):
try:
results.append(self.iterable.next(... | def _rebuffer(self):
"""
(internal) refill the repeat buffer
"""
# collect a stride worth of results(result lists) or exceptions
results = []
exceptions = []
for i in xrange(self.stride):
try:
results.append(self.iterable.next(... | [
"(",
"internal",
")",
"refill",
"the",
"repeat",
"buffer"
] | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L1639-L1666 | [
"def",
"_rebuffer",
"(",
"self",
")",
":",
"# collect a stride worth of results(result lists) or exceptions",
"results",
"=",
"[",
"]",
"exceptions",
"=",
"[",
"]",
"for",
"i",
"in",
"xrange",
"(",
"self",
".",
"stride",
")",
":",
"try",
":",
"results",
".",
... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | _InputIterator.next | (internal) returns the next result from the iterator if the piper is
started. | src/papy/core.py | def next(self):
"""
(internal) returns the next result from the iterator if the piper is
started.
"""
if self.piper.imap is imap and \
self.piper.started is False:
raise StopIteration
else:
return self.iterator.next() | def next(self):
"""
(internal) returns the next result from the iterator if the piper is
started.
"""
if self.piper.imap is imap and \
self.piper.started is False:
raise StopIteration
else:
return self.iterator.next() | [
"(",
"internal",
")",
"returns",
"the",
"next",
"result",
"from",
"the",
"iterator",
"if",
"the",
"piper",
"is",
"started",
"."
] | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L1681-L1691 | [
"def",
"next",
"(",
"self",
")",
":",
"if",
"self",
".",
"piper",
".",
"imap",
"is",
"imap",
"and",
"self",
".",
"piper",
".",
"started",
"is",
"False",
":",
"raise",
"StopIteration",
"else",
":",
"return",
"self",
".",
"iterator",
".",
"next",
"(",
... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | _TeePiper.next | (internal) returns the next result from the ``itertools.tee`` object for
the wrapped ``Piper`` instance or re-raises an ``Exception``. | src/papy/core.py | def next(self):
"""
(internal) returns the next result from the ``itertools.tee`` object for
the wrapped ``Piper`` instance or re-raises an ``Exception``.
"""
# do not acquire lock if NuMap is not finished.
if self.finished:
raise StopIteration
... | def next(self):
"""
(internal) returns the next result from the ``itertools.tee`` object for
the wrapped ``Piper`` instance or re-raises an ``Exception``.
"""
# do not acquire lock if NuMap is not finished.
if self.finished:
raise StopIteration
... | [
"(",
"internal",
")",
"returns",
"the",
"next",
"result",
"from",
"the",
"itertools",
".",
"tee",
"object",
"for",
"the",
"wrapped",
"Piper",
"instance",
"or",
"re",
"-",
"raises",
"an",
"Exception",
"."
] | mcieslik-mctp/papy | python | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L1728-L1759 | [
"def",
"next",
"(",
"self",
")",
":",
"# do not acquire lock if NuMap is not finished.",
"if",
"self",
".",
"finished",
":",
"raise",
"StopIteration",
"# get per-tee lock",
"self",
".",
"piper",
".",
"tee_locks",
"[",
"self",
".",
"i",
"]",
".",
"acquire",
"(",
... | 708e50827b5db46bbea081982cb74b9b0e464064 |
train | ResultsService.list_csv | Get a list of results as CSV.
:param filter: (optional) Filters to apply as a string list.
:param type: (optional) `union` or `inter` as string.
:param sort: (optional) Sort fields to apply as string list.
:param limit: (optional) Limit returned list length.
:param page: (option... | cdrouter/results.py | def list_csv(self, filter=None, type=None, sort=None, limit=None, page=None): # pylint: disable=redefined-builtin
"""Get a list of results as CSV.
:param filter: (optional) Filters to apply as a string list.
:param type: (optional) `union` or `inter` as string.
:param sort: (optional) S... | def list_csv(self, filter=None, type=None, sort=None, limit=None, page=None): # pylint: disable=redefined-builtin
"""Get a list of results as CSV.
:param filter: (optional) Filters to apply as a string list.
:param type: (optional) `union` or `inter` as string.
:param sort: (optional) S... | [
"Get",
"a",
"list",
"of",
"results",
"as",
"CSV",
"."
] | qacafe/cdrouter.py | python | https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L600-L610 | [
"def",
"list_csv",
"(",
"self",
",",
"filter",
"=",
"None",
",",
"type",
"=",
"None",
",",
"sort",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"page",
"=",
"None",
")",
":",
"# pylint: disable=redefined-builtin",
"return",
"self",
".",
"service",
".",
... | aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5 |
train | ResultsService.updates | Get updates of a running result via long-polling. If no updates are available, CDRouter waits up to 10 seconds before sending an empty response.
:param id: Result ID as an int.
:param update_id: (optional) Update ID as an int.
:return: :class:`results.Update <results.Update>` object
:r... | cdrouter/results.py | def updates(self, id, update_id=None): # pylint: disable=invalid-name,redefined-builtin
"""Get updates of a running result via long-polling. If no updates are available, CDRouter waits up to 10 seconds before sending an empty response.
:param id: Result ID as an int.
:param update_id: (optiona... | def updates(self, id, update_id=None): # pylint: disable=invalid-name,redefined-builtin
"""Get updates of a running result via long-polling. If no updates are available, CDRouter waits up to 10 seconds before sending an empty response.
:param id: Result ID as an int.
:param update_id: (optiona... | [
"Get",
"updates",
"of",
"a",
"running",
"result",
"via",
"long",
"-",
"polling",
".",
"If",
"no",
"updates",
"are",
"available",
"CDRouter",
"waits",
"up",
"to",
"10",
"seconds",
"before",
"sending",
"an",
"empty",
"response",
"."
] | qacafe/cdrouter.py | python | https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L623-L636 | [
"def",
"updates",
"(",
"self",
",",
"id",
",",
"update_id",
"=",
"None",
")",
":",
"# pylint: disable=invalid-name,redefined-builtin",
"if",
"update_id",
"is",
"None",
":",
"update_id",
"=",
"-",
"1",
"schema",
"=",
"UpdateSchema",
"(",
")",
"resp",
"=",
"se... | aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5 |
train | ResultsService.pause | Pause a running result.
:param id: Result ID as an int.
:param when: Must be string `end-of-test` or `end-of-loop`. | cdrouter/results.py | def pause(self, id, when=None): # pylint: disable=invalid-name,redefined-builtin
"""Pause a running result.
:param id: Result ID as an int.
:param when: Must be string `end-of-test` or `end-of-loop`.
"""
return self.service.post(self.base+str(id)+'/pause/', params={'when': when}... | def pause(self, id, when=None): # pylint: disable=invalid-name,redefined-builtin
"""Pause a running result.
:param id: Result ID as an int.
:param when: Must be string `end-of-test` or `end-of-loop`.
"""
return self.service.post(self.base+str(id)+'/pause/', params={'when': when}... | [
"Pause",
"a",
"running",
"result",
"."
] | qacafe/cdrouter.py | python | https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L660-L666 | [
"def",
"pause",
"(",
"self",
",",
"id",
",",
"when",
"=",
"None",
")",
":",
"# pylint: disable=invalid-name,redefined-builtin",
"return",
"self",
".",
"service",
".",
"post",
"(",
"self",
".",
"base",
"+",
"str",
"(",
"id",
")",
"+",
"'/pause/'",
",",
"p... | aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5 |
train | ResultsService.unpause | Unpause a running result.
:param id: Result ID as an int. | cdrouter/results.py | def unpause(self, id): # pylint: disable=invalid-name,redefined-builtin
"""Unpause a running result.
:param id: Result ID as an int.
"""
return self.service.post(self.base+str(id)+'/unpause/') | def unpause(self, id): # pylint: disable=invalid-name,redefined-builtin
"""Unpause a running result.
:param id: Result ID as an int.
"""
return self.service.post(self.base+str(id)+'/unpause/') | [
"Unpause",
"a",
"running",
"result",
"."
] | qacafe/cdrouter.py | python | https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L682-L687 | [
"def",
"unpause",
"(",
"self",
",",
"id",
")",
":",
"# pylint: disable=invalid-name,redefined-builtin",
"return",
"self",
".",
"service",
".",
"post",
"(",
"self",
".",
"base",
"+",
"str",
"(",
"id",
")",
"+",
"'/unpause/'",
")"
] | aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5 |
train | ResultsService.export | Export a result.
:param id: Result ID as an int.
:param exclude_captures: If bool `True`, don't export capture files
:rtype: tuple `(io.BytesIO, 'filename')` | cdrouter/results.py | def export(self, id, exclude_captures=False): # pylint: disable=invalid-name,redefined-builtin
"""Export a result.
:param id: Result ID as an int.
:param exclude_captures: If bool `True`, don't export capture files
:rtype: tuple `(io.BytesIO, 'filename')`
"""
return self... | def export(self, id, exclude_captures=False): # pylint: disable=invalid-name,redefined-builtin
"""Export a result.
:param id: Result ID as an int.
:param exclude_captures: If bool `True`, don't export capture files
:rtype: tuple `(io.BytesIO, 'filename')`
"""
return self... | [
"Export",
"a",
"result",
"."
] | qacafe/cdrouter.py | python | https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L727-L734 | [
"def",
"export",
"(",
"self",
",",
"id",
",",
"exclude_captures",
"=",
"False",
")",
":",
"# pylint: disable=invalid-name,redefined-builtin",
"return",
"self",
".",
"service",
".",
"export",
"(",
"self",
".",
"base",
",",
"id",
",",
"params",
"=",
"{",
"'exc... | aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5 |
train | ResultsService.bulk_export | Bulk export a set of results.
:param ids: Int list of result IDs.
:rtype: tuple `(io.BytesIO, 'filename')` | cdrouter/results.py | def bulk_export(self, ids, exclude_captures=False):
"""Bulk export a set of results.
:param ids: Int list of result IDs.
:rtype: tuple `(io.BytesIO, 'filename')`
"""
return self.service.bulk_export(self.base, ids, params={'exclude_captures': exclude_captures}) | def bulk_export(self, ids, exclude_captures=False):
"""Bulk export a set of results.
:param ids: Int list of result IDs.
:rtype: tuple `(io.BytesIO, 'filename')`
"""
return self.service.bulk_export(self.base, ids, params={'exclude_captures': exclude_captures}) | [
"Bulk",
"export",
"a",
"set",
"of",
"results",
"."
] | qacafe/cdrouter.py | python | https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L736-L742 | [
"def",
"bulk_export",
"(",
"self",
",",
"ids",
",",
"exclude_captures",
"=",
"False",
")",
":",
"return",
"self",
".",
"service",
".",
"bulk_export",
"(",
"self",
".",
"base",
",",
"ids",
",",
"params",
"=",
"{",
"'exclude_captures'",
":",
"exclude_capture... | aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5 |
train | ResultsService.bulk_copy | Bulk copy a set of results.
:param ids: Int list of result IDs.
:return: :class:`results.Result <results.Result>` list | cdrouter/results.py | def bulk_copy(self, ids):
"""Bulk copy a set of results.
:param ids: Int list of result IDs.
:return: :class:`results.Result <results.Result>` list
"""
schema = ResultSchema()
return self.service.bulk_copy(self.base, self.RESOURCE, ids, schema) | def bulk_copy(self, ids):
"""Bulk copy a set of results.
:param ids: Int list of result IDs.
:return: :class:`results.Result <results.Result>` list
"""
schema = ResultSchema()
return self.service.bulk_copy(self.base, self.RESOURCE, ids, schema) | [
"Bulk",
"copy",
"a",
"set",
"of",
"results",
"."
] | qacafe/cdrouter.py | python | https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L744-L751 | [
"def",
"bulk_copy",
"(",
"self",
",",
"ids",
")",
":",
"schema",
"=",
"ResultSchema",
"(",
")",
"return",
"self",
".",
"service",
".",
"bulk_copy",
"(",
"self",
".",
"base",
",",
"self",
".",
"RESOURCE",
",",
"ids",
",",
"schema",
")"
] | aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5 |
train | ResultsService.all_stats | Compute stats for all results.
:return: :class:`results.AllStats <results.AllStats>` object
:rtype: results.AllStats | cdrouter/results.py | def all_stats(self):
"""Compute stats for all results.
:return: :class:`results.AllStats <results.AllStats>` object
:rtype: results.AllStats
"""
schema = AllStatsSchema()
resp = self.service.post(self.base, params={'stats': 'all'})
return self.service.decode(sche... | def all_stats(self):
"""Compute stats for all results.
:return: :class:`results.AllStats <results.AllStats>` object
:rtype: results.AllStats
"""
schema = AllStatsSchema()
resp = self.service.post(self.base, params={'stats': 'all'})
return self.service.decode(sche... | [
"Compute",
"stats",
"for",
"all",
"results",
"."
] | qacafe/cdrouter.py | python | https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L776-L784 | [
"def",
"all_stats",
"(",
"self",
")",
":",
"schema",
"=",
"AllStatsSchema",
"(",
")",
"resp",
"=",
"self",
".",
"service",
".",
"post",
"(",
"self",
".",
"base",
",",
"params",
"=",
"{",
"'stats'",
":",
"'all'",
"}",
")",
"return",
"self",
".",
"se... | aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5 |
train | ResultsService.set_stats | Compute stats for a set of results.
:param id: Result IDs as int list.
:return: :class:`results.SetStats <results.SetStats>` object
:rtype: results.SetStats | cdrouter/results.py | def set_stats(self, ids):
"""Compute stats for a set of results.
:param id: Result IDs as int list.
:return: :class:`results.SetStats <results.SetStats>` object
:rtype: results.SetStats
"""
schema = SetStatsSchema()
resp = self.service.post(self.base, params={'st... | def set_stats(self, ids):
"""Compute stats for a set of results.
:param id: Result IDs as int list.
:return: :class:`results.SetStats <results.SetStats>` object
:rtype: results.SetStats
"""
schema = SetStatsSchema()
resp = self.service.post(self.base, params={'st... | [
"Compute",
"stats",
"for",
"a",
"set",
"of",
"results",
"."
] | qacafe/cdrouter.py | python | https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L786-L795 | [
"def",
"set_stats",
"(",
"self",
",",
"ids",
")",
":",
"schema",
"=",
"SetStatsSchema",
"(",
")",
"resp",
"=",
"self",
".",
"service",
".",
"post",
"(",
"self",
".",
"base",
",",
"params",
"=",
"{",
"'stats'",
":",
"'set'",
"}",
",",
"json",
"=",
... | aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5 |
train | ResultsService.diff_stats | Compute diff stats for a set of results.
:param id: Result IDs as int list.
:return: :class:`results.DiffStats <results.DiffStats>` object
:rtype: results.DiffStats | cdrouter/results.py | def diff_stats(self, ids):
"""Compute diff stats for a set of results.
:param id: Result IDs as int list.
:return: :class:`results.DiffStats <results.DiffStats>` object
:rtype: results.DiffStats
"""
schema = DiffStatsSchema()
resp = self.service.post(self.base, p... | def diff_stats(self, ids):
"""Compute diff stats for a set of results.
:param id: Result IDs as int list.
:return: :class:`results.DiffStats <results.DiffStats>` object
:rtype: results.DiffStats
"""
schema = DiffStatsSchema()
resp = self.service.post(self.base, p... | [
"Compute",
"diff",
"stats",
"for",
"a",
"set",
"of",
"results",
"."
] | qacafe/cdrouter.py | python | https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L797-L806 | [
"def",
"diff_stats",
"(",
"self",
",",
"ids",
")",
":",
"schema",
"=",
"DiffStatsSchema",
"(",
")",
"resp",
"=",
"self",
".",
"service",
".",
"post",
"(",
"self",
".",
"base",
",",
"params",
"=",
"{",
"'stats'",
":",
"'diff'",
"}",
",",
"json",
"="... | aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5 |
train | ResultsService.single_stats | Compute stats for a result.
:param id: Result ID as an int.
:return: :class:`results.SingleStats <results.SingleStats>` object
:rtype: results.SingleStats | cdrouter/results.py | def single_stats(self, id): # pylint: disable=invalid-name,redefined-builtin
"""Compute stats for a result.
:param id: Result ID as an int.
:return: :class:`results.SingleStats <results.SingleStats>` object
:rtype: results.SingleStats
"""
schema = SingleStatsSchema()
... | def single_stats(self, id): # pylint: disable=invalid-name,redefined-builtin
"""Compute stats for a result.
:param id: Result ID as an int.
:return: :class:`results.SingleStats <results.SingleStats>` object
:rtype: results.SingleStats
"""
schema = SingleStatsSchema()
... | [
"Compute",
"stats",
"for",
"a",
"result",
"."
] | qacafe/cdrouter.py | python | https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L808-L817 | [
"def",
"single_stats",
"(",
"self",
",",
"id",
")",
":",
"# pylint: disable=invalid-name,redefined-builtin",
"schema",
"=",
"SingleStatsSchema",
"(",
")",
"resp",
"=",
"self",
".",
"service",
".",
"get",
"(",
"self",
".",
"base",
"+",
"str",
"(",
"id",
")",
... | aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5 |
train | ResultsService.progress_stats | Compute progress stats for a result.
:param id: Result ID as an int.
:return: :class:`results.Progress <results.Progress>` object
:rtype: results.Progress | cdrouter/results.py | def progress_stats(self, id): # pylint: disable=invalid-name,redefined-builtin
"""Compute progress stats for a result.
:param id: Result ID as an int.
:return: :class:`results.Progress <results.Progress>` object
:rtype: results.Progress
"""
schema = ProgressSchema()
... | def progress_stats(self, id): # pylint: disable=invalid-name,redefined-builtin
"""Compute progress stats for a result.
:param id: Result ID as an int.
:return: :class:`results.Progress <results.Progress>` object
:rtype: results.Progress
"""
schema = ProgressSchema()
... | [
"Compute",
"progress",
"stats",
"for",
"a",
"result",
"."
] | qacafe/cdrouter.py | python | https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L819-L828 | [
"def",
"progress_stats",
"(",
"self",
",",
"id",
")",
":",
"# pylint: disable=invalid-name,redefined-builtin",
"schema",
"=",
"ProgressSchema",
"(",
")",
"resp",
"=",
"self",
".",
"service",
".",
"get",
"(",
"self",
".",
"base",
"+",
"str",
"(",
"id",
")",
... | aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5 |
train | ResultsService.summary_stats | Compute summary stats for a result.
:param id: Result ID as an int.
:return: :class:`results.SummaryStats <results.SummaryStats>` object
:rtype: results.SummaryStats | cdrouter/results.py | def summary_stats(self, id): # pylint: disable=invalid-name,redefined-builtin
"""Compute summary stats for a result.
:param id: Result ID as an int.
:return: :class:`results.SummaryStats <results.SummaryStats>` object
:rtype: results.SummaryStats
"""
schema = SummaryStat... | def summary_stats(self, id): # pylint: disable=invalid-name,redefined-builtin
"""Compute summary stats for a result.
:param id: Result ID as an int.
:return: :class:`results.SummaryStats <results.SummaryStats>` object
:rtype: results.SummaryStats
"""
schema = SummaryStat... | [
"Compute",
"summary",
"stats",
"for",
"a",
"result",
"."
] | qacafe/cdrouter.py | python | https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L830-L839 | [
"def",
"summary_stats",
"(",
"self",
",",
"id",
")",
":",
"# pylint: disable=invalid-name,redefined-builtin",
"schema",
"=",
"SummaryStatsSchema",
"(",
")",
"resp",
"=",
"self",
".",
"service",
".",
"get",
"(",
"self",
".",
"base",
"+",
"str",
"(",
"id",
")"... | aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5 |
train | ResultsService.list_logdir | Get a list of logdir files.
:param id: Result ID as an int.
:param filter: Filter to apply as string.
:param sort: Sort field to apply as string.
:return: :class:`results.LogDirFile <results.LogDirFile>` list | cdrouter/results.py | def list_logdir(self, id, filter=None, sort=None): # pylint: disable=invalid-name,redefined-builtin
"""Get a list of logdir files.
:param id: Result ID as an int.
:param filter: Filter to apply as string.
:param sort: Sort field to apply as string.
:return: :class:`results.LogDi... | def list_logdir(self, id, filter=None, sort=None): # pylint: disable=invalid-name,redefined-builtin
"""Get a list of logdir files.
:param id: Result ID as an int.
:param filter: Filter to apply as string.
:param sort: Sort field to apply as string.
:return: :class:`results.LogDi... | [
"Get",
"a",
"list",
"of",
"logdir",
"files",
"."
] | qacafe/cdrouter.py | python | https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L841-L851 | [
"def",
"list_logdir",
"(",
"self",
",",
"id",
",",
"filter",
"=",
"None",
",",
"sort",
"=",
"None",
")",
":",
"# pylint: disable=invalid-name,redefined-builtin",
"schema",
"=",
"LogDirFileSchema",
"(",
")",
"resp",
"=",
"self",
".",
"service",
".",
"list",
"... | aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5 |
train | ResultsService.get_logdir_file | Download a logdir file.
:param id: Result ID as an int.
:param filename: Logdir filename as string.
:rtype: tuple `(io.BytesIO, 'filename')` | cdrouter/results.py | def get_logdir_file(self, id, filename): # pylint: disable=invalid-name,redefined-builtin
"""Download a logdir file.
:param id: Result ID as an int.
:param filename: Logdir filename as string.
:rtype: tuple `(io.BytesIO, 'filename')`
"""
resp = self.service.get(self.base... | def get_logdir_file(self, id, filename): # pylint: disable=invalid-name,redefined-builtin
"""Download a logdir file.
:param id: Result ID as an int.
:param filename: Logdir filename as string.
:rtype: tuple `(io.BytesIO, 'filename')`
"""
resp = self.service.get(self.base... | [
"Download",
"a",
"logdir",
"file",
"."
] | qacafe/cdrouter.py | python | https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L853-L865 | [
"def",
"get_logdir_file",
"(",
"self",
",",
"id",
",",
"filename",
")",
":",
"# pylint: disable=invalid-name,redefined-builtin",
"resp",
"=",
"self",
".",
"service",
".",
"get",
"(",
"self",
".",
"base",
"+",
"str",
"(",
"id",
")",
"+",
"'/logdir/'",
"+",
... | aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5 |
train | ResultsService.download_logdir_archive | Download logdir archive in tgz or zip format.
:param id: Result ID as an int.
:param format: (optional) Format to download, must be string `zip` or `tgz`.
:param exclude_captures: If bool `True`, don't include capture files
:rtype: tuple `(io.BytesIO, 'filename')` | cdrouter/results.py | def download_logdir_archive(self, id, format='zip', exclude_captures=False): # pylint: disable=invalid-name,redefined-builtin
"""Download logdir archive in tgz or zip format.
:param id: Result ID as an int.
:param format: (optional) Format to download, must be string `zip` or `tgz`.
:pa... | def download_logdir_archive(self, id, format='zip', exclude_captures=False): # pylint: disable=invalid-name,redefined-builtin
"""Download logdir archive in tgz or zip format.
:param id: Result ID as an int.
:param format: (optional) Format to download, must be string `zip` or `tgz`.
:pa... | [
"Download",
"logdir",
"archive",
"in",
"tgz",
"or",
"zip",
"format",
"."
] | qacafe/cdrouter.py | python | https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/results.py#L867-L880 | [
"def",
"download_logdir_archive",
"(",
"self",
",",
"id",
",",
"format",
"=",
"'zip'",
",",
"exclude_captures",
"=",
"False",
")",
":",
"# pylint: disable=invalid-name,redefined-builtin",
"resp",
"=",
"self",
".",
"service",
".",
"get",
"(",
"self",
".",
"base",... | aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5 |
train | logout | CERN logout view. | invenio_oauthclient/contrib/cern.py | def logout():
"""CERN logout view."""
logout_url = REMOTE_APP['logout_url']
apps = current_app.config.get('OAUTHCLIENT_REMOTE_APPS')
if apps:
cern_app = apps.get('cern', REMOTE_APP)
logout_url = cern_app['logout_url']
return redirect(logout_url, code=302) | def logout():
"""CERN logout view."""
logout_url = REMOTE_APP['logout_url']
apps = current_app.config.get('OAUTHCLIENT_REMOTE_APPS')
if apps:
cern_app = apps.get('cern', REMOTE_APP)
logout_url = cern_app['logout_url']
return redirect(logout_url, code=302) | [
"CERN",
"logout",
"view",
"."
] | inveniosoftware/invenio-oauthclient | python | https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/cern.py#L178-L187 | [
"def",
"logout",
"(",
")",
":",
"logout_url",
"=",
"REMOTE_APP",
"[",
"'logout_url'",
"]",
"apps",
"=",
"current_app",
".",
"config",
".",
"get",
"(",
"'OAUTHCLIENT_REMOTE_APPS'",
")",
"if",
"apps",
":",
"cern_app",
"=",
"apps",
".",
"get",
"(",
"'cern'",
... | 2500dc6935738107617aeade79e050d7608004bb |
train | find_remote_by_client_id | Return a remote application based with given client ID. | invenio_oauthclient/contrib/cern.py | def find_remote_by_client_id(client_id):
"""Return a remote application based with given client ID."""
for remote in current_oauthclient.oauth.remote_apps.values():
if remote.name == 'cern' and remote.consumer_key == client_id:
return remote | def find_remote_by_client_id(client_id):
"""Return a remote application based with given client ID."""
for remote in current_oauthclient.oauth.remote_apps.values():
if remote.name == 'cern' and remote.consumer_key == client_id:
return remote | [
"Return",
"a",
"remote",
"application",
"based",
"with",
"given",
"client",
"ID",
"."
] | inveniosoftware/invenio-oauthclient | python | https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/cern.py#L190-L194 | [
"def",
"find_remote_by_client_id",
"(",
"client_id",
")",
":",
"for",
"remote",
"in",
"current_oauthclient",
".",
"oauth",
".",
"remote_apps",
".",
"values",
"(",
")",
":",
"if",
"remote",
".",
"name",
"==",
"'cern'",
"and",
"remote",
".",
"consumer_key",
"=... | 2500dc6935738107617aeade79e050d7608004bb |
train | fetch_groups | Prepare list of allowed group names.
:param groups: The complete list of groups.
:returns: A filtered list of groups. | invenio_oauthclient/contrib/cern.py | def fetch_groups(groups):
"""Prepare list of allowed group names.
:param groups: The complete list of groups.
:returns: A filtered list of groups.
"""
hidden_groups = current_app.config.get(
'OAUTHCLIENT_CERN_HIDDEN_GROUPS', OAUTHCLIENT_CERN_HIDDEN_GROUPS)
hidden_groups_re = current_app... | def fetch_groups(groups):
"""Prepare list of allowed group names.
:param groups: The complete list of groups.
:returns: A filtered list of groups.
"""
hidden_groups = current_app.config.get(
'OAUTHCLIENT_CERN_HIDDEN_GROUPS', OAUTHCLIENT_CERN_HIDDEN_GROUPS)
hidden_groups_re = current_app... | [
"Prepare",
"list",
"of",
"allowed",
"group",
"names",
"."
] | inveniosoftware/invenio-oauthclient | python | https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/cern.py#L197-L216 | [
"def",
"fetch_groups",
"(",
"groups",
")",
":",
"hidden_groups",
"=",
"current_app",
".",
"config",
".",
"get",
"(",
"'OAUTHCLIENT_CERN_HIDDEN_GROUPS'",
",",
"OAUTHCLIENT_CERN_HIDDEN_GROUPS",
")",
"hidden_groups_re",
"=",
"current_app",
".",
"config",
".",
"get",
"(... | 2500dc6935738107617aeade79e050d7608004bb |
train | fetch_extra_data | Return a dict with extra data retrieved from cern oauth. | invenio_oauthclient/contrib/cern.py | def fetch_extra_data(resource):
"""Return a dict with extra data retrieved from cern oauth."""
person_id = resource.get('PersonID', [None])[0]
identity_class = resource.get('IdentityClass', [None])[0]
department = resource.get('Department', [None])[0]
return dict(
person_id=person_id,
... | def fetch_extra_data(resource):
"""Return a dict with extra data retrieved from cern oauth."""
person_id = resource.get('PersonID', [None])[0]
identity_class = resource.get('IdentityClass', [None])[0]
department = resource.get('Department', [None])[0]
return dict(
person_id=person_id,
... | [
"Return",
"a",
"dict",
"with",
"extra",
"data",
"retrieved",
"from",
"cern",
"oauth",
"."
] | inveniosoftware/invenio-oauthclient | python | https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/cern.py#L219-L229 | [
"def",
"fetch_extra_data",
"(",
"resource",
")",
":",
"person_id",
"=",
"resource",
".",
"get",
"(",
"'PersonID'",
",",
"[",
"None",
"]",
")",
"[",
"0",
"]",
"identity_class",
"=",
"resource",
".",
"get",
"(",
"'IdentityClass'",
",",
"[",
"None",
"]",
... | 2500dc6935738107617aeade79e050d7608004bb |
train | account_groups_and_extra_data | Fetch account groups and extra data from resource if necessary. | invenio_oauthclient/contrib/cern.py | def account_groups_and_extra_data(account, resource,
refresh_timedelta=None):
"""Fetch account groups and extra data from resource if necessary."""
updated = datetime.utcnow()
modified_since = updated
if refresh_timedelta is not None:
modified_since += refresh_t... | def account_groups_and_extra_data(account, resource,
refresh_timedelta=None):
"""Fetch account groups and extra data from resource if necessary."""
updated = datetime.utcnow()
modified_since = updated
if refresh_timedelta is not None:
modified_since += refresh_t... | [
"Fetch",
"account",
"groups",
"and",
"extra",
"data",
"from",
"resource",
"if",
"necessary",
"."
] | inveniosoftware/invenio-oauthclient | python | https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/cern.py#L232-L256 | [
"def",
"account_groups_and_extra_data",
"(",
"account",
",",
"resource",
",",
"refresh_timedelta",
"=",
"None",
")",
":",
"updated",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"modified_since",
"=",
"updated",
"if",
"refresh_timedelta",
"is",
"not",
"None",
":",
... | 2500dc6935738107617aeade79e050d7608004bb |
train | extend_identity | Extend identity with roles based on CERN groups. | invenio_oauthclient/contrib/cern.py | def extend_identity(identity, groups):
"""Extend identity with roles based on CERN groups."""
provides = set([UserNeed(current_user.email)] + [
RoleNeed('{0}@cern.ch'.format(name)) for name in groups
])
identity.provides |= provides
session[OAUTHCLIENT_CERN_SESSION_KEY] = provides | def extend_identity(identity, groups):
"""Extend identity with roles based on CERN groups."""
provides = set([UserNeed(current_user.email)] + [
RoleNeed('{0}@cern.ch'.format(name)) for name in groups
])
identity.provides |= provides
session[OAUTHCLIENT_CERN_SESSION_KEY] = provides | [
"Extend",
"identity",
"with",
"roles",
"based",
"on",
"CERN",
"groups",
"."
] | inveniosoftware/invenio-oauthclient | python | https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/cern.py#L259-L265 | [
"def",
"extend_identity",
"(",
"identity",
",",
"groups",
")",
":",
"provides",
"=",
"set",
"(",
"[",
"UserNeed",
"(",
"current_user",
".",
"email",
")",
"]",
"+",
"[",
"RoleNeed",
"(",
"'{0}@cern.ch'",
".",
"format",
"(",
"name",
")",
")",
"for",
"nam... | 2500dc6935738107617aeade79e050d7608004bb |
train | get_dict_from_response | Prepare new mapping with 'Value's groupped by 'Type'. | invenio_oauthclient/contrib/cern.py | def get_dict_from_response(response):
"""Prepare new mapping with 'Value's groupped by 'Type'."""
result = {}
if getattr(response, '_resp') and response._resp.code > 400:
return result
for i in response.data:
# strip the schema from the key
k = i['Type'].replace(REMOTE_APP_RESOU... | def get_dict_from_response(response):
"""Prepare new mapping with 'Value's groupped by 'Type'."""
result = {}
if getattr(response, '_resp') and response._resp.code > 400:
return result
for i in response.data:
# strip the schema from the key
k = i['Type'].replace(REMOTE_APP_RESOU... | [
"Prepare",
"new",
"mapping",
"with",
"Value",
"s",
"groupped",
"by",
"Type",
"."
] | inveniosoftware/invenio-oauthclient | python | https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/cern.py#L274-L285 | [
"def",
"get_dict_from_response",
"(",
"response",
")",
":",
"result",
"=",
"{",
"}",
"if",
"getattr",
"(",
"response",
",",
"'_resp'",
")",
"and",
"response",
".",
"_resp",
".",
"code",
">",
"400",
":",
"return",
"result",
"for",
"i",
"in",
"response",
... | 2500dc6935738107617aeade79e050d7608004bb |
train | get_resource | Query CERN Resources to get user info and groups. | invenio_oauthclient/contrib/cern.py | def get_resource(remote):
"""Query CERN Resources to get user info and groups."""
cached_resource = session.pop('cern_resource', None)
if cached_resource:
return cached_resource
response = remote.get(REMOTE_APP_RESOURCE_API_URL)
dict_response = get_dict_from_response(response)
session['... | def get_resource(remote):
"""Query CERN Resources to get user info and groups."""
cached_resource = session.pop('cern_resource', None)
if cached_resource:
return cached_resource
response = remote.get(REMOTE_APP_RESOURCE_API_URL)
dict_response = get_dict_from_response(response)
session['... | [
"Query",
"CERN",
"Resources",
"to",
"get",
"user",
"info",
"and",
"groups",
"."
] | inveniosoftware/invenio-oauthclient | python | https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/cern.py#L288-L297 | [
"def",
"get_resource",
"(",
"remote",
")",
":",
"cached_resource",
"=",
"session",
".",
"pop",
"(",
"'cern_resource'",
",",
"None",
")",
"if",
"cached_resource",
":",
"return",
"cached_resource",
"response",
"=",
"remote",
".",
"get",
"(",
"REMOTE_APP_RESOURCE_A... | 2500dc6935738107617aeade79e050d7608004bb |
train | account_info | Retrieve remote account information used to find local user. | invenio_oauthclient/contrib/cern.py | def account_info(remote, resp):
"""Retrieve remote account information used to find local user."""
resource = get_resource(remote)
valid_identities = current_app.config.get(
'OAUTHCLIENT_CERN_ALLOWED_IDENTITY_CLASSES',
OAUTHCLIENT_CERN_ALLOWED_IDENTITY_CLASSES
)
identity_class = res... | def account_info(remote, resp):
"""Retrieve remote account information used to find local user."""
resource = get_resource(remote)
valid_identities = current_app.config.get(
'OAUTHCLIENT_CERN_ALLOWED_IDENTITY_CLASSES',
OAUTHCLIENT_CERN_ALLOWED_IDENTITY_CLASSES
)
identity_class = res... | [
"Retrieve",
"remote",
"account",
"information",
"used",
"to",
"find",
"local",
"user",
"."
] | inveniosoftware/invenio-oauthclient | python | https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/cern.py#L300-L327 | [
"def",
"account_info",
"(",
"remote",
",",
"resp",
")",
":",
"resource",
"=",
"get_resource",
"(",
"remote",
")",
"valid_identities",
"=",
"current_app",
".",
"config",
".",
"get",
"(",
"'OAUTHCLIENT_CERN_ALLOWED_IDENTITY_CLASSES'",
",",
"OAUTHCLIENT_CERN_ALLOWED_IDEN... | 2500dc6935738107617aeade79e050d7608004bb |
train | disconnect_handler | Handle unlinking of remote account. | invenio_oauthclient/contrib/cern.py | def disconnect_handler(remote, *args, **kwargs):
"""Handle unlinking of remote account."""
if not current_user.is_authenticated:
return current_app.login_manager.unauthorized()
account = RemoteAccount.get(user_id=current_user.get_id(),
client_id=remote.consumer_key)
... | def disconnect_handler(remote, *args, **kwargs):
"""Handle unlinking of remote account."""
if not current_user.is_authenticated:
return current_app.login_manager.unauthorized()
account = RemoteAccount.get(user_id=current_user.get_id(),
client_id=remote.consumer_key)
... | [
"Handle",
"unlinking",
"of",
"remote",
"account",
"."
] | inveniosoftware/invenio-oauthclient | python | https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/cern.py#L330-L347 | [
"def",
"disconnect_handler",
"(",
"remote",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"current_user",
".",
"is_authenticated",
":",
"return",
"current_app",
".",
"login_manager",
".",
"unauthorized",
"(",
")",
"account",
"=",
"RemoteA... | 2500dc6935738107617aeade79e050d7608004bb |
train | account_setup | Perform additional setup after user have been logged in. | invenio_oauthclient/contrib/cern.py | def account_setup(remote, token, resp):
"""Perform additional setup after user have been logged in."""
resource = get_resource(remote)
with db.session.begin_nested():
person_id = resource.get('PersonID', [None])
external_id = resource.get('uidNumber', person_id)[0]
# Set CERN perso... | def account_setup(remote, token, resp):
"""Perform additional setup after user have been logged in."""
resource = get_resource(remote)
with db.session.begin_nested():
person_id = resource.get('PersonID', [None])
external_id = resource.get('uidNumber', person_id)[0]
# Set CERN perso... | [
"Perform",
"additional",
"setup",
"after",
"user",
"have",
"been",
"logged",
"in",
"."
] | inveniosoftware/invenio-oauthclient | python | https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/cern.py#L350-L369 | [
"def",
"account_setup",
"(",
"remote",
",",
"token",
",",
"resp",
")",
":",
"resource",
"=",
"get_resource",
"(",
"remote",
")",
"with",
"db",
".",
"session",
".",
"begin_nested",
"(",
")",
":",
"person_id",
"=",
"resource",
".",
"get",
"(",
"'PersonID'"... | 2500dc6935738107617aeade79e050d7608004bb |
train | on_identity_changed | Store groups in session whenever identity changes.
:param identity: The user identity where information are stored. | invenio_oauthclient/contrib/cern.py | def on_identity_changed(sender, identity):
"""Store groups in session whenever identity changes.
:param identity: The user identity where information are stored.
"""
if isinstance(identity, AnonymousIdentity):
return
client_id = current_app.config['CERN_APP_CREDENTIALS']['consumer_key']
... | def on_identity_changed(sender, identity):
"""Store groups in session whenever identity changes.
:param identity: The user identity where information are stored.
"""
if isinstance(identity, AnonymousIdentity):
return
client_id = current_app.config['CERN_APP_CREDENTIALS']['consumer_key']
... | [
"Store",
"groups",
"in",
"session",
"whenever",
"identity",
"changes",
"."
] | inveniosoftware/invenio-oauthclient | python | https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/cern.py#L373-L400 | [
"def",
"on_identity_changed",
"(",
"sender",
",",
"identity",
")",
":",
"if",
"isinstance",
"(",
"identity",
",",
"AnonymousIdentity",
")",
":",
"return",
"client_id",
"=",
"current_app",
".",
"config",
"[",
"'CERN_APP_CREDENTIALS'",
"]",
"[",
"'consumer_key'",
... | 2500dc6935738107617aeade79e050d7608004bb |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.