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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Erotemic/utool | utool/util_inspect.py | get_docstr | def get_docstr(func_or_class):
""" Get the docstring from a live object """
import utool as ut
try:
docstr_ = func_or_class.func_doc
except AttributeError:
docstr_ = func_or_class.__doc__
if docstr_ is None:
docstr_ = ''
docstr = ut.unindent(docstr_)
return docstr | python | def get_docstr(func_or_class):
""" Get the docstring from a live object """
import utool as ut
try:
docstr_ = func_or_class.func_doc
except AttributeError:
docstr_ = func_or_class.__doc__
if docstr_ is None:
docstr_ = ''
docstr = ut.unindent(docstr_)
return docstr | [
"def",
"get_docstr",
"(",
"func_or_class",
")",
":",
"import",
"utool",
"as",
"ut",
"try",
":",
"docstr_",
"=",
"func_or_class",
".",
"func_doc",
"except",
"AttributeError",
":",
"docstr_",
"=",
"func_or_class",
".",
"__doc__",
"if",
"docstr_",
"is",
"None",
... | Get the docstring from a live object | [
"Get",
"the",
"docstring",
"from",
"a",
"live",
"object"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L1354-L1364 | train | Get the docstring from a live object |
Erotemic/utool | utool/util_inspect.py | special_parse_process_python_code | def special_parse_process_python_code(sourcecode):
r"""
pip install redbaron
http://stackoverflow.com/questions/7456933/python-ast-with-preserved-comments
CommandLine:
python -m utool.util_inspect special_parse_process_python_code --show
Example:
>>> # DISABLE_DOCTEST
>>> f... | python | def special_parse_process_python_code(sourcecode):
r"""
pip install redbaron
http://stackoverflow.com/questions/7456933/python-ast-with-preserved-comments
CommandLine:
python -m utool.util_inspect special_parse_process_python_code --show
Example:
>>> # DISABLE_DOCTEST
>>> f... | [
"def",
"special_parse_process_python_code",
"(",
"sourcecode",
")",
":",
"import",
"ast",
"import",
"astor",
"#sourcecode = 'from __future__ import print_function\\n' + sourcecode",
"sourcecode_",
"=",
"sourcecode",
".",
"encode",
"(",
"'utf8'",
")",
"pt",
"=",
"ast",
"."... | r"""
pip install redbaron
http://stackoverflow.com/questions/7456933/python-ast-with-preserved-comments
CommandLine:
python -m utool.util_inspect special_parse_process_python_code --show
Example:
>>> # DISABLE_DOCTEST
>>> from utool.util_inspect import * # NOQA
>>> imp... | [
"r",
"pip",
"install",
"redbaron",
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"questions",
"/",
"7456933",
"/",
"python",
"-",
"ast",
"-",
"with",
"-",
"preserved",
"-",
"comments"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L1388-L1423 | train | r This function is used to parse a python source code into a full syntax tree |
Erotemic/utool | utool/util_inspect.py | parse_function_names | def parse_function_names(sourcecode, top_level=True, ignore_condition=1):
"""
Finds all function names in a file without importing it
Args:
sourcecode (str):
Returns:
list: func_names
CommandLine:
python -m utool.util_inspect parse_function_names
Example:
>>> ... | python | def parse_function_names(sourcecode, top_level=True, ignore_condition=1):
"""
Finds all function names in a file without importing it
Args:
sourcecode (str):
Returns:
list: func_names
CommandLine:
python -m utool.util_inspect parse_function_names
Example:
>>> ... | [
"def",
"parse_function_names",
"(",
"sourcecode",
",",
"top_level",
"=",
"True",
",",
"ignore_condition",
"=",
"1",
")",
":",
"import",
"ast",
"import",
"utool",
"as",
"ut",
"func_names",
"=",
"[",
"]",
"if",
"six",
".",
"PY2",
":",
"sourcecode",
"=",
"u... | Finds all function names in a file without importing it
Args:
sourcecode (str):
Returns:
list: func_names
CommandLine:
python -m utool.util_inspect parse_function_names
Example:
>>> # ENABLE_DOCTEST
>>> from utool.util_inspect import * # NOQA
>>> impo... | [
"Finds",
"all",
"function",
"names",
"in",
"a",
"file",
"without",
"importing",
"it"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L1428-L1527 | train | A function that returns a list of function names in a file. |
Erotemic/utool | utool/util_inspect.py | parse_project_imports | def parse_project_imports(dpath):
"""
dpath = ub.truepath('~/code/clab/clab')
Script:
>>> dpath = ut.get_argval('--dpath')
>>> parse_project_imports()
"""
import ubelt as ub
import glob
from os.path import join, exists
package_modules = set()
for fpath in glob.glob(... | python | def parse_project_imports(dpath):
"""
dpath = ub.truepath('~/code/clab/clab')
Script:
>>> dpath = ut.get_argval('--dpath')
>>> parse_project_imports()
"""
import ubelt as ub
import glob
from os.path import join, exists
package_modules = set()
for fpath in glob.glob(... | [
"def",
"parse_project_imports",
"(",
"dpath",
")",
":",
"import",
"ubelt",
"as",
"ub",
"import",
"glob",
"from",
"os",
".",
"path",
"import",
"join",
",",
"exists",
"package_modules",
"=",
"set",
"(",
")",
"for",
"fpath",
"in",
"glob",
".",
"glob",
"(",
... | dpath = ub.truepath('~/code/clab/clab')
Script:
>>> dpath = ut.get_argval('--dpath')
>>> parse_project_imports() | [
"dpath",
"=",
"ub",
".",
"truepath",
"(",
"~",
"/",
"code",
"/",
"clab",
"/",
"clab",
")"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L1544-L1580 | train | Parse the project imports. |
Erotemic/utool | utool/util_inspect.py | parse_import_names | def parse_import_names(sourcecode, top_level=True, fpath=None, branch=False):
"""
Finds all function names in a file without importing it
Args:
sourcecode (str):
Returns:
list: func_names
CommandLine:
python -m utool.util_inspect parse_import_names
References:
... | python | def parse_import_names(sourcecode, top_level=True, fpath=None, branch=False):
"""
Finds all function names in a file without importing it
Args:
sourcecode (str):
Returns:
list: func_names
CommandLine:
python -m utool.util_inspect parse_import_names
References:
... | [
"def",
"parse_import_names",
"(",
"sourcecode",
",",
"top_level",
"=",
"True",
",",
"fpath",
"=",
"None",
",",
"branch",
"=",
"False",
")",
":",
"import",
"ast",
"import_names",
"=",
"[",
"]",
"if",
"six",
".",
"PY2",
":",
"import",
"utool",
"as",
"ut"... | Finds all function names in a file without importing it
Args:
sourcecode (str):
Returns:
list: func_names
CommandLine:
python -m utool.util_inspect parse_import_names
References:
https://stackoverflow.com/questions/20445733/how-to-tell-which-modules-have-been-imported... | [
"Finds",
"all",
"function",
"names",
"in",
"a",
"file",
"without",
"importing",
"it"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L1583-L1680 | train | Parse a source code and return a list of all function names that are imported in the current directory. |
Erotemic/utool | utool/util_inspect.py | find_funcs_called_with_kwargs | def find_funcs_called_with_kwargs(sourcecode, target_kwargs_name='kwargs'):
r"""
Finds functions that are called with the keyword `kwargs` variable
CommandLine:
python3 -m utool.util_inspect find_funcs_called_with_kwargs
Example:
>>> # ENABLE_DOCTEST
>>> import utool as ut
... | python | def find_funcs_called_with_kwargs(sourcecode, target_kwargs_name='kwargs'):
r"""
Finds functions that are called with the keyword `kwargs` variable
CommandLine:
python3 -m utool.util_inspect find_funcs_called_with_kwargs
Example:
>>> # ENABLE_DOCTEST
>>> import utool as ut
... | [
"def",
"find_funcs_called_with_kwargs",
"(",
"sourcecode",
",",
"target_kwargs_name",
"=",
"'kwargs'",
")",
":",
"import",
"ast",
"sourcecode",
"=",
"'from __future__ import print_function\\n'",
"+",
"sourcecode",
"pt",
"=",
"ast",
".",
"parse",
"(",
"sourcecode",
")"... | r"""
Finds functions that are called with the keyword `kwargs` variable
CommandLine:
python3 -m utool.util_inspect find_funcs_called_with_kwargs
Example:
>>> # ENABLE_DOCTEST
>>> import utool as ut
>>> sourcecode = ut.codeblock(
'''
x, y = li... | [
"r",
"Finds",
"functions",
"that",
"are",
"called",
"with",
"the",
"keyword",
"kwargs",
"variable"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L1683-L1792 | train | r Finds functions that are called with keyword arguments. |
Erotemic/utool | utool/util_inspect.py | is_valid_python | def is_valid_python(code, reraise=True, ipy_magic_workaround=False):
"""
References:
http://stackoverflow.com/questions/23576681/python-check-syntax
"""
import ast
try:
if ipy_magic_workaround:
code = '\n'.join(['pass' if re.match(r'\s*%[a-z]*', line) else line for line i... | python | def is_valid_python(code, reraise=True, ipy_magic_workaround=False):
"""
References:
http://stackoverflow.com/questions/23576681/python-check-syntax
"""
import ast
try:
if ipy_magic_workaround:
code = '\n'.join(['pass' if re.match(r'\s*%[a-z]*', line) else line for line i... | [
"def",
"is_valid_python",
"(",
"code",
",",
"reraise",
"=",
"True",
",",
"ipy_magic_workaround",
"=",
"False",
")",
":",
"import",
"ast",
"try",
":",
"if",
"ipy_magic_workaround",
":",
"code",
"=",
"'\\n'",
".",
"join",
"(",
"[",
"'pass'",
"if",
"re",
".... | References:
http://stackoverflow.com/questions/23576681/python-check-syntax | [
"References",
":",
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"questions",
"/",
"23576681",
"/",
"python",
"-",
"check",
"-",
"syntax"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L1796-L1813 | train | Check if python code is valid. |
Erotemic/utool | utool/util_inspect.py | parse_return_type | def parse_return_type(sourcecode):
r"""
parse_return_type
Args:
sourcecode (?):
Returns:
tuple: (return_type, return_name, return_header)
Ignore:
testcase
automated_helpers query_vsone_verified
CommandLine:
python -m utool.util_inspect parse_return_ty... | python | def parse_return_type(sourcecode):
r"""
parse_return_type
Args:
sourcecode (?):
Returns:
tuple: (return_type, return_name, return_header)
Ignore:
testcase
automated_helpers query_vsone_verified
CommandLine:
python -m utool.util_inspect parse_return_ty... | [
"def",
"parse_return_type",
"(",
"sourcecode",
")",
":",
"import",
"ast",
"return_type",
",",
"return_name",
",",
"return_header",
"=",
"(",
"None",
",",
"None",
",",
"None",
")",
"if",
"sourcecode",
"is",
"None",
":",
"return",
"return_type",
",",
"return_n... | r"""
parse_return_type
Args:
sourcecode (?):
Returns:
tuple: (return_type, return_name, return_header)
Ignore:
testcase
automated_helpers query_vsone_verified
CommandLine:
python -m utool.util_inspect parse_return_type
python -m utool.util_inspect... | [
"r"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L1816-L2004 | train | r This function parses the return type of a single sourcecode into a set of items. |
Erotemic/utool | utool/util_inspect.py | exec_func_src | def exec_func_src(func, globals_=None, locals_=None, key_list=None,
sentinal=None, update=None, keys=None, verbose=False,
start=None, stop=None):
"""
execs a func and returns requested local vars.
Does not modify globals unless update=True (or in IPython)
SeeAlso:
... | python | def exec_func_src(func, globals_=None, locals_=None, key_list=None,
sentinal=None, update=None, keys=None, verbose=False,
start=None, stop=None):
"""
execs a func and returns requested local vars.
Does not modify globals unless update=True (or in IPython)
SeeAlso:
... | [
"def",
"exec_func_src",
"(",
"func",
",",
"globals_",
"=",
"None",
",",
"locals_",
"=",
"None",
",",
"key_list",
"=",
"None",
",",
"sentinal",
"=",
"None",
",",
"update",
"=",
"None",
",",
"keys",
"=",
"None",
",",
"verbose",
"=",
"False",
",",
"star... | execs a func and returns requested local vars.
Does not modify globals unless update=True (or in IPython)
SeeAlso:
ut.execstr_funckw | [
"execs",
"a",
"func",
"and",
"returns",
"requested",
"local",
"vars",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L2117-L2168 | train | execs a function and returns requested local vars |
Erotemic/utool | utool/util_inspect.py | exec_func_src2 | def exec_func_src2(func, globals_=None, locals_=None, sentinal=None,
verbose=False, start=None, stop=None):
"""
execs a func and returns requested local vars.
Does not modify globals unless update=True (or in IPython)
SeeAlso:
ut.execstr_funckw
"""
import utool as ut... | python | def exec_func_src2(func, globals_=None, locals_=None, sentinal=None,
verbose=False, start=None, stop=None):
"""
execs a func and returns requested local vars.
Does not modify globals unless update=True (or in IPython)
SeeAlso:
ut.execstr_funckw
"""
import utool as ut... | [
"def",
"exec_func_src2",
"(",
"func",
",",
"globals_",
"=",
"None",
",",
"locals_",
"=",
"None",
",",
"sentinal",
"=",
"None",
",",
"verbose",
"=",
"False",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
")",
":",
"import",
"utool",
"as",
"ut",... | execs a func and returns requested local vars.
Does not modify globals unless update=True (or in IPython)
SeeAlso:
ut.execstr_funckw | [
"execs",
"a",
"func",
"and",
"returns",
"requested",
"local",
"vars",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L2171-L2198 | train | execs a function and returns requested local vars |
Erotemic/utool | utool/util_inspect.py | exec_func_src3 | def exec_func_src3(func, globals_, sentinal=None, verbose=False,
start=None, stop=None):
"""
execs a func and returns requested local vars.
Does not modify globals unless update=True (or in IPython)
SeeAlso:
ut.execstr_funckw
"""
import utool as ut
sourcecode = u... | python | def exec_func_src3(func, globals_, sentinal=None, verbose=False,
start=None, stop=None):
"""
execs a func and returns requested local vars.
Does not modify globals unless update=True (or in IPython)
SeeAlso:
ut.execstr_funckw
"""
import utool as ut
sourcecode = u... | [
"def",
"exec_func_src3",
"(",
"func",
",",
"globals_",
",",
"sentinal",
"=",
"None",
",",
"verbose",
"=",
"False",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
")",
":",
"import",
"utool",
"as",
"ut",
"sourcecode",
"=",
"ut",
".",
"get_func_sou... | execs a func and returns requested local vars.
Does not modify globals unless update=True (or in IPython)
SeeAlso:
ut.execstr_funckw | [
"execs",
"a",
"func",
"and",
"returns",
"requested",
"local",
"vars",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L2201-L2219 | train | execs a function and returns requested local vars |
Erotemic/utool | utool/util_inspect.py | get_func_sourcecode | def get_func_sourcecode(func, stripdef=False, stripret=False,
strip_docstr=False, strip_comments=False,
remove_linenums=None):
"""
wrapper around inspect.getsource but takes into account utool decorators
strip flags are very hacky as of now
Args:
... | python | def get_func_sourcecode(func, stripdef=False, stripret=False,
strip_docstr=False, strip_comments=False,
remove_linenums=None):
"""
wrapper around inspect.getsource but takes into account utool decorators
strip flags are very hacky as of now
Args:
... | [
"def",
"get_func_sourcecode",
"(",
"func",
",",
"stripdef",
"=",
"False",
",",
"stripret",
"=",
"False",
",",
"strip_docstr",
"=",
"False",
",",
"strip_comments",
"=",
"False",
",",
"remove_linenums",
"=",
"None",
")",
":",
"import",
"utool",
"as",
"ut",
"... | wrapper around inspect.getsource but takes into account utool decorators
strip flags are very hacky as of now
Args:
func (function):
stripdef (bool):
stripret (bool): (default = False)
strip_docstr (bool): (default = False)
strip_comments (bool): (default = False)
... | [
"wrapper",
"around",
"inspect",
".",
"getsource",
"but",
"takes",
"into",
"account",
"utool",
"decorators",
"strip",
"flags",
"are",
"very",
"hacky",
"as",
"of",
"now"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L2270-L2423 | train | wrapper around inspect. getsource but takes into account utool decorators |
Erotemic/utool | utool/util_inspect.py | get_func_argspec | def get_func_argspec(func):
"""
wrapper around inspect.getargspec but takes into account utool decorators
"""
if hasattr(func, '_utinfo'):
argspec = func._utinfo['orig_argspec']
return argspec
if isinstance(func, property):
func = func.fget
try:
argspec = inspect.... | python | def get_func_argspec(func):
"""
wrapper around inspect.getargspec but takes into account utool decorators
"""
if hasattr(func, '_utinfo'):
argspec = func._utinfo['orig_argspec']
return argspec
if isinstance(func, property):
func = func.fget
try:
argspec = inspect.... | [
"def",
"get_func_argspec",
"(",
"func",
")",
":",
"if",
"hasattr",
"(",
"func",
",",
"'_utinfo'",
")",
":",
"argspec",
"=",
"func",
".",
"_utinfo",
"[",
"'orig_argspec'",
"]",
"return",
"argspec",
"if",
"isinstance",
"(",
"func",
",",
"property",
")",
":... | wrapper around inspect.getargspec but takes into account utool decorators | [
"wrapper",
"around",
"inspect",
".",
"getargspec",
"but",
"takes",
"into",
"account",
"utool",
"decorators"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L2445-L2458 | train | get the argspec of a function |
Erotemic/utool | utool/util_inspect.py | get_kwargs | def get_kwargs(func):
"""
Args:
func (function):
Returns:
tuple: keys, is_arbitrary
keys (list): kwargs keys
is_arbitrary (bool): has generic **kwargs
CommandLine:
python -m utool.util_inspect --test-get_kwargs
Ignore:
def func1(a, b, c):
... | python | def get_kwargs(func):
"""
Args:
func (function):
Returns:
tuple: keys, is_arbitrary
keys (list): kwargs keys
is_arbitrary (bool): has generic **kwargs
CommandLine:
python -m utool.util_inspect --test-get_kwargs
Ignore:
def func1(a, b, c):
... | [
"def",
"get_kwargs",
"(",
"func",
")",
":",
"#if argspec.keywords is None:",
"import",
"utool",
"as",
"ut",
"argspec",
"=",
"inspect",
".",
"getargspec",
"(",
"func",
")",
"if",
"argspec",
".",
"defaults",
"is",
"not",
"None",
":",
"num_args",
"=",
"len",
... | Args:
func (function):
Returns:
tuple: keys, is_arbitrary
keys (list): kwargs keys
is_arbitrary (bool): has generic **kwargs
CommandLine:
python -m utool.util_inspect --test-get_kwargs
Ignore:
def func1(a, b, c):
pass
def func2(a... | [
"Args",
":",
"func",
"(",
"function",
")",
":"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L2461-L2516 | train | Function to get keyword arguments for a single object |
Erotemic/utool | utool/util_inspect.py | lookup_attribute_chain | def lookup_attribute_chain(attrname, namespace):
"""
>>> attrname = funcname
>>> namespace = mod.__dict__
>>> import utool as ut
>>> globals_ = ut.util_inspect.__dict__
>>> attrname = 'KWReg.print_defaultkw'
"""
#subdict = meta_util_six.get_funcglobals(root_func)
... | python | def lookup_attribute_chain(attrname, namespace):
"""
>>> attrname = funcname
>>> namespace = mod.__dict__
>>> import utool as ut
>>> globals_ = ut.util_inspect.__dict__
>>> attrname = 'KWReg.print_defaultkw'
"""
#subdict = meta_util_six.get_funcglobals(root_func)
... | [
"def",
"lookup_attribute_chain",
"(",
"attrname",
",",
"namespace",
")",
":",
"#subdict = meta_util_six.get_funcglobals(root_func)",
"subtup",
"=",
"attrname",
".",
"split",
"(",
"'.'",
")",
"subdict",
"=",
"namespace",
"for",
"attr",
"in",
"subtup",
"[",
":",
"-"... | >>> attrname = funcname
>>> namespace = mod.__dict__
>>> import utool as ut
>>> globals_ = ut.util_inspect.__dict__
>>> attrname = 'KWReg.print_defaultkw' | [
">>>",
"attrname",
"=",
"funcname",
">>>",
"namespace",
"=",
"mod",
".",
"__dict__"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L2519-L2536 | train | lookup_attribute_chain - Lookup the attribute chain for a given attribute name in a namespace |
Erotemic/utool | utool/util_inspect.py | recursive_parse_kwargs | def recursive_parse_kwargs(root_func, path_=None, verbose=None):
"""
recursive kwargs parser
TODO: rectify with others
FIXME: if docstr indentation is off, this fails
SeeAlso:
argparse_funckw
recursive_parse_kwargs
parse_kwarg_keys
parse_func_kwarg_keys
get_f... | python | def recursive_parse_kwargs(root_func, path_=None, verbose=None):
"""
recursive kwargs parser
TODO: rectify with others
FIXME: if docstr indentation is off, this fails
SeeAlso:
argparse_funckw
recursive_parse_kwargs
parse_kwarg_keys
parse_func_kwarg_keys
get_f... | [
"def",
"recursive_parse_kwargs",
"(",
"root_func",
",",
"path_",
"=",
"None",
",",
"verbose",
"=",
"None",
")",
":",
"if",
"verbose",
"is",
"None",
":",
"verbose",
"=",
"VERBOSE_INSPECT",
"if",
"verbose",
":",
"print",
"(",
"'[inspect] recursive parse kwargs roo... | recursive kwargs parser
TODO: rectify with others
FIXME: if docstr indentation is off, this fails
SeeAlso:
argparse_funckw
recursive_parse_kwargs
parse_kwarg_keys
parse_func_kwarg_keys
get_func_kwargs
Args:
root_func (function): live python function
... | [
"recursive",
"kwargs",
"parser",
"TODO",
":",
"rectify",
"with",
"others",
"FIXME",
":",
"if",
"docstr",
"indentation",
"is",
"off",
"this",
"fails"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L2539-L2729 | train | recursive function to parse kwargs |
Erotemic/utool | utool/util_inspect.py | parse_func_kwarg_keys | def parse_func_kwarg_keys(func, with_vals=False):
""" hacky inference of kwargs keys
SeeAlso:
argparse_funckw
recursive_parse_kwargs
parse_kwarg_keys
parse_func_kwarg_keys
get_func_kwargs
"""
sourcecode = get_func_sourcecode(func, strip_docstr=True,
... | python | def parse_func_kwarg_keys(func, with_vals=False):
""" hacky inference of kwargs keys
SeeAlso:
argparse_funckw
recursive_parse_kwargs
parse_kwarg_keys
parse_func_kwarg_keys
get_func_kwargs
"""
sourcecode = get_func_sourcecode(func, strip_docstr=True,
... | [
"def",
"parse_func_kwarg_keys",
"(",
"func",
",",
"with_vals",
"=",
"False",
")",
":",
"sourcecode",
"=",
"get_func_sourcecode",
"(",
"func",
",",
"strip_docstr",
"=",
"True",
",",
"strip_comments",
"=",
"True",
")",
"kwkeys",
"=",
"parse_kwarg_keys",
"(",
"so... | hacky inference of kwargs keys
SeeAlso:
argparse_funckw
recursive_parse_kwargs
parse_kwarg_keys
parse_func_kwarg_keys
get_func_kwargs | [
"hacky",
"inference",
"of",
"kwargs",
"keys"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L2740-L2755 | train | recursive function to parse keyword arguments from sourcecode |
Erotemic/utool | utool/util_inspect.py | get_func_kwargs | def get_func_kwargs(func, recursive=True):
"""
func = ibeis.run_experiment
SeeAlso:
argparse_funckw
recursive_parse_kwargs
parse_kwarg_keys
parse_func_kwarg_keys
get_func_kwargs
"""
import utool as ut
argspec = ut.get_func_argspec(func)
if argspec.def... | python | def get_func_kwargs(func, recursive=True):
"""
func = ibeis.run_experiment
SeeAlso:
argparse_funckw
recursive_parse_kwargs
parse_kwarg_keys
parse_func_kwarg_keys
get_func_kwargs
"""
import utool as ut
argspec = ut.get_func_argspec(func)
if argspec.def... | [
"def",
"get_func_kwargs",
"(",
"func",
",",
"recursive",
"=",
"True",
")",
":",
"import",
"utool",
"as",
"ut",
"argspec",
"=",
"ut",
".",
"get_func_argspec",
"(",
"func",
")",
"if",
"argspec",
".",
"defaults",
"is",
"None",
":",
"header_kw",
"=",
"{",
... | func = ibeis.run_experiment
SeeAlso:
argparse_funckw
recursive_parse_kwargs
parse_kwarg_keys
parse_func_kwarg_keys
get_func_kwargs | [
"func",
"=",
"ibeis",
".",
"run_experiment"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L2758-L2777 | train | get kwargs from a function |
Erotemic/utool | utool/util_inspect.py | parse_kwarg_keys | def parse_kwarg_keys(source, keywords='kwargs', with_vals=False):
r"""
Parses the source code to find keys used by the `**kwargs` keywords
dictionary variable. if `with_vals` is True, we also attempt to infer the
default values.
Args:
source (str):
Returns:
list: kwarg_keys
... | python | def parse_kwarg_keys(source, keywords='kwargs', with_vals=False):
r"""
Parses the source code to find keys used by the `**kwargs` keywords
dictionary variable. if `with_vals` is True, we also attempt to infer the
default values.
Args:
source (str):
Returns:
list: kwarg_keys
... | [
"def",
"parse_kwarg_keys",
"(",
"source",
",",
"keywords",
"=",
"'kwargs'",
",",
"with_vals",
"=",
"False",
")",
":",
"import",
"utool",
"as",
"ut",
"import",
"ast",
"sourcecode",
"=",
"'from __future__ import print_function, unicode_literals\\n'",
"+",
"ut",
".",
... | r"""
Parses the source code to find keys used by the `**kwargs` keywords
dictionary variable. if `with_vals` is True, we also attempt to infer the
default values.
Args:
source (str):
Returns:
list: kwarg_keys
CommandLine:
python -m utool.util_inspect parse_kwarg_keys
... | [
"r",
"Parses",
"the",
"source",
"code",
"to",
"find",
"keys",
"used",
"by",
"the",
"**",
"kwargs",
"keywords",
"dictionary",
"variable",
".",
"if",
"with_vals",
"is",
"True",
"we",
"also",
"attempt",
"to",
"infer",
"the",
"default",
"values",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L2780-L2992 | train | r Parses the source code to find keys used by the kwargs keywords
dictionary variable. |
Erotemic/utool | utool/util_inspect.py | argparse_funckw | def argparse_funckw(func, defaults={}, **kwargs):
"""
allows kwargs to be specified on the commandline from testfuncs
Args:
func (function):
Kwargs:
lbl, verbose, only_specified, force_keys, type_hint, alias_dict
Returns:
dict: funckw
CommandLine:
python -m ut... | python | def argparse_funckw(func, defaults={}, **kwargs):
"""
allows kwargs to be specified on the commandline from testfuncs
Args:
func (function):
Kwargs:
lbl, verbose, only_specified, force_keys, type_hint, alias_dict
Returns:
dict: funckw
CommandLine:
python -m ut... | [
"def",
"argparse_funckw",
"(",
"func",
",",
"defaults",
"=",
"{",
"}",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"utool",
"as",
"ut",
"funckw_",
"=",
"ut",
".",
"get_funckw",
"(",
"func",
",",
"recursive",
"=",
"True",
")",
"funckw_",
".",
"update... | allows kwargs to be specified on the commandline from testfuncs
Args:
func (function):
Kwargs:
lbl, verbose, only_specified, force_keys, type_hint, alias_dict
Returns:
dict: funckw
CommandLine:
python -m utool.util_inspect argparse_funckw
SeeAlso:
exec_fu... | [
"allows",
"kwargs",
"to",
"be",
"specified",
"on",
"the",
"commandline",
"from",
"testfuncs"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L3030-L3069 | train | A wrapper for argparse. get_funckw that returns a dict of the arguments passed to the function |
Erotemic/utool | utool/util_inspect.py | infer_function_info | def infer_function_info(func):
r"""
Infers information for make_default_docstr
# TODO: Interleave old documentation with new documentation
Args:
func (function): live python function
CommandLine:
python -m utool --tf infer_function_info:0
python -m utool --tf infer_function... | python | def infer_function_info(func):
r"""
Infers information for make_default_docstr
# TODO: Interleave old documentation with new documentation
Args:
func (function): live python function
CommandLine:
python -m utool --tf infer_function_info:0
python -m utool --tf infer_function... | [
"def",
"infer_function_info",
"(",
"func",
")",
":",
"import",
"utool",
"as",
"ut",
"import",
"re",
"# TODO: allow a jedi argument",
"if",
"False",
":",
"from",
"jedi",
".",
"evaluate",
"import",
"docstrings",
"script",
"=",
"func",
".",
"script",
"argname_list"... | r"""
Infers information for make_default_docstr
# TODO: Interleave old documentation with new documentation
Args:
func (function): live python function
CommandLine:
python -m utool --tf infer_function_info:0
python -m utool --tf infer_function_info:1 --funcname=ibeis_cnn.models... | [
"r",
"Infers",
"information",
"for",
"make_default_docstr",
"#",
"TODO",
":",
"Interleave",
"old",
"documentation",
"with",
"new",
"documentation"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L3072-L3275 | train | r Infer information for a function |
glormph/msstitch | src/app/drivers/mzidtsv/spectra.py | TSVSpectraDriver.get_psms | def get_psms(self):
"""Creates iterator to write to new tsv. Contains input tsv
lines plus quant data for these."""
self.header = actions.create_header(self.oldheader, self.spectracol)
self.psms = actions.generate_psms_spectradata(self.lookup, self.fn,
... | python | def get_psms(self):
"""Creates iterator to write to new tsv. Contains input tsv
lines plus quant data for these."""
self.header = actions.create_header(self.oldheader, self.spectracol)
self.psms = actions.generate_psms_spectradata(self.lookup, self.fn,
... | [
"def",
"get_psms",
"(",
"self",
")",
":",
"self",
".",
"header",
"=",
"actions",
".",
"create_header",
"(",
"self",
".",
"oldheader",
",",
"self",
".",
"spectracol",
")",
"self",
".",
"psms",
"=",
"actions",
".",
"generate_psms_spectradata",
"(",
"self",
... | Creates iterator to write to new tsv. Contains input tsv
lines plus quant data for these. | [
"Creates",
"iterator",
"to",
"write",
"to",
"new",
"tsv",
".",
"Contains",
"input",
"tsv",
"lines",
"plus",
"quant",
"data",
"for",
"these",
"."
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/drivers/mzidtsv/spectra.py#L18-L23 | train | Creates iterator to write to new tsv. Contains input tsv
lines plus quant data for these. |
Erotemic/utool | _broken/_grave.py | roundrobin | def roundrobin(*iterables):
"""roundrobin('ABC', 'D', 'EF') --> A D E B F C"""
raise NotImplementedError('not sure if this implementation is correct')
# http://stackoverflow.com/questions/11125212/interleaving-lists-in-python
#sentinel = object()
#return (x for x in chain(*zip_longest(fillvalue=sent... | python | def roundrobin(*iterables):
"""roundrobin('ABC', 'D', 'EF') --> A D E B F C"""
raise NotImplementedError('not sure if this implementation is correct')
# http://stackoverflow.com/questions/11125212/interleaving-lists-in-python
#sentinel = object()
#return (x for x in chain(*zip_longest(fillvalue=sent... | [
"def",
"roundrobin",
"(",
"*",
"iterables",
")",
":",
"raise",
"NotImplementedError",
"(",
"'not sure if this implementation is correct'",
")",
"# http://stackoverflow.com/questions/11125212/interleaving-lists-in-python",
"#sentinel = object()",
"#return (x for x in chain(*zip_longest(fi... | roundrobin('ABC', 'D', 'EF') --> A D E B F C | [
"roundrobin",
"(",
"ABC",
"D",
"EF",
")",
"--",
">",
"A",
"D",
"E",
"B",
"F",
"C"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/_broken/_grave.py#L47-L64 | train | Yields the elements of the given iterable in order. |
Erotemic/utool | _broken/_grave.py | format_ | def format_(num, n=8):
"""
makes numbers pretty e.g.
nums = [9001, 9.053]
print([format_(num) for num in nums])
"""
if num is None:
return 'None'
if util_type.is_float(num):
ret = ('%.' + str(n) + 'E') % num
exp_pos = ret.find('E')
exp_part = ret[... | python | def format_(num, n=8):
"""
makes numbers pretty e.g.
nums = [9001, 9.053]
print([format_(num) for num in nums])
"""
if num is None:
return 'None'
if util_type.is_float(num):
ret = ('%.' + str(n) + 'E') % num
exp_pos = ret.find('E')
exp_part = ret[... | [
"def",
"format_",
"(",
"num",
",",
"n",
"=",
"8",
")",
":",
"if",
"num",
"is",
"None",
":",
"return",
"'None'",
"if",
"util_type",
".",
"is_float",
"(",
"num",
")",
":",
"ret",
"=",
"(",
"'%.'",
"+",
"str",
"(",
"n",
")",
"+",
"'E'",
")",
"%"... | makes numbers pretty e.g.
nums = [9001, 9.053]
print([format_(num) for num in nums]) | [
"makes",
"numbers",
"pretty",
"e",
".",
"g",
".",
"nums",
"=",
"[",
"9001",
"9",
".",
"053",
"]",
"print",
"(",
"[",
"format_",
"(",
"num",
")",
"for",
"num",
"in",
"nums",
"]",
")"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/_broken/_grave.py#L111-L132 | train | Formats a number into a human readable string. |
neithere/monk | monk/manipulation.py | normalize_list_of_dicts | def normalize_list_of_dicts(value, default_key, default_value=UNDEFINED):
"""
Converts given value to a list of dictionaries as follows:
* ``[{...}]`` → ``[{...}]``
* ``{...}`` → ``[{...}]``
* ``'xyz'`` → ``[{default_key: 'xyz'}]``
* ``None`` → ``[{default_key: default_value}]`` (if spe... | python | def normalize_list_of_dicts(value, default_key, default_value=UNDEFINED):
"""
Converts given value to a list of dictionaries as follows:
* ``[{...}]`` → ``[{...}]``
* ``{...}`` → ``[{...}]``
* ``'xyz'`` → ``[{default_key: 'xyz'}]``
* ``None`` → ``[{default_key: default_value}]`` (if spe... | [
"def",
"normalize_list_of_dicts",
"(",
"value",
",",
"default_key",
",",
"default_value",
"=",
"UNDEFINED",
")",
":",
"if",
"value",
"is",
"None",
":",
"if",
"default_value",
"is",
"UNDEFINED",
":",
"return",
"[",
"]",
"value",
"=",
"default_value",
"if",
"i... | Converts given value to a list of dictionaries as follows:
* ``[{...}]`` → ``[{...}]``
* ``{...}`` → ``[{...}]``
* ``'xyz'`` → ``[{default_key: 'xyz'}]``
* ``None`` → ``[{default_key: default_value}]`` (if specified)
* ``None`` → ``[]``
:param default_value:
only Unicode, i.... | [
"Converts",
"given",
"value",
"to",
"a",
"list",
"of",
"dictionaries",
"as",
"follows",
":"
] | 4b2ee5152b081ac288ce8568422a027b5e7d2b1c | https://github.com/neithere/monk/blob/4b2ee5152b081ac288ce8568422a027b5e7d2b1c/monk/manipulation.py#L108-L139 | train | Converts given value to a list of dictionaries as follows |
Erotemic/utool | utool/Preferences.py | _qt_set_leaf_data | def _qt_set_leaf_data(self, qvar):
""" Sets backend data using QVariants """
if VERBOSE_PREF:
print('')
print('+--- [pref.qt_set_leaf_data]')
print('[pref.qt_set_leaf_data] qvar = %r' % qvar)
print('[pref.qt_set_leaf_data] _intern.name=%r' % self._intern.name)
print('[pre... | python | def _qt_set_leaf_data(self, qvar):
""" Sets backend data using QVariants """
if VERBOSE_PREF:
print('')
print('+--- [pref.qt_set_leaf_data]')
print('[pref.qt_set_leaf_data] qvar = %r' % qvar)
print('[pref.qt_set_leaf_data] _intern.name=%r' % self._intern.name)
print('[pre... | [
"def",
"_qt_set_leaf_data",
"(",
"self",
",",
"qvar",
")",
":",
"if",
"VERBOSE_PREF",
":",
"print",
"(",
"''",
")",
"print",
"(",
"'+--- [pref.qt_set_leaf_data]'",
")",
"print",
"(",
"'[pref.qt_set_leaf_data] qvar = %r'",
"%",
"qvar",
")",
"print",
"(",
"'[pref.... | Sets backend data using QVariants | [
"Sets",
"backend",
"data",
"using",
"QVariants"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/Preferences.py#L511-L591 | train | Sets the backend data for the leafs of the tree. |
Erotemic/utool | utool/Preferences.py | Pref.toggle | def toggle(self, key):
""" Toggles a boolean key """
val = self[key]
assert isinstance(val, bool), 'key[%r] = %r is not a bool' % (key, val)
self.pref_update(key, not val) | python | def toggle(self, key):
""" Toggles a boolean key """
val = self[key]
assert isinstance(val, bool), 'key[%r] = %r is not a bool' % (key, val)
self.pref_update(key, not val) | [
"def",
"toggle",
"(",
"self",
",",
"key",
")",
":",
"val",
"=",
"self",
"[",
"key",
"]",
"assert",
"isinstance",
"(",
"val",
",",
"bool",
")",
",",
"'key[%r] = %r is not a bool'",
"%",
"(",
"key",
",",
"val",
")",
"self",
".",
"pref_update",
"(",
"ke... | Toggles a boolean key | [
"Toggles",
"a",
"boolean",
"key"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/Preferences.py#L143-L147 | train | Toggles a boolean key |
Erotemic/utool | utool/Preferences.py | Pref.change_combo_val | def change_combo_val(self, new_val):
"""
Checks to see if a selection is a valid index or choice of a combo
preference
"""
choice_obj = self._intern.value
assert isinstance(self._intern.value, PrefChoice), 'must be a choice'
return choice_obj.get_tuple() | python | def change_combo_val(self, new_val):
"""
Checks to see if a selection is a valid index or choice of a combo
preference
"""
choice_obj = self._intern.value
assert isinstance(self._intern.value, PrefChoice), 'must be a choice'
return choice_obj.get_tuple() | [
"def",
"change_combo_val",
"(",
"self",
",",
"new_val",
")",
":",
"choice_obj",
"=",
"self",
".",
"_intern",
".",
"value",
"assert",
"isinstance",
"(",
"self",
".",
"_intern",
".",
"value",
",",
"PrefChoice",
")",
",",
"'must be a choice'",
"return",
"choice... | Checks to see if a selection is a valid index or choice of a combo
preference | [
"Checks",
"to",
"see",
"if",
"a",
"selection",
"is",
"a",
"valid",
"index",
"or",
"choice",
"of",
"a",
"combo",
"preference"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/Preferences.py#L149-L156 | train | Changes the value of the combo item |
Erotemic/utool | utool/Preferences.py | Pref.__new_attr | def __new_attr(self, name, attr):
"""
On a new child attribute:
1) Check to see if it is wrapped by a Pref object
2) If not do so, if so add it to the tree structure
"""
if isinstance(attr, Pref):
# Child attribute already has a Pref wrapping
... | python | def __new_attr(self, name, attr):
"""
On a new child attribute:
1) Check to see if it is wrapped by a Pref object
2) If not do so, if so add it to the tree structure
"""
if isinstance(attr, Pref):
# Child attribute already has a Pref wrapping
... | [
"def",
"__new_attr",
"(",
"self",
",",
"name",
",",
"attr",
")",
":",
"if",
"isinstance",
"(",
"attr",
",",
"Pref",
")",
":",
"# Child attribute already has a Pref wrapping",
"if",
"VERBOSE_PREF",
":",
"print",
"(",
"'[pref.__new_attr]: %s.%s = %r'",
"%",
"(",
"... | On a new child attribute:
1) Check to see if it is wrapped by a Pref object
2) If not do so, if so add it to the tree structure | [
"On",
"a",
"new",
"child",
"attribute",
":",
"1",
")",
"Check",
"to",
"see",
"if",
"it",
"is",
"wrapped",
"by",
"a",
"Pref",
"object",
"2",
")",
"If",
"not",
"do",
"so",
"if",
"so",
"add",
"it",
"to",
"the",
"tree",
"structure"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/Preferences.py#L197-L225 | train | Add a new child attribute to the tree structure. |
Erotemic/utool | utool/Preferences.py | Pref.iteritems | def iteritems(self):
"""
Wow this class is messed up. I had to overwrite items when
moving to python3, just because I haden't called it yet
"""
for (key, val) in six.iteritems(self.__dict__):
if key in self._printable_exclude:
continue
yiel... | python | def iteritems(self):
"""
Wow this class is messed up. I had to overwrite items when
moving to python3, just because I haden't called it yet
"""
for (key, val) in six.iteritems(self.__dict__):
if key in self._printable_exclude:
continue
yiel... | [
"def",
"iteritems",
"(",
"self",
")",
":",
"for",
"(",
"key",
",",
"val",
")",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"__dict__",
")",
":",
"if",
"key",
"in",
"self",
".",
"_printable_exclude",
":",
"continue",
"yield",
"(",
"key",
",",
"... | Wow this class is messed up. I had to overwrite items when
moving to python3, just because I haden't called it yet | [
"Wow",
"this",
"class",
"is",
"messed",
"up",
".",
"I",
"had",
"to",
"overwrite",
"items",
"when",
"moving",
"to",
"python3",
"just",
"because",
"I",
"haden",
"t",
"called",
"it",
"yet"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/Preferences.py#L320-L328 | train | Iterate over the items of the object. |
Erotemic/utool | utool/Preferences.py | Pref.to_dict | def to_dict(self, split_structs_bit=False):
""" Converts prefeters to a dictionary.
Children Pref can be optionally separated """
pref_dict = {}
struct_dict = {}
for (key, val) in six.iteritems(self):
if split_structs_bit and isinstance(val, Pref):
str... | python | def to_dict(self, split_structs_bit=False):
""" Converts prefeters to a dictionary.
Children Pref can be optionally separated """
pref_dict = {}
struct_dict = {}
for (key, val) in six.iteritems(self):
if split_structs_bit and isinstance(val, Pref):
str... | [
"def",
"to_dict",
"(",
"self",
",",
"split_structs_bit",
"=",
"False",
")",
":",
"pref_dict",
"=",
"{",
"}",
"struct_dict",
"=",
"{",
"}",
"for",
"(",
"key",
",",
"val",
")",
"in",
"six",
".",
"iteritems",
"(",
"self",
")",
":",
"if",
"split_structs_... | Converts prefeters to a dictionary.
Children Pref can be optionally separated | [
"Converts",
"prefeters",
"to",
"a",
"dictionary",
".",
"Children",
"Pref",
"can",
"be",
"optionally",
"separated"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/Preferences.py#L342-L354 | train | Converts prefeters to a dictionary. |
Erotemic/utool | utool/Preferences.py | Pref.save | def save(self):
""" Saves prefs to disk in dict format """
fpath = self.get_fpath()
if fpath in ['', None]:
if self._tree.parent is not None:
if VERBOSE_PREF:
print('[pref.save] Can my parent save me?') # ...to disk
return self._tr... | python | def save(self):
""" Saves prefs to disk in dict format """
fpath = self.get_fpath()
if fpath in ['', None]:
if self._tree.parent is not None:
if VERBOSE_PREF:
print('[pref.save] Can my parent save me?') # ...to disk
return self._tr... | [
"def",
"save",
"(",
"self",
")",
":",
"fpath",
"=",
"self",
".",
"get_fpath",
"(",
")",
"if",
"fpath",
"in",
"[",
"''",
",",
"None",
"]",
":",
"if",
"self",
".",
"_tree",
".",
"parent",
"is",
"not",
"None",
":",
"if",
"VERBOSE_PREF",
":",
"print"... | Saves prefs to disk in dict format | [
"Saves",
"prefs",
"to",
"disk",
"in",
"dict",
"format"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/Preferences.py#L358-L373 | train | Saves prefs to disk in dict format |
Erotemic/utool | utool/Preferences.py | Pref.load | def load(self):
""" Read pref dict stored on disk. Overwriting current values. """
if VERBOSE_PREF:
print('[pref.load()]')
#if not os.path.exists(self._intern.fpath):
# msg = '[pref] fpath=%r does not exist' % (self._intern.fpath)
# return msg
... | python | def load(self):
""" Read pref dict stored on disk. Overwriting current values. """
if VERBOSE_PREF:
print('[pref.load()]')
#if not os.path.exists(self._intern.fpath):
# msg = '[pref] fpath=%r does not exist' % (self._intern.fpath)
# return msg
... | [
"def",
"load",
"(",
"self",
")",
":",
"if",
"VERBOSE_PREF",
":",
"print",
"(",
"'[pref.load()]'",
")",
"#if not os.path.exists(self._intern.fpath):",
"# msg = '[pref] fpath=%r does not exist' % (self._intern.fpath)",
"# return msg",
"fpath",
"=",
"self",
".",
"get_fpath... | Read pref dict stored on disk. Overwriting current values. | [
"Read",
"pref",
"dict",
"stored",
"on",
"disk",
".",
"Overwriting",
"current",
"values",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/Preferences.py#L378-L404 | train | Load the pref dict stored on disk. Overwrites current values. |
Erotemic/utool | utool/Preferences.py | Pref.full_name | def full_name(self):
""" returns name all the way up the tree """
if self._tree.parent is None:
return self._intern.name
return self._tree.parent.full_name() + '.' + self._intern.name | python | def full_name(self):
""" returns name all the way up the tree """
if self._tree.parent is None:
return self._intern.name
return self._tree.parent.full_name() + '.' + self._intern.name | [
"def",
"full_name",
"(",
"self",
")",
":",
"if",
"self",
".",
"_tree",
".",
"parent",
"is",
"None",
":",
"return",
"self",
".",
"_intern",
".",
"name",
"return",
"self",
".",
"_tree",
".",
"parent",
".",
"full_name",
"(",
")",
"+",
"'.'",
"+",
"sel... | returns name all the way up the tree | [
"returns",
"name",
"all",
"the",
"way",
"up",
"the",
"tree"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/Preferences.py#L418-L422 | train | returns the full name of the user |
Erotemic/utool | utool/Preferences.py | Pref.pref_update | def pref_update(self, key, new_val):
""" Changes a preference value and saves it to disk """
print('Update and save pref from: %s=%r, to: %s=%r' %
(key, six.text_type(self[key]), key, six.text_type(new_val)))
self.__setattr__(key, new_val)
return self.save() | python | def pref_update(self, key, new_val):
""" Changes a preference value and saves it to disk """
print('Update and save pref from: %s=%r, to: %s=%r' %
(key, six.text_type(self[key]), key, six.text_type(new_val)))
self.__setattr__(key, new_val)
return self.save() | [
"def",
"pref_update",
"(",
"self",
",",
"key",
",",
"new_val",
")",
":",
"print",
"(",
"'Update and save pref from: %s=%r, to: %s=%r'",
"%",
"(",
"key",
",",
"six",
".",
"text_type",
"(",
"self",
"[",
"key",
"]",
")",
",",
"key",
",",
"six",
".",
"text_t... | Changes a preference value and saves it to disk | [
"Changes",
"a",
"preference",
"value",
"and",
"saves",
"it",
"to",
"disk"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/Preferences.py#L441-L446 | train | Updates a preference value and saves it to disk |
product-definition-center/pdc-client | pdc_client/plugins/permission.py | PermissionPlugin.__get_permissions | def __get_permissions(self, res, **kwargs):
"""
This call returns current login user's permissions.
"""
response = res._(**kwargs)
return response.get('permissions', None) | python | def __get_permissions(self, res, **kwargs):
"""
This call returns current login user's permissions.
"""
response = res._(**kwargs)
return response.get('permissions', None) | [
"def",
"__get_permissions",
"(",
"self",
",",
"res",
",",
"*",
"*",
"kwargs",
")",
":",
"response",
"=",
"res",
".",
"_",
"(",
"*",
"*",
"kwargs",
")",
"return",
"response",
".",
"get",
"(",
"'permissions'",
",",
"None",
")"
] | This call returns current login user's permissions. | [
"This",
"call",
"returns",
"current",
"login",
"user",
"s",
"permissions",
"."
] | 7236fd8b72e675ebb321bbe337289d9fbeb6119f | https://github.com/product-definition-center/pdc-client/blob/7236fd8b72e675ebb321bbe337289d9fbeb6119f/pdc_client/plugins/permission.py#L32-L37 | train | This method returns current login user s permissions. |
Erotemic/utool | utool/util_class.py | inject_instance | def inject_instance(self, classkey=None, allow_override=False,
verbose=VERBOSE_CLASS, strict=True):
"""
Injects an instance (self) of type (classkey)
with all functions registered to (classkey)
call this in the __init__ class function
Args:
self: the class instance
... | python | def inject_instance(self, classkey=None, allow_override=False,
verbose=VERBOSE_CLASS, strict=True):
"""
Injects an instance (self) of type (classkey)
with all functions registered to (classkey)
call this in the __init__ class function
Args:
self: the class instance
... | [
"def",
"inject_instance",
"(",
"self",
",",
"classkey",
"=",
"None",
",",
"allow_override",
"=",
"False",
",",
"verbose",
"=",
"VERBOSE_CLASS",
",",
"strict",
"=",
"True",
")",
":",
"import",
"utool",
"as",
"ut",
"if",
"verbose",
":",
"print",
"(",
"'[ut... | Injects an instance (self) of type (classkey)
with all functions registered to (classkey)
call this in the __init__ class function
Args:
self: the class instance
classkey: key for a class, preferably the class type itself, but it
doesnt have to be
SeeAlso:
make_cla... | [
"Injects",
"an",
"instance",
"(",
"self",
")",
"of",
"type",
"(",
"classkey",
")",
"with",
"all",
"functions",
"registered",
"to",
"(",
"classkey",
")"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_class.py#L53-L116 | train | Injects an instance of the class with all functions registered to the classkey. |
Erotemic/utool | utool/util_class.py | inject_all_external_modules | def inject_all_external_modules(self, classname=None,
allow_override='override+warn',
strict=True):
"""
dynamically injects registered module methods into a class instance
FIXME: naming convention and use this in all places where this clas is ... | python | def inject_all_external_modules(self, classname=None,
allow_override='override+warn',
strict=True):
"""
dynamically injects registered module methods into a class instance
FIXME: naming convention and use this in all places where this clas is ... | [
"def",
"inject_all_external_modules",
"(",
"self",
",",
"classname",
"=",
"None",
",",
"allow_override",
"=",
"'override+warn'",
",",
"strict",
"=",
"True",
")",
":",
"#import utool as ut",
"if",
"classname",
"is",
"None",
":",
"classname",
"=",
"self",
".",
"... | dynamically injects registered module methods into a class instance
FIXME: naming convention and use this in all places where this clas is used | [
"dynamically",
"injects",
"registered",
"module",
"methods",
"into",
"a",
"class",
"instance"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_class.py#L128-L160 | train | injects all external modules into a class instance |
Erotemic/utool | utool/util_class.py | get_injected_modules | def get_injected_modules(classname):
r"""
Example:
>>> # DISABLE_DOCTEST
>>> from utool.util_class import __CLASSNAME_CLASSKEY_REGISTER__ # NOQA
"""
modname_list = __CLASSNAME_CLASSKEY_REGISTER__[classname]
injected_modules = []
for modstr in modname_list:
parts = modst... | python | def get_injected_modules(classname):
r"""
Example:
>>> # DISABLE_DOCTEST
>>> from utool.util_class import __CLASSNAME_CLASSKEY_REGISTER__ # NOQA
"""
modname_list = __CLASSNAME_CLASSKEY_REGISTER__[classname]
injected_modules = []
for modstr in modname_list:
parts = modst... | [
"def",
"get_injected_modules",
"(",
"classname",
")",
":",
"modname_list",
"=",
"__CLASSNAME_CLASSKEY_REGISTER__",
"[",
"classname",
"]",
"injected_modules",
"=",
"[",
"]",
"for",
"modstr",
"in",
"modname_list",
":",
"parts",
"=",
"modstr",
".",
"split",
"(",
"'... | r"""
Example:
>>> # DISABLE_DOCTEST
>>> from utool.util_class import __CLASSNAME_CLASSKEY_REGISTER__ # NOQA | [
"r",
"Example",
":",
">>>",
"#",
"DISABLE_DOCTEST",
">>>",
"from",
"utool",
".",
"util_class",
"import",
"__CLASSNAME_CLASSKEY_REGISTER__",
"#",
"NOQA"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_class.py#L174-L193 | train | r Returns a list of modules that are injected by the given class. |
Erotemic/utool | utool/util_class.py | autogen_explicit_injectable_metaclass | def autogen_explicit_injectable_metaclass(classname, regen_command=None,
conditional_imports=None):
r"""
Args:
classname (?):
Returns:
?:
CommandLine:
python -m utool.util_class --exec-autogen_explicit_injectable_metaclass
Example:... | python | def autogen_explicit_injectable_metaclass(classname, regen_command=None,
conditional_imports=None):
r"""
Args:
classname (?):
Returns:
?:
CommandLine:
python -m utool.util_class --exec-autogen_explicit_injectable_metaclass
Example:... | [
"def",
"autogen_explicit_injectable_metaclass",
"(",
"classname",
",",
"regen_command",
"=",
"None",
",",
"conditional_imports",
"=",
"None",
")",
":",
"import",
"utool",
"as",
"ut",
"vals_list",
"=",
"[",
"]",
"def",
"make_redirect",
"(",
"func",
")",
":",
"#... | r"""
Args:
classname (?):
Returns:
?:
CommandLine:
python -m utool.util_class --exec-autogen_explicit_injectable_metaclass
Example:
>>> # DISABLE_DOCTEST
>>> from utool.util_class import * # NOQA
>>> from utool.util_class import __CLASSTYPE_ATTRIBUTES... | [
"r",
"Args",
":",
"classname",
"(",
"?",
")",
":"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_class.py#L226-L325 | train | r Automatically creates explicit injectable metaclass |
Erotemic/utool | utool/util_class.py | make_class_method_decorator | def make_class_method_decorator(classkey, modname=None):
"""
register a class to be injectable
classkey is a key that identifies the injected class
REMEMBER to call inject_instance in __init__
Args:
classkey : the class to be injected into
modname : the global __name__ of the module... | python | def make_class_method_decorator(classkey, modname=None):
"""
register a class to be injectable
classkey is a key that identifies the injected class
REMEMBER to call inject_instance in __init__
Args:
classkey : the class to be injected into
modname : the global __name__ of the module... | [
"def",
"make_class_method_decorator",
"(",
"classkey",
",",
"modname",
"=",
"None",
")",
":",
"global",
"__APP_MODNAME_REGISTER__",
"#if util_arg.VERBOSE or VERBOSE_CLASS:",
"if",
"VERBOSE_CLASS",
":",
"print",
"(",
"'[util_class] register via make_class_method_decorator classkey... | register a class to be injectable
classkey is a key that identifies the injected class
REMEMBER to call inject_instance in __init__
Args:
classkey : the class to be injected into
modname : the global __name__ of the module youa re injecting from
Returns:
closure_decorate_class_... | [
"register",
"a",
"class",
"to",
"be",
"injectable",
"classkey",
"is",
"a",
"key",
"that",
"identifies",
"the",
"injected",
"class",
"REMEMBER",
"to",
"call",
"inject_instance",
"in",
"__init__"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_class.py#L328-L386 | train | This function creates a decorator for injectable methods in a CheeseShop class. |
Erotemic/utool | utool/util_class.py | make_class_postinject_decorator | def make_class_postinject_decorator(classkey, modname=None):
"""
Args:
classkey : the class to be injected into
modname : the global __name__ of the module youa re injecting from
Returns:
closure_decorate_postinject (func): decorator for injectable methods
SeeAlso:
make... | python | def make_class_postinject_decorator(classkey, modname=None):
"""
Args:
classkey : the class to be injected into
modname : the global __name__ of the module youa re injecting from
Returns:
closure_decorate_postinject (func): decorator for injectable methods
SeeAlso:
make... | [
"def",
"make_class_postinject_decorator",
"(",
"classkey",
",",
"modname",
"=",
"None",
")",
":",
"if",
"util_arg",
".",
"VERBOSE",
"or",
"VERBOSE_CLASS",
":",
"print",
"(",
"'[util_class] register class_postinject classkey=%r, modname=%r'",
"%",
"(",
"classkey",
",",
... | Args:
classkey : the class to be injected into
modname : the global __name__ of the module youa re injecting from
Returns:
closure_decorate_postinject (func): decorator for injectable methods
SeeAlso:
make_class_method_decorator | [
"Args",
":",
"classkey",
":",
"the",
"class",
"to",
"be",
"injected",
"into",
"modname",
":",
"the",
"global",
"__name__",
"of",
"the",
"module",
"youa",
"re",
"injecting",
"from"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_class.py#L389-L410 | train | Decorator for injectable methods in the class. |
Erotemic/utool | utool/util_class.py | decorate_class_method | def decorate_class_method(func, classkey=None, skipmain=False):
"""
Will inject all decorated function as methods of classkey
classkey is some identifying string, tuple, or object
func can also be a tuple
"""
#import utool as ut
global __CLASSTYPE_ATTRIBUTES__
assert classkey is not No... | python | def decorate_class_method(func, classkey=None, skipmain=False):
"""
Will inject all decorated function as methods of classkey
classkey is some identifying string, tuple, or object
func can also be a tuple
"""
#import utool as ut
global __CLASSTYPE_ATTRIBUTES__
assert classkey is not No... | [
"def",
"decorate_class_method",
"(",
"func",
",",
"classkey",
"=",
"None",
",",
"skipmain",
"=",
"False",
")",
":",
"#import utool as ut",
"global",
"__CLASSTYPE_ATTRIBUTES__",
"assert",
"classkey",
"is",
"not",
"None",
",",
"'must specify classkey'",
"#if not (skipma... | Will inject all decorated function as methods of classkey
classkey is some identifying string, tuple, or object
func can also be a tuple | [
"Will",
"inject",
"all",
"decorated",
"function",
"as",
"methods",
"of",
"classkey"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_class.py#L413-L426 | train | Decorator for classkey |
Erotemic/utool | utool/util_class.py | decorate_postinject | def decorate_postinject(func, classkey=None, skipmain=False):
"""
Will perform func with argument self after inject_instance is called on classkey
classkey is some identifying string, tuple, or object
"""
#import utool as ut
global __CLASSTYPE_POSTINJECT_FUNCS__
assert classkey is not None,... | python | def decorate_postinject(func, classkey=None, skipmain=False):
"""
Will perform func with argument self after inject_instance is called on classkey
classkey is some identifying string, tuple, or object
"""
#import utool as ut
global __CLASSTYPE_POSTINJECT_FUNCS__
assert classkey is not None,... | [
"def",
"decorate_postinject",
"(",
"func",
",",
"classkey",
"=",
"None",
",",
"skipmain",
"=",
"False",
")",
":",
"#import utool as ut",
"global",
"__CLASSTYPE_POSTINJECT_FUNCS__",
"assert",
"classkey",
"is",
"not",
"None",
",",
"'must specify classkey'",
"#if not (sk... | Will perform func with argument self after inject_instance is called on classkey
classkey is some identifying string, tuple, or object | [
"Will",
"perform",
"func",
"with",
"argument",
"self",
"after",
"inject_instance",
"is",
"called",
"on",
"classkey"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_class.py#L429-L440 | train | Decorator to add a function to the postinject function |
Erotemic/utool | utool/util_class.py | inject_func_as_method | def inject_func_as_method(self, func, method_name=None, class_=None,
allow_override=False, allow_main=False,
verbose=True, override=None, force=False):
""" Injects a function into an object as a method
Wraps func as a bound method of self. Then injects func i... | python | def inject_func_as_method(self, func, method_name=None, class_=None,
allow_override=False, allow_main=False,
verbose=True, override=None, force=False):
""" Injects a function into an object as a method
Wraps func as a bound method of self. Then injects func i... | [
"def",
"inject_func_as_method",
"(",
"self",
",",
"func",
",",
"method_name",
"=",
"None",
",",
"class_",
"=",
"None",
",",
"allow_override",
"=",
"False",
",",
"allow_main",
"=",
"False",
",",
"verbose",
"=",
"True",
",",
"override",
"=",
"None",
",",
"... | Injects a function into an object as a method
Wraps func as a bound method of self. Then injects func into self
It is preferable to use make_class_method_decorator and inject_instance
Args:
self (object): class instance
func : some function whos first arugment is a class instance
meth... | [
"Injects",
"a",
"function",
"into",
"an",
"object",
"as",
"a",
"method"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_class.py#L454-L520 | train | Injects a function into an object as a method of the class instance. |
Erotemic/utool | utool/util_class.py | inject_func_as_property | def inject_func_as_property(self, func, method_name=None, class_=None):
"""
WARNING:
properties are more safely injected using metaclasses
References:
http://stackoverflow.com/questions/13850114/dynamically-adding-methods-with-or-without-metaclass-in-python
"""
if method_name is Non... | python | def inject_func_as_property(self, func, method_name=None, class_=None):
"""
WARNING:
properties are more safely injected using metaclasses
References:
http://stackoverflow.com/questions/13850114/dynamically-adding-methods-with-or-without-metaclass-in-python
"""
if method_name is Non... | [
"def",
"inject_func_as_property",
"(",
"self",
",",
"func",
",",
"method_name",
"=",
"None",
",",
"class_",
"=",
"None",
")",
":",
"if",
"method_name",
"is",
"None",
":",
"method_name",
"=",
"get_funcname",
"(",
"func",
")",
"#new_method = func.__get__(self, sel... | WARNING:
properties are more safely injected using metaclasses
References:
http://stackoverflow.com/questions/13850114/dynamically-adding-methods-with-or-without-metaclass-in-python | [
"WARNING",
":",
"properties",
"are",
"more",
"safely",
"injected",
"using",
"metaclasses"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_class.py#L523-L535 | train | Injects a function as a property of the current object. |
Erotemic/utool | utool/util_class.py | inject_func_as_unbound_method | def inject_func_as_unbound_method(class_, func, method_name=None):
""" This is actually quite simple """
if method_name is None:
method_name = get_funcname(func)
setattr(class_, method_name, func) | python | def inject_func_as_unbound_method(class_, func, method_name=None):
""" This is actually quite simple """
if method_name is None:
method_name = get_funcname(func)
setattr(class_, method_name, func) | [
"def",
"inject_func_as_unbound_method",
"(",
"class_",
",",
"func",
",",
"method_name",
"=",
"None",
")",
":",
"if",
"method_name",
"is",
"None",
":",
"method_name",
"=",
"get_funcname",
"(",
"func",
")",
"setattr",
"(",
"class_",
",",
"method_name",
",",
"f... | This is actually quite simple | [
"This",
"is",
"actually",
"quite",
"simple"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_class.py#L538-L542 | train | Injects a function as an unbound method of the given class. |
Erotemic/utool | utool/util_class.py | makeForwardingMetaclass | def makeForwardingMetaclass(forwarding_dest_getter, whitelist, base_class=object):
"""
makes a metaclass that overrides __getattr__ and __setattr__ to forward some
specific attribute references to a specified instance variable
"""
class ForwardingMetaclass(base_class.__class__):
def __init__... | python | def makeForwardingMetaclass(forwarding_dest_getter, whitelist, base_class=object):
"""
makes a metaclass that overrides __getattr__ and __setattr__ to forward some
specific attribute references to a specified instance variable
"""
class ForwardingMetaclass(base_class.__class__):
def __init__... | [
"def",
"makeForwardingMetaclass",
"(",
"forwarding_dest_getter",
",",
"whitelist",
",",
"base_class",
"=",
"object",
")",
":",
"class",
"ForwardingMetaclass",
"(",
"base_class",
".",
"__class__",
")",
":",
"def",
"__init__",
"(",
"metaself",
",",
"name",
",",
"b... | makes a metaclass that overrides __getattr__ and __setattr__ to forward some
specific attribute references to a specified instance variable | [
"makes",
"a",
"metaclass",
"that",
"overrides",
"__getattr__",
"and",
"__setattr__",
"to",
"forward",
"some",
"specific",
"attribute",
"references",
"to",
"a",
"specified",
"instance",
"variable"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_class.py#L545-L577 | train | Creates a metaclass that overrides __getattr__ and __setattr__ to forward some attribute references to a specified instance variable. |
Erotemic/utool | utool/util_class.py | reloading_meta_metaclass_factory | def reloading_meta_metaclass_factory(BASE_TYPE=type):
""" hack for pyqt """
class ReloadingMetaclass2(BASE_TYPE):
def __init__(metaself, name, bases, dct):
super(ReloadingMetaclass2, metaself).__init__(name, bases, dct)
#print('Making rrr for %r' % (name,))
metaself.r... | python | def reloading_meta_metaclass_factory(BASE_TYPE=type):
""" hack for pyqt """
class ReloadingMetaclass2(BASE_TYPE):
def __init__(metaself, name, bases, dct):
super(ReloadingMetaclass2, metaself).__init__(name, bases, dct)
#print('Making rrr for %r' % (name,))
metaself.r... | [
"def",
"reloading_meta_metaclass_factory",
"(",
"BASE_TYPE",
"=",
"type",
")",
":",
"class",
"ReloadingMetaclass2",
"(",
"BASE_TYPE",
")",
":",
"def",
"__init__",
"(",
"metaself",
",",
"name",
",",
"bases",
",",
"dct",
")",
":",
"super",
"(",
"ReloadingMetacla... | hack for pyqt | [
"hack",
"for",
"pyqt"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_class.py#L695-L702 | train | creates a reloading metaclass class that is a class that is a subclass of the base class. |
Erotemic/utool | utool/util_class.py | reload_class | def reload_class(self, verbose=True, reload_module=True):
"""
special class reloading function
This function is often injected as rrr of classes
"""
import utool as ut
verbose = verbose or VERBOSE_CLASS
classname = self.__class__.__name__
try:
modname = self.__class__.__module__
... | python | def reload_class(self, verbose=True, reload_module=True):
"""
special class reloading function
This function is often injected as rrr of classes
"""
import utool as ut
verbose = verbose or VERBOSE_CLASS
classname = self.__class__.__name__
try:
modname = self.__class__.__module__
... | [
"def",
"reload_class",
"(",
"self",
",",
"verbose",
"=",
"True",
",",
"reload_module",
"=",
"True",
")",
":",
"import",
"utool",
"as",
"ut",
"verbose",
"=",
"verbose",
"or",
"VERBOSE_CLASS",
"classname",
"=",
"self",
".",
"__class__",
".",
"__name__",
"try... | special class reloading function
This function is often injected as rrr of classes | [
"special",
"class",
"reloading",
"function",
"This",
"function",
"is",
"often",
"injected",
"as",
"rrr",
"of",
"classes"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_class.py#L705-L785 | train | Reloads the class in the current object |
Erotemic/utool | utool/util_class.py | reload_class_methods | def reload_class_methods(self, class_, verbose=True):
"""
rebinds all class methods
Args:
self (object): class instance to reload
class_ (type): type to reload as
Example:
>>> # DISABLE_DOCTEST
>>> from utool.util_class import * # NOQA
>>> self = '?'
>>... | python | def reload_class_methods(self, class_, verbose=True):
"""
rebinds all class methods
Args:
self (object): class instance to reload
class_ (type): type to reload as
Example:
>>> # DISABLE_DOCTEST
>>> from utool.util_class import * # NOQA
>>> self = '?'
>>... | [
"def",
"reload_class_methods",
"(",
"self",
",",
"class_",
",",
"verbose",
"=",
"True",
")",
":",
"if",
"verbose",
":",
"print",
"(",
"'[util_class] Reloading self=%r as class_=%r'",
"%",
"(",
"self",
",",
"class_",
")",
")",
"self",
".",
"__class__",
"=",
"... | rebinds all class methods
Args:
self (object): class instance to reload
class_ (type): type to reload as
Example:
>>> # DISABLE_DOCTEST
>>> from utool.util_class import * # NOQA
>>> self = '?'
>>> class_ = '?'
>>> result = reload_class_methods(self, cla... | [
"rebinds",
"all",
"class",
"methods"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_class.py#L788-L814 | train | rebinds all class methods to the same class instance |
Erotemic/utool | utool/util_class.py | get_comparison_methods | def get_comparison_methods():
""" makes methods for >, <, =, etc... """
method_list = []
def _register(func):
method_list.append(func)
return func
# Comparison operators for sorting and uniqueness
@_register
def __lt__(self, other):
return compare_instance(op.lt, self, o... | python | def get_comparison_methods():
""" makes methods for >, <, =, etc... """
method_list = []
def _register(func):
method_list.append(func)
return func
# Comparison operators for sorting and uniqueness
@_register
def __lt__(self, other):
return compare_instance(op.lt, self, o... | [
"def",
"get_comparison_methods",
"(",
")",
":",
"method_list",
"=",
"[",
"]",
"def",
"_register",
"(",
"func",
")",
":",
"method_list",
".",
"append",
"(",
"func",
")",
"return",
"func",
"# Comparison operators for sorting and uniqueness",
"@",
"_register",
"def",... | makes methods for >, <, =, etc... | [
"makes",
"methods",
"for",
">",
"<",
"=",
"etc",
"..."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_class.py#L831-L863 | train | returns a list of comparison methods |
Erotemic/utool | utool/util_class.py | remove_private_obfuscation | def remove_private_obfuscation(self):
"""
removes the python obfuscation of class privates so they can be executed as
they appear in class source. Useful when playing with IPython.
"""
classname = self.__class__.__name__
attrlist = [attr for attr in dir(self) if attr.startswith('_' + classname +... | python | def remove_private_obfuscation(self):
"""
removes the python obfuscation of class privates so they can be executed as
they appear in class source. Useful when playing with IPython.
"""
classname = self.__class__.__name__
attrlist = [attr for attr in dir(self) if attr.startswith('_' + classname +... | [
"def",
"remove_private_obfuscation",
"(",
"self",
")",
":",
"classname",
"=",
"self",
".",
"__class__",
".",
"__name__",
"attrlist",
"=",
"[",
"attr",
"for",
"attr",
"in",
"dir",
"(",
"self",
")",
"if",
"attr",
".",
"startswith",
"(",
"'_'",
"+",
"classn... | removes the python obfuscation of class privates so they can be executed as
they appear in class source. Useful when playing with IPython. | [
"removes",
"the",
"python",
"obfuscation",
"of",
"class",
"privates",
"so",
"they",
"can",
"be",
"executed",
"as",
"they",
"appear",
"in",
"class",
"source",
".",
"Useful",
"when",
"playing",
"with",
"IPython",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_class.py#L968-L978 | train | Removes the python obfuscation of class privates so they can be executed as
. Useful when playing with IPython. |
Erotemic/utool | utool/util_class.py | get_classname | def get_classname(class_, local=False):
r"""
Args:
class_ (type):
local (bool): (default = False)
Returns:
str: classname
CommandLine:
python -m utool.util_class --exec-get_classname --show
Example:
>>> # DISABLE_DOCTEST
>>> from utool.util_class im... | python | def get_classname(class_, local=False):
r"""
Args:
class_ (type):
local (bool): (default = False)
Returns:
str: classname
CommandLine:
python -m utool.util_class --exec-get_classname --show
Example:
>>> # DISABLE_DOCTEST
>>> from utool.util_class im... | [
"def",
"get_classname",
"(",
"class_",
",",
"local",
"=",
"False",
")",
":",
"if",
"not",
"local",
":",
"classname",
"=",
"class_",
".",
"__module__",
"+",
"'.'",
"+",
"class_",
".",
"__name__",
"else",
":",
"classname",
"=",
"class_",
".",
"__name__",
... | r"""
Args:
class_ (type):
local (bool): (default = False)
Returns:
str: classname
CommandLine:
python -m utool.util_class --exec-get_classname --show
Example:
>>> # DISABLE_DOCTEST
>>> from utool.util_class import * # NOQA
>>> import utool as u... | [
"r",
"Args",
":",
"class_",
"(",
"type",
")",
":",
"local",
"(",
"bool",
")",
":",
"(",
"default",
"=",
"False",
")"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_class.py#L981-L1006 | train | r Get the classname of the object in the current directory |
moluwole/Bast | bast/migration.py | Migration.get_config | def get_config():
"""
Gets the config from the os.environ. This is used to create the config dict for use by the ORM
:return: str, dict
"""
db_type = os.environ['DB_TYPE']
db_host = os.environ['DB_HOST']
db_user = os.environ['DB_USER']
db_database = os.env... | python | def get_config():
"""
Gets the config from the os.environ. This is used to create the config dict for use by the ORM
:return: str, dict
"""
db_type = os.environ['DB_TYPE']
db_host = os.environ['DB_HOST']
db_user = os.environ['DB_USER']
db_database = os.env... | [
"def",
"get_config",
"(",
")",
":",
"db_type",
"=",
"os",
".",
"environ",
"[",
"'DB_TYPE'",
"]",
"db_host",
"=",
"os",
".",
"environ",
"[",
"'DB_HOST'",
"]",
"db_user",
"=",
"os",
".",
"environ",
"[",
"'DB_USER'",
"]",
"db_database",
"=",
"os",
".",
... | Gets the config from the os.environ. This is used to create the config dict for use by the ORM
:return: str, dict | [
"Gets",
"the",
"config",
"from",
"the",
"os",
".",
"environ",
".",
"This",
"is",
"used",
"to",
"create",
"the",
"config",
"dict",
"for",
"use",
"by",
"the",
"ORM",
":",
"return",
":",
"str",
"dict"
] | eecf55ae72e6f24af7c101549be0422cd2c1c95a | https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/migration.py#L76-L99 | train | Gets the config from the os. environ. |
moluwole/Bast | bast/migration.py | Migration.check_packages | def check_packages(db_name):
"""
Check if the driver for the user defined host is available. If it is not available, download it using PIP
:param db_name:
:return:
"""
print('Checking for required Database Driver')
reqs = subprocess.check_output([sys.executable, ... | python | def check_packages(db_name):
"""
Check if the driver for the user defined host is available. If it is not available, download it using PIP
:param db_name:
:return:
"""
print('Checking for required Database Driver')
reqs = subprocess.check_output([sys.executable, ... | [
"def",
"check_packages",
"(",
"db_name",
")",
":",
"print",
"(",
"'Checking for required Database Driver'",
")",
"reqs",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"sys",
".",
"executable",
",",
"'-m'",
",",
"'pip'",
",",
"'freeze'",
"]",
")",
"installe... | Check if the driver for the user defined host is available. If it is not available, download it using PIP
:param db_name:
:return: | [
"Check",
"if",
"the",
"driver",
"for",
"the",
"user",
"defined",
"host",
"is",
"available",
".",
"If",
"it",
"is",
"not",
"available",
"download",
"it",
"using",
"PIP",
":",
"param",
"db_name",
":",
":",
"return",
":"
] | eecf55ae72e6f24af7c101549be0422cd2c1c95a | https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/migration.py#L102-L125 | train | Check if the driver for the user defined host is available. |
glormph/msstitch | src/app/actions/mslookup/proteinquant.py | create_peptidequant_lookup | def create_peptidequant_lookup(fns, pqdb, poolnames, pepseq_colnr,
ms1_qcolpattern=None, isobqcolpattern=None,
psmnrpattern=None, fdrcolpattern=None,
pepcolpattern=None):
"""Calls lower level function to create a peptide qu... | python | def create_peptidequant_lookup(fns, pqdb, poolnames, pepseq_colnr,
ms1_qcolpattern=None, isobqcolpattern=None,
psmnrpattern=None, fdrcolpattern=None,
pepcolpattern=None):
"""Calls lower level function to create a peptide qu... | [
"def",
"create_peptidequant_lookup",
"(",
"fns",
",",
"pqdb",
",",
"poolnames",
",",
"pepseq_colnr",
",",
"ms1_qcolpattern",
"=",
"None",
",",
"isobqcolpattern",
"=",
"None",
",",
"psmnrpattern",
"=",
"None",
",",
"fdrcolpattern",
"=",
"None",
",",
"pepcolpatter... | Calls lower level function to create a peptide quant lookup | [
"Calls",
"lower",
"level",
"function",
"to",
"create",
"a",
"peptide",
"quant",
"lookup"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mslookup/proteinquant.py#L5-L15 | train | Creates a peptide quant lookup for a given pool. |
glormph/msstitch | src/app/actions/mslookup/proteinquant.py | create_proteinquant_lookup | def create_proteinquant_lookup(fns, pqdb, poolnames, protacc_colnr,
ms1_qcolpattern=None, isobqcolpattern=None,
psmnrpattern=None, probcolpattern=None,
fdrcolpattern=None, pepcolpattern=None):
"""Calls lower level function ... | python | def create_proteinquant_lookup(fns, pqdb, poolnames, protacc_colnr,
ms1_qcolpattern=None, isobqcolpattern=None,
psmnrpattern=None, probcolpattern=None,
fdrcolpattern=None, pepcolpattern=None):
"""Calls lower level function ... | [
"def",
"create_proteinquant_lookup",
"(",
"fns",
",",
"pqdb",
",",
"poolnames",
",",
"protacc_colnr",
",",
"ms1_qcolpattern",
"=",
"None",
",",
"isobqcolpattern",
"=",
"None",
",",
"psmnrpattern",
"=",
"None",
",",
"probcolpattern",
"=",
"None",
",",
"fdrcolpatt... | Calls lower level function to create a protein quant lookup | [
"Calls",
"lower",
"level",
"function",
"to",
"create",
"a",
"protein",
"quant",
"lookup"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mslookup/proteinquant.py#L18-L28 | train | Creates a protein quant lookup for a given set of pool names. |
glormph/msstitch | src/app/actions/mslookup/proteinquant.py | create_pep_protein_quant_lookup | def create_pep_protein_quant_lookup(fns, pqdb, poolnames, featcolnr, patterns,
storefuns, isobqcolpattern=None,
psmnrpattern=None):
"""Does the work when creating peptide and protein quant lookups. This
loops through storing options and par... | python | def create_pep_protein_quant_lookup(fns, pqdb, poolnames, featcolnr, patterns,
storefuns, isobqcolpattern=None,
psmnrpattern=None):
"""Does the work when creating peptide and protein quant lookups. This
loops through storing options and par... | [
"def",
"create_pep_protein_quant_lookup",
"(",
"fns",
",",
"pqdb",
",",
"poolnames",
",",
"featcolnr",
",",
"patterns",
",",
"storefuns",
",",
"isobqcolpattern",
"=",
"None",
",",
"psmnrpattern",
"=",
"None",
")",
":",
"tablefn_map",
"=",
"create_tablefn_map",
"... | Does the work when creating peptide and protein quant lookups. This
loops through storing options and parses columns, passing on to the
storing functions | [
"Does",
"the",
"work",
"when",
"creating",
"peptide",
"and",
"protein",
"quant",
"lookups",
".",
"This",
"loops",
"through",
"storing",
"options",
"and",
"parses",
"columns",
"passing",
"on",
"to",
"the",
"storing",
"functions"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mslookup/proteinquant.py#L31-L57 | train | This function creates a peptide and protein quant lookup table. |
glormph/msstitch | src/app/actions/mslookup/proteinquant.py | create_tablefn_map | def create_tablefn_map(fns, pqdb, poolnames):
"""Stores protein/peptide table names in DB, returns a map with their
respective DB IDs"""
poolmap = {name: pid for (name, pid) in pqdb.get_all_poolnames()}
pqdb.store_table_files([(poolmap[pool], os.path.basename(fn))
for fn, poo... | python | def create_tablefn_map(fns, pqdb, poolnames):
"""Stores protein/peptide table names in DB, returns a map with their
respective DB IDs"""
poolmap = {name: pid for (name, pid) in pqdb.get_all_poolnames()}
pqdb.store_table_files([(poolmap[pool], os.path.basename(fn))
for fn, poo... | [
"def",
"create_tablefn_map",
"(",
"fns",
",",
"pqdb",
",",
"poolnames",
")",
":",
"poolmap",
"=",
"{",
"name",
":",
"pid",
"for",
"(",
"name",
",",
"pid",
")",
"in",
"pqdb",
".",
"get_all_poolnames",
"(",
")",
"}",
"pqdb",
".",
"store_table_files",
"("... | Stores protein/peptide table names in DB, returns a map with their
respective DB IDs | [
"Stores",
"protein",
"/",
"peptide",
"table",
"names",
"in",
"DB",
"returns",
"a",
"map",
"with",
"their",
"respective",
"DB",
"IDs"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mslookup/proteinquant.py#L60-L66 | train | Stores protein table names in DB returns a map with their
respective DB IDs |
glormph/msstitch | src/app/actions/mslookup/proteinquant.py | get_colmap | def get_colmap(fns, pattern, single_col=False, antipattern=False):
"""For table files, loops through headers and checks which column(s)
match a passed pattern. Those column(s) names are returned in a map with
filenames as keys"""
colmap = {}
for fn in fns:
header = tsvreader.get_tsv_header(f... | python | def get_colmap(fns, pattern, single_col=False, antipattern=False):
"""For table files, loops through headers and checks which column(s)
match a passed pattern. Those column(s) names are returned in a map with
filenames as keys"""
colmap = {}
for fn in fns:
header = tsvreader.get_tsv_header(f... | [
"def",
"get_colmap",
"(",
"fns",
",",
"pattern",
",",
"single_col",
"=",
"False",
",",
"antipattern",
"=",
"False",
")",
":",
"colmap",
"=",
"{",
"}",
"for",
"fn",
"in",
"fns",
":",
"header",
"=",
"tsvreader",
".",
"get_tsv_header",
"(",
"fn",
")",
"... | For table files, loops through headers and checks which column(s)
match a passed pattern. Those column(s) names are returned in a map with
filenames as keys | [
"For",
"table",
"files",
"loops",
"through",
"headers",
"and",
"checks",
"which",
"column",
"(",
"s",
")",
"match",
"a",
"passed",
"pattern",
".",
"Those",
"column",
"(",
"s",
")",
"names",
"are",
"returned",
"in",
"a",
"map",
"with",
"filenames",
"as",
... | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mslookup/proteinquant.py#L69-L84 | train | For a list of table files loops through headers and checks which column names match a passed pattern. |
glormph/msstitch | src/app/actions/mslookup/proteinquant.py | store_single_col_data | def store_single_col_data(fns, prottable_id_map, pacc_map, pqdbmethod,
protacc_colnr, colmap):
"""General method to store single column data from protein tables
in lookup"""
to_store = []
for fn, header, pquant in tsvreader.generate_tsv_pep_protein_quants(fns):
pacc_id ... | python | def store_single_col_data(fns, prottable_id_map, pacc_map, pqdbmethod,
protacc_colnr, colmap):
"""General method to store single column data from protein tables
in lookup"""
to_store = []
for fn, header, pquant in tsvreader.generate_tsv_pep_protein_quants(fns):
pacc_id ... | [
"def",
"store_single_col_data",
"(",
"fns",
",",
"prottable_id_map",
",",
"pacc_map",
",",
"pqdbmethod",
",",
"protacc_colnr",
",",
"colmap",
")",
":",
"to_store",
"=",
"[",
"]",
"for",
"fn",
",",
"header",
",",
"pquant",
"in",
"tsvreader",
".",
"generate_ts... | General method to store single column data from protein tables
in lookup | [
"General",
"method",
"to",
"store",
"single",
"column",
"data",
"from",
"protein",
"tables",
"in",
"lookup"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mslookup/proteinquant.py#L87-L99 | train | Store data from single column tables in lookup table. |
glormph/msstitch | src/app/actions/mslookup/proteinquant.py | create_isobaric_quant_lookup | def create_isobaric_quant_lookup(fns, tablefn_map, featmap, pqdb,
featcolnr, allquantcols, psmcolmap):
"""Creates a lookup dict from peptide/protein quant input files and some
input parameters. This assumes the order of quant columns and
number-of-PSM columns is the same."""... | python | def create_isobaric_quant_lookup(fns, tablefn_map, featmap, pqdb,
featcolnr, allquantcols, psmcolmap):
"""Creates a lookup dict from peptide/protein quant input files and some
input parameters. This assumes the order of quant columns and
number-of-PSM columns is the same."""... | [
"def",
"create_isobaric_quant_lookup",
"(",
"fns",
",",
"tablefn_map",
",",
"featmap",
",",
"pqdb",
",",
"featcolnr",
",",
"allquantcols",
",",
"psmcolmap",
")",
":",
"pqdb",
".",
"store_quant_channels",
"(",
"map_psmnrcol_to_quantcol",
"(",
"allquantcols",
",",
"... | Creates a lookup dict from peptide/protein quant input files and some
input parameters. This assumes the order of quant columns and
number-of-PSM columns is the same. | [
"Creates",
"a",
"lookup",
"dict",
"from",
"peptide",
"/",
"protein",
"quant",
"input",
"files",
"and",
"some",
"input",
"parameters",
".",
"This",
"assumes",
"the",
"order",
"of",
"quant",
"columns",
"and",
"number",
"-",
"of",
"-",
"PSM",
"columns",
"is",... | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mslookup/proteinquant.py#L102-L119 | train | Creates a dictionary that contains the peptide - > protein quant data for each peptide - > protein quant. |
glormph/msstitch | src/app/actions/mslookup/proteinquant.py | map_psmnrcol_to_quantcol | def map_psmnrcol_to_quantcol(quantcols, psmcols, tablefn_map):
"""This function yields tuples of table filename, isobaric quant column
and if necessary number-of-PSM column"""
if not psmcols:
for fn in quantcols:
for qcol in quantcols[fn]:
yield (tablefn_map[fn], qcol)
... | python | def map_psmnrcol_to_quantcol(quantcols, psmcols, tablefn_map):
"""This function yields tuples of table filename, isobaric quant column
and if necessary number-of-PSM column"""
if not psmcols:
for fn in quantcols:
for qcol in quantcols[fn]:
yield (tablefn_map[fn], qcol)
... | [
"def",
"map_psmnrcol_to_quantcol",
"(",
"quantcols",
",",
"psmcols",
",",
"tablefn_map",
")",
":",
"if",
"not",
"psmcols",
":",
"for",
"fn",
"in",
"quantcols",
":",
"for",
"qcol",
"in",
"quantcols",
"[",
"fn",
"]",
":",
"yield",
"(",
"tablefn_map",
"[",
... | This function yields tuples of table filename, isobaric quant column
and if necessary number-of-PSM column | [
"This",
"function",
"yields",
"tuples",
"of",
"table",
"filename",
"isobaric",
"quant",
"column",
"and",
"if",
"necessary",
"number",
"-",
"of",
"-",
"PSM",
"column"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mslookup/proteinquant.py#L122-L132 | train | This function maps the number - of - PSM column to the isobaric quant column and isobaric quant column. |
glormph/msstitch | src/app/actions/mslookup/proteinquant.py | get_isob_quant_data | def get_isob_quant_data(pquant, header, fnid, featmap, featcol, qmap):
"""Turns a dict from a line of protein/peptide quant data into a set of
tuples that can be stored in db"""
feat_dbid = featmap[pquant[header[featcol]]]
for channel_name, (channel_id, psmfield) in qmap[fnid].items():
if psmfie... | python | def get_isob_quant_data(pquant, header, fnid, featmap, featcol, qmap):
"""Turns a dict from a line of protein/peptide quant data into a set of
tuples that can be stored in db"""
feat_dbid = featmap[pquant[header[featcol]]]
for channel_name, (channel_id, psmfield) in qmap[fnid].items():
if psmfie... | [
"def",
"get_isob_quant_data",
"(",
"pquant",
",",
"header",
",",
"fnid",
",",
"featmap",
",",
"featcol",
",",
"qmap",
")",
":",
"feat_dbid",
"=",
"featmap",
"[",
"pquant",
"[",
"header",
"[",
"featcol",
"]",
"]",
"]",
"for",
"channel_name",
",",
"(",
"... | Turns a dict from a line of protein/peptide quant data into a set of
tuples that can be stored in db | [
"Turns",
"a",
"dict",
"from",
"a",
"line",
"of",
"protein",
"/",
"peptide",
"quant",
"data",
"into",
"a",
"set",
"of",
"tuples",
"that",
"can",
"be",
"stored",
"in",
"db"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mslookup/proteinquant.py#L135-L144 | train | Turns a dict from a line of protein quant data into a set of tuples that can be stored in db |
Erotemic/utool | utool/experimental/euler_tour_tree_avl.py | euler_tour | def euler_tour(G, node=None, seen=None, visited=None):
"""
definition from
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.192.8615&rep=rep1&type=pdf
Example:
>>> # DISABLE_DOCTEST
>>> from utool.experimental.euler_tour_tree_avl import * # NOQA
>>> edges = [
>>... | python | def euler_tour(G, node=None, seen=None, visited=None):
"""
definition from
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.192.8615&rep=rep1&type=pdf
Example:
>>> # DISABLE_DOCTEST
>>> from utool.experimental.euler_tour_tree_avl import * # NOQA
>>> edges = [
>>... | [
"def",
"euler_tour",
"(",
"G",
",",
"node",
"=",
"None",
",",
"seen",
"=",
"None",
",",
"visited",
"=",
"None",
")",
":",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"next",
"(",
"G",
".",
"nodes",
"(",
")",
")",
"if",
"visited",
"is",
"None"... | definition from
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.192.8615&rep=rep1&type=pdf
Example:
>>> # DISABLE_DOCTEST
>>> from utool.experimental.euler_tour_tree_avl import * # NOQA
>>> edges = [
>>> ('R', 'A'), ('R', 'B'),
>>> ('B', 'C'), ('C', 'D'... | [
"definition",
"from",
"http",
":",
"//",
"citeseerx",
".",
"ist",
".",
"psu",
".",
"edu",
"/",
"viewdoc",
"/",
"download?doi",
"=",
"10",
".",
"1",
".",
"1",
".",
"192",
".",
"8615&rep",
"=",
"rep1&type",
"=",
"pdf"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L41-L73 | train | euler tour for a tree |
Erotemic/utool | utool/experimental/euler_tour_tree_avl.py | avl_release_kids | def avl_release_kids(node):
"""
splits a node from its kids maintaining parent pointers
"""
left, right = node.left, node.right
if left is not None:
# assert left.parent is node
left.parent = None
if right is not None:
# assert right.parent is node
right.parent = ... | python | def avl_release_kids(node):
"""
splits a node from its kids maintaining parent pointers
"""
left, right = node.left, node.right
if left is not None:
# assert left.parent is node
left.parent = None
if right is not None:
# assert right.parent is node
right.parent = ... | [
"def",
"avl_release_kids",
"(",
"node",
")",
":",
"left",
",",
"right",
"=",
"node",
".",
"left",
",",
"node",
".",
"right",
"if",
"left",
"is",
"not",
"None",
":",
"# assert left.parent is node",
"left",
".",
"parent",
"=",
"None",
"if",
"right",
"is",
... | splits a node from its kids maintaining parent pointers | [
"splits",
"a",
"node",
"from",
"its",
"kids",
"maintaining",
"parent",
"pointers"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L500-L514 | train | release kids from a node |
Erotemic/utool | utool/experimental/euler_tour_tree_avl.py | avl_release_parent | def avl_release_parent(node):
"""
removes the parent of a child
"""
parent = node.parent
if parent is not None:
if parent.right is node:
parent.right = None
elif parent.left is node:
parent.left = None
else:
raise AssertionError('impossible... | python | def avl_release_parent(node):
"""
removes the parent of a child
"""
parent = node.parent
if parent is not None:
if parent.right is node:
parent.right = None
elif parent.left is node:
parent.left = None
else:
raise AssertionError('impossible... | [
"def",
"avl_release_parent",
"(",
"node",
")",
":",
"parent",
"=",
"node",
".",
"parent",
"if",
"parent",
"is",
"not",
"None",
":",
"if",
"parent",
".",
"right",
"is",
"node",
":",
"parent",
".",
"right",
"=",
"None",
"elif",
"parent",
".",
"left",
"... | removes the parent of a child | [
"removes",
"the",
"parent",
"of",
"a",
"child"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L517-L531 | train | Release the parent of a node. |
Erotemic/utool | utool/experimental/euler_tour_tree_avl.py | avl_rotate_single | def avl_rotate_single(root, direction):
"""
Single rotation, either 0 (left) or 1 (right).
Figure:
a,0 (left)
---------->
a b
\ / \
b a c
\
c
a = root
sa... | python | def avl_rotate_single(root, direction):
"""
Single rotation, either 0 (left) or 1 (right).
Figure:
a,0 (left)
---------->
a b
\ / \
b a c
\
c
a = root
sa... | [
"def",
"avl_rotate_single",
"(",
"root",
",",
"direction",
")",
":",
"other_side",
"=",
"1",
"-",
"direction",
"save",
"=",
"root",
"[",
"other_side",
"]",
"save",
".",
"parent",
"=",
"root",
".",
"parent",
"# root[other_side] = save[direction]",
"# save[directi... | Single rotation, either 0 (left) or 1 (right).
Figure:
a,0 (left)
---------->
a b
\ / \
b a c
\
c
a = root
save = root.right | [
"Single",
"rotation",
"either",
"0",
"(",
"left",
")",
"or",
"1",
"(",
"right",
")",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L534-L562 | train | rotate a single node in the tree |
Erotemic/utool | utool/experimental/euler_tour_tree_avl.py | avl_rotate_double | def avl_rotate_double(root, direction):
"""
Double rotation, either 0 (left) or 1 (right).
Figure:
c,1 (right)
----------->
a a c
/ b,0 / a,1 / \
b ---> b --> b a
\ ... | python | def avl_rotate_double(root, direction):
"""
Double rotation, either 0 (left) or 1 (right).
Figure:
c,1 (right)
----------->
a a c
/ b,0 / a,1 / \
b ---> b --> b a
\ ... | [
"def",
"avl_rotate_double",
"(",
"root",
",",
"direction",
")",
":",
"other_side",
"=",
"1",
"-",
"direction",
"root",
"[",
"other_side",
"]",
"=",
"avl_rotate_single",
"(",
"root",
"[",
"other_side",
"]",
",",
"other_side",
")",
"return",
"avl_rotate_single",... | Double rotation, either 0 (left) or 1 (right).
Figure:
c,1 (right)
----------->
a a c
/ b,0 / a,1 / \
b ---> b --> b a
\ /
c c | [
"Double",
"rotation",
"either",
"0",
"(",
"left",
")",
"or",
"1",
"(",
"right",
")",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L565-L580 | train | rotate the tree root by the given direction |
Erotemic/utool | utool/experimental/euler_tour_tree_avl.py | avl_join_dir_recursive | def avl_join_dir_recursive(t1, t2, node, direction):
"""
Recursive version of join_left and join_right
TODO: make this iterative using a stack
"""
other_side = 1 - direction
if _DEBUG_JOIN_DIR:
print('--JOIN DIR (dir=%r) --' % (direction,))
ascii_tree(t1, 't1')
ascii_tree... | python | def avl_join_dir_recursive(t1, t2, node, direction):
"""
Recursive version of join_left and join_right
TODO: make this iterative using a stack
"""
other_side = 1 - direction
if _DEBUG_JOIN_DIR:
print('--JOIN DIR (dir=%r) --' % (direction,))
ascii_tree(t1, 't1')
ascii_tree... | [
"def",
"avl_join_dir_recursive",
"(",
"t1",
",",
"t2",
",",
"node",
",",
"direction",
")",
":",
"other_side",
"=",
"1",
"-",
"direction",
"if",
"_DEBUG_JOIN_DIR",
":",
"print",
"(",
"'--JOIN DIR (dir=%r) --'",
"%",
"(",
"direction",
",",
")",
")",
"ascii_tre... | Recursive version of join_left and join_right
TODO: make this iterative using a stack | [
"Recursive",
"version",
"of",
"join_left",
"and",
"join_right",
"TODO",
":",
"make",
"this",
"iterative",
"using",
"a",
"stack"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L587-L664 | train | Recursive version of avl_join_dir |
Erotemic/utool | utool/experimental/euler_tour_tree_avl.py | avl_join | def avl_join(t1, t2, node):
"""
Joins two trees `t1` and `t1` with an intermediate key-value pair
CommandLine:
python -m utool.experimental.euler_tour_tree_avl avl_join
Example:
>>> # DISABLE_DOCTEST
>>> from utool.experimental.euler_tour_tree_avl import * # NOQA
>>> s... | python | def avl_join(t1, t2, node):
"""
Joins two trees `t1` and `t1` with an intermediate key-value pair
CommandLine:
python -m utool.experimental.euler_tour_tree_avl avl_join
Example:
>>> # DISABLE_DOCTEST
>>> from utool.experimental.euler_tour_tree_avl import * # NOQA
>>> s... | [
"def",
"avl_join",
"(",
"t1",
",",
"t2",
",",
"node",
")",
":",
"if",
"DEBUG_JOIN",
":",
"print",
"(",
"'-- JOIN node=%r'",
"%",
"(",
"node",
",",
")",
")",
"if",
"t1",
"is",
"None",
"and",
"t2",
"is",
"None",
":",
"if",
"DEBUG_JOIN",
":",
"print",... | Joins two trees `t1` and `t1` with an intermediate key-value pair
CommandLine:
python -m utool.experimental.euler_tour_tree_avl avl_join
Example:
>>> # DISABLE_DOCTEST
>>> from utool.experimental.euler_tour_tree_avl import * # NOQA
>>> self = EulerTourTree(['a', 'b', 'c', 'b',... | [
"Joins",
"two",
"trees",
"t1",
"and",
"t1",
"with",
"an",
"intermediate",
"key",
"-",
"value",
"pair"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L667-L746 | train | A function that joins two trees t1 and t2 with an intermediate key - value pair |
Erotemic/utool | utool/experimental/euler_tour_tree_avl.py | avl_split_last | def avl_split_last(root):
"""
Removes the maximum element from the tree
Returns:
tuple: new_root, last_node
O(log(n)) = O(height(root))
"""
if root is None:
raise IndexError('Empty tree has no maximum element')
root, left, right = avl_release_kids(root)
if right is None... | python | def avl_split_last(root):
"""
Removes the maximum element from the tree
Returns:
tuple: new_root, last_node
O(log(n)) = O(height(root))
"""
if root is None:
raise IndexError('Empty tree has no maximum element')
root, left, right = avl_release_kids(root)
if right is None... | [
"def",
"avl_split_last",
"(",
"root",
")",
":",
"if",
"root",
"is",
"None",
":",
"raise",
"IndexError",
"(",
"'Empty tree has no maximum element'",
")",
"root",
",",
"left",
",",
"right",
"=",
"avl_release_kids",
"(",
"root",
")",
"if",
"right",
"is",
"None"... | Removes the maximum element from the tree
Returns:
tuple: new_root, last_node
O(log(n)) = O(height(root)) | [
"Removes",
"the",
"maximum",
"element",
"from",
"the",
"tree"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L749-L766 | train | Returns the new root and last node of the tree with the maximum element removed from the tree |
Erotemic/utool | utool/experimental/euler_tour_tree_avl.py | avl_split_first | def avl_split_first(root):
"""
Removes the minimum element from the tree
Returns:
tuple: new_root, first_node
O(log(n)) = O(height(root))
"""
if root is None:
raise IndexError('Empty tree has no maximum element')
root, left, right = avl_release_kids(root)
if left is Non... | python | def avl_split_first(root):
"""
Removes the minimum element from the tree
Returns:
tuple: new_root, first_node
O(log(n)) = O(height(root))
"""
if root is None:
raise IndexError('Empty tree has no maximum element')
root, left, right = avl_release_kids(root)
if left is Non... | [
"def",
"avl_split_first",
"(",
"root",
")",
":",
"if",
"root",
"is",
"None",
":",
"raise",
"IndexError",
"(",
"'Empty tree has no maximum element'",
")",
"root",
",",
"left",
",",
"right",
"=",
"avl_release_kids",
"(",
"root",
")",
"if",
"left",
"is",
"None"... | Removes the minimum element from the tree
Returns:
tuple: new_root, first_node
O(log(n)) = O(height(root)) | [
"Removes",
"the",
"minimum",
"element",
"from",
"the",
"tree"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L769-L786 | train | Returns the new root and first node of the tree with minimum element removed from the tree |
Erotemic/utool | utool/experimental/euler_tour_tree_avl.py | avl_join2 | def avl_join2(t1, t2):
"""
join two trees without any intermediate key
Returns:
Node: new_root
O(log(n) + log(m)) = O(r(t1) + r(t2))
For AVL-Trees the rank r(t1) = height(t1) - 1
"""
if t1 is None and t2 is None:
new_root = None
elif t2 is None:
new_root = t1
... | python | def avl_join2(t1, t2):
"""
join two trees without any intermediate key
Returns:
Node: new_root
O(log(n) + log(m)) = O(r(t1) + r(t2))
For AVL-Trees the rank r(t1) = height(t1) - 1
"""
if t1 is None and t2 is None:
new_root = None
elif t2 is None:
new_root = t1
... | [
"def",
"avl_join2",
"(",
"t1",
",",
"t2",
")",
":",
"if",
"t1",
"is",
"None",
"and",
"t2",
"is",
"None",
":",
"new_root",
"=",
"None",
"elif",
"t2",
"is",
"None",
":",
"new_root",
"=",
"t1",
"elif",
"t1",
"is",
"None",
":",
"new_root",
"=",
"t2",... | join two trees without any intermediate key
Returns:
Node: new_root
O(log(n) + log(m)) = O(r(t1) + r(t2))
For AVL-Trees the rank r(t1) = height(t1) - 1 | [
"join",
"two",
"trees",
"without",
"any",
"intermediate",
"key"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L789-L831 | train | A function to join two trees with any intermediate key. |
Erotemic/utool | utool/experimental/euler_tour_tree_avl.py | avl_new_top | def avl_new_top(t1, t2, top, direction=0):
"""
if direction == 0:
(t1, t2) is (left, right)
if direction == 1:
(t1, t2) is (right, left)
"""
top.parent = None
assert top.parent is None, str(top.parent.value)
top.set_child(direction, t1)
top.set_child(1 - direction, t2)
... | python | def avl_new_top(t1, t2, top, direction=0):
"""
if direction == 0:
(t1, t2) is (left, right)
if direction == 1:
(t1, t2) is (right, left)
"""
top.parent = None
assert top.parent is None, str(top.parent.value)
top.set_child(direction, t1)
top.set_child(1 - direction, t2)
... | [
"def",
"avl_new_top",
"(",
"t1",
",",
"t2",
",",
"top",
",",
"direction",
"=",
"0",
")",
":",
"top",
".",
"parent",
"=",
"None",
"assert",
"top",
".",
"parent",
"is",
"None",
",",
"str",
"(",
"top",
".",
"parent",
".",
"value",
")",
"top",
".",
... | if direction == 0:
(t1, t2) is (left, right)
if direction == 1:
(t1, t2) is (right, left) | [
"if",
"direction",
"==",
"0",
":",
"(",
"t1",
"t2",
")",
"is",
"(",
"left",
"right",
")",
"if",
"direction",
"==",
"1",
":",
"(",
"t1",
"t2",
")",
"is",
"(",
"right",
"left",
")"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L834-L846 | train | Create a new top node. |
Erotemic/utool | utool/experimental/euler_tour_tree_avl.py | backtrace_root | def backtrace_root(node):
"""
Example:
>>> from utool.experimental.euler_tour_tree_avl import * # NOQA
>>> self = EulerTourTree(range(10))
>>> self._assert_nodes()
>>> root = self.root
>>> node = self.get_node(5)
>>> self.print_tree()
>>> print('node = %r... | python | def backtrace_root(node):
"""
Example:
>>> from utool.experimental.euler_tour_tree_avl import * # NOQA
>>> self = EulerTourTree(range(10))
>>> self._assert_nodes()
>>> root = self.root
>>> node = self.get_node(5)
>>> self.print_tree()
>>> print('node = %r... | [
"def",
"backtrace_root",
"(",
"node",
")",
":",
"# Trace path to the root",
"rpath",
"=",
"[",
"]",
"prev",
"=",
"node",
"now",
"=",
"node",
".",
"parent",
"while",
"now",
"is",
"not",
"None",
":",
"if",
"now",
".",
"left",
"is",
"prev",
":",
"rpath",
... | Example:
>>> from utool.experimental.euler_tour_tree_avl import * # NOQA
>>> self = EulerTourTree(range(10))
>>> self._assert_nodes()
>>> root = self.root
>>> node = self.get_node(5)
>>> self.print_tree()
>>> print('node = %r' % (node,))
>>> rpath = backt... | [
"Example",
":",
">>>",
"from",
"utool",
".",
"experimental",
".",
"euler_tour_tree_avl",
"import",
"*",
"#",
"NOQA",
">>>",
"self",
"=",
"EulerTourTree",
"(",
"range",
"(",
"10",
"))",
">>>",
"self",
".",
"_assert_nodes",
"()",
">>>",
"root",
"=",
"self",
... | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L852-L878 | train | Trace path to the root node |
Erotemic/utool | utool/experimental/euler_tour_tree_avl.py | avl_split | def avl_split(root, node):
"""
O(log(n))
Args:
root (Node): tree root
node (Node): node to split at
Returns:
puple: (tl, tr, node)
tl contains all keys in the tree less than node
tr contains all keys in the tree greater than node
node is the ... | python | def avl_split(root, node):
"""
O(log(n))
Args:
root (Node): tree root
node (Node): node to split at
Returns:
puple: (tl, tr, node)
tl contains all keys in the tree less than node
tr contains all keys in the tree greater than node
node is the ... | [
"def",
"avl_split",
"(",
"root",
",",
"node",
")",
":",
"DEBUG_SPLIT",
"=",
"0",
"# Get the backtrace to the root",
"rpath",
"=",
"backtrace_root",
"(",
"node",
")",
"if",
"len",
"(",
"rpath",
")",
">",
"0",
":",
"assert",
"rpath",
"[",
"-",
"1",
"]",
... | O(log(n))
Args:
root (Node): tree root
node (Node): node to split at
Returns:
puple: (tl, tr, node)
tl contains all keys in the tree less than node
tr contains all keys in the tree greater than node
node is the node we split out
CommandLine:
... | [
"O",
"(",
"log",
"(",
"n",
"))"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L921-L1016 | train | This function splits the tree at the root and node into a tree with the same root and node. |
Erotemic/utool | utool/experimental/euler_tour_tree_avl.py | avl_insert_dir | def avl_insert_dir(root, new_node, direction=1):
"""
Inserts a single node all the way to the left (direction=1) or right (direction=1)
CommandLine:
python -m utool.experimental.euler_tour_tree_avl avl_insert_dir --show
python -m utool.experimental.euler_tour_tree_avl avl_insert_dir
Ex... | python | def avl_insert_dir(root, new_node, direction=1):
"""
Inserts a single node all the way to the left (direction=1) or right (direction=1)
CommandLine:
python -m utool.experimental.euler_tour_tree_avl avl_insert_dir --show
python -m utool.experimental.euler_tour_tree_avl avl_insert_dir
Ex... | [
"def",
"avl_insert_dir",
"(",
"root",
",",
"new_node",
",",
"direction",
"=",
"1",
")",
":",
"if",
"root",
"is",
"None",
":",
"return",
"new_node",
"assert",
"new_node",
".",
"parent",
"is",
"None",
",",
"str",
"(",
"(",
"new_node",
",",
"new_node",
".... | Inserts a single node all the way to the left (direction=1) or right (direction=1)
CommandLine:
python -m utool.experimental.euler_tour_tree_avl avl_insert_dir --show
python -m utool.experimental.euler_tour_tree_avl avl_insert_dir
Example:
>>> # DISABLE_DOCTEST
>>> from utool.e... | [
"Inserts",
"a",
"single",
"node",
"all",
"the",
"way",
"to",
"the",
"left",
"(",
"direction",
"=",
"1",
")",
"or",
"right",
"(",
"direction",
"=",
"1",
")"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L1068-L1167 | train | This function creates a new node in the tree and returns it |
Erotemic/utool | utool/experimental/euler_tour_tree_avl.py | EulerTourTree.reroot | def reroot(self, first_node, last_node):
"""
Notes:
● Pick any occurrence of the new root r.
● Split the tour into A and B, where B is the
part of the tour before r.
● Delete the first node of A and append r.
● Concatenate B and A.
... | python | def reroot(self, first_node, last_node):
"""
Notes:
● Pick any occurrence of the new root r.
● Split the tour into A and B, where B is the
part of the tour before r.
● Delete the first node of A and append r.
● Concatenate B and A.
... | [
"def",
"reroot",
"(",
"self",
",",
"first_node",
",",
"last_node",
")",
":",
"min_elem",
"=",
"self",
".",
"min_elem",
"(",
")",
"if",
"min_elem",
"==",
"first_node",
".",
"value",
":",
"print",
"(",
"'Already rooted there'",
")",
"return",
"# tour = list(se... | Notes:
● Pick any occurrence of the new root r.
● Split the tour into A and B, where B is the
part of the tour before r.
● Delete the first node of A and append r.
● Concatenate B and A.
To change the root of T from r to s:
Let os ... | [
"Notes",
":",
"●",
"Pick",
"any",
"occurrence",
"of",
"the",
"new",
"root",
"r",
".",
"●",
"Split",
"the",
"tour",
"into",
"A",
"and",
"B",
"where",
"B",
"is",
"the",
"part",
"of",
"the",
"tour",
"before",
"r",
".",
"●",
"Delete",
"the",
"first",
... | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L209-L323 | train | This function will take the first node of the tree and the last node of the tree and return the new root node. |
Erotemic/utool | utool/experimental/euler_tour_tree_avl.py | EulerTourTree._traverse_nodes | def _traverse_nodes(self):
""" Debugging function (exposes cython nodes as dummy nodes) """
node = self.root
stack = []
while stack or node is not None:
if node is not None:
stack.append(node)
node = node.left
else:
... | python | def _traverse_nodes(self):
""" Debugging function (exposes cython nodes as dummy nodes) """
node = self.root
stack = []
while stack or node is not None:
if node is not None:
stack.append(node)
node = node.left
else:
... | [
"def",
"_traverse_nodes",
"(",
"self",
")",
":",
"node",
"=",
"self",
".",
"root",
"stack",
"=",
"[",
"]",
"while",
"stack",
"or",
"node",
"is",
"not",
"None",
":",
"if",
"node",
"is",
"not",
"None",
":",
"stack",
".",
"append",
"(",
"node",
")",
... | Debugging function (exposes cython nodes as dummy nodes) | [
"Debugging",
"function",
"(",
"exposes",
"cython",
"nodes",
"as",
"dummy",
"nodes",
")"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L382-L393 | train | Traverse the tree and yield nodes. |
Erotemic/utool | utool/experimental/euler_tour_tree_avl.py | EulerTourTree.to_networkx | def to_networkx(self, labels=None, edge_labels=False):
""" Get a networkx representation of the binary search tree. """
import networkx as nx
graph = nx.DiGraph()
for node in self._traverse_nodes():
u = node.key
graph.add_node(u) # Minor redundancy
# ... | python | def to_networkx(self, labels=None, edge_labels=False):
""" Get a networkx representation of the binary search tree. """
import networkx as nx
graph = nx.DiGraph()
for node in self._traverse_nodes():
u = node.key
graph.add_node(u) # Minor redundancy
# ... | [
"def",
"to_networkx",
"(",
"self",
",",
"labels",
"=",
"None",
",",
"edge_labels",
"=",
"False",
")",
":",
"import",
"networkx",
"as",
"nx",
"graph",
"=",
"nx",
".",
"DiGraph",
"(",
")",
"for",
"node",
"in",
"self",
".",
"_traverse_nodes",
"(",
")",
... | Get a networkx representation of the binary search tree. | [
"Get",
"a",
"networkx",
"representation",
"of",
"the",
"binary",
"search",
"tree",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L395-L419 | train | Returns a networkx representation of the binary search tree. |
Erotemic/utool | utool/experimental/euler_tour_tree_avl.py | EulerTourTree.repr_tree | def repr_tree(self):
"""
reconstruct represented tree as a DiGraph to
preserve the current rootedness
"""
import utool as ut
import networkx as nx
repr_tree = nx.DiGraph()
for u, v in ut.itertwo(self.values()):
if not repr_tree.has_edge(v, u):
... | python | def repr_tree(self):
"""
reconstruct represented tree as a DiGraph to
preserve the current rootedness
"""
import utool as ut
import networkx as nx
repr_tree = nx.DiGraph()
for u, v in ut.itertwo(self.values()):
if not repr_tree.has_edge(v, u):
... | [
"def",
"repr_tree",
"(",
"self",
")",
":",
"import",
"utool",
"as",
"ut",
"import",
"networkx",
"as",
"nx",
"repr_tree",
"=",
"nx",
".",
"DiGraph",
"(",
")",
"for",
"u",
",",
"v",
"in",
"ut",
".",
"itertwo",
"(",
"self",
".",
"values",
"(",
")",
... | reconstruct represented tree as a DiGraph to
preserve the current rootedness | [
"reconstruct",
"represented",
"tree",
"as",
"a",
"DiGraph",
"to",
"preserve",
"the",
"current",
"rootedness"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/euler_tour_tree_avl.py#L422-L433 | train | reconstruct represented tree as a DiGraph |
glormph/msstitch | src/app/lookups/sqlite/peptable.py | PepTableGeneCentricDB.get_proteins_psms_for_map | def get_proteins_psms_for_map(self):
"""Gets gene-PSM combinations from DB and filters out uniques
on the fly. Filtering is done since PSM are stored per protein,
not per gene, so there may be a lot of *plicates"""
fields = ['p.gene_acc', 'sets.set_name',
'pep.sequence'... | python | def get_proteins_psms_for_map(self):
"""Gets gene-PSM combinations from DB and filters out uniques
on the fly. Filtering is done since PSM are stored per protein,
not per gene, so there may be a lot of *plicates"""
fields = ['p.gene_acc', 'sets.set_name',
'pep.sequence'... | [
"def",
"get_proteins_psms_for_map",
"(",
"self",
")",
":",
"fields",
"=",
"[",
"'p.gene_acc'",
",",
"'sets.set_name'",
",",
"'pep.sequence'",
",",
"'psm.psm_id'",
"]",
"firstjoin",
"=",
"(",
"'protein_psm'",
",",
"'pp'",
",",
"'protein_acc'",
")",
"genetable",
"... | Gets gene-PSM combinations from DB and filters out uniques
on the fly. Filtering is done since PSM are stored per protein,
not per gene, so there may be a lot of *plicates | [
"Gets",
"gene",
"-",
"PSM",
"combinations",
"from",
"DB",
"and",
"filters",
"out",
"uniques",
"on",
"the",
"fly",
".",
"Filtering",
"is",
"done",
"since",
"PSM",
"are",
"stored",
"per",
"protein",
"not",
"per",
"gene",
"so",
"there",
"may",
"be",
"a",
... | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/lookups/sqlite/peptable.py#L40-L48 | train | Gets the gene - PSM combinations for a given protein map. |
Erotemic/utool | utool/_internal/meta_util_path.py | unixjoin | def unixjoin(*args):
"""
Like os.path.join, but uses forward slashes on win32
"""
isabs_list = list(map(isabs, args))
if any(isabs_list):
poslist = [count for count, flag in enumerate(isabs_list) if flag]
pos = poslist[-1]
return '/'.join(args[pos:])
else:
return ... | python | def unixjoin(*args):
"""
Like os.path.join, but uses forward slashes on win32
"""
isabs_list = list(map(isabs, args))
if any(isabs_list):
poslist = [count for count, flag in enumerate(isabs_list) if flag]
pos = poslist[-1]
return '/'.join(args[pos:])
else:
return ... | [
"def",
"unixjoin",
"(",
"*",
"args",
")",
":",
"isabs_list",
"=",
"list",
"(",
"map",
"(",
"isabs",
",",
"args",
")",
")",
"if",
"any",
"(",
"isabs_list",
")",
":",
"poslist",
"=",
"[",
"count",
"for",
"count",
",",
"flag",
"in",
"enumerate",
"(",
... | Like os.path.join, but uses forward slashes on win32 | [
"Like",
"os",
".",
"path",
".",
"join",
"but",
"uses",
"forward",
"slashes",
"on",
"win32"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/meta_util_path.py#L25-L35 | train | Like os. path. join but uses forward slashes on win32
|
glormph/msstitch | src/app/actions/prottable/picktdprotein.py | pick_target_decoy | def pick_target_decoy(tfeature, dfeature):
"""Feed it with a target and decoy score and the protein/gene/id names,
and this will return target/decoy type, the winning ID and the score"""
tscore, dscore = get_score(tfeature), get_score(dfeature)
if tscore == dscore:
# same score or both False
... | python | def pick_target_decoy(tfeature, dfeature):
"""Feed it with a target and decoy score and the protein/gene/id names,
and this will return target/decoy type, the winning ID and the score"""
tscore, dscore = get_score(tfeature), get_score(dfeature)
if tscore == dscore:
# same score or both False
... | [
"def",
"pick_target_decoy",
"(",
"tfeature",
",",
"dfeature",
")",
":",
"tscore",
",",
"dscore",
"=",
"get_score",
"(",
"tfeature",
")",
",",
"get_score",
"(",
"dfeature",
")",
"if",
"tscore",
"==",
"dscore",
":",
"# same score or both False",
"return",
"False... | Feed it with a target and decoy score and the protein/gene/id names,
and this will return target/decoy type, the winning ID and the score | [
"Feed",
"it",
"with",
"a",
"target",
"and",
"decoy",
"score",
"and",
"the",
"protein",
"/",
"gene",
"/",
"id",
"names",
"and",
"this",
"will",
"return",
"target",
"/",
"decoy",
"type",
"the",
"winning",
"ID",
"and",
"the",
"score"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/prottable/picktdprotein.py#L105-L124 | train | Feed it with a target and decoy score and the protein / gene id names and this will return the target and decoy type the winning ID and the score |
glormph/msstitch | src/app/actions/pycolator/splitmerge.py | create_merge_psm_map | def create_merge_psm_map(peptides, ns):
"""Loops through peptides, stores sequences mapped to PSM ids."""
psmmap = {}
for peptide in peptides:
seq = reader.get_peptide_seq(peptide, ns)
psm_ids = reader.get_psm_ids_from_peptide(peptide, ns)
for psm_id in psm_ids:
try:
... | python | def create_merge_psm_map(peptides, ns):
"""Loops through peptides, stores sequences mapped to PSM ids."""
psmmap = {}
for peptide in peptides:
seq = reader.get_peptide_seq(peptide, ns)
psm_ids = reader.get_psm_ids_from_peptide(peptide, ns)
for psm_id in psm_ids:
try:
... | [
"def",
"create_merge_psm_map",
"(",
"peptides",
",",
"ns",
")",
":",
"psmmap",
"=",
"{",
"}",
"for",
"peptide",
"in",
"peptides",
":",
"seq",
"=",
"reader",
".",
"get_peptide_seq",
"(",
"peptide",
",",
"ns",
")",
"psm_ids",
"=",
"reader",
".",
"get_psm_i... | Loops through peptides, stores sequences mapped to PSM ids. | [
"Loops",
"through",
"peptides",
"stores",
"sequences",
"mapped",
"to",
"PSM",
"ids",
"."
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/pycolator/splitmerge.py#L8-L21 | train | Loops through peptides stores sequences mapped to PSM ids. |
glormph/msstitch | src/app/actions/pycolator/splitmerge.py | merge_peptides | def merge_peptides(fns, ns):
"""Loops peptides from multiple files, fetches PSMs from
sequence:PSM map, outputs correctly PSM mapped peptides"""
peptides_to_map = reader.generate_peptides_multiple_fractions(fns, ns)
psmmap = create_merge_psm_map(peptides_to_map, ns)
peptides = reader.generate_peptid... | python | def merge_peptides(fns, ns):
"""Loops peptides from multiple files, fetches PSMs from
sequence:PSM map, outputs correctly PSM mapped peptides"""
peptides_to_map = reader.generate_peptides_multiple_fractions(fns, ns)
psmmap = create_merge_psm_map(peptides_to_map, ns)
peptides = reader.generate_peptid... | [
"def",
"merge_peptides",
"(",
"fns",
",",
"ns",
")",
":",
"peptides_to_map",
"=",
"reader",
".",
"generate_peptides_multiple_fractions",
"(",
"fns",
",",
"ns",
")",
"psmmap",
"=",
"create_merge_psm_map",
"(",
"peptides_to_map",
",",
"ns",
")",
"peptides",
"=",
... | Loops peptides from multiple files, fetches PSMs from
sequence:PSM map, outputs correctly PSM mapped peptides | [
"Loops",
"peptides",
"from",
"multiple",
"files",
"fetches",
"PSMs",
"from",
"sequence",
":",
"PSM",
"map",
"outputs",
"correctly",
"PSM",
"mapped",
"peptides"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/pycolator/splitmerge.py#L24-L37 | train | Loops peptides from multiple files fetches PSMs from
sequence : PSM map outputs correctly PSM mapped peptides |
glormph/msstitch | src/app/actions/pycolator/splitmerge.py | protein_header_split_generator | def protein_header_split_generator(elements, headers, ns):
"""Loop through proteins of each PSM/peptide. If a protein does not
match any of headers, discard PSM/peptide immediately"""
for el in elements:
header_not_matching = False
for protein in el.findall('{%s}protein_id' % ns['xmlns']):
... | python | def protein_header_split_generator(elements, headers, ns):
"""Loop through proteins of each PSM/peptide. If a protein does not
match any of headers, discard PSM/peptide immediately"""
for el in elements:
header_not_matching = False
for protein in el.findall('{%s}protein_id' % ns['xmlns']):
... | [
"def",
"protein_header_split_generator",
"(",
"elements",
",",
"headers",
",",
"ns",
")",
":",
"for",
"el",
"in",
"elements",
":",
"header_not_matching",
"=",
"False",
"for",
"protein",
"in",
"el",
".",
"findall",
"(",
"'{%s}protein_id'",
"%",
"ns",
"[",
"'x... | Loop through proteins of each PSM/peptide. If a protein does not
match any of headers, discard PSM/peptide immediately | [
"Loop",
"through",
"proteins",
"of",
"each",
"PSM",
"/",
"peptide",
".",
"If",
"a",
"protein",
"does",
"not",
"match",
"any",
"of",
"headers",
"discard",
"PSM",
"/",
"peptide",
"immediately"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/pycolator/splitmerge.py#L57-L69 | train | Yields a generator that iterates through proteins of each PSM or PETTAG element and yields a string of the PSM and PETTAG elements that do not match any of the headers. |
samuelcolvin/buildpg | buildpg/asyncpg.py | create_pool_b | def create_pool_b(
dsn=None,
*,
min_size=10,
max_size=10,
max_queries=50000,
max_inactive_connection_lifetime=300.0,
setup=None,
init=None,
loop=None,
connection_class=BuildPgConnection,
**connect_kwargs,
):
"""
Create a connection pool.
Can be used either with a... | python | def create_pool_b(
dsn=None,
*,
min_size=10,
max_size=10,
max_queries=50000,
max_inactive_connection_lifetime=300.0,
setup=None,
init=None,
loop=None,
connection_class=BuildPgConnection,
**connect_kwargs,
):
"""
Create a connection pool.
Can be used either with a... | [
"def",
"create_pool_b",
"(",
"dsn",
"=",
"None",
",",
"*",
",",
"min_size",
"=",
"10",
",",
"max_size",
"=",
"10",
",",
"max_queries",
"=",
"50000",
",",
"max_inactive_connection_lifetime",
"=",
"300.0",
",",
"setup",
"=",
"None",
",",
"init",
"=",
"None... | Create a connection pool.
Can be used either with an ``async with`` block:
Identical to ``asyncpg.create_pool`` except that both the pool and connection have the *_b varients of
``execute``, ``fetch``, ``fetchval``, ``fetchrow`` etc
Arguments are exactly the same as ``asyncpg.create_pool``. | [
"Create",
"a",
"connection",
"pool",
"."
] | 33cccff45279834d02ec7e97d8417da8fd2a875d | https://github.com/samuelcolvin/buildpg/blob/33cccff45279834d02ec7e97d8417da8fd2a875d/buildpg/asyncpg.py#L85-L119 | train | Create a connection pool. |
LEMS/pylems | lems/sim/runnable.py | Runnable.copy | def copy(self):
"""
Make a copy of this runnable.
@return: Copy of this runnable.
@rtype: lems.sim.runnable.Runnable
"""
if self.debug: print("Coping....."+self.id)
r = Runnable(self.id, self.component, self.parent)
copies = dict()
# Copy simulat... | python | def copy(self):
"""
Make a copy of this runnable.
@return: Copy of this runnable.
@rtype: lems.sim.runnable.Runnable
"""
if self.debug: print("Coping....."+self.id)
r = Runnable(self.id, self.component, self.parent)
copies = dict()
# Copy simulat... | [
"def",
"copy",
"(",
"self",
")",
":",
"if",
"self",
".",
"debug",
":",
"print",
"(",
"\"Coping.....\"",
"+",
"self",
".",
"id",
")",
"r",
"=",
"Runnable",
"(",
"self",
".",
"id",
",",
"self",
".",
"component",
",",
"self",
".",
"parent",
")",
"co... | Make a copy of this runnable.
@return: Copy of this runnable.
@rtype: lems.sim.runnable.Runnable | [
"Make",
"a",
"copy",
"of",
"this",
"runnable",
"."
] | 4eeb719d2f23650fe16c38626663b69b5c83818b | https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/sim/runnable.py#L597-L793 | train | Make a copy of this runnable. |
LEMS/pylems | lems/sim/sim.py | Simulation.add_runnable | def add_runnable(self, runnable):
"""
Adds a runnable component to the list of runnable components in
this simulation.
@param runnable: A runnable component
@type runnable: lems.sim.runnable.Runnable
"""
if runnable.id in self.runnables:
raise SimErr... | python | def add_runnable(self, runnable):
"""
Adds a runnable component to the list of runnable components in
this simulation.
@param runnable: A runnable component
@type runnable: lems.sim.runnable.Runnable
"""
if runnable.id in self.runnables:
raise SimErr... | [
"def",
"add_runnable",
"(",
"self",
",",
"runnable",
")",
":",
"if",
"runnable",
".",
"id",
"in",
"self",
".",
"runnables",
":",
"raise",
"SimError",
"(",
"'Duplicate runnable component {0}'",
".",
"format",
"(",
"runnable",
".",
"id",
")",
")",
"self",
".... | Adds a runnable component to the list of runnable components in
this simulation.
@param runnable: A runnable component
@type runnable: lems.sim.runnable.Runnable | [
"Adds",
"a",
"runnable",
"component",
"to",
"the",
"list",
"of",
"runnable",
"components",
"in",
"this",
"simulation",
"."
] | 4eeb719d2f23650fe16c38626663b69b5c83818b | https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/sim/sim.py#L37-L49 | train | Adds a runnable component to the list of runnable components in
this simulation. |
LEMS/pylems | lems/sim/sim.py | Simulation.run | def run(self):
"""
Runs the simulation.
"""
self.init_run()
if self.debug: self.dump("AfterInit: ")
#print("++++++++++++++++ Time: %f"%self.current_time)
while self.step():
#self.dump("Time: %f"%self.current_time)
#print("++++++++++++++++ ... | python | def run(self):
"""
Runs the simulation.
"""
self.init_run()
if self.debug: self.dump("AfterInit: ")
#print("++++++++++++++++ Time: %f"%self.current_time)
while self.step():
#self.dump("Time: %f"%self.current_time)
#print("++++++++++++++++ ... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"init_run",
"(",
")",
"if",
"self",
".",
"debug",
":",
"self",
".",
"dump",
"(",
"\"AfterInit: \"",
")",
"#print(\"++++++++++++++++ Time: %f\"%self.current_time)",
"while",
"self",
".",
"step",
"(",
")",
":",... | Runs the simulation. | [
"Runs",
"the",
"simulation",
"."
] | 4eeb719d2f23650fe16c38626663b69b5c83818b | https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/sim/sim.py#L86-L97 | train | Runs the simulation. |
moluwole/Bast | bast/cli.py | controller_creatr | def controller_creatr(filename):
"""Name of the controller file to be created"""
if not check():
click.echo(Fore.RED + 'ERROR: Ensure you are in a bast app to run the create:controller command')
return
path = os.path.abspath('.') + '/controller'
if not os.path.exists(path):
os.m... | python | def controller_creatr(filename):
"""Name of the controller file to be created"""
if not check():
click.echo(Fore.RED + 'ERROR: Ensure you are in a bast app to run the create:controller command')
return
path = os.path.abspath('.') + '/controller'
if not os.path.exists(path):
os.m... | [
"def",
"controller_creatr",
"(",
"filename",
")",
":",
"if",
"not",
"check",
"(",
")",
":",
"click",
".",
"echo",
"(",
"Fore",
".",
"RED",
"+",
"'ERROR: Ensure you are in a bast app to run the create:controller command'",
")",
"return",
"path",
"=",
"os",
".",
"... | Name of the controller file to be created | [
"Name",
"of",
"the",
"controller",
"file",
"to",
"be",
"created"
] | eecf55ae72e6f24af7c101549be0422cd2c1c95a | https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/cli.py#L41-L61 | train | Create a new controller file |
moluwole/Bast | bast/cli.py | view_creatr | def view_creatr(filename):
"""Name of the View File to be created"""
if not check():
click.echo(Fore.RED + 'ERROR: Ensure you are in a bast app to run the create:view command')
return
path = os.path.abspath('.') + '/public/templates'
if not os.path.exists(path):
os.makedirs(path... | python | def view_creatr(filename):
"""Name of the View File to be created"""
if not check():
click.echo(Fore.RED + 'ERROR: Ensure you are in a bast app to run the create:view command')
return
path = os.path.abspath('.') + '/public/templates'
if not os.path.exists(path):
os.makedirs(path... | [
"def",
"view_creatr",
"(",
"filename",
")",
":",
"if",
"not",
"check",
"(",
")",
":",
"click",
".",
"echo",
"(",
"Fore",
".",
"RED",
"+",
"'ERROR: Ensure you are in a bast app to run the create:view command'",
")",
"return",
"path",
"=",
"os",
".",
"path",
"."... | Name of the View File to be created | [
"Name",
"of",
"the",
"View",
"File",
"to",
"be",
"created"
] | eecf55ae72e6f24af7c101549be0422cd2c1c95a | https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/cli.py#L85-L99 | train | Create a new view file |
moluwole/Bast | bast/cli.py | create_new | def create_new(projectname):
"""Name of the project"""
git_url = "https://github.com/moluwole/Bast_skeleton"
path = os.path.abspath('.') + "/" + projectname
if not os.path.exists(path):
os.makedirs(path)
click.echo(Fore.GREEN + ' ___ ___ __________')
click.echo(Fore.GREEN + ' / _... | python | def create_new(projectname):
"""Name of the project"""
git_url = "https://github.com/moluwole/Bast_skeleton"
path = os.path.abspath('.') + "/" + projectname
if not os.path.exists(path):
os.makedirs(path)
click.echo(Fore.GREEN + ' ___ ___ __________')
click.echo(Fore.GREEN + ' / _... | [
"def",
"create_new",
"(",
"projectname",
")",
":",
"git_url",
"=",
"\"https://github.com/moluwole/Bast_skeleton\"",
"path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"'.'",
")",
"+",
"\"/\"",
"+",
"projectname",
"if",
"not",
"os",
".",
"path",
".",
"exist... | Name of the project | [
"Name",
"of",
"the",
"project"
] | eecf55ae72e6f24af7c101549be0422cd2c1c95a | https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/cli.py#L137-L168 | train | Create a new Bast project |
moluwole/Bast | bast/cli.py | migration_creatr | def migration_creatr(migration_file, create, table):
"""Name of the migration file"""
if not check():
click.echo(Fore.RED + 'ERROR: Ensure you are in a bast app to run the create:migration command')
return
migration = CreateMigration()
if table is None:
table = snake_case(migrat... | python | def migration_creatr(migration_file, create, table):
"""Name of the migration file"""
if not check():
click.echo(Fore.RED + 'ERROR: Ensure you are in a bast app to run the create:migration command')
return
migration = CreateMigration()
if table is None:
table = snake_case(migrat... | [
"def",
"migration_creatr",
"(",
"migration_file",
",",
"create",
",",
"table",
")",
":",
"if",
"not",
"check",
"(",
")",
":",
"click",
".",
"echo",
"(",
"Fore",
".",
"RED",
"+",
"'ERROR: Ensure you are in a bast app to run the create:migration command'",
")",
"ret... | Name of the migration file | [
"Name",
"of",
"the",
"migration",
"file"
] | eecf55ae72e6f24af7c101549be0422cd2c1c95a | https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/cli.py#L175-L185 | train | Create a migration file |
mbunse/socket_client_server | socket_client_server/socket_client_server.py | Sock_Base.send_msg | def send_msg(self, connection, data):
"""
Function to send messages
Parameters
----------
connection: socket or connection
data: data that can be serialized to json
"""
# serialize as JSON
msg = json.dumps(data)
# Prefix... | python | def send_msg(self, connection, data):
"""
Function to send messages
Parameters
----------
connection: socket or connection
data: data that can be serialized to json
"""
# serialize as JSON
msg = json.dumps(data)
# Prefix... | [
"def",
"send_msg",
"(",
"self",
",",
"connection",
",",
"data",
")",
":",
"# serialize as JSON\r",
"msg",
"=",
"json",
".",
"dumps",
"(",
"data",
")",
"# Prefix each message with a 4-byte length (network byte order)\r",
"msg",
"=",
"struct",
".",
"pack",
"(",
"'>I... | Function to send messages
Parameters
----------
connection: socket or connection
data: data that can be serialized to json | [
"Function",
"to",
"send",
"messages",
"Parameters",
"----------",
"connection",
":",
"socket",
"or",
"connection",
"data",
":",
"data",
"that",
"can",
"be",
"serialized",
"to",
"json"
] | 8e884925cf887d386554c1859f626d8f01bd0036 | https://github.com/mbunse/socket_client_server/blob/8e884925cf887d386554c1859f626d8f01bd0036/socket_client_server/socket_client_server.py#L25-L39 | train | Send a message to the specified socket. |
mbunse/socket_client_server | socket_client_server/socket_client_server.py | Sock_Base.recv_msg | def recv_msg(self, connection):
"""
Function to receive messages
Parameters
----------
connection: socket or connection
Return value
------------
message received as dictionary
"""
# Read message length and unpack it into an i... | python | def recv_msg(self, connection):
"""
Function to receive messages
Parameters
----------
connection: socket or connection
Return value
------------
message received as dictionary
"""
# Read message length and unpack it into an i... | [
"def",
"recv_msg",
"(",
"self",
",",
"connection",
")",
":",
"# Read message length and unpack it into an integer\r",
"raw_msglen",
"=",
"self",
".",
"__recvall",
"(",
"connection",
",",
"4",
",",
"decode_json",
"=",
"False",
")",
"if",
"not",
"raw_msglen",
":",
... | Function to receive messages
Parameters
----------
connection: socket or connection
Return value
------------
message received as dictionary | [
"Function",
"to",
"receive",
"messages",
"Parameters",
"----------",
"connection",
":",
"socket",
"or",
"connection",
"Return",
"value",
"------------",
"message",
"received",
"as",
"dictionary"
] | 8e884925cf887d386554c1859f626d8f01bd0036 | https://github.com/mbunse/socket_client_server/blob/8e884925cf887d386554c1859f626d8f01bd0036/socket_client_server/socket_client_server.py#L41-L59 | train | Read a message from the socket and return it as a dictionary |
mbunse/socket_client_server | socket_client_server/socket_client_server.py | Sock_Client.send | def send(self, data):
"""
Send date to server
Parameters
----------
data: object that can be serialized to JSON
"""
answer = None
try:
logging.info("Client conntecting to {server}".format(server=self.server_address))
if ... | python | def send(self, data):
"""
Send date to server
Parameters
----------
data: object that can be serialized to JSON
"""
answer = None
try:
logging.info("Client conntecting to {server}".format(server=self.server_address))
if ... | [
"def",
"send",
"(",
"self",
",",
"data",
")",
":",
"answer",
"=",
"None",
"try",
":",
"logging",
".",
"info",
"(",
"\"Client conntecting to {server}\"",
".",
"format",
"(",
"server",
"=",
"self",
".",
"server_address",
")",
")",
"if",
"six",
".",
"PY2",
... | Send date to server
Parameters
----------
data: object that can be serialized to JSON | [
"Send",
"date",
"to",
"server",
"Parameters",
"----------",
"data",
":",
"object",
"that",
"can",
"be",
"serialized",
"to",
"JSON"
] | 8e884925cf887d386554c1859f626d8f01bd0036 | https://github.com/mbunse/socket_client_server/blob/8e884925cf887d386554c1859f626d8f01bd0036/socket_client_server/socket_client_server.py#L88-L111 | train | Send date to server |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.