repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
klmitch/turnstile | turnstile/tools.py | setup_limits | def setup_limits(conf_file, limits_file, do_reload=True,
dry_run=False, debug=False):
"""
Set up or update limits in the Redis database.
:param conf_file: Name of the configuration file, for connecting
to the Redis database.
:param limits_file: Name of the XML fil... | python | def setup_limits(conf_file, limits_file, do_reload=True,
dry_run=False, debug=False):
"""
Set up or update limits in the Redis database.
:param conf_file: Name of the configuration file, for connecting
to the Redis database.
:param limits_file: Name of the XML fil... | [
"def",
"setup_limits",
"(",
"conf_file",
",",
"limits_file",
",",
"do_reload",
"=",
"True",
",",
"dry_run",
"=",
"False",
",",
"debug",
"=",
"False",
")",
":",
"# If dry_run is set, default debug to True",
"if",
"dry_run",
":",
"debug",
"=",
"True",
"# Connect t... | Set up or update limits in the Redis database.
:param conf_file: Name of the configuration file, for connecting
to the Redis database.
:param limits_file: Name of the XML file describing the limits to
configure.
:param do_reload: Controls reloading behavior. I... | [
"Set",
"up",
"or",
"update",
"limits",
"in",
"the",
"Redis",
"database",
"."
] | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/tools.py#L473-L555 | train | Setup or update limits in the Redis database. |
klmitch/turnstile | turnstile/tools.py | make_limit_node | def make_limit_node(root, limit):
"""
Given a Limit object, generate an XML node.
:param root: The root node of the XML tree being built.
:param limit: The Limit object to serialize to XML.
"""
# Build the base limit node
limit_node = etree.SubElement(root, 'limit',
... | python | def make_limit_node(root, limit):
"""
Given a Limit object, generate an XML node.
:param root: The root node of the XML tree being built.
:param limit: The Limit object to serialize to XML.
"""
# Build the base limit node
limit_node = etree.SubElement(root, 'limit',
... | [
"def",
"make_limit_node",
"(",
"root",
",",
"limit",
")",
":",
"# Build the base limit node",
"limit_node",
"=",
"etree",
".",
"SubElement",
"(",
"root",
",",
"'limit'",
",",
"{",
"'class'",
":",
"limit",
".",
"_limit_full_name",
"}",
")",
"# Walk through all th... | Given a Limit object, generate an XML node.
:param root: The root node of the XML tree being built.
:param limit: The Limit object to serialize to XML. | [
"Given",
"a",
"Limit",
"object",
"generate",
"an",
"XML",
"node",
"."
] | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/tools.py#L562-L602 | train | Given a root node and a Limit object generate an XML node. |
klmitch/turnstile | turnstile/tools.py | dump_limits | def dump_limits(conf_file, limits_file, debug=False):
"""
Dump the current limits from the Redis database.
:param conf_file: Name of the configuration file, for connecting
to the Redis database.
:param limits_file: Name of the XML file that the limits will be
... | python | def dump_limits(conf_file, limits_file, debug=False):
"""
Dump the current limits from the Redis database.
:param conf_file: Name of the configuration file, for connecting
to the Redis database.
:param limits_file: Name of the XML file that the limits will be
... | [
"def",
"dump_limits",
"(",
"conf_file",
",",
"limits_file",
",",
"debug",
"=",
"False",
")",
":",
"# Connect to the database...",
"conf",
"=",
"config",
".",
"Config",
"(",
"conf_file",
"=",
"conf_file",
")",
"db",
"=",
"conf",
".",
"get_database",
"(",
")",... | Dump the current limits from the Redis database.
:param conf_file: Name of the configuration file, for connecting
to the Redis database.
:param limits_file: Name of the XML file that the limits will be
dumped to. Use '-' to dump to stdout.
:param debug: If Tru... | [
"Dump",
"the",
"current",
"limits",
"from",
"the",
"Redis",
"database",
"."
] | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/tools.py#L617-L652 | train | Dump the current limits from the Redis database to the specified XML file. |
klmitch/turnstile | turnstile/tools.py | remote_daemon | def remote_daemon(conf_file):
"""
Run the external control daemon.
:param conf_file: Name of the configuration file.
"""
eventlet.monkey_patch()
conf = config.Config(conf_file=conf_file)
daemon = remote.RemoteControlDaemon(None, conf)
daemon.serve() | python | def remote_daemon(conf_file):
"""
Run the external control daemon.
:param conf_file: Name of the configuration file.
"""
eventlet.monkey_patch()
conf = config.Config(conf_file=conf_file)
daemon = remote.RemoteControlDaemon(None, conf)
daemon.serve() | [
"def",
"remote_daemon",
"(",
"conf_file",
")",
":",
"eventlet",
".",
"monkey_patch",
"(",
")",
"conf",
"=",
"config",
".",
"Config",
"(",
"conf_file",
"=",
"conf_file",
")",
"daemon",
"=",
"remote",
".",
"RemoteControlDaemon",
"(",
"None",
",",
"conf",
")"... | Run the external control daemon.
:param conf_file: Name of the configuration file. | [
"Run",
"the",
"external",
"control",
"daemon",
"."
] | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/tools.py#L673-L683 | train | Run the external control daemon. |
klmitch/turnstile | turnstile/tools.py | turnstile_command | def turnstile_command(conf_file, command, arguments=[], channel=None,
debug=False):
"""
Issue a command to all running control daemons.
:param conf_file: Name of the configuration file.
:param command: The command to execute. Note that 'ping' is
handled specia... | python | def turnstile_command(conf_file, command, arguments=[], channel=None,
debug=False):
"""
Issue a command to all running control daemons.
:param conf_file: Name of the configuration file.
:param command: The command to execute. Note that 'ping' is
handled specia... | [
"def",
"turnstile_command",
"(",
"conf_file",
",",
"command",
",",
"arguments",
"=",
"[",
"]",
",",
"channel",
"=",
"None",
",",
"debug",
"=",
"False",
")",
":",
"# Connect to the database...",
"conf",
"=",
"config",
".",
"Config",
"(",
"conf_file",
"=",
"... | Issue a command to all running control daemons.
:param conf_file: Name of the configuration file.
:param command: The command to execute. Note that 'ping' is
handled specially; in particular, the "channel"
parameter is implied. (A random value will be
... | [
"Issue",
"a",
"command",
"to",
"all",
"running",
"control",
"daemons",
"."
] | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/tools.py#L712-L803 | train | Issue a command to all running control daemons. |
klmitch/turnstile | turnstile/tools.py | compactor_daemon | def compactor_daemon(conf_file):
"""
Run the compactor daemon.
:param conf_file: Name of the configuration file.
"""
eventlet.monkey_patch()
conf = config.Config(conf_file=conf_file)
compactor.compactor(conf) | python | def compactor_daemon(conf_file):
"""
Run the compactor daemon.
:param conf_file: Name of the configuration file.
"""
eventlet.monkey_patch()
conf = config.Config(conf_file=conf_file)
compactor.compactor(conf) | [
"def",
"compactor_daemon",
"(",
"conf_file",
")",
":",
"eventlet",
".",
"monkey_patch",
"(",
")",
"conf",
"=",
"config",
".",
"Config",
"(",
"conf_file",
"=",
"conf_file",
")",
"compactor",
".",
"compactor",
"(",
"conf",
")"
] | Run the compactor daemon.
:param conf_file: Name of the configuration file. | [
"Run",
"the",
"compactor",
"daemon",
"."
] | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/tools.py#L820-L829 | train | Run the compactor daemon. |
klmitch/turnstile | turnstile/tools.py | ScriptAdaptor._wrap | def _wrap(cls, func):
"""
Ensures that the function is wrapped in a ScriptAdaptor
object. If it is not, a new ScriptAdaptor will be returned.
If it is, the ScriptAdaptor is returned.
:param func: The function to be wrapped.
"""
if isinstance(func, cls):
... | python | def _wrap(cls, func):
"""
Ensures that the function is wrapped in a ScriptAdaptor
object. If it is not, a new ScriptAdaptor will be returned.
If it is, the ScriptAdaptor is returned.
:param func: The function to be wrapped.
"""
if isinstance(func, cls):
... | [
"def",
"_wrap",
"(",
"cls",
",",
"func",
")",
":",
"if",
"isinstance",
"(",
"func",
",",
"cls",
")",
":",
"return",
"func",
"return",
"functools",
".",
"update_wrapper",
"(",
"cls",
"(",
"func",
")",
",",
"func",
")"
] | Ensures that the function is wrapped in a ScriptAdaptor
object. If it is not, a new ScriptAdaptor will be returned.
If it is, the ScriptAdaptor is returned.
:param func: The function to be wrapped. | [
"Ensures",
"that",
"the",
"function",
"is",
"wrapped",
"in",
"a",
"ScriptAdaptor",
"object",
".",
"If",
"it",
"is",
"not",
"a",
"new",
"ScriptAdaptor",
"will",
"be",
"returned",
".",
"If",
"it",
"is",
"the",
"ScriptAdaptor",
"is",
"returned",
"."
] | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/tools.py#L50-L61 | train | Wraps a function in a ScriptAdaptor object. |
klmitch/turnstile | turnstile/tools.py | ScriptAdaptor.setup_args | def setup_args(self, parser):
"""
Set up an argparse.ArgumentParser object by adding all the
arguments taken by the function.
"""
# Add all the arguments to the argument parser
for args, kwargs in self._arguments:
parser.add_argument(*args, **kwargs) | python | def setup_args(self, parser):
"""
Set up an argparse.ArgumentParser object by adding all the
arguments taken by the function.
"""
# Add all the arguments to the argument parser
for args, kwargs in self._arguments:
parser.add_argument(*args, **kwargs) | [
"def",
"setup_args",
"(",
"self",
",",
"parser",
")",
":",
"# Add all the arguments to the argument parser",
"for",
"args",
",",
"kwargs",
"in",
"self",
".",
"_arguments",
":",
"parser",
".",
"add_argument",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Set up an argparse.ArgumentParser object by adding all the
arguments taken by the function. | [
"Set",
"up",
"an",
"argparse",
".",
"ArgumentParser",
"object",
"by",
"adding",
"all",
"the",
"arguments",
"taken",
"by",
"the",
"function",
"."
] | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/tools.py#L131-L139 | train | Setup the argparse. ArgumentParser object by adding all the arguments taken by the function. |
klmitch/turnstile | turnstile/tools.py | ScriptAdaptor.get_kwargs | def get_kwargs(self, args):
"""
Given a Namespace object drawn from argparse, determines the
keyword arguments to pass to the underlying function. Note
that, if the underlying function accepts all keyword
arguments, the dictionary returned will contain the entire
content... | python | def get_kwargs(self, args):
"""
Given a Namespace object drawn from argparse, determines the
keyword arguments to pass to the underlying function. Note
that, if the underlying function accepts all keyword
arguments, the dictionary returned will contain the entire
content... | [
"def",
"get_kwargs",
"(",
"self",
",",
"args",
")",
":",
"# Now we need to figure out which arguments the final function",
"# actually needs",
"kwargs",
"=",
"{",
"}",
"argspec",
"=",
"inspect",
".",
"getargspec",
"(",
"self",
".",
"_func",
")",
"required",
"=",
"... | Given a Namespace object drawn from argparse, determines the
keyword arguments to pass to the underlying function. Note
that, if the underlying function accepts all keyword
arguments, the dictionary returned will contain the entire
contents of the Namespace object. Also note that an
... | [
"Given",
"a",
"Namespace",
"object",
"drawn",
"from",
"argparse",
"determines",
"the",
"keyword",
"arguments",
"to",
"pass",
"to",
"the",
"underlying",
"function",
".",
"Note",
"that",
"if",
"the",
"underlying",
"function",
"accepts",
"all",
"keyword",
"argument... | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/tools.py#L141-L177 | train | Given a Namespace object drawn from argparse determines the keyword arguments that the underlying function needs to pass to the underlying function. |
klmitch/turnstile | turnstile/tools.py | ScriptAdaptor.safe_call | def safe_call(self, kwargs, args=None):
"""
Call the underlying function safely, given a set of keyword
arguments. If successful, the function return value (likely
None) will be returned. If the underlying function raises an
exception, the return value will be the exception mes... | python | def safe_call(self, kwargs, args=None):
"""
Call the underlying function safely, given a set of keyword
arguments. If successful, the function return value (likely
None) will be returned. If the underlying function raises an
exception, the return value will be the exception mes... | [
"def",
"safe_call",
"(",
"self",
",",
"kwargs",
",",
"args",
"=",
"None",
")",
":",
"# Now let's call the function",
"try",
":",
"return",
"self",
".",
"_func",
"(",
"*",
"*",
"kwargs",
")",
"except",
"Exception",
"as",
"exc",
":",
"if",
"args",
"and",
... | Call the underlying function safely, given a set of keyword
arguments. If successful, the function return value (likely
None) will be returned. If the underlying function raises an
exception, the return value will be the exception message,
unless an argparse Namespace object defining a... | [
"Call",
"the",
"underlying",
"function",
"safely",
"given",
"a",
"set",
"of",
"keyword",
"arguments",
".",
"If",
"successful",
"the",
"function",
"return",
"value",
"(",
"likely",
"None",
")",
"will",
"be",
"returned",
".",
"If",
"the",
"underlying",
"functi... | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/tools.py#L179-L204 | train | Call the underlying function safely given a set of keyword arguments and return the return value. |
klmitch/turnstile | turnstile/tools.py | ScriptAdaptor.console | def console(self):
"""
Call the function as a console script. Command line arguments
are parsed, preprocessors are called, then the function is
called. If a 'debug' attribute is set by the command line
arguments, and it is True, any exception raised by the
underlying fu... | python | def console(self):
"""
Call the function as a console script. Command line arguments
are parsed, preprocessors are called, then the function is
called. If a 'debug' attribute is set by the command line
arguments, and it is True, any exception raised by the
underlying fu... | [
"def",
"console",
"(",
"self",
")",
":",
"# First, let's parse the arguments",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"self",
".",
"description",
")",
"self",
".",
"setup_args",
"(",
"parser",
")",
"args",
"=",
"parser",
"."... | Call the function as a console script. Command line arguments
are parsed, preprocessors are called, then the function is
called. If a 'debug' attribute is set by the command line
arguments, and it is True, any exception raised by the
underlying function will be reraised; otherwise, the... | [
"Call",
"the",
"function",
"as",
"a",
"console",
"script",
".",
"Command",
"line",
"arguments",
"are",
"parsed",
"preprocessors",
"are",
"called",
"then",
"the",
"function",
"is",
"called",
".",
"If",
"a",
"debug",
"attribute",
"is",
"set",
"by",
"the",
"c... | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/tools.py#L206-L238 | train | Call the underlying function as a console script. |
BernardFW/bernard | src/bernard/utils.py | import_class | def import_class(name: Text) -> Type:
"""
Import a class based on its full name.
:param name: name of the class
"""
parts = name.split('.')
module_name = parts[:-1]
class_name = parts[-1]
module_ = importlib.import_module('.'.join(module_name))
return getattr(module_, class_name) | python | def import_class(name: Text) -> Type:
"""
Import a class based on its full name.
:param name: name of the class
"""
parts = name.split('.')
module_name = parts[:-1]
class_name = parts[-1]
module_ = importlib.import_module('.'.join(module_name))
return getattr(module_, class_name) | [
"def",
"import_class",
"(",
"name",
":",
"Text",
")",
"->",
"Type",
":",
"parts",
"=",
"name",
".",
"split",
"(",
"'.'",
")",
"module_name",
"=",
"parts",
"[",
":",
"-",
"1",
"]",
"class_name",
"=",
"parts",
"[",
"-",
"1",
"]",
"module_",
"=",
"i... | Import a class based on its full name.
:param name: name of the class | [
"Import",
"a",
"class",
"based",
"on",
"its",
"full",
"name",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/utils.py#L34-L45 | train | Imports a class based on its full name. |
BernardFW/bernard | src/bernard/utils.py | make_ro | def make_ro(obj: Any, forgive_type=False):
"""
Make a json-serializable type recursively read-only
:param obj: Any json-serializable type
:param forgive_type: If you can forgive a type to be unknown (instead of
raising an exception)
"""
if isinstance(obj, (str, bytes, ... | python | def make_ro(obj: Any, forgive_type=False):
"""
Make a json-serializable type recursively read-only
:param obj: Any json-serializable type
:param forgive_type: If you can forgive a type to be unknown (instead of
raising an exception)
"""
if isinstance(obj, (str, bytes, ... | [
"def",
"make_ro",
"(",
"obj",
":",
"Any",
",",
"forgive_type",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"(",
"str",
",",
"bytes",
",",
"int",
",",
"float",
",",
"bool",
",",
"RoDict",
",",
"RoList",
")",
")",
"or",
"obj",
"is"... | Make a json-serializable type recursively read-only
:param obj: Any json-serializable type
:param forgive_type: If you can forgive a type to be unknown (instead of
raising an exception) | [
"Make",
"a",
"json",
"-",
"serializable",
"type",
"recursively",
"read",
"-",
"only"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/utils.py#L127-L147 | train | Make a json - serializable type recursively read - only
|
BernardFW/bernard | src/bernard/utils.py | make_rw | def make_rw(obj: Any):
"""
Copy a RO object into a RW structure made with standard Python classes.
WARNING there is no protection against recursion.
"""
if isinstance(obj, RoDict):
return {k: make_rw(v) for k, v in obj.items()}
elif isinstance(obj, RoList):
return [make_rw(x) f... | python | def make_rw(obj: Any):
"""
Copy a RO object into a RW structure made with standard Python classes.
WARNING there is no protection against recursion.
"""
if isinstance(obj, RoDict):
return {k: make_rw(v) for k, v in obj.items()}
elif isinstance(obj, RoList):
return [make_rw(x) f... | [
"def",
"make_rw",
"(",
"obj",
":",
"Any",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"RoDict",
")",
":",
"return",
"{",
"k",
":",
"make_rw",
"(",
"v",
")",
"for",
"k",
",",
"v",
"in",
"obj",
".",
"items",
"(",
")",
"}",
"elif",
"isinstance"... | Copy a RO object into a RW structure made with standard Python classes.
WARNING there is no protection against recursion. | [
"Copy",
"a",
"RO",
"object",
"into",
"a",
"RW",
"structure",
"made",
"with",
"standard",
"Python",
"classes",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/utils.py#L150-L162 | train | Make a RO object into a RW structure made with standard Python classes. |
BernardFW/bernard | src/bernard/utils.py | patch_qs | def patch_qs(url: Text, data: Dict[Text, Text]) -> Text:
"""
Given an URL, change the query string to include the values specified in
the dictionary.
If the keys of the dictionary can be found in the query string of the URL,
then they will be removed.
It is guaranteed that all other values of ... | python | def patch_qs(url: Text, data: Dict[Text, Text]) -> Text:
"""
Given an URL, change the query string to include the values specified in
the dictionary.
If the keys of the dictionary can be found in the query string of the URL,
then they will be removed.
It is guaranteed that all other values of ... | [
"def",
"patch_qs",
"(",
"url",
":",
"Text",
",",
"data",
":",
"Dict",
"[",
"Text",
",",
"Text",
"]",
")",
"->",
"Text",
":",
"qs_id",
"=",
"4",
"p",
"=",
"list",
"(",
"urlparse",
"(",
"url",
")",
")",
"qs",
"=",
"parse_qsl",
"(",
"p",
"[",
"q... | Given an URL, change the query string to include the values specified in
the dictionary.
If the keys of the dictionary can be found in the query string of the URL,
then they will be removed.
It is guaranteed that all other values of the query string will keep their
order. | [
"Given",
"an",
"URL",
"change",
"the",
"query",
"string",
"to",
"include",
"the",
"values",
"specified",
"in",
"the",
"dictionary",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/utils.py#L203-L225 | train | Given an URL and a dictionary of values that can be found in the query string of the URL change the query string to include the values specified in the dictionary. |
BernardFW/bernard | src/bernard/utils.py | dict_is_subset | def dict_is_subset(subset: Any, full_set: Any) -> bool:
"""
Checks that all keys present in `subset` are present and have the same
value in `full_set`. If a key is in `full_set` but not in `subset` then
True will be returned anyways.
"""
if not isinstance(subset, full_set.__class__):
re... | python | def dict_is_subset(subset: Any, full_set: Any) -> bool:
"""
Checks that all keys present in `subset` are present and have the same
value in `full_set`. If a key is in `full_set` but not in `subset` then
True will be returned anyways.
"""
if not isinstance(subset, full_set.__class__):
re... | [
"def",
"dict_is_subset",
"(",
"subset",
":",
"Any",
",",
"full_set",
":",
"Any",
")",
"->",
"bool",
":",
"if",
"not",
"isinstance",
"(",
"subset",
",",
"full_set",
".",
"__class__",
")",
":",
"return",
"False",
"elif",
"isinstance",
"(",
"subset",
",",
... | Checks that all keys present in `subset` are present and have the same
value in `full_set`. If a key is in `full_set` but not in `subset` then
True will be returned anyways. | [
"Checks",
"that",
"all",
"keys",
"present",
"in",
"subset",
"are",
"present",
"and",
"have",
"the",
"same",
"value",
"in",
"full_set",
".",
"If",
"a",
"key",
"is",
"in",
"full_set",
"but",
"not",
"in",
"subset",
"then",
"True",
"will",
"be",
"returned",
... | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/utils.py#L234-L259 | train | Checks that all keys present in subset are present and have the same
value in full_set. |
BernardFW/bernard | src/bernard/utils.py | ClassExp._compile | def _compile(self, expression):
"""
Transform a class exp into an actual regex
"""
x = self.RE_PYTHON_VAR.sub('(?:\\1,)', expression)
x = self.RE_SPACES.sub('', x)
return re.compile(x) | python | def _compile(self, expression):
"""
Transform a class exp into an actual regex
"""
x = self.RE_PYTHON_VAR.sub('(?:\\1,)', expression)
x = self.RE_SPACES.sub('', x)
return re.compile(x) | [
"def",
"_compile",
"(",
"self",
",",
"expression",
")",
":",
"x",
"=",
"self",
".",
"RE_PYTHON_VAR",
".",
"sub",
"(",
"'(?:\\\\1,)'",
",",
"expression",
")",
"x",
"=",
"self",
".",
"RE_SPACES",
".",
"sub",
"(",
"''",
",",
"x",
")",
"return",
"re",
... | Transform a class exp into an actual regex | [
"Transform",
"a",
"class",
"exp",
"into",
"an",
"actual",
"regex"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/utils.py#L177-L184 | train | Transform a class exp into a regex |
BernardFW/bernard | src/bernard/utils.py | ClassExp._make_string | def _make_string(self, objects: List[Any]) -> Text:
"""
Transforms a list of objects into a matchable string
"""
return ''.join(x.__class__.__name__ + ',' for x in objects) | python | def _make_string(self, objects: List[Any]) -> Text:
"""
Transforms a list of objects into a matchable string
"""
return ''.join(x.__class__.__name__ + ',' for x in objects) | [
"def",
"_make_string",
"(",
"self",
",",
"objects",
":",
"List",
"[",
"Any",
"]",
")",
"->",
"Text",
":",
"return",
"''",
".",
"join",
"(",
"x",
".",
"__class__",
".",
"__name__",
"+",
"','",
"for",
"x",
"in",
"objects",
")"
] | Transforms a list of objects into a matchable string | [
"Transforms",
"a",
"list",
"of",
"objects",
"into",
"a",
"matchable",
"string"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/utils.py#L186-L191 | train | Transforms a list of objects into a matchable string |
BernardFW/bernard | src/bernard/utils.py | ClassExp.match | def match(self, objects: List[Any]) -> bool:
"""
Return True if the list of objects matches the expression.
"""
s = self._make_string(objects)
m = self._compiled_expression.match(s)
return m is not None | python | def match(self, objects: List[Any]) -> bool:
"""
Return True if the list of objects matches the expression.
"""
s = self._make_string(objects)
m = self._compiled_expression.match(s)
return m is not None | [
"def",
"match",
"(",
"self",
",",
"objects",
":",
"List",
"[",
"Any",
"]",
")",
"->",
"bool",
":",
"s",
"=",
"self",
".",
"_make_string",
"(",
"objects",
")",
"m",
"=",
"self",
".",
"_compiled_expression",
".",
"match",
"(",
"s",
")",
"return",
"m"... | Return True if the list of objects matches the expression. | [
"Return",
"True",
"if",
"the",
"list",
"of",
"objects",
"matches",
"the",
"expression",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/utils.py#L193-L200 | train | Return True if the list of objects matches the expression. |
jstitch/MambuPy | MambuPy/rest/mambutransaction.py | MambuTransactions.convertDict2Attrs | def convertDict2Attrs(self, *args, **kwargs):
"""The trick for iterable Mambu Objects comes here:
You iterate over each element of the responded List from Mambu,
and create a Mambu Transaction object for each one, initializing
them one at a time, and changing the attrs attribute (which ... | python | def convertDict2Attrs(self, *args, **kwargs):
"""The trick for iterable Mambu Objects comes here:
You iterate over each element of the responded List from Mambu,
and create a Mambu Transaction object for each one, initializing
them one at a time, and changing the attrs attribute (which ... | [
"def",
"convertDict2Attrs",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"n",
",",
"t",
"in",
"enumerate",
"(",
"self",
".",
"attrs",
")",
":",
"# ok ok, I'm modifying elements of a list while iterating it. BAD PRACTICE!",
"try",
":",... | The trick for iterable Mambu Objects comes here:
You iterate over each element of the responded List from Mambu,
and create a Mambu Transaction object for each one, initializing
them one at a time, and changing the attrs attribute (which just
holds a list of plain dictionaries) with a M... | [
"The",
"trick",
"for",
"iterable",
"Mambu",
"Objects",
"comes",
"here",
":"
] | 2af98cc12e7ed5ec183b3e97644e880e70b79ee8 | https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambutransaction.py#L72-L100 | train | This method converts a dictionary of plain dictionaries into a list of Mambu Transaction objects. |
jstitch/MambuPy | MambuPy/mambuconfig.py | get_conf | def get_conf(conf, sect, opt):
""" Gets a config 'opt' from 'conf' file, under section 'sect'.
If no 'opt' exists under 'sect', it looks for option on the default_configs
dictionary
If there exists an environmental variable named MAMBUPY_{upper_case_opt},
it overrides whatever the conf files or de... | python | def get_conf(conf, sect, opt):
""" Gets a config 'opt' from 'conf' file, under section 'sect'.
If no 'opt' exists under 'sect', it looks for option on the default_configs
dictionary
If there exists an environmental variable named MAMBUPY_{upper_case_opt},
it overrides whatever the conf files or de... | [
"def",
"get_conf",
"(",
"conf",
",",
"sect",
",",
"opt",
")",
":",
"argu",
"=",
"getattr",
"(",
"args",
",",
"\"mambupy_\"",
"+",
"opt",
".",
"lower",
"(",
")",
")",
"if",
"not",
"argu",
":",
"envir",
"=",
"os",
".",
"environ",
".",
"get",
"(",
... | Gets a config 'opt' from 'conf' file, under section 'sect'.
If no 'opt' exists under 'sect', it looks for option on the default_configs
dictionary
If there exists an environmental variable named MAMBUPY_{upper_case_opt},
it overrides whatever the conf files or default_configs dict says.
But if yo... | [
"Gets",
"a",
"config",
"opt",
"from",
"conf",
"file",
"under",
"section",
"sect",
"."
] | 2af98cc12e7ed5ec183b3e97644e880e70b79ee8 | https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/mambuconfig.py#L119-L152 | train | Gets a config option from conf file under section sect. |
obilaniu/Nauka | src/nauka/fhs.py | iso8601timestamp | def iso8601timestamp(T=None, nanos=True, utc=False):
"""Get ISO8601-formatted timestamp string."""
T = time.time() if T is None else T
Ti = math.floor(T)
Tn = round((T-Ti)*1e9)
if Tn >= 1e9:
Ti += 1
Tn = 0
s = time.gmtime(Ti) if utc else time.localtime(Ti)
f = time.strftime("%Y%m%dT%H%M%S", s)
... | python | def iso8601timestamp(T=None, nanos=True, utc=False):
"""Get ISO8601-formatted timestamp string."""
T = time.time() if T is None else T
Ti = math.floor(T)
Tn = round((T-Ti)*1e9)
if Tn >= 1e9:
Ti += 1
Tn = 0
s = time.gmtime(Ti) if utc else time.localtime(Ti)
f = time.strftime("%Y%m%dT%H%M%S", s)
... | [
"def",
"iso8601timestamp",
"(",
"T",
"=",
"None",
",",
"nanos",
"=",
"True",
",",
"utc",
"=",
"False",
")",
":",
"T",
"=",
"time",
".",
"time",
"(",
")",
"if",
"T",
"is",
"None",
"else",
"T",
"Ti",
"=",
"math",
".",
"floor",
"(",
"T",
")",
"T... | Get ISO8601-formatted timestamp string. | [
"Get",
"ISO8601",
"-",
"formatted",
"timestamp",
"string",
"."
] | 1492a4f9d204a868c1a8a1d327bd108490b856b4 | https://github.com/obilaniu/Nauka/blob/1492a4f9d204a868c1a8a1d327bd108490b856b4/src/nauka/fhs.py#L5-L18 | train | Get ISO8601 - formatted timestamp string. |
obilaniu/Nauka | src/nauka/fhs.py | createWorkDir | def createWorkDir(baseDir,
projName,
expUUID,
expNames = [],
nanos = True,
utc = False):
"""Create working directory for experiment if not existing already."""
#
# First, ensure the project's top-level hierarchy, espe... | python | def createWorkDir(baseDir,
projName,
expUUID,
expNames = [],
nanos = True,
utc = False):
"""Create working directory for experiment if not existing already."""
#
# First, ensure the project's top-level hierarchy, espe... | [
"def",
"createWorkDir",
"(",
"baseDir",
",",
"projName",
",",
"expUUID",
",",
"expNames",
"=",
"[",
"]",
",",
"nanos",
"=",
"True",
",",
"utc",
"=",
"False",
")",
":",
"#",
"# First, ensure the project's top-level hierarchy, especially by-uuid/,",
"# exists, so that... | Create working directory for experiment if not existing already. | [
"Create",
"working",
"directory",
"for",
"experiment",
"if",
"not",
"existing",
"already",
"."
] | 1492a4f9d204a868c1a8a1d327bd108490b856b4 | https://github.com/obilaniu/Nauka/blob/1492a4f9d204a868c1a8a1d327bd108490b856b4/src/nauka/fhs.py#L21-L89 | train | Create a working directory for the given experiment. |
polyaxon/hestia | hestia/humanize.py | humanize_timesince | def humanize_timesince(start_time): # pylint:disable=too-many-return-statements
"""Creates a string representation of time since the given `start_time`."""
if not start_time:
return start_time
delta = local_now() - start_time
# assumption: negative delta values originate from clock
# ... | python | def humanize_timesince(start_time): # pylint:disable=too-many-return-statements
"""Creates a string representation of time since the given `start_time`."""
if not start_time:
return start_time
delta = local_now() - start_time
# assumption: negative delta values originate from clock
# ... | [
"def",
"humanize_timesince",
"(",
"start_time",
")",
":",
"# pylint:disable=too-many-return-statements",
"if",
"not",
"start_time",
":",
"return",
"start_time",
"delta",
"=",
"local_now",
"(",
")",
"-",
"start_time",
"# assumption: negative delta values originate from clock",... | Creates a string representation of time since the given `start_time`. | [
"Creates",
"a",
"string",
"representation",
"of",
"time",
"since",
"the",
"given",
"start_time",
"."
] | 382ed139cff8bf35c987cfc30a31b72c0d6b808e | https://github.com/polyaxon/hestia/blob/382ed139cff8bf35c987cfc30a31b72c0d6b808e/hestia/humanize.py#L7-L43 | train | Creates a string representation of time since the given start_time. |
polyaxon/hestia | hestia/humanize.py | humanize_timedelta | def humanize_timedelta(seconds):
"""Creates a string representation of timedelta."""
hours, remainder = divmod(seconds, 3600)
days, hours = divmod(hours, 24)
minutes, seconds = divmod(remainder, 60)
if days:
result = '{}d'.format(days)
if hours:
result += ' {}h'.format(h... | python | def humanize_timedelta(seconds):
"""Creates a string representation of timedelta."""
hours, remainder = divmod(seconds, 3600)
days, hours = divmod(hours, 24)
minutes, seconds = divmod(remainder, 60)
if days:
result = '{}d'.format(days)
if hours:
result += ' {}h'.format(h... | [
"def",
"humanize_timedelta",
"(",
"seconds",
")",
":",
"hours",
",",
"remainder",
"=",
"divmod",
"(",
"seconds",
",",
"3600",
")",
"days",
",",
"hours",
"=",
"divmod",
"(",
"hours",
",",
"24",
")",
"minutes",
",",
"seconds",
"=",
"divmod",
"(",
"remain... | Creates a string representation of timedelta. | [
"Creates",
"a",
"string",
"representation",
"of",
"timedelta",
"."
] | 382ed139cff8bf35c987cfc30a31b72c0d6b808e | https://github.com/polyaxon/hestia/blob/382ed139cff8bf35c987cfc30a31b72c0d6b808e/hestia/humanize.py#L46-L72 | train | Creates a string representation of timedelta. |
peopledoc/mock-services | mock_services/http_mock.py | HttpMock.start | def start(self):
"""Overrides default start behaviour by raising ConnectionError instead
of custom requests_mock.exceptions.NoMockAddress.
"""
if self._http_last_send is not None:
raise RuntimeError('HttpMock has already been started')
# 1) save request.Session.send ... | python | def start(self):
"""Overrides default start behaviour by raising ConnectionError instead
of custom requests_mock.exceptions.NoMockAddress.
"""
if self._http_last_send is not None:
raise RuntimeError('HttpMock has already been started')
# 1) save request.Session.send ... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"self",
".",
"_http_last_send",
"is",
"not",
"None",
":",
"raise",
"RuntimeError",
"(",
"'HttpMock has already been started'",
")",
"# 1) save request.Session.send in self._last_send",
"# 2) replace request.Session.send with Mocker... | Overrides default start behaviour by raising ConnectionError instead
of custom requests_mock.exceptions.NoMockAddress. | [
"Overrides",
"default",
"start",
"behaviour",
"by",
"raising",
"ConnectionError",
"instead",
"of",
"custom",
"requests_mock",
".",
"exceptions",
".",
"NoMockAddress",
"."
] | fd3838280df8869725b538768357435eedf299c1 | https://github.com/peopledoc/mock-services/blob/fd3838280df8869725b538768357435eedf299c1/mock_services/http_mock.py#L63-L76 | train | Overrides default start behaviour by raising ConnectionError instead of custom requests_mock. exceptions. NoMockAddress.
|
axel-events/axel | axel/axel.py | Event.handle | def handle(self, handler):
""" Registers a handler. The handler can be transmitted together
with two arguments as a list or dictionary. The arguments are:
memoize
if True, the execution result will be cached in self.memoize
timeout
will allocate... | python | def handle(self, handler):
""" Registers a handler. The handler can be transmitted together
with two arguments as a list or dictionary. The arguments are:
memoize
if True, the execution result will be cached in self.memoize
timeout
will allocate... | [
"def",
"handle",
"(",
"self",
",",
"handler",
")",
":",
"handler_",
",",
"memoize",
",",
"timeout",
"=",
"self",
".",
"_extract",
"(",
"handler",
")",
"with",
"self",
".",
"_hlock",
":",
"handlers",
"=",
"self",
".",
"handlers",
".",
"copy",
"(",
")"... | Registers a handler. The handler can be transmitted together
with two arguments as a list or dictionary. The arguments are:
memoize
if True, the execution result will be cached in self.memoize
timeout
will allocate a predefined time interval for the exec... | [
"Registers",
"a",
"handler",
".",
"The",
"handler",
"can",
"be",
"transmitted",
"together",
"with",
"two",
"arguments",
"as",
"a",
"list",
"or",
"dictionary",
".",
"The",
"arguments",
"are",
":",
"memoize",
"if",
"True",
"the",
"execution",
"result",
"will",... | 08a663347ef21614b96f92f60f4de57a502db73c | https://github.com/axel-events/axel/blob/08a663347ef21614b96f92f60f4de57a502db73c/axel/axel.py#L139-L161 | train | Registers a new handler for the specified time interval. |
axel-events/axel | axel/axel.py | Event.unhandle | def unhandle(self, handler):
""" Unregisters a handler """
h, _, _ = self._extract(handler)
key = hash(h)
with self._hlock:
if key not in self.handlers:
raise ValueError('Handler "%s" was not found' % str(h))
handlers = self.handlers.copy()
... | python | def unhandle(self, handler):
""" Unregisters a handler """
h, _, _ = self._extract(handler)
key = hash(h)
with self._hlock:
if key not in self.handlers:
raise ValueError('Handler "%s" was not found' % str(h))
handlers = self.handlers.copy()
... | [
"def",
"unhandle",
"(",
"self",
",",
"handler",
")",
":",
"h",
",",
"_",
",",
"_",
"=",
"self",
".",
"_extract",
"(",
"handler",
")",
"key",
"=",
"hash",
"(",
"h",
")",
"with",
"self",
".",
"_hlock",
":",
"if",
"key",
"not",
"in",
"self",
".",
... | Unregisters a handler | [
"Unregisters",
"a",
"handler"
] | 08a663347ef21614b96f92f60f4de57a502db73c | https://github.com/axel-events/axel/blob/08a663347ef21614b96f92f60f4de57a502db73c/axel/axel.py#L163-L173 | train | Unregisters a handler from the list of handlers. |
axel-events/axel | axel/axel.py | Event.fire | def fire(self, *args, **kw):
""" Stores all registered handlers in a queue for processing """
result = []
with self._hlock:
handlers = self.handlers
if self.threads == 0: # same-thread execution - synchronized
for k in handlers:
# handl... | python | def fire(self, *args, **kw):
""" Stores all registered handlers in a queue for processing """
result = []
with self._hlock:
handlers = self.handlers
if self.threads == 0: # same-thread execution - synchronized
for k in handlers:
# handl... | [
"def",
"fire",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"result",
"=",
"[",
"]",
"with",
"self",
".",
"_hlock",
":",
"handlers",
"=",
"self",
".",
"handlers",
"if",
"self",
".",
"threads",
"==",
"0",
":",
"# same-thread executi... | Stores all registered handlers in a queue for processing | [
"Stores",
"all",
"registered",
"handlers",
"in",
"a",
"queue",
"for",
"processing"
] | 08a663347ef21614b96f92f60f4de57a502db73c | https://github.com/axel-events/axel/blob/08a663347ef21614b96f92f60f4de57a502db73c/axel/axel.py#L175-L247 | train | Executes all handlers in a queue and returns a list of results. |
axel-events/axel | axel/axel.py | Event.clear | def clear(self):
""" Discards all registered handlers and cached results """
with self._hlock:
self.handlers.clear()
with self._mlock:
self.memoize.clear() | python | def clear(self):
""" Discards all registered handlers and cached results """
with self._hlock:
self.handlers.clear()
with self._mlock:
self.memoize.clear() | [
"def",
"clear",
"(",
"self",
")",
":",
"with",
"self",
".",
"_hlock",
":",
"self",
".",
"handlers",
".",
"clear",
"(",
")",
"with",
"self",
".",
"_mlock",
":",
"self",
".",
"memoize",
".",
"clear",
"(",
")"
] | Discards all registered handlers and cached results | [
"Discards",
"all",
"registered",
"handlers",
"and",
"cached",
"results"
] | 08a663347ef21614b96f92f60f4de57a502db73c | https://github.com/axel-events/axel/blob/08a663347ef21614b96f92f60f4de57a502db73c/axel/axel.py#L254-L259 | train | Discards all registered handlers and cached results |
axel-events/axel | axel/axel.py | Event._extract | def _extract(self, item):
""" Extracts a handler and handler's arguments that can be provided
as list or dictionary. If arguments are provided as list, they are
considered to have this sequence: (handler, memoize, timeout)
Examples:
event += handler
... | python | def _extract(self, item):
""" Extracts a handler and handler's arguments that can be provided
as list or dictionary. If arguments are provided as list, they are
considered to have this sequence: (handler, memoize, timeout)
Examples:
event += handler
... | [
"def",
"_extract",
"(",
"self",
",",
"item",
")",
":",
"if",
"not",
"item",
":",
"raise",
"ValueError",
"(",
"'Invalid arguments'",
")",
"handler",
"=",
"None",
"memoize",
"=",
"False",
"timeout",
"=",
"0",
"if",
"not",
"isinstance",
"(",
"item",
",",
... | Extracts a handler and handler's arguments that can be provided
as list or dictionary. If arguments are provided as list, they are
considered to have this sequence: (handler, memoize, timeout)
Examples:
event += handler
event += (handler, True, 1.5)... | [
"Extracts",
"a",
"handler",
"and",
"handler",
"s",
"arguments",
"that",
"can",
"be",
"provided",
"as",
"list",
"or",
"dictionary",
".",
"If",
"arguments",
"are",
"provided",
"as",
"list",
"they",
"are",
"considered",
"to",
"have",
"this",
"sequence",
":",
... | 08a663347ef21614b96f92f60f4de57a502db73c | https://github.com/axel-events/axel/blob/08a663347ef21614b96f92f60f4de57a502db73c/axel/axel.py#L261-L290 | train | Extracts a handler and handler s arguments that can be provided
AttributeNames as list or dictionary. |
axel-events/axel | axel/axel.py | Event._memoize | def _memoize(self, handler, memoize, timeout, *args, **kw):
""" Caches the execution result of successful executions
hash = hash(handler)
memoize = {
hash : ((args, kw, result), (args, kw, result), ...),
hash : ((args, kw, result), ...), ... ... | python | def _memoize(self, handler, memoize, timeout, *args, **kw):
""" Caches the execution result of successful executions
hash = hash(handler)
memoize = {
hash : ((args, kw, result), (args, kw, result), ...),
hash : ((args, kw, result), ...), ... ... | [
"def",
"_memoize",
"(",
"self",
",",
"handler",
",",
"memoize",
",",
"timeout",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"not",
"isinstance",
"(",
"handler",
",",
"Event",
")",
"and",
"self",
".",
"sender",
"is",
"not",
"None",
":",
... | Caches the execution result of successful executions
hash = hash(handler)
memoize = {
hash : ((args, kw, result), (args, kw, result), ...),
hash : ((args, kw, result), ...), ...
} | [
"Caches",
"the",
"execution",
"result",
"of",
"successful",
"executions",
"hash",
"=",
"hash",
"(",
"handler",
")",
"memoize",
"=",
"{",
"hash",
":",
"((",
"args",
"kw",
"result",
")",
"(",
"args",
"kw",
"result",
")",
"...",
")",
"hash",
":",
"((",
... | 08a663347ef21614b96f92f60f4de57a502db73c | https://github.com/axel-events/axel/blob/08a663347ef21614b96f92f60f4de57a502db73c/axel/axel.py#L292-L334 | train | Memoizes the execution result of successful executionsudo
|
axel-events/axel | axel/axel.py | Event._timeout | def _timeout(self, timeout, handler, *args, **kw):
""" Controls the time allocated for the execution of a method """
t = spawn_thread(target=handler, args=args, kw=kw)
t.daemon = True
t.start()
t.join(timeout)
if not t.is_alive():
if t.exc_info:
... | python | def _timeout(self, timeout, handler, *args, **kw):
""" Controls the time allocated for the execution of a method """
t = spawn_thread(target=handler, args=args, kw=kw)
t.daemon = True
t.start()
t.join(timeout)
if not t.is_alive():
if t.exc_info:
... | [
"def",
"_timeout",
"(",
"self",
",",
"timeout",
",",
"handler",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"t",
"=",
"spawn_thread",
"(",
"target",
"=",
"handler",
",",
"args",
"=",
"args",
",",
"kw",
"=",
"kw",
")",
"t",
".",
"daemon",
"... | Controls the time allocated for the execution of a method | [
"Controls",
"the",
"time",
"allocated",
"for",
"the",
"execution",
"of",
"a",
"method"
] | 08a663347ef21614b96f92f60f4de57a502db73c | https://github.com/axel-events/axel/blob/08a663347ef21614b96f92f60f4de57a502db73c/axel/axel.py#L336-L352 | train | Handles the timeout of the method execution |
axel-events/axel | axel/axel.py | Event._threads | def _threads(self, handlers):
""" Calculates maximum number of threads that will be started """
if self.threads < len(handlers):
return self.threads
return len(handlers) | python | def _threads(self, handlers):
""" Calculates maximum number of threads that will be started """
if self.threads < len(handlers):
return self.threads
return len(handlers) | [
"def",
"_threads",
"(",
"self",
",",
"handlers",
")",
":",
"if",
"self",
".",
"threads",
"<",
"len",
"(",
"handlers",
")",
":",
"return",
"self",
".",
"threads",
"return",
"len",
"(",
"handlers",
")"
] | Calculates maximum number of threads that will be started | [
"Calculates",
"maximum",
"number",
"of",
"threads",
"that",
"will",
"be",
"started"
] | 08a663347ef21614b96f92f60f4de57a502db73c | https://github.com/axel-events/axel/blob/08a663347ef21614b96f92f60f4de57a502db73c/axel/axel.py#L354-L358 | train | Calculates the maximum number of threads that will be started |
axel-events/axel | axel/axel.py | Event._error | def _error(self, exc_info):
""" Retrieves the error info """
if self.exc_info:
if self.traceback:
return exc_info
return exc_info[:2]
return exc_info[1] | python | def _error(self, exc_info):
""" Retrieves the error info """
if self.exc_info:
if self.traceback:
return exc_info
return exc_info[:2]
return exc_info[1] | [
"def",
"_error",
"(",
"self",
",",
"exc_info",
")",
":",
"if",
"self",
".",
"exc_info",
":",
"if",
"self",
".",
"traceback",
":",
"return",
"exc_info",
"return",
"exc_info",
"[",
":",
"2",
"]",
"return",
"exc_info",
"[",
"1",
"]"
] | Retrieves the error info | [
"Retrieves",
"the",
"error",
"info"
] | 08a663347ef21614b96f92f60f4de57a502db73c | https://github.com/axel-events/axel/blob/08a663347ef21614b96f92f60f4de57a502db73c/axel/axel.py#L360-L366 | train | Returns the error info from the exception info. |
azogue/i2csense | i2csense/htu21d.py | HTU21D.update | def update(self):
"""Read raw data and calculate temperature and humidity."""
if not self._ok:
self.log_error("Trying to restore OK mode w/ soft reset")
self._ok = self._soft_reset()
try:
self._bus.write_byte(self._i2c_add, CMD_READ_TEMP_NOHOLD)
sl... | python | def update(self):
"""Read raw data and calculate temperature and humidity."""
if not self._ok:
self.log_error("Trying to restore OK mode w/ soft reset")
self._ok = self._soft_reset()
try:
self._bus.write_byte(self._i2c_add, CMD_READ_TEMP_NOHOLD)
sl... | [
"def",
"update",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_ok",
":",
"self",
".",
"log_error",
"(",
"\"Trying to restore OK mode w/ soft reset\"",
")",
"self",
".",
"_ok",
"=",
"self",
".",
"_soft_reset",
"(",
")",
"try",
":",
"self",
".",
"_bus... | Read raw data and calculate temperature and humidity. | [
"Read",
"raw",
"data",
"and",
"calculate",
"temperature",
"and",
"humidity",
"."
] | ecc6806dcee9de827a5414a9e836d271fedca9b9 | https://github.com/azogue/i2csense/blob/ecc6806dcee9de827a5414a9e836d271fedca9b9/i2csense/htu21d.py#L87-L126 | train | Read raw data and calculate temperature and humidity. |
reanahub/reana-db | reana_db/models.py | Workflow.get_owner_access_token | def get_owner_access_token(self):
"""Return workflow owner access token."""
from .database import Session
db_session = Session.object_session(self)
owner = db_session.query(User).filter_by(
id_=self.owner_id).first()
return owner.access_token | python | def get_owner_access_token(self):
"""Return workflow owner access token."""
from .database import Session
db_session = Session.object_session(self)
owner = db_session.query(User).filter_by(
id_=self.owner_id).first()
return owner.access_token | [
"def",
"get_owner_access_token",
"(",
"self",
")",
":",
"from",
".",
"database",
"import",
"Session",
"db_session",
"=",
"Session",
".",
"object_session",
"(",
"self",
")",
"owner",
"=",
"db_session",
".",
"query",
"(",
"User",
")",
".",
"filter_by",
"(",
... | Return workflow owner access token. | [
"Return",
"workflow",
"owner",
"access",
"token",
"."
] | 4efcb46d23af035689964d8c25a804c5a8f1dfc3 | https://github.com/reanahub/reana-db/blob/4efcb46d23af035689964d8c25a804c5a8f1dfc3/reana_db/models.py#L167-L173 | train | Return workflow owner access token. |
reanahub/reana-db | reana_db/models.py | Workflow.update_workflow_status | def update_workflow_status(db_session, workflow_uuid, status,
new_logs='', message=None):
"""Update database workflow status.
:param workflow_uuid: UUID which represents the workflow.
:param status: String that represents the workflow status.
:param new_lo... | python | def update_workflow_status(db_session, workflow_uuid, status,
new_logs='', message=None):
"""Update database workflow status.
:param workflow_uuid: UUID which represents the workflow.
:param status: String that represents the workflow status.
:param new_lo... | [
"def",
"update_workflow_status",
"(",
"db_session",
",",
"workflow_uuid",
",",
"status",
",",
"new_logs",
"=",
"''",
",",
"message",
"=",
"None",
")",
":",
"try",
":",
"workflow",
"=",
"db_session",
".",
"query",
"(",
"Workflow",
")",
".",
"filter_by",
"("... | Update database workflow status.
:param workflow_uuid: UUID which represents the workflow.
:param status: String that represents the workflow status.
:param new_logs: New logs from workflow execution.
:param message: Unused. | [
"Update",
"database",
"workflow",
"status",
"."
] | 4efcb46d23af035689964d8c25a804c5a8f1dfc3 | https://github.com/reanahub/reana-db/blob/4efcb46d23af035689964d8c25a804c5a8f1dfc3/reana_db/models.py#L176-L198 | train | Update database workflow status. |
bacher09/xrcon | xrcon/utils.py | parse_server_addr | def parse_server_addr(str_addr, default_port=26000):
"""Parse address and returns host and port
Args:
str_addr --- string that contains server ip or hostname and optionaly
port
Returns: tuple (host, port)
Examples:
>>> parse_server_addr('127.0.0.1:26006')
('127.0.0.1', 26006)... | python | def parse_server_addr(str_addr, default_port=26000):
"""Parse address and returns host and port
Args:
str_addr --- string that contains server ip or hostname and optionaly
port
Returns: tuple (host, port)
Examples:
>>> parse_server_addr('127.0.0.1:26006')
('127.0.0.1', 26006)... | [
"def",
"parse_server_addr",
"(",
"str_addr",
",",
"default_port",
"=",
"26000",
")",
":",
"m",
"=",
"ADDR_STR_RE",
".",
"match",
"(",
"str_addr",
")",
"if",
"m",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Bad address string \"{0}\"'",
".",
"format",
"(... | Parse address and returns host and port
Args:
str_addr --- string that contains server ip or hostname and optionaly
port
Returns: tuple (host, port)
Examples:
>>> parse_server_addr('127.0.0.1:26006')
('127.0.0.1', 26006)
>>> parse_server_addr('[2001:db8:85a3:8d3:1319:8a2e:370... | [
"Parse",
"address",
"and",
"returns",
"host",
"and",
"port"
] | 6a883f780265cbca31af7a379dc7cb28fdd8b73f | https://github.com/bacher09/xrcon/blob/6a883f780265cbca31af7a379dc7cb28fdd8b73f/xrcon/utils.py#L103-L142 | train | Parse server address and return host and port |
pyQode/pyqode.cobol | pyqode/cobol/modes/goto.py | GoToDefinitionMode.on_state_changed | def on_state_changed(self, state):
"""
Connects/disconnects slots to/from signals when the mode state
changed.
"""
super(GoToDefinitionMode, self).on_state_changed(state)
if state:
self.editor.mouse_moved.connect(self._on_mouse_moved)
self.editor.m... | python | def on_state_changed(self, state):
"""
Connects/disconnects slots to/from signals when the mode state
changed.
"""
super(GoToDefinitionMode, self).on_state_changed(state)
if state:
self.editor.mouse_moved.connect(self._on_mouse_moved)
self.editor.m... | [
"def",
"on_state_changed",
"(",
"self",
",",
"state",
")",
":",
"super",
"(",
"GoToDefinitionMode",
",",
"self",
")",
".",
"on_state_changed",
"(",
"state",
")",
"if",
"state",
":",
"self",
".",
"editor",
".",
"mouse_moved",
".",
"connect",
"(",
"self",
... | Connects/disconnects slots to/from signals when the mode state
changed. | [
"Connects",
"/",
"disconnects",
"slots",
"to",
"/",
"from",
"signals",
"when",
"the",
"mode",
"state",
"changed",
"."
] | eedae4e320a4b2d0c44abb2c3061091321648fb7 | https://github.com/pyQode/pyqode.cobol/blob/eedae4e320a4b2d0c44abb2c3061091321648fb7/pyqode/cobol/modes/goto.py#L29-L46 | train | Connects and disconnects slots to and from signals when the mode state has changed. |
pyQode/pyqode.cobol | pyqode/cobol/modes/goto.py | GoToDefinitionMode._on_mouse_moved | def _on_mouse_moved(self, event):
""" mouse moved callback """
if event.modifiers() & Qt.ControlModifier:
self._select_word_under_mouse_cursor()
else:
self._remove_decoration()
self.editor.set_mouse_cursor(Qt.IBeamCursor)
self._previous_cursor_star... | python | def _on_mouse_moved(self, event):
""" mouse moved callback """
if event.modifiers() & Qt.ControlModifier:
self._select_word_under_mouse_cursor()
else:
self._remove_decoration()
self.editor.set_mouse_cursor(Qt.IBeamCursor)
self._previous_cursor_star... | [
"def",
"_on_mouse_moved",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"modifiers",
"(",
")",
"&",
"Qt",
".",
"ControlModifier",
":",
"self",
".",
"_select_word_under_mouse_cursor",
"(",
")",
"else",
":",
"self",
".",
"_remove_decoration",
"(",
... | mouse moved callback | [
"mouse",
"moved",
"callback"
] | eedae4e320a4b2d0c44abb2c3061091321648fb7 | https://github.com/pyQode/pyqode.cobol/blob/eedae4e320a4b2d0c44abb2c3061091321648fb7/pyqode/cobol/modes/goto.py#L58-L66 | train | mouse moved callback |
pyQode/pyqode.cobol | pyqode/cobol/modes/goto.py | GoToDefinitionMode._add_decoration | def _add_decoration(self, cursor):
"""
Adds a decoration for the word under ``cursor``.
"""
if self.select_word(cursor):
self.editor.set_mouse_cursor(Qt.PointingHandCursor)
else:
self.editor.set_mouse_cursor(Qt.IBeamCursor) | python | def _add_decoration(self, cursor):
"""
Adds a decoration for the word under ``cursor``.
"""
if self.select_word(cursor):
self.editor.set_mouse_cursor(Qt.PointingHandCursor)
else:
self.editor.set_mouse_cursor(Qt.IBeamCursor) | [
"def",
"_add_decoration",
"(",
"self",
",",
"cursor",
")",
":",
"if",
"self",
".",
"select_word",
"(",
"cursor",
")",
":",
"self",
".",
"editor",
".",
"set_mouse_cursor",
"(",
"Qt",
".",
"PointingHandCursor",
")",
"else",
":",
"self",
".",
"editor",
".",... | Adds a decoration for the word under ``cursor``. | [
"Adds",
"a",
"decoration",
"for",
"the",
"word",
"under",
"cursor",
"."
] | eedae4e320a4b2d0c44abb2c3061091321648fb7 | https://github.com/pyQode/pyqode.cobol/blob/eedae4e320a4b2d0c44abb2c3061091321648fb7/pyqode/cobol/modes/goto.py#L105-L112 | train | Adds a decoration for the word under cursor. |
pyQode/pyqode.cobol | pyqode/cobol/modes/goto.py | GoToDefinitionMode.request_goto | def request_goto(self, tc=None):
"""
Request a go to assignment.
:param tc: Text cursor which contains the text that we must look for
its assignment. Can be None to go to the text that is under
the text cursor.
:type tc: QtGui.QTextCursor
""... | python | def request_goto(self, tc=None):
"""
Request a go to assignment.
:param tc: Text cursor which contains the text that we must look for
its assignment. Can be None to go to the text that is under
the text cursor.
:type tc: QtGui.QTextCursor
""... | [
"def",
"request_goto",
"(",
"self",
",",
"tc",
"=",
"None",
")",
":",
"if",
"not",
"tc",
":",
"tc",
"=",
"TextHelper",
"(",
"self",
".",
"editor",
")",
".",
"word_under_cursor",
"(",
"select_whole_word",
"=",
"True",
")",
"if",
"not",
"self",
".",
"_... | Request a go to assignment.
:param tc: Text cursor which contains the text that we must look for
its assignment. Can be None to go to the text that is under
the text cursor.
:type tc: QtGui.QTextCursor | [
"Request",
"a",
"go",
"to",
"assignment",
"."
] | eedae4e320a4b2d0c44abb2c3061091321648fb7 | https://github.com/pyQode/pyqode.cobol/blob/eedae4e320a4b2d0c44abb2c3061091321648fb7/pyqode/cobol/modes/goto.py#L122-L137 | train | Request a go to assignment. |
jasonrbriggs/proton | python/proton/template.py | get_template | def get_template(name):
"""
Return a copy of the template with the specified name. If not found, or an error occurs
during the load, return None.
"""
path = os.path.join(base_dir, name)
if path not in templates:
try:
templates[path] = Template(path)
except IOError:
... | python | def get_template(name):
"""
Return a copy of the template with the specified name. If not found, or an error occurs
during the load, return None.
"""
path = os.path.join(base_dir, name)
if path not in templates:
try:
templates[path] = Template(path)
except IOError:
... | [
"def",
"get_template",
"(",
"name",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"base_dir",
",",
"name",
")",
"if",
"path",
"not",
"in",
"templates",
":",
"try",
":",
"templates",
"[",
"path",
"]",
"=",
"Template",
"(",
"path",
")",... | Return a copy of the template with the specified name. If not found, or an error occurs
during the load, return None. | [
"Return",
"a",
"copy",
"of",
"the",
"template",
"with",
"the",
"specified",
"name",
".",
"If",
"not",
"found",
"or",
"an",
"error",
"occurs",
"during",
"the",
"load",
"return",
"None",
"."
] | e734734750797ef0caaa1680379e07b86d7a53e3 | https://github.com/jasonrbriggs/proton/blob/e734734750797ef0caaa1680379e07b86d7a53e3/python/proton/template.py#L366-L379 | train | Returns a copy of the template with the specified name. |
jasonrbriggs/proton | python/proton/template.py | Template.check_element | def check_element(self, elem, check_children=False, next_to_elem=None):
"""
Given an element, check its attributes for references to the three proton attributes ('eid', 'aid' and 'rid').
"""
self.__add_element('eid', elem.attribs, self.__element_ids, elem, next_to_elem)
self.__ad... | python | def check_element(self, elem, check_children=False, next_to_elem=None):
"""
Given an element, check its attributes for references to the three proton attributes ('eid', 'aid' and 'rid').
"""
self.__add_element('eid', elem.attribs, self.__element_ids, elem, next_to_elem)
self.__ad... | [
"def",
"check_element",
"(",
"self",
",",
"elem",
",",
"check_children",
"=",
"False",
",",
"next_to_elem",
"=",
"None",
")",
":",
"self",
".",
"__add_element",
"(",
"'eid'",
",",
"elem",
".",
"attribs",
",",
"self",
".",
"__element_ids",
",",
"elem",
",... | Given an element, check its attributes for references to the three proton attributes ('eid', 'aid' and 'rid'). | [
"Given",
"an",
"element",
"check",
"its",
"attributes",
"for",
"references",
"to",
"the",
"three",
"proton",
"attributes",
"(",
"eid",
"aid",
"and",
"rid",
")",
"."
] | e734734750797ef0caaa1680379e07b86d7a53e3 | https://github.com/jasonrbriggs/proton/blob/e734734750797ef0caaa1680379e07b86d7a53e3/python/proton/template.py#L183-L192 | train | Checks the attributes of an entry - set entry for references to the three proton attributes. |
jasonrbriggs/proton | python/proton/template.py | Template.set_value | def set_value(self, eid, val, idx='*'):
"""
Set the content of an xml element marked with the matching eid attribute.
"""
if eid in self.__element_ids:
elems = self.__element_ids[eid]
if type(val) in SEQ_TYPES:
idx = 0
if idx == '*':
... | python | def set_value(self, eid, val, idx='*'):
"""
Set the content of an xml element marked with the matching eid attribute.
"""
if eid in self.__element_ids:
elems = self.__element_ids[eid]
if type(val) in SEQ_TYPES:
idx = 0
if idx == '*':
... | [
"def",
"set_value",
"(",
"self",
",",
"eid",
",",
"val",
",",
"idx",
"=",
"'*'",
")",
":",
"if",
"eid",
"in",
"self",
".",
"__element_ids",
":",
"elems",
"=",
"self",
".",
"__element_ids",
"[",
"eid",
"]",
"if",
"type",
"(",
"val",
")",
"in",
"SE... | Set the content of an xml element marked with the matching eid attribute. | [
"Set",
"the",
"content",
"of",
"an",
"xml",
"element",
"marked",
"with",
"the",
"matching",
"eid",
"attribute",
"."
] | e734734750797ef0caaa1680379e07b86d7a53e3 | https://github.com/jasonrbriggs/proton/blob/e734734750797ef0caaa1680379e07b86d7a53e3/python/proton/template.py#L220-L232 | train | Set the content of an xml element marked with the matching eid attribute. |
jasonrbriggs/proton | python/proton/template.py | Template.set_attribute | def set_attribute(self, aid, attrib, val, idx='*'):
"""
Set the value of an xml attribute marked with the matching aid attribute.
"""
if aid in self.__attrib_ids:
elems = self.__attrib_ids[aid]
if idx == '*':
for elem in elems:
... | python | def set_attribute(self, aid, attrib, val, idx='*'):
"""
Set the value of an xml attribute marked with the matching aid attribute.
"""
if aid in self.__attrib_ids:
elems = self.__attrib_ids[aid]
if idx == '*':
for elem in elems:
... | [
"def",
"set_attribute",
"(",
"self",
",",
"aid",
",",
"attrib",
",",
"val",
",",
"idx",
"=",
"'*'",
")",
":",
"if",
"aid",
"in",
"self",
".",
"__attrib_ids",
":",
"elems",
"=",
"self",
".",
"__attrib_ids",
"[",
"aid",
"]",
"if",
"idx",
"==",
"'*'",... | Set the value of an xml attribute marked with the matching aid attribute. | [
"Set",
"the",
"value",
"of",
"an",
"xml",
"attribute",
"marked",
"with",
"the",
"matching",
"aid",
"attribute",
"."
] | e734734750797ef0caaa1680379e07b86d7a53e3 | https://github.com/jasonrbriggs/proton/blob/e734734750797ef0caaa1680379e07b86d7a53e3/python/proton/template.py#L244-L255 | train | Set the value of an attribute in an xml element. |
jasonrbriggs/proton | python/proton/template.py | Template.set_properties | def set_properties(self, eid, value, idx='*'):
"""
Set the value and/or attributes of an xml element, marked with the matching eid attribute, using the
properties of the specified object.
"""
if value.__class__ not in Template.class_cache:
props = []
for n... | python | def set_properties(self, eid, value, idx='*'):
"""
Set the value and/or attributes of an xml element, marked with the matching eid attribute, using the
properties of the specified object.
"""
if value.__class__ not in Template.class_cache:
props = []
for n... | [
"def",
"set_properties",
"(",
"self",
",",
"eid",
",",
"value",
",",
"idx",
"=",
"'*'",
")",
":",
"if",
"value",
".",
"__class__",
"not",
"in",
"Template",
".",
"class_cache",
":",
"props",
"=",
"[",
"]",
"for",
"name",
"in",
"dir",
"(",
"value",
"... | Set the value and/or attributes of an xml element, marked with the matching eid attribute, using the
properties of the specified object. | [
"Set",
"the",
"value",
"and",
"/",
"or",
"attributes",
"of",
"an",
"xml",
"element",
"marked",
"with",
"the",
"matching",
"eid",
"attribute",
"using",
"the",
"properties",
"of",
"the",
"specified",
"object",
"."
] | e734734750797ef0caaa1680379e07b86d7a53e3 | https://github.com/jasonrbriggs/proton/blob/e734734750797ef0caaa1680379e07b86d7a53e3/python/proton/template.py#L262-L277 | train | Set the value and attributes of an xml element marked with the matching eid attribute using the the
properties of the specified object. |
jasonrbriggs/proton | python/proton/template.py | Template.hide | def hide(self, eid, index=0):
"""
Hide the element with the matching eid. If no match, look for an element with a matching rid.
"""
elems = None
if eid in self.__element_ids:
elems = self.__element_ids[eid]
elif eid in self.__repeat_ids:
elems = se... | python | def hide(self, eid, index=0):
"""
Hide the element with the matching eid. If no match, look for an element with a matching rid.
"""
elems = None
if eid in self.__element_ids:
elems = self.__element_ids[eid]
elif eid in self.__repeat_ids:
elems = se... | [
"def",
"hide",
"(",
"self",
",",
"eid",
",",
"index",
"=",
"0",
")",
":",
"elems",
"=",
"None",
"if",
"eid",
"in",
"self",
".",
"__element_ids",
":",
"elems",
"=",
"self",
".",
"__element_ids",
"[",
"eid",
"]",
"elif",
"eid",
"in",
"self",
".",
"... | Hide the element with the matching eid. If no match, look for an element with a matching rid. | [
"Hide",
"the",
"element",
"with",
"the",
"matching",
"eid",
".",
"If",
"no",
"match",
"look",
"for",
"an",
"element",
"with",
"a",
"matching",
"rid",
"."
] | e734734750797ef0caaa1680379e07b86d7a53e3 | https://github.com/jasonrbriggs/proton/blob/e734734750797ef0caaa1680379e07b86d7a53e3/python/proton/template.py#L279-L291 | train | Hide the element with the matching eid. If no match look for an element with the matching rid. If no match look for an element with the matching eid. If no match look for an element with the matching rid. |
jasonrbriggs/proton | python/proton/template.py | Template.repeat | def repeat(self, rid, count, index=0):
"""
Repeat an xml element marked with the matching rid.
"""
elems = None
if rid in self.__repeat_ids:
elems = self.__repeat_ids[rid]
elif rid in self.__element_ids:
elems = self.__element_ids
if elems... | python | def repeat(self, rid, count, index=0):
"""
Repeat an xml element marked with the matching rid.
"""
elems = None
if rid in self.__repeat_ids:
elems = self.__repeat_ids[rid]
elif rid in self.__element_ids:
elems = self.__element_ids
if elems... | [
"def",
"repeat",
"(",
"self",
",",
"rid",
",",
"count",
",",
"index",
"=",
"0",
")",
":",
"elems",
"=",
"None",
"if",
"rid",
"in",
"self",
".",
"__repeat_ids",
":",
"elems",
"=",
"self",
".",
"__repeat_ids",
"[",
"rid",
"]",
"elif",
"rid",
"in",
... | Repeat an xml element marked with the matching rid. | [
"Repeat",
"an",
"xml",
"element",
"marked",
"with",
"the",
"matching",
"rid",
"."
] | e734734750797ef0caaa1680379e07b86d7a53e3 | https://github.com/jasonrbriggs/proton/blob/e734734750797ef0caaa1680379e07b86d7a53e3/python/proton/template.py#L293-L305 | train | Repeat an xml element with the matching rid. |
jasonrbriggs/proton | python/proton/template.py | Template.replace | def replace(self, eid, replacement, index=0):
"""
Replace an xml element marked with the matching eid. If the replacement value is an Element or TextElement,
it's swapped in untouched. If it's a Template, the children of the root element in the template are used.
Otherwise the replacemen... | python | def replace(self, eid, replacement, index=0):
"""
Replace an xml element marked with the matching eid. If the replacement value is an Element or TextElement,
it's swapped in untouched. If it's a Template, the children of the root element in the template are used.
Otherwise the replacemen... | [
"def",
"replace",
"(",
"self",
",",
"eid",
",",
"replacement",
",",
"index",
"=",
"0",
")",
":",
"if",
"eid",
"in",
"self",
".",
"__element_ids",
":",
"elems",
"=",
"self",
".",
"__element_ids",
"[",
"eid",
"]",
"elif",
"eid",
"in",
"self",
".",
"_... | Replace an xml element marked with the matching eid. If the replacement value is an Element or TextElement,
it's swapped in untouched. If it's a Template, the children of the root element in the template are used.
Otherwise the replacement value is wrapped with a TextElement. | [
"Replace",
"an",
"xml",
"element",
"marked",
"with",
"the",
"matching",
"eid",
".",
"If",
"the",
"replacement",
"value",
"is",
"an",
"Element",
"or",
"TextElement",
"it",
"s",
"swapped",
"in",
"untouched",
".",
"If",
"it",
"s",
"a",
"Template",
"the",
"c... | e734734750797ef0caaa1680379e07b86d7a53e3 | https://github.com/jasonrbriggs/proton/blob/e734734750797ef0caaa1680379e07b86d7a53e3/python/proton/template.py#L316-L347 | train | Replace an xml element with the matching eid. |
jpscaletti/authcode | authcode/auth.py | Auth.set_hasher | def set_hasher(self, hash, rounds=None):
"""Updates the has algorithm and, optionally, the number of rounds
to use.
Raises:
`~WrongHashAlgorithm` if new algorithm isn't one of the three
recomended options.
"""
hash = hash.replace('-', '_')
if has... | python | def set_hasher(self, hash, rounds=None):
"""Updates the has algorithm and, optionally, the number of rounds
to use.
Raises:
`~WrongHashAlgorithm` if new algorithm isn't one of the three
recomended options.
"""
hash = hash.replace('-', '_')
if has... | [
"def",
"set_hasher",
"(",
"self",
",",
"hash",
",",
"rounds",
"=",
"None",
")",
":",
"hash",
"=",
"hash",
".",
"replace",
"(",
"'-'",
",",
"'_'",
")",
"if",
"hash",
"not",
"in",
"VALID_HASHERS",
":",
"raise",
"WrongHashAlgorithm",
"(",
"WRONG_HASH_MESSAG... | Updates the has algorithm and, optionally, the number of rounds
to use.
Raises:
`~WrongHashAlgorithm` if new algorithm isn't one of the three
recomended options. | [
"Updates",
"the",
"has",
"algorithm",
"and",
"optionally",
"the",
"number",
"of",
"rounds",
"to",
"use",
"."
] | 91529b6d0caec07d1452758d937e1e0745826139 | https://github.com/jpscaletti/authcode/blob/91529b6d0caec07d1452758d937e1e0745826139/authcode/auth.py#L140-L167 | train | Updates the has algorithm and optionally the number of rounds
to use. |
klmitch/turnstile | turnstile/config.py | Config.get | def get(self, key, default=None):
"""
Retrieve the given configuration option. Configuration
options that can be queried this way are those that are
specified without prefix in the paste.ini file, or which are
specified in the '[turnstile]' section of the configuration
f... | python | def get(self, key, default=None):
"""
Retrieve the given configuration option. Configuration
options that can be queried this way are those that are
specified without prefix in the paste.ini file, or which are
specified in the '[turnstile]' section of the configuration
f... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"default",
"=",
"None",
")",
":",
"return",
"self",
".",
"_config",
".",
"get",
"(",
"None",
",",
"{",
"}",
")",
".",
"get",
"(",
"key",
",",
"default",
")"
] | Retrieve the given configuration option. Configuration
options that can be queried this way are those that are
specified without prefix in the paste.ini file, or which are
specified in the '[turnstile]' section of the configuration
file. Returns the default value (None if not specified... | [
"Retrieve",
"the",
"given",
"configuration",
"option",
".",
"Configuration",
"options",
"that",
"can",
"be",
"queried",
"this",
"way",
"are",
"those",
"that",
"are",
"specified",
"without",
"prefix",
"in",
"the",
"paste",
".",
"ini",
"file",
"or",
"which",
"... | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/config.py#L174-L184 | train | Retrieves the given configuration option. |
klmitch/turnstile | turnstile/config.py | Config.get_database | def get_database(self, override=None):
"""
Convenience function for obtaining a handle to the Redis
database. By default, uses the connection options from the
'[redis]' section. However, if the override parameter is
given, it specifies a section containing overrides for the
... | python | def get_database(self, override=None):
"""
Convenience function for obtaining a handle to the Redis
database. By default, uses the connection options from the
'[redis]' section. However, if the override parameter is
given, it specifies a section containing overrides for the
... | [
"def",
"get_database",
"(",
"self",
",",
"override",
"=",
"None",
")",
":",
"# Grab the database connection arguments",
"redis_args",
"=",
"self",
"[",
"'redis'",
"]",
"# If we have an override, read some overrides from that",
"# section",
"if",
"override",
":",
"redis_ar... | Convenience function for obtaining a handle to the Redis
database. By default, uses the connection options from the
'[redis]' section. However, if the override parameter is
given, it specifies a section containing overrides for the
Redis connection info; the keys will all be prefixed w... | [
"Convenience",
"function",
"for",
"obtaining",
"a",
"handle",
"to",
"the",
"Redis",
"database",
".",
"By",
"default",
"uses",
"the",
"connection",
"options",
"from",
"the",
"[",
"redis",
"]",
"section",
".",
"However",
"if",
"the",
"override",
"parameter",
"... | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/config.py#L186-L225 | train | Returns a redis database handle for the specified RedisCOOKIE. |
klmitch/turnstile | turnstile/config.py | Config.to_bool | def to_bool(value, do_raise=True):
"""Convert a string to a boolean value.
If the string consists of digits, the integer value of the string
is coerced to a boolean value. Otherwise, any of the strings "t",
"true", "on", "y", and "yes" are considered True and any of the
strings... | python | def to_bool(value, do_raise=True):
"""Convert a string to a boolean value.
If the string consists of digits, the integer value of the string
is coerced to a boolean value. Otherwise, any of the strings "t",
"true", "on", "y", and "yes" are considered True and any of the
strings... | [
"def",
"to_bool",
"(",
"value",
",",
"do_raise",
"=",
"True",
")",
":",
"value",
"=",
"value",
".",
"lower",
"(",
")",
"# Try it as an integer",
"if",
"value",
".",
"isdigit",
"(",
")",
":",
"return",
"bool",
"(",
"int",
"(",
"value",
")",
")",
"# OK... | Convert a string to a boolean value.
If the string consists of digits, the integer value of the string
is coerced to a boolean value. Otherwise, any of the strings "t",
"true", "on", "y", and "yes" are considered True and any of the
strings "f", "false", "off", "n", and "no" are consid... | [
"Convert",
"a",
"string",
"to",
"a",
"boolean",
"value",
"."
] | 8fe9a359b45e505d3192ab193ecf9be177ab1a17 | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/config.py#L228-L254 | train | Convert a string to a boolean value. |
BernardFW/bernard | src/bernard/layers/definitions.py | BaseLayer.become | async def become(self, layer_type: Type[L], request: 'Request') -> L:
"""
Transform this layer into another layer type
"""
raise ValueError('Cannot become "{}"'.format(layer_type.__name__)) | python | async def become(self, layer_type: Type[L], request: 'Request') -> L:
"""
Transform this layer into another layer type
"""
raise ValueError('Cannot become "{}"'.format(layer_type.__name__)) | [
"async",
"def",
"become",
"(",
"self",
",",
"layer_type",
":",
"Type",
"[",
"L",
"]",
",",
"request",
":",
"'Request'",
")",
"->",
"L",
":",
"raise",
"ValueError",
"(",
"'Cannot become \"{}\"'",
".",
"format",
"(",
"layer_type",
".",
"__name__",
")",
")"... | Transform this layer into another layer type | [
"Transform",
"this",
"layer",
"into",
"another",
"layer",
"type"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/layers/definitions.py#L75-L80 | train | Transform this layer into another layer type. |
BernardFW/bernard | src/bernard/layers/definitions.py | Text.become | async def become(self, layer_type: Type[L], request: 'Request'):
"""
Transforms the translatable string into an actual string and put it
inside a RawText.
"""
if layer_type != RawText:
super(Text, self).become(layer_type, request)
return RawText(await render(... | python | async def become(self, layer_type: Type[L], request: 'Request'):
"""
Transforms the translatable string into an actual string and put it
inside a RawText.
"""
if layer_type != RawText:
super(Text, self).become(layer_type, request)
return RawText(await render(... | [
"async",
"def",
"become",
"(",
"self",
",",
"layer_type",
":",
"Type",
"[",
"L",
"]",
",",
"request",
":",
"'Request'",
")",
":",
"if",
"layer_type",
"!=",
"RawText",
":",
"super",
"(",
"Text",
",",
"self",
")",
".",
"become",
"(",
"layer_type",
",",... | Transforms the translatable string into an actual string and put it
inside a RawText. | [
"Transforms",
"the",
"translatable",
"string",
"into",
"an",
"actual",
"string",
"and",
"put",
"it",
"inside",
"a",
"RawText",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/layers/definitions.py#L110-L118 | train | Transforms the translatable string into an actual string and put it into a RawText. |
BernardFW/bernard | src/bernard/engine/fsm.py | FSM.health_check | async def health_check(self) -> Iterator[HealthCheckFail]:
"""
Perform the checks. So far:
- Make a list of the unique destination states from the transitions
list, then check the health of each of them.
"""
ds_class = getattr(settings, 'DEFAULT_STATE', '')
fo... | python | async def health_check(self) -> Iterator[HealthCheckFail]:
"""
Perform the checks. So far:
- Make a list of the unique destination states from the transitions
list, then check the health of each of them.
"""
ds_class = getattr(settings, 'DEFAULT_STATE', '')
fo... | [
"async",
"def",
"health_check",
"(",
"self",
")",
"->",
"Iterator",
"[",
"HealthCheckFail",
"]",
":",
"ds_class",
"=",
"getattr",
"(",
"settings",
",",
"'DEFAULT_STATE'",
",",
"''",
")",
"forbidden_defaults",
"=",
"[",
"None",
",",
"''",
",",
"'bernard.engin... | Perform the checks. So far:
- Make a list of the unique destination states from the transitions
list, then check the health of each of them. | [
"Perform",
"the",
"checks",
".",
"So",
"far",
":"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/fsm.py#L92-L132 | train | Checks the health of the states in the states module. |
BernardFW/bernard | src/bernard/engine/fsm.py | FSM._make_register | def _make_register(self) -> BaseRegisterStore:
"""
Make the register storage.
"""
s = settings.REGISTER_STORE
store_class = import_class(s['class'])
return store_class(**s['params']) | python | def _make_register(self) -> BaseRegisterStore:
"""
Make the register storage.
"""
s = settings.REGISTER_STORE
store_class = import_class(s['class'])
return store_class(**s['params']) | [
"def",
"_make_register",
"(",
"self",
")",
"->",
"BaseRegisterStore",
":",
"s",
"=",
"settings",
".",
"REGISTER_STORE",
"store_class",
"=",
"import_class",
"(",
"s",
"[",
"'class'",
"]",
")",
"return",
"store_class",
"(",
"*",
"*",
"s",
"[",
"'params'",
"]... | Make the register storage. | [
"Make",
"the",
"register",
"storage",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/fsm.py#L141-L148 | train | Make the register storage. |
BernardFW/bernard | src/bernard/engine/fsm.py | FSM._make_transitions | def _make_transitions(self) -> List[Transition]:
"""
Load the transitions file.
"""
module_name = settings.TRANSITIONS_MODULE
module_ = importlib.import_module(module_name)
return module_.transitions | python | def _make_transitions(self) -> List[Transition]:
"""
Load the transitions file.
"""
module_name = settings.TRANSITIONS_MODULE
module_ = importlib.import_module(module_name)
return module_.transitions | [
"def",
"_make_transitions",
"(",
"self",
")",
"->",
"List",
"[",
"Transition",
"]",
":",
"module_name",
"=",
"settings",
".",
"TRANSITIONS_MODULE",
"module_",
"=",
"importlib",
".",
"import_module",
"(",
"module_name",
")",
"return",
"module_",
".",
"transitions... | Load the transitions file. | [
"Load",
"the",
"transitions",
"file",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/fsm.py#L150-L157 | train | Load the transitions file and return the list of transitions. |
BernardFW/bernard | src/bernard/engine/fsm.py | FSM._make_allowed_states | def _make_allowed_states(self) -> Iterator[Text]:
"""
Sometimes we load states from the database. In order to avoid loading
an arbitrary class, we list here the state classes that are allowed.
"""
for trans in self.transitions:
yield trans.dest.name()
if... | python | def _make_allowed_states(self) -> Iterator[Text]:
"""
Sometimes we load states from the database. In order to avoid loading
an arbitrary class, we list here the state classes that are allowed.
"""
for trans in self.transitions:
yield trans.dest.name()
if... | [
"def",
"_make_allowed_states",
"(",
"self",
")",
"->",
"Iterator",
"[",
"Text",
"]",
":",
"for",
"trans",
"in",
"self",
".",
"transitions",
":",
"yield",
"trans",
".",
"dest",
".",
"name",
"(",
")",
"if",
"trans",
".",
"origin",
":",
"yield",
"trans",
... | Sometimes we load states from the database. In order to avoid loading
an arbitrary class, we list here the state classes that are allowed. | [
"Sometimes",
"we",
"load",
"states",
"from",
"the",
"database",
".",
"In",
"order",
"to",
"avoid",
"loading",
"an",
"arbitrary",
"class",
"we",
"list",
"here",
"the",
"state",
"classes",
"that",
"are",
"allowed",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/fsm.py#L159-L169 | train | Generate the names of all allowed states. |
BernardFW/bernard | src/bernard/engine/fsm.py | FSM._find_trigger | async def _find_trigger(self,
request: Request,
origin: Optional[Text]=None,
internal: bool=False) \
-> Tuple[
Optional[BaseTrigger],
Optional[Type[BaseState]],
Optional[bool],... | python | async def _find_trigger(self,
request: Request,
origin: Optional[Text]=None,
internal: bool=False) \
-> Tuple[
Optional[BaseTrigger],
Optional[Type[BaseState]],
Optional[bool],... | [
"async",
"def",
"_find_trigger",
"(",
"self",
",",
"request",
":",
"Request",
",",
"origin",
":",
"Optional",
"[",
"Text",
"]",
"=",
"None",
",",
"internal",
":",
"bool",
"=",
"False",
")",
"->",
"Tuple",
"[",
"Optional",
"[",
"BaseTrigger",
"]",
",",
... | Find the best trigger for this request, or go away. | [
"Find",
"the",
"best",
"trigger",
"for",
"this",
"request",
"or",
"go",
"away",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/fsm.py#L171-L203 | train | Find the best trigger for this request or go away. |
BernardFW/bernard | src/bernard/engine/fsm.py | FSM._confused_state | def _confused_state(self, request: Request) -> Type[BaseState]:
"""
If we're confused, find which state to call.
"""
origin = request.register.get(Register.STATE)
if origin in self._allowed_states:
try:
return import_class(origin)
except ... | python | def _confused_state(self, request: Request) -> Type[BaseState]:
"""
If we're confused, find which state to call.
"""
origin = request.register.get(Register.STATE)
if origin in self._allowed_states:
try:
return import_class(origin)
except ... | [
"def",
"_confused_state",
"(",
"self",
",",
"request",
":",
"Request",
")",
"->",
"Type",
"[",
"BaseState",
"]",
":",
"origin",
"=",
"request",
".",
"register",
".",
"get",
"(",
"Register",
".",
"STATE",
")",
"if",
"origin",
"in",
"self",
".",
"_allowe... | If we're confused, find which state to call. | [
"If",
"we",
"re",
"confused",
"find",
"which",
"state",
"to",
"call",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/fsm.py#L206-L219 | train | Find which state to call. |
BernardFW/bernard | src/bernard/engine/fsm.py | FSM._build_state | async def _build_state(self,
request: Request,
message: BaseMessage,
responder: Responder) \
-> Tuple[
Optional[BaseState],
Optional[BaseTrigger],
Optional[bool],
]:
... | python | async def _build_state(self,
request: Request,
message: BaseMessage,
responder: Responder) \
-> Tuple[
Optional[BaseState],
Optional[BaseTrigger],
Optional[bool],
]:
... | [
"async",
"def",
"_build_state",
"(",
"self",
",",
"request",
":",
"Request",
",",
"message",
":",
"BaseMessage",
",",
"responder",
":",
"Responder",
")",
"->",
"Tuple",
"[",
"Optional",
"[",
"BaseState",
"]",
",",
"Optional",
"[",
"BaseTrigger",
"]",
",",
... | Build the state for this request. | [
"Build",
"the",
"state",
"for",
"this",
"request",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/fsm.py#L221-L245 | train | Build the state for this request. |
BernardFW/bernard | src/bernard/engine/fsm.py | FSM._run_state | async def _run_state(self, responder, state, trigger, request) \
-> BaseState:
"""
Execute the state, or if execution fails handle it.
"""
user_trigger = trigger
# noinspection PyBroadException
try:
if trigger:
await state.handle(... | python | async def _run_state(self, responder, state, trigger, request) \
-> BaseState:
"""
Execute the state, or if execution fails handle it.
"""
user_trigger = trigger
# noinspection PyBroadException
try:
if trigger:
await state.handle(... | [
"async",
"def",
"_run_state",
"(",
"self",
",",
"responder",
",",
"state",
",",
"trigger",
",",
"request",
")",
"->",
"BaseState",
":",
"user_trigger",
"=",
"trigger",
"# noinspection PyBroadException",
"try",
":",
"if",
"trigger",
":",
"await",
"state",
".",
... | Execute the state, or if execution fails handle it. | [
"Execute",
"the",
"state",
"or",
"if",
"execution",
"fails",
"handle",
"it",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/fsm.py#L247-L281 | train | Execute the state and handle it. |
BernardFW/bernard | src/bernard/engine/fsm.py | FSM._build_state_register | async def _build_state_register(self,
state: BaseState,
request: Request,
responder: Responder) -> Dict:
"""
Build the next register to store.
- The state is the name of the current s... | python | async def _build_state_register(self,
state: BaseState,
request: Request,
responder: Responder) -> Dict:
"""
Build the next register to store.
- The state is the name of the current s... | [
"async",
"def",
"_build_state_register",
"(",
"self",
",",
"state",
":",
"BaseState",
",",
"request",
":",
"Request",
",",
"responder",
":",
"Responder",
")",
"->",
"Dict",
":",
"return",
"{",
"Register",
".",
"STATE",
":",
"state",
".",
"name",
"(",
")"... | Build the next register to store.
- The state is the name of the current state
- The transition is made by all successive layers present in the
response. | [
"Build",
"the",
"next",
"register",
"to",
"store",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/fsm.py#L283-L299 | train | Builds the next register to store. |
BernardFW/bernard | src/bernard/engine/fsm.py | FSM._handle_message | async def _handle_message(self,
message: BaseMessage,
responder: Responder) -> Optional[Dict]:
"""
Handles a message: find a state and run it.
:return: The register that was saved
"""
async def noop(request: Request, r... | python | async def _handle_message(self,
message: BaseMessage,
responder: Responder) -> Optional[Dict]:
"""
Handles a message: find a state and run it.
:return: The register that was saved
"""
async def noop(request: Request, r... | [
"async",
"def",
"_handle_message",
"(",
"self",
",",
"message",
":",
"BaseMessage",
",",
"responder",
":",
"Responder",
")",
"->",
"Optional",
"[",
"Dict",
"]",
":",
"async",
"def",
"noop",
"(",
"request",
":",
"Request",
",",
"responder",
":",
"Responder"... | Handles a message: find a state and run it.
:return: The register that was saved | [
"Handles",
"a",
"message",
":",
"find",
"a",
"state",
"and",
"run",
"it",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/fsm.py#L301-L368 | train | Handles a message from the broker and runs it. |
BernardFW/bernard | src/bernard/engine/fsm.py | FSM.handle_message | def handle_message(self,
message: BaseMessage,
responder: Responder,
create_task: True):
"""
Public method to handle a message. It requires:
- A message from the platform
- A responder from the platform
... | python | def handle_message(self,
message: BaseMessage,
responder: Responder,
create_task: True):
"""
Public method to handle a message. It requires:
- A message from the platform
- A responder from the platform
... | [
"def",
"handle_message",
"(",
"self",
",",
"message",
":",
"BaseMessage",
",",
"responder",
":",
"Responder",
",",
"create_task",
":",
"True",
")",
":",
"coro",
"=",
"self",
".",
"_handle_message",
"(",
"message",
",",
"responder",
")",
"if",
"create_task",
... | Public method to handle a message. It requires:
- A message from the platform
- A responder from the platform
If `create_task` is true, them the task will automatically be added to
the loop. However, if it is not, the coroutine will be returned and it
will be the respon... | [
"Public",
"method",
"to",
"handle",
"a",
"message",
".",
"It",
"requires",
":"
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/engine/fsm.py#L370-L391 | train | This method handles a message from the platform and returns a coroutine that will be executed when the message is received. |
kata198/python-subprocess2 | subprocess2/simple.py | Simple.runGetResults | def runGetResults(cmd, stdout=True, stderr=True, encoding=sys.getdefaultencoding()):
'''
runGetResults - Simple method to run a command and return the results of the execution as a dict.
@param cmd <str/list> - String of command and arguments, or list of command and arguments
... | python | def runGetResults(cmd, stdout=True, stderr=True, encoding=sys.getdefaultencoding()):
'''
runGetResults - Simple method to run a command and return the results of the execution as a dict.
@param cmd <str/list> - String of command and arguments, or list of command and arguments
... | [
"def",
"runGetResults",
"(",
"cmd",
",",
"stdout",
"=",
"True",
",",
"stderr",
"=",
"True",
",",
"encoding",
"=",
"sys",
".",
"getdefaultencoding",
"(",
")",
")",
":",
"if",
"stderr",
"in",
"(",
"'stdout'",
",",
"subprocess",
".",
"STDOUT",
")",
":",
... | runGetResults - Simple method to run a command and return the results of the execution as a dict.
@param cmd <str/list> - String of command and arguments, or list of command and arguments
If cmd is a string, the command will be executed as if ran exactly as written in a shell. This mode su... | [
"runGetResults",
"-",
"Simple",
"method",
"to",
"run",
"a",
"command",
"and",
"return",
"the",
"results",
"of",
"the",
"execution",
"as",
"a",
"dict",
"."
] | 8544b0b651d8e14de9fdd597baa704182e248b01 | https://github.com/kata198/python-subprocess2/blob/8544b0b651d8e14de9fdd597baa704182e248b01/subprocess2/simple.py#L31-L144 | train | This method is used to run a command and return the results of the execution as a dict. |
kata198/python-subprocess2 | subprocess2/simple.py | Simple.runGetOutput | def runGetOutput(cmd, raiseOnFailure=False, encoding=sys.getdefaultencoding()):
'''
runGetOutput - Simply runs a command and returns the output as a string. Use #runGetResults if you need something more complex.
@param cmd <str/list> - String of command and arguments, or list of command... | python | def runGetOutput(cmd, raiseOnFailure=False, encoding=sys.getdefaultencoding()):
'''
runGetOutput - Simply runs a command and returns the output as a string. Use #runGetResults if you need something more complex.
@param cmd <str/list> - String of command and arguments, or list of command... | [
"def",
"runGetOutput",
"(",
"cmd",
",",
"raiseOnFailure",
"=",
"False",
",",
"encoding",
"=",
"sys",
".",
"getdefaultencoding",
"(",
")",
")",
":",
"results",
"=",
"Simple",
".",
"runGetResults",
"(",
"cmd",
",",
"stdout",
"=",
"True",
",",
"stderr",
"="... | runGetOutput - Simply runs a command and returns the output as a string. Use #runGetResults if you need something more complex.
@param cmd <str/list> - String of command and arguments, or list of command and arguments
If cmd is a string, the command will be executed as if ran exactly as wr... | [
"runGetOutput",
"-",
"Simply",
"runs",
"a",
"command",
"and",
"returns",
"the",
"output",
"as",
"a",
"string",
".",
"Use",
"#runGetResults",
"if",
"you",
"need",
"something",
"more",
"complex",
"."
] | 8544b0b651d8e14de9fdd597baa704182e248b01 | https://github.com/kata198/python-subprocess2/blob/8544b0b651d8e14de9fdd597baa704182e248b01/subprocess2/simple.py#L147-L193 | train | Runs a command and returns the output of the command. |
BernardFW/bernard | src/bernard/storage/context/base.py | create_context_store | def create_context_store(name='default',
ttl=settings.CONTEXT_DEFAULT_TTL,
store=settings.CONTEXT_STORE) -> 'BaseContextStore':
"""
Create a context store. By default using the default configured context
store, but you can use a custom class if you want to u... | python | def create_context_store(name='default',
ttl=settings.CONTEXT_DEFAULT_TTL,
store=settings.CONTEXT_STORE) -> 'BaseContextStore':
"""
Create a context store. By default using the default configured context
store, but you can use a custom class if you want to u... | [
"def",
"create_context_store",
"(",
"name",
"=",
"'default'",
",",
"ttl",
"=",
"settings",
".",
"CONTEXT_DEFAULT_TTL",
",",
"store",
"=",
"settings",
".",
"CONTEXT_STORE",
")",
"->",
"'BaseContextStore'",
":",
"store_class",
"=",
"import_class",
"(",
"store",
"[... | Create a context store. By default using the default configured context
store, but you can use a custom class if you want to using the `store`
setting.
The time to live of each store (aka there is one per conversation) is
defined by the `ttl` value, which is also inferred by default from the
config... | [
"Create",
"a",
"context",
"store",
".",
"By",
"default",
"using",
"the",
"default",
"configured",
"context",
"store",
"but",
"you",
"can",
"use",
"a",
"custom",
"class",
"if",
"you",
"want",
"to",
"using",
"the",
"store",
"setting",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/storage/context/base.py#L34-L68 | train | Create a new context store. |
BernardFW/bernard | src/bernard/storage/context/base.py | BaseContextStore.inject | def inject(self,
require: Optional[List[Text]] = None,
fail: Text = 'missing_context',
var_name: Text = 'context'):
"""
This is a decorator intended to be used on states (and actually only
work on state handlers).
The `require` argument is a ... | python | def inject(self,
require: Optional[List[Text]] = None,
fail: Text = 'missing_context',
var_name: Text = 'context'):
"""
This is a decorator intended to be used on states (and actually only
work on state handlers).
The `require` argument is a ... | [
"def",
"inject",
"(",
"self",
",",
"require",
":",
"Optional",
"[",
"List",
"[",
"Text",
"]",
"]",
"=",
"None",
",",
"fail",
":",
"Text",
"=",
"'missing_context'",
",",
"var_name",
":",
"Text",
"=",
"'context'",
")",
":",
"def",
"decorator",
"(",
"fu... | This is a decorator intended to be used on states (and actually only
work on state handlers).
The `require` argument is a list of keys to be checked in the context.
If at least one of them is missing, then instead of calling the handler
another method will be called. By default the meth... | [
"This",
"is",
"a",
"decorator",
"intended",
"to",
"be",
"used",
"on",
"states",
"(",
"and",
"actually",
"only",
"work",
"on",
"state",
"handlers",
")",
"."
] | 9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/storage/context/base.py#L125-L173 | train | Decorator for state handlers that checks the state s context and injects it into the handler. |
AlejandroFrias/case-conversion | case_conversion/case_conversion.py | camelcase | def camelcase(text, acronyms=None):
"""Return text in camelCase style.
Args:
text: input string to convert case
detect_acronyms: should attempt to detect acronyms
acronyms: a list of acronyms to detect
>>> camelcase("hello world")
'helloWorld'
>>> camelcase("HELLO_HTML_WORL... | python | def camelcase(text, acronyms=None):
"""Return text in camelCase style.
Args:
text: input string to convert case
detect_acronyms: should attempt to detect acronyms
acronyms: a list of acronyms to detect
>>> camelcase("hello world")
'helloWorld'
>>> camelcase("HELLO_HTML_WORL... | [
"def",
"camelcase",
"(",
"text",
",",
"acronyms",
"=",
"None",
")",
":",
"words",
",",
"_case",
",",
"_sep",
"=",
"case_parse",
".",
"parse_case",
"(",
"text",
",",
"acronyms",
")",
"if",
"words",
":",
"words",
"[",
"0",
"]",
"=",
"words",
"[",
"0"... | Return text in camelCase style.
Args:
text: input string to convert case
detect_acronyms: should attempt to detect acronyms
acronyms: a list of acronyms to detect
>>> camelcase("hello world")
'helloWorld'
>>> camelcase("HELLO_HTML_WORLD", True, ["HTML"])
'helloHTMLWorld' | [
"Return",
"text",
"in",
"camelCase",
"style",
"."
] | 79ebce1403fbdac949b2da21b8f6fbe3234ddb31 | https://github.com/AlejandroFrias/case-conversion/blob/79ebce1403fbdac949b2da21b8f6fbe3234ddb31/case_conversion/case_conversion.py#L13-L29 | train | Return text in camelCase style. |
AlejandroFrias/case-conversion | case_conversion/case_conversion.py | pascalcase | def pascalcase(text, acronyms=None):
"""Return text in PascalCase style (aka MixedCase).
Args:
text: input string to convert case
detect_acronyms: should attempt to detect acronyms
acronyms: a list of acronyms to detect
>>> pascalcase("hello world")
'HelloWorld'
>>> pascalc... | python | def pascalcase(text, acronyms=None):
"""Return text in PascalCase style (aka MixedCase).
Args:
text: input string to convert case
detect_acronyms: should attempt to detect acronyms
acronyms: a list of acronyms to detect
>>> pascalcase("hello world")
'HelloWorld'
>>> pascalc... | [
"def",
"pascalcase",
"(",
"text",
",",
"acronyms",
"=",
"None",
")",
":",
"words",
",",
"_case",
",",
"_sep",
"=",
"case_parse",
".",
"parse_case",
"(",
"text",
",",
"acronyms",
")",
"return",
"''",
".",
"join",
"(",
"words",
")"
] | Return text in PascalCase style (aka MixedCase).
Args:
text: input string to convert case
detect_acronyms: should attempt to detect acronyms
acronyms: a list of acronyms to detect
>>> pascalcase("hello world")
'HelloWorld'
>>> pascalcase("HELLO_HTML_WORLD", True, ["HTML"])
... | [
"Return",
"text",
"in",
"PascalCase",
"style",
"(",
"aka",
"MixedCase",
")",
"."
] | 79ebce1403fbdac949b2da21b8f6fbe3234ddb31 | https://github.com/AlejandroFrias/case-conversion/blob/79ebce1403fbdac949b2da21b8f6fbe3234ddb31/case_conversion/case_conversion.py#L32-L46 | train | Return text in PascalCase style. |
AlejandroFrias/case-conversion | case_conversion/case_conversion.py | constcase | def constcase(text, acronyms=None):
"""Return text in CONST_CASE style (aka SCREAMING_SNAKE_CASE).
Args:
text: input string to convert case
detect_acronyms: should attempt to detect acronyms
acronyms: a list of acronyms to detect
>>> constcase("hello world")
'HELLO_WORLD'
>... | python | def constcase(text, acronyms=None):
"""Return text in CONST_CASE style (aka SCREAMING_SNAKE_CASE).
Args:
text: input string to convert case
detect_acronyms: should attempt to detect acronyms
acronyms: a list of acronyms to detect
>>> constcase("hello world")
'HELLO_WORLD'
>... | [
"def",
"constcase",
"(",
"text",
",",
"acronyms",
"=",
"None",
")",
":",
"words",
",",
"_case",
",",
"_sep",
"=",
"case_parse",
".",
"parse_case",
"(",
"text",
",",
"acronyms",
")",
"return",
"'_'",
".",
"join",
"(",
"[",
"w",
".",
"upper",
"(",
")... | Return text in CONST_CASE style (aka SCREAMING_SNAKE_CASE).
Args:
text: input string to convert case
detect_acronyms: should attempt to detect acronyms
acronyms: a list of acronyms to detect
>>> constcase("hello world")
'HELLO_WORLD'
>>> constcase("helloHTMLWorld", True, ["HTML... | [
"Return",
"text",
"in",
"CONST_CASE",
"style",
"(",
"aka",
"SCREAMING_SNAKE_CASE",
")",
"."
] | 79ebce1403fbdac949b2da21b8f6fbe3234ddb31 | https://github.com/AlejandroFrias/case-conversion/blob/79ebce1403fbdac949b2da21b8f6fbe3234ddb31/case_conversion/case_conversion.py#L115-L129 | train | Return text in CONST_CASE style. |
AlejandroFrias/case-conversion | case_conversion/case_conversion.py | dotcase | def dotcase(text, acronyms=None):
"""Return text in dot.case style.
Args:
text: input string to convert case
detect_acronyms: should attempt to detect acronyms
acronyms: a list of acronyms to detect
>>> dotcase("hello world")
'hello.world'
>>> dotcase("helloHTMLWorld", True... | python | def dotcase(text, acronyms=None):
"""Return text in dot.case style.
Args:
text: input string to convert case
detect_acronyms: should attempt to detect acronyms
acronyms: a list of acronyms to detect
>>> dotcase("hello world")
'hello.world'
>>> dotcase("helloHTMLWorld", True... | [
"def",
"dotcase",
"(",
"text",
",",
"acronyms",
"=",
"None",
")",
":",
"words",
",",
"_case",
",",
"_sep",
"=",
"case_parse",
".",
"parse_case",
"(",
"text",
",",
"acronyms",
")",
"return",
"'.'",
".",
"join",
"(",
"[",
"w",
".",
"lower",
"(",
")",... | Return text in dot.case style.
Args:
text: input string to convert case
detect_acronyms: should attempt to detect acronyms
acronyms: a list of acronyms to detect
>>> dotcase("hello world")
'hello.world'
>>> dotcase("helloHTMLWorld", True, ["HTML"])
'hello.html.world' | [
"Return",
"text",
"in",
"dot",
".",
"case",
"style",
"."
] | 79ebce1403fbdac949b2da21b8f6fbe3234ddb31 | https://github.com/AlejandroFrias/case-conversion/blob/79ebce1403fbdac949b2da21b8f6fbe3234ddb31/case_conversion/case_conversion.py#L148-L162 | train | Return text in dot. case style. |
AlejandroFrias/case-conversion | case_conversion/case_conversion.py | separate_words | def separate_words(text, acronyms=None):
"""Return text in "seperate words" style.
Args:
text: input string to convert case
detect_acronyms: should attempt to detect acronyms
acronyms: a list of acronyms to detect
>>> separate_words("HELLO_WORLD")
'HELLO WORLD'
>>> separate... | python | def separate_words(text, acronyms=None):
"""Return text in "seperate words" style.
Args:
text: input string to convert case
detect_acronyms: should attempt to detect acronyms
acronyms: a list of acronyms to detect
>>> separate_words("HELLO_WORLD")
'HELLO WORLD'
>>> separate... | [
"def",
"separate_words",
"(",
"text",
",",
"acronyms",
"=",
"None",
")",
":",
"words",
",",
"_case",
",",
"_sep",
"=",
"case_parse",
".",
"parse_case",
"(",
"text",
",",
"acronyms",
",",
"preserve_case",
"=",
"True",
")",
"return",
"' '",
".",
"join",
... | Return text in "seperate words" style.
Args:
text: input string to convert case
detect_acronyms: should attempt to detect acronyms
acronyms: a list of acronyms to detect
>>> separate_words("HELLO_WORLD")
'HELLO WORLD'
>>> separate_words("helloHTMLWorld", True, ["HTML"])
'he... | [
"Return",
"text",
"in",
"seperate",
"words",
"style",
"."
] | 79ebce1403fbdac949b2da21b8f6fbe3234ddb31 | https://github.com/AlejandroFrias/case-conversion/blob/79ebce1403fbdac949b2da21b8f6fbe3234ddb31/case_conversion/case_conversion.py#L165-L179 | train | Return text in seperate words style. |
samghelms/mathviz | examples/utils.py | get_next_token | def get_next_token(string):
'''
"eats" up the string until it hits an ending character to get valid leaf expressions.
For example, given \\Phi_{z}(L) = \\sum_{i=1}^{N} \\frac{1}{C_{i} \\times V_{\\rm max, i}},
this function would pull out \\Phi, stopping at _
@ string: str
returns a tuple of (ex... | python | def get_next_token(string):
'''
"eats" up the string until it hits an ending character to get valid leaf expressions.
For example, given \\Phi_{z}(L) = \\sum_{i=1}^{N} \\frac{1}{C_{i} \\times V_{\\rm max, i}},
this function would pull out \\Phi, stopping at _
@ string: str
returns a tuple of (ex... | [
"def",
"get_next_token",
"(",
"string",
")",
":",
"STOP_CHARS",
"=",
"\"_ {}^ \\n ,()=\"",
"UNARY_CHARS",
"=",
"\"^_\"",
"# ^ and _ are valid leaf expressions--just ones that should be handled on their own",
"if",
"string",
"[",
"0",
"]",
"in",
"STOP_CHARS",
":",
"return",
... | "eats" up the string until it hits an ending character to get valid leaf expressions.
For example, given \\Phi_{z}(L) = \\sum_{i=1}^{N} \\frac{1}{C_{i} \\times V_{\\rm max, i}},
this function would pull out \\Phi, stopping at _
@ string: str
returns a tuple of (expression [ex: \\Phi], remaining_chars [e... | [
"eats",
"up",
"the",
"string",
"until",
"it",
"hits",
"an",
"ending",
"character",
"to",
"get",
"valid",
"leaf",
"expressions",
".",
"For",
"example",
"given",
"\\\\",
"Phi_",
"{",
"z",
"}",
"(",
"L",
")",
"=",
"\\\\",
"sum_",
"{",
"i",
"=",
"1",
"... | 30fe89537379faea4de8c8b568ac6e52e4d15353 | https://github.com/samghelms/mathviz/blob/30fe89537379faea4de8c8b568ac6e52e4d15353/examples/utils.py#L14-L35 | train | Returns the next token in the string. |
jstitch/MambuPy | MambuPy/rest/mambucentre.py | MambuCentres.convertDict2Attrs | def convertDict2Attrs(self, *args, **kwargs):
"""The trick for iterable Mambu Objects comes here:
You iterate over each element of the responded List from Mambu,
and create a Mambu Centre object for each one, initializing them
one at a time, and changing the attrs attribute (which just
... | python | def convertDict2Attrs(self, *args, **kwargs):
"""The trick for iterable Mambu Objects comes here:
You iterate over each element of the responded List from Mambu,
and create a Mambu Centre object for each one, initializing them
one at a time, and changing the attrs attribute (which just
... | [
"def",
"convertDict2Attrs",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"n",
",",
"b",
"in",
"enumerate",
"(",
"self",
".",
"attrs",
")",
":",
"# ok ok, I'm modifying elements of a list while iterating it. BAD PRACTICE!",
"try",
":",... | The trick for iterable Mambu Objects comes here:
You iterate over each element of the responded List from Mambu,
and create a Mambu Centre object for each one, initializing them
one at a time, and changing the attrs attribute (which just
holds a list of plain dictionaries) with a MambuC... | [
"The",
"trick",
"for",
"iterable",
"Mambu",
"Objects",
"comes",
"here",
":"
] | 2af98cc12e7ed5ec183b3e97644e880e70b79ee8 | https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambucentre.py#L56-L84 | train | This function converts a list of plain dictionaries into a MambuCentre object. |
jstitch/MambuPy | MambuPy/rest/mamburoles.py | MambuRoles.convertDict2Attrs | def convertDict2Attrs(self, *args, **kwargs):
"""The trick for iterable Mambu Objects comes here:
You iterate over each element of the responded List from Mambu,
and create a Mambu Role (or your own itemclass) object for each
one, initializing them one at a time, and changing the attrs
... | python | def convertDict2Attrs(self, *args, **kwargs):
"""The trick for iterable Mambu Objects comes here:
You iterate over each element of the responded List from Mambu,
and create a Mambu Role (or your own itemclass) object for each
one, initializing them one at a time, and changing the attrs
... | [
"def",
"convertDict2Attrs",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"n",
",",
"u",
"in",
"enumerate",
"(",
"self",
".",
"attrs",
")",
":",
"try",
":",
"params",
"=",
"self",
".",
"params",
"except",
"AttributeError",
... | The trick for iterable Mambu Objects comes here:
You iterate over each element of the responded List from Mambu,
and create a Mambu Role (or your own itemclass) object for each
one, initializing them one at a time, and changing the attrs
attribute (which just holds a list of plain dicti... | [
"The",
"trick",
"for",
"iterable",
"Mambu",
"Objects",
"comes",
"here",
":"
] | 2af98cc12e7ed5ec183b3e97644e880e70b79ee8 | https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mamburoles.py#L76-L97 | train | This function converts a list of plain dictionaries into a list of Mambu User objects. |
reanahub/reana-db | reana_db/database.py | init_db | def init_db():
"""Initialize the DB."""
import reana_db.models
if not database_exists(engine.url):
create_database(engine.url)
Base.metadata.create_all(bind=engine) | python | def init_db():
"""Initialize the DB."""
import reana_db.models
if not database_exists(engine.url):
create_database(engine.url)
Base.metadata.create_all(bind=engine) | [
"def",
"init_db",
"(",
")",
":",
"import",
"reana_db",
".",
"models",
"if",
"not",
"database_exists",
"(",
"engine",
".",
"url",
")",
":",
"create_database",
"(",
"engine",
".",
"url",
")",
"Base",
".",
"metadata",
".",
"create_all",
"(",
"bind",
"=",
... | Initialize the DB. | [
"Initialize",
"the",
"DB",
"."
] | 4efcb46d23af035689964d8c25a804c5a8f1dfc3 | https://github.com/reanahub/reana-db/blob/4efcb46d23af035689964d8c25a804c5a8f1dfc3/reana_db/database.py#L28-L33 | train | Initialize the DB. |
greenelab/PathCORE-T | pathcore/network.py | _load_significant_pathways_file | def _load_significant_pathways_file(path_to_file):
"""Read in the significant pathways file as a
pandas.DataFrame.
"""
feature_pathway_df = pd.read_table(
path_to_file, header=0,
usecols=["feature", "side", "pathway"])
feature_pathway_df = feature_pathway_df.sort_values(
by=[... | python | def _load_significant_pathways_file(path_to_file):
"""Read in the significant pathways file as a
pandas.DataFrame.
"""
feature_pathway_df = pd.read_table(
path_to_file, header=0,
usecols=["feature", "side", "pathway"])
feature_pathway_df = feature_pathway_df.sort_values(
by=[... | [
"def",
"_load_significant_pathways_file",
"(",
"path_to_file",
")",
":",
"feature_pathway_df",
"=",
"pd",
".",
"read_table",
"(",
"path_to_file",
",",
"header",
"=",
"0",
",",
"usecols",
"=",
"[",
"\"feature\"",
",",
"\"side\"",
",",
"\"pathway\"",
"]",
")",
"... | Read in the significant pathways file as a
pandas.DataFrame. | [
"Read",
"in",
"the",
"significant",
"pathways",
"file",
"as",
"a",
"pandas",
".",
"DataFrame",
"."
] | 9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c | https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/network.py#L552-L561 | train | Read in the significant pathways file as a
pandas. DataFrame. |
greenelab/PathCORE-T | pathcore/network.py | _pathway_feature_permutation | def _pathway_feature_permutation(pathway_feature_tuples,
permutation_max_iters):
"""Permute the pathways across features for one side in the
network. Used in `permute_pathways_across_features`
Parameters
-----------
pathway_feature_tuples : list(tup(str, int))
... | python | def _pathway_feature_permutation(pathway_feature_tuples,
permutation_max_iters):
"""Permute the pathways across features for one side in the
network. Used in `permute_pathways_across_features`
Parameters
-----------
pathway_feature_tuples : list(tup(str, int))
... | [
"def",
"_pathway_feature_permutation",
"(",
"pathway_feature_tuples",
",",
"permutation_max_iters",
")",
":",
"pathways",
",",
"features",
"=",
"[",
"list",
"(",
"elements_at_position",
")",
"for",
"elements_at_position",
"in",
"zip",
"(",
"*",
"pathway_feature_tuples",... | Permute the pathways across features for one side in the
network. Used in `permute_pathways_across_features`
Parameters
-----------
pathway_feature_tuples : list(tup(str, int))
a tuple list [(pathway, feature)] where the pathway, feature pairing
indicates that a pathway was overrepresented ... | [
"Permute",
"the",
"pathways",
"across",
"features",
"for",
"one",
"side",
"in",
"the",
"network",
".",
"Used",
"in",
"permute_pathways_across_features"
] | 9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c | https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/network.py#L568-L652 | train | Permute the pathways across features for one side in the system. Used in _permute_pathways_across_features. |
greenelab/PathCORE-T | pathcore/network.py | _permutation_correctness | def _permutation_correctness(pathway_feature_tuples, original):
"""Determine whether the generated permutation is a valid permutation.
Used in `permute_pathways_across_features`.
(Cannot be identical to the original significant pathways list,
and a feature should map to a distinct set of pathways.)
... | python | def _permutation_correctness(pathway_feature_tuples, original):
"""Determine whether the generated permutation is a valid permutation.
Used in `permute_pathways_across_features`.
(Cannot be identical to the original significant pathways list,
and a feature should map to a distinct set of pathways.)
... | [
"def",
"_permutation_correctness",
"(",
"pathway_feature_tuples",
",",
"original",
")",
":",
"if",
"pathway_feature_tuples",
":",
"if",
"set",
"(",
"pathway_feature_tuples",
")",
"==",
"set",
"(",
"original",
")",
":",
"return",
"False",
"pathways_in_feature",
"=",
... | Determine whether the generated permutation is a valid permutation.
Used in `permute_pathways_across_features`.
(Cannot be identical to the original significant pathways list,
and a feature should map to a distinct set of pathways.) | [
"Determine",
"whether",
"the",
"generated",
"permutation",
"is",
"a",
"valid",
"permutation",
".",
"Used",
"in",
"permute_pathways_across_features",
".",
"(",
"Cannot",
"be",
"identical",
"to",
"the",
"original",
"significant",
"pathways",
"list",
"and",
"a",
"fea... | 9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c | https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/network.py#L655-L672 | train | Determine whether the generated permutation is a valid permutation. |
greenelab/PathCORE-T | pathcore/network.py | Edge.connected_to | def connected_to(self, vertex_id):
"""
Parameters
-----------
vertex_id : int
Get what `vertex_id` is connected to.
Returns
-----------
int|None, the vertex id connected to the
input `vertex_id` in this edge, as long as `vertex_id` is
... | python | def connected_to(self, vertex_id):
"""
Parameters
-----------
vertex_id : int
Get what `vertex_id` is connected to.
Returns
-----------
int|None, the vertex id connected to the
input `vertex_id` in this edge, as long as `vertex_id` is
... | [
"def",
"connected_to",
"(",
"self",
",",
"vertex_id",
")",
":",
"if",
"vertex_id",
"not",
"in",
"self",
".",
"edge",
":",
"return",
"None",
"connected_to",
"=",
"(",
"self",
".",
"edge",
"[",
"1",
"]",
"if",
"self",
".",
"edge",
"[",
"0",
"]",
"=="... | Parameters
-----------
vertex_id : int
Get what `vertex_id` is connected to.
Returns
-----------
int|None, the vertex id connected to the
input `vertex_id` in this edge, as long as `vertex_id` is
one of the vertices connected by this edge. | [
"Parameters",
"-----------",
"vertex_id",
":",
"int",
"Get",
"what",
"vertex_id",
"is",
"connected",
"to",
"."
] | 9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c | https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/network.py#L59-L76 | train | Return the entry point id that is connected to the given vertex_id. |
greenelab/PathCORE-T | pathcore/network.py | CoNetwork.read_network_file | def read_network_file(self, path_to_network_file):
"""
Parameters
-----------
path_to_network_file : str
Expects a network file with columns "pw0" and "pw1." A "features"
column that specifies the features where the (pw0, pw1) edge is
present will assign a w... | python | def read_network_file(self, path_to_network_file):
"""
Parameters
-----------
path_to_network_file : str
Expects a network file with columns "pw0" and "pw1." A "features"
column that specifies the features where the (pw0, pw1) edge is
present will assign a w... | [
"def",
"read_network_file",
"(",
"self",
",",
"path_to_network_file",
")",
":",
"network_df",
"=",
"pd",
".",
"read_table",
"(",
"path_to_network_file",
")",
"network_edges",
"=",
"{",
"}",
"for",
"_",
",",
"row",
"in",
"network_df",
".",
"iterrows",
"(",
")... | Parameters
-----------
path_to_network_file : str
Expects a network file with columns "pw0" and "pw1." A "features"
column that specifies the features where the (pw0, pw1) edge is
present will assign a weight to the edge, though it is not required
(edge will have ... | [
"Parameters",
"-----------",
"path_to_network_file",
":",
"str",
"Expects",
"a",
"network",
"file",
"with",
"columns",
"pw0",
"and",
"pw1",
".",
"A",
"features",
"column",
"that",
"specifies",
"the",
"features",
"where",
"the",
"(",
"pw0",
"pw1",
")",
"edge",
... | 9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c | https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/network.py#L130-L153 | train | Reads a network file and adds edges to the species. |
greenelab/PathCORE-T | pathcore/network.py | CoNetwork._construct_from_dataframe | def _construct_from_dataframe(self):
"""Build the network using the significant pathways dataframe
by identifying pairwise direct (same-side) relationships.
"""
direct_edges = {}
feature_side_grouping = self.feature_pathway_df.groupby(
["feature", "side"])
for... | python | def _construct_from_dataframe(self):
"""Build the network using the significant pathways dataframe
by identifying pairwise direct (same-side) relationships.
"""
direct_edges = {}
feature_side_grouping = self.feature_pathway_df.groupby(
["feature", "side"])
for... | [
"def",
"_construct_from_dataframe",
"(",
"self",
")",
":",
"direct_edges",
"=",
"{",
"}",
"feature_side_grouping",
"=",
"self",
".",
"feature_pathway_df",
".",
"groupby",
"(",
"[",
"\"feature\"",
",",
"\"side\"",
"]",
")",
"for",
"(",
"feature",
",",
"_",
")... | Build the network using the significant pathways dataframe
by identifying pairwise direct (same-side) relationships. | [
"Build",
"the",
"network",
"using",
"the",
"significant",
"pathways",
"dataframe",
"by",
"identifying",
"pairwise",
"direct",
"(",
"same",
"-",
"side",
")",
"relationships",
"."
] | 9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c | https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/network.py#L155-L175 | train | Build the network from the significant pathways dataframe. |
greenelab/PathCORE-T | pathcore/network.py | CoNetwork._construct_from_permutation | def _construct_from_permutation(self, significant_pathways):
"""Build the network from a dictionary of (side -> tuple lists),
where the side is specified as "pos" and/or "neg" (from the feature
gene signature(s)) and mapped to a tuple list of [(pathway, feature)].
Used during the PathCOR... | python | def _construct_from_permutation(self, significant_pathways):
"""Build the network from a dictionary of (side -> tuple lists),
where the side is specified as "pos" and/or "neg" (from the feature
gene signature(s)) and mapped to a tuple list of [(pathway, feature)].
Used during the PathCOR... | [
"def",
"_construct_from_permutation",
"(",
"self",
",",
"significant_pathways",
")",
":",
"for",
"side",
",",
"pathway_feature_tuples",
"in",
"significant_pathways",
".",
"items",
"(",
")",
":",
"feature_pathway_dict",
"=",
"self",
".",
"_collect_pathways_by_feature",
... | Build the network from a dictionary of (side -> tuple lists),
where the side is specified as "pos" and/or "neg" (from the feature
gene signature(s)) and mapped to a tuple list of [(pathway, feature)].
Used during the PathCORE-T permutation test by applying the method
`permute_pathways_ac... | [
"Build",
"the",
"network",
"from",
"a",
"dictionary",
"of",
"(",
"side",
"-",
">",
"tuple",
"lists",
")",
"where",
"the",
"side",
"is",
"specified",
"as",
"pos",
"and",
"/",
"or",
"neg",
"(",
"from",
"the",
"feature",
"gene",
"signature",
"(",
"s",
"... | 9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c | https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/network.py#L177-L187 | train | Builds a CoNetwork from a dictionary of significant pathways and their edges. |
greenelab/PathCORE-T | pathcore/network.py | CoNetwork.permute_pathways_across_features | def permute_pathways_across_features(self):
"""Return a permutation of the network. Requires that the
significant pathways file has been specified during CoNetwork
initialization (or set `self.feature_pathway_df` to the
pandas.DataFrame afterwards).
"""
side_labels = self... | python | def permute_pathways_across_features(self):
"""Return a permutation of the network. Requires that the
significant pathways file has been specified during CoNetwork
initialization (or set `self.feature_pathway_df` to the
pandas.DataFrame afterwards).
"""
side_labels = self... | [
"def",
"permute_pathways_across_features",
"(",
"self",
")",
":",
"side_labels",
"=",
"self",
".",
"feature_pathway_df",
".",
"side",
".",
"unique",
"(",
")",
"pathway_features",
"=",
"{",
"}",
"for",
"side",
"in",
"side_labels",
":",
"pathway_features",
"[",
... | Return a permutation of the network. Requires that the
significant pathways file has been specified during CoNetwork
initialization (or set `self.feature_pathway_df` to the
pandas.DataFrame afterwards). | [
"Return",
"a",
"permutation",
"of",
"the",
"network",
".",
"Requires",
"that",
"the",
"significant",
"pathways",
"file",
"has",
"been",
"specified",
"during",
"CoNetwork",
"initialization",
"(",
"or",
"set",
"self",
".",
"feature_pathway_df",
"to",
"the",
"panda... | 9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c | https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/network.py#L189-L221 | train | Return a permutation of the network. Requires that the significant pathways file has been specified during the CoNetwork. |
greenelab/PathCORE-T | pathcore/network.py | CoNetwork.weight_by_edge_odds_ratios | def weight_by_edge_odds_ratios(self,
edges_expected_weight,
flag_as_significant):
"""Applied during the permutation test. Update the edges in the
network to be weighted by their odds ratios. The odds ratio measures
how unexpec... | python | def weight_by_edge_odds_ratios(self,
edges_expected_weight,
flag_as_significant):
"""Applied during the permutation test. Update the edges in the
network to be weighted by their odds ratios. The odds ratio measures
how unexpec... | [
"def",
"weight_by_edge_odds_ratios",
"(",
"self",
",",
"edges_expected_weight",
",",
"flag_as_significant",
")",
":",
"for",
"edge_id",
",",
"expected_weight",
"in",
"edges_expected_weight",
":",
"edge_obj",
"=",
"self",
".",
"edges",
"[",
"edge_id",
"]",
"edge_obj"... | Applied during the permutation test. Update the edges in the
network to be weighted by their odds ratios. The odds ratio measures
how unexpected the observed edge weight is based on the expected
weight.
Parameters
-----------
edges_expected_weight : list(tup(int, int), f... | [
"Applied",
"during",
"the",
"permutation",
"test",
".",
"Update",
"the",
"edges",
"in",
"the",
"network",
"to",
"be",
"weighted",
"by",
"their",
"odds",
"ratios",
".",
"The",
"odds",
"ratio",
"measures",
"how",
"unexpected",
"the",
"observed",
"edge",
"weigh... | 9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c | https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/network.py#L223-L247 | train | Applies the edge weights by odds ratios. |
greenelab/PathCORE-T | pathcore/network.py | CoNetwork.aggregate | def aggregate(self, merge):
"""Combine this network with another network. The aggregation step
takes the union of the edges in the two networks, where we take the
sum of weights for edges common to both networks.
Parameters
-----------
merge : CoNetwork
the CoN... | python | def aggregate(self, merge):
"""Combine this network with another network. The aggregation step
takes the union of the edges in the two networks, where we take the
sum of weights for edges common to both networks.
Parameters
-----------
merge : CoNetwork
the CoN... | [
"def",
"aggregate",
"(",
"self",
",",
"merge",
")",
":",
"self",
".",
"features",
"=",
"set",
"(",
")",
"self",
".",
"n_features",
"+=",
"merge",
".",
"n_features",
"vertex_id_conversion",
"=",
"self",
".",
"convert_pathway_mapping",
"(",
"merge",
".",
"pa... | Combine this network with another network. The aggregation step
takes the union of the edges in the two networks, where we take the
sum of weights for edges common to both networks.
Parameters
-----------
merge : CoNetwork
the CoNetwork object being merged into the cur... | [
"Combine",
"this",
"network",
"with",
"another",
"network",
".",
"The",
"aggregation",
"step",
"takes",
"the",
"union",
"of",
"the",
"edges",
"in",
"the",
"two",
"networks",
"where",
"we",
"take",
"the",
"sum",
"of",
"weights",
"for",
"edges",
"common",
"t... | 9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c | https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/network.py#L249-L276 | train | Combine this CoNetwork object with another CoNetwork object. |
greenelab/PathCORE-T | pathcore/network.py | CoNetwork.convert_pathway_mapping | def convert_pathway_mapping(self, other_pathway_mapping):
"""Used to convert the pathway-to-vertex id mapping in one CoNetwork
to the one used in the current CoNetwork (`self`).
The following tasks are carried out in the remapping:
(1) If `self.pathways` contains the pathway to be merged... | python | def convert_pathway_mapping(self, other_pathway_mapping):
"""Used to convert the pathway-to-vertex id mapping in one CoNetwork
to the one used in the current CoNetwork (`self`).
The following tasks are carried out in the remapping:
(1) If `self.pathways` contains the pathway to be merged... | [
"def",
"convert_pathway_mapping",
"(",
"self",
",",
"other_pathway_mapping",
")",
":",
"vertex_id_conversion",
"=",
"{",
"}",
"for",
"pathway",
",",
"vertex_id",
"in",
"other_pathway_mapping",
".",
"items",
"(",
")",
":",
"if",
"pathway",
"in",
"self",
".",
"p... | Used to convert the pathway-to-vertex id mapping in one CoNetwork
to the one used in the current CoNetwork (`self`).
The following tasks are carried out in the remapping:
(1) If `self.pathways` contains the pathway to be merged, map the
vertex id in `other_pathway_mapping` to the ver... | [
"Used",
"to",
"convert",
"the",
"pathway",
"-",
"to",
"-",
"vertex",
"id",
"mapping",
"in",
"one",
"CoNetwork",
"to",
"the",
"one",
"used",
"in",
"the",
"current",
"CoNetwork",
"(",
"self",
")",
".",
"The",
"following",
"tasks",
"are",
"carried",
"out",
... | 9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c | https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/network.py#L278-L307 | train | This function converts the pathway - to - vertex id mapping in one CoNetwork to the one used in the current CoNetwork. |
greenelab/PathCORE-T | pathcore/network.py | CoNetwork.remapped_edge | def remapped_edge(self, vertex_id_conversion, other_edge_id):
"""Given an edge (`vertex0_id`, `vertex1_id`) from a
different CoNetwork, return the corresponding edge id from this
CoNetwork (`self`).
Parameters
-----------
vertex_id_conversion : dict (int -> int)
... | python | def remapped_edge(self, vertex_id_conversion, other_edge_id):
"""Given an edge (`vertex0_id`, `vertex1_id`) from a
different CoNetwork, return the corresponding edge id from this
CoNetwork (`self`).
Parameters
-----------
vertex_id_conversion : dict (int -> int)
... | [
"def",
"remapped_edge",
"(",
"self",
",",
"vertex_id_conversion",
",",
"other_edge_id",
")",
":",
"vertex0_id",
",",
"vertex1_id",
"=",
"other_edge_id",
"self_vertex0",
"=",
"vertex_id_conversion",
"[",
"vertex0_id",
"]",
"self_vertex1",
"=",
"vertex_id_conversion",
"... | Given an edge (`vertex0_id`, `vertex1_id`) from a
different CoNetwork, return the corresponding edge id from this
CoNetwork (`self`).
Parameters
-----------
vertex_id_conversion : dict (int -> int)
the dict produced by `convert_pathway_mapping,` which maps
th... | [
"Given",
"an",
"edge",
"(",
"vertex0_id",
"vertex1_id",
")",
"from",
"a",
"different",
"CoNetwork",
"return",
"the",
"corresponding",
"edge",
"id",
"from",
"this",
"CoNetwork",
"(",
"self",
")",
"."
] | 9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c | https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/network.py#L309-L330 | train | Given an edge from this CoNetwork and another CoNetwork return the corresponding edge id. |
greenelab/PathCORE-T | pathcore/network.py | CoNetwork.edge_tuple | def edge_tuple(self, vertex0_id, vertex1_id):
"""To avoid duplicate edges where the vertex ids are reversed,
we maintain that the vertex ids are ordered so that the corresponding
pathway names are alphabetical.
Parameters
-----------
vertex0_id : int
one vertex... | python | def edge_tuple(self, vertex0_id, vertex1_id):
"""To avoid duplicate edges where the vertex ids are reversed,
we maintain that the vertex ids are ordered so that the corresponding
pathway names are alphabetical.
Parameters
-----------
vertex0_id : int
one vertex... | [
"def",
"edge_tuple",
"(",
"self",
",",
"vertex0_id",
",",
"vertex1_id",
")",
":",
"pw0",
"=",
"self",
".",
"__getitem__",
"(",
"vertex0_id",
")",
"pw1",
"=",
"self",
".",
"__getitem__",
"(",
"vertex1_id",
")",
"if",
"not",
"pw0",
"or",
"not",
"pw1",
":... | To avoid duplicate edges where the vertex ids are reversed,
we maintain that the vertex ids are ordered so that the corresponding
pathway names are alphabetical.
Parameters
-----------
vertex0_id : int
one vertex in the edge
vertex1_id : int
the other... | [
"To",
"avoid",
"duplicate",
"edges",
"where",
"the",
"vertex",
"ids",
"are",
"reversed",
"we",
"maintain",
"that",
"the",
"vertex",
"ids",
"are",
"ordered",
"so",
"that",
"the",
"corresponding",
"pathway",
"names",
"are",
"alphabetical",
"."
] | 9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c | https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/network.py#L332-L360 | train | Return the edge id and edge id of the edge that is in the network. |
greenelab/PathCORE-T | pathcore/network.py | CoNetwork.add_pathway | def add_pathway(self, pathway):
"""Updates `self.pathways` and `self.n_pathways.`
Parameters
-----------
pathway : str
the pathway to add to the network.
"""
if pathway not in self.pathways:
self.pathways[pathway] = self.n_pathways
self.... | python | def add_pathway(self, pathway):
"""Updates `self.pathways` and `self.n_pathways.`
Parameters
-----------
pathway : str
the pathway to add to the network.
"""
if pathway not in self.pathways:
self.pathways[pathway] = self.n_pathways
self.... | [
"def",
"add_pathway",
"(",
"self",
",",
"pathway",
")",
":",
"if",
"pathway",
"not",
"in",
"self",
".",
"pathways",
":",
"self",
".",
"pathways",
"[",
"pathway",
"]",
"=",
"self",
".",
"n_pathways",
"self",
".",
"n_pathways",
"+=",
"1",
"return",
"self... | Updates `self.pathways` and `self.n_pathways.`
Parameters
-----------
pathway : str
the pathway to add to the network. | [
"Updates",
"self",
".",
"pathways",
"and",
"self",
".",
"n_pathways",
"."
] | 9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c | https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/network.py#L362-L373 | train | Adds a pathway to the pathway list. Returns the pathway number. |
greenelab/PathCORE-T | pathcore/network.py | CoNetwork.get_edge_pathways | def get_edge_pathways(self, edge_id):
"""Get the pathways associated with an edge.
Parameters
-----------
edge_id : tup(int, int)
Returns
-----------
tup(str, str)|None, the edge as a pair of 2 pathways if the edge id
is in this network
"""
... | python | def get_edge_pathways(self, edge_id):
"""Get the pathways associated with an edge.
Parameters
-----------
edge_id : tup(int, int)
Returns
-----------
tup(str, str)|None, the edge as a pair of 2 pathways if the edge id
is in this network
"""
... | [
"def",
"get_edge_pathways",
"(",
"self",
",",
"edge_id",
")",
":",
"vertex0_id",
",",
"vertex1_id",
"=",
"edge_id",
"pw0",
"=",
"self",
".",
"get_pathway_from_vertex_id",
"(",
"vertex0_id",
")",
"pw1",
"=",
"self",
".",
"get_pathway_from_vertex_id",
"(",
"vertex... | Get the pathways associated with an edge.
Parameters
-----------
edge_id : tup(int, int)
Returns
-----------
tup(str, str)|None, the edge as a pair of 2 pathways if the edge id
is in this network | [
"Get",
"the",
"pathways",
"associated",
"with",
"an",
"edge",
"."
] | 9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c | https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/network.py#L388-L405 | train | Get the pathways associated with an edge. |
greenelab/PathCORE-T | pathcore/network.py | CoNetwork.get_vertex_obj_from_pathway | def get_vertex_obj_from_pathway(self, pathway):
"""Get the vertex object that corresponds to a pathway name
Parameters
-----------
pathway : str
Returns
-----------
Vertex|None, the Vertex obj if the pathway is in this network
"""
if pathway in s... | python | def get_vertex_obj_from_pathway(self, pathway):
"""Get the vertex object that corresponds to a pathway name
Parameters
-----------
pathway : str
Returns
-----------
Vertex|None, the Vertex obj if the pathway is in this network
"""
if pathway in s... | [
"def",
"get_vertex_obj_from_pathway",
"(",
"self",
",",
"pathway",
")",
":",
"if",
"pathway",
"in",
"self",
".",
"pathways",
":",
"vertex_id",
"=",
"self",
".",
"pathways",
"[",
"pathway",
"]",
"return",
"self",
".",
"vertices",
"[",
"vertex_id",
"]",
"els... | Get the vertex object that corresponds to a pathway name
Parameters
-----------
pathway : str
Returns
-----------
Vertex|None, the Vertex obj if the pathway is in this network | [
"Get",
"the",
"vertex",
"object",
"that",
"corresponds",
"to",
"a",
"pathway",
"name"
] | 9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c | https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/network.py#L422-L437 | train | Get the vertex object that corresponds to a pathway name |
greenelab/PathCORE-T | pathcore/network.py | CoNetwork.get_adjacent_pathways | def get_adjacent_pathways(self, pathway):
"""Get the pathways adjacent to this pathway in the network
Parameters
-----------
pathway : str
Returns
-----------
list(str), a list of pathways adjacent to the input pathway
"""
vertex_id = self.pathwa... | python | def get_adjacent_pathways(self, pathway):
"""Get the pathways adjacent to this pathway in the network
Parameters
-----------
pathway : str
Returns
-----------
list(str), a list of pathways adjacent to the input pathway
"""
vertex_id = self.pathwa... | [
"def",
"get_adjacent_pathways",
"(",
"self",
",",
"pathway",
")",
":",
"vertex_id",
"=",
"self",
".",
"pathways",
"[",
"pathway",
"]",
"adjacent",
"=",
"self",
".",
"vertices",
"[",
"vertex_id",
"]",
".",
"get_adjacent_vertex_ids",
"(",
")",
"adjacent_pathways... | Get the pathways adjacent to this pathway in the network
Parameters
-----------
pathway : str
Returns
-----------
list(str), a list of pathways adjacent to the input pathway | [
"Get",
"the",
"pathways",
"adjacent",
"to",
"this",
"pathway",
"in",
"the",
"network"
] | 9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c | https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/network.py#L439-L456 | train | Get the pathways adjacent to this pathway in the network. |
greenelab/PathCORE-T | pathcore/network.py | CoNetwork.to_dataframe | def to_dataframe(self, drop_weights_below=0, whitelist=None):
""" Conversion of the network to a pandas.DataFrame.
Parameters
-----------
drop_weights_below : int (default=0)
specify an edge weight threshold - remove all edges with weight
below this value
whi... | python | def to_dataframe(self, drop_weights_below=0, whitelist=None):
""" Conversion of the network to a pandas.DataFrame.
Parameters
-----------
drop_weights_below : int (default=0)
specify an edge weight threshold - remove all edges with weight
below this value
whi... | [
"def",
"to_dataframe",
"(",
"self",
",",
"drop_weights_below",
"=",
"0",
",",
"whitelist",
"=",
"None",
")",
":",
"network_df_cols",
"=",
"[",
"\"pw0\"",
",",
"\"pw1\"",
",",
"\"weight\"",
"]",
"if",
"self",
".",
"features",
":",
"network_df_cols",
".",
"a... | Conversion of the network to a pandas.DataFrame.
Parameters
-----------
drop_weights_below : int (default=0)
specify an edge weight threshold - remove all edges with weight
below this value
whitelist : [set|list](tup(int, int))|None (default=None)
option to... | [
"Conversion",
"of",
"the",
"network",
"to",
"a",
"pandas",
".",
"DataFrame",
"."
] | 9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c | https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/network.py#L458-L501 | train | This method converts the pathway co - occurrence network to a pandas. DataFrame. |
greenelab/PathCORE-T | pathcore/network.py | CoNetwork._add_edge_to_vertex | def _add_edge_to_vertex(self, vertex_id, edge):
"""Adds the edge to the Vertex object's `edges` dictionary
"""
connected_to = edge.connected_to(vertex_id)
if vertex_id not in self.vertices:
vertex_obj = Vertex(vertex_id)
self.vertices[vertex_id] = vertex_obj
... | python | def _add_edge_to_vertex(self, vertex_id, edge):
"""Adds the edge to the Vertex object's `edges` dictionary
"""
connected_to = edge.connected_to(vertex_id)
if vertex_id not in self.vertices:
vertex_obj = Vertex(vertex_id)
self.vertices[vertex_id] = vertex_obj
... | [
"def",
"_add_edge_to_vertex",
"(",
"self",
",",
"vertex_id",
",",
"edge",
")",
":",
"connected_to",
"=",
"edge",
".",
"connected_to",
"(",
"vertex_id",
")",
"if",
"vertex_id",
"not",
"in",
"self",
".",
"vertices",
":",
"vertex_obj",
"=",
"Vertex",
"(",
"ve... | Adds the edge to the Vertex object's `edges` dictionary | [
"Adds",
"the",
"edge",
"to",
"the",
"Vertex",
"object",
"s",
"edges",
"dictionary"
] | 9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c | https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/network.py#L503-L510 | train | Adds the edge to the vertex s edges dictionary. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.