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_project.py
grep_projects
def grep_projects(tofind_list, user_profile=None, verbose=True, new=False, **kwargs): r""" Greps the projects defined in the current UserProfile Args: tofind_list (list): user_profile (None): (default = None) Kwargs: user_profile CommandLine: pyth...
python
def grep_projects(tofind_list, user_profile=None, verbose=True, new=False, **kwargs): r""" Greps the projects defined in the current UserProfile Args: tofind_list (list): user_profile (None): (default = None) Kwargs: user_profile CommandLine: pyth...
[ "def", "grep_projects", "(", "tofind_list", ",", "user_profile", "=", "None", ",", "verbose", "=", "True", ",", "new", "=", "False", ",", "*", "*", "kwargs", ")", ":", "import", "utool", "as", "ut", "user_profile", "=", "ensure_user_profile", "(", "user_pr...
r""" Greps the projects defined in the current UserProfile Args: tofind_list (list): user_profile (None): (default = None) Kwargs: user_profile CommandLine: python -m utool --tf grep_projects grep_projects Example: >>> # DISABLE_DOCTEST >>> from ut...
[ "r", "Greps", "the", "projects", "defined", "in", "the", "current", "UserProfile" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_project.py#L606-L708
train
r Greps the projects defined in the current UserProfile
Erotemic/utool
utool/util_project.py
sed_projects
def sed_projects(regexpr, repl, force=False, recursive=True, user_profile=None, **kwargs): r""" Args: regexpr (?): repl (?): force (bool): (default = False) recursive (bool): (default = True) user_profile (None): (default = None) CommandLine: python -m utool...
python
def sed_projects(regexpr, repl, force=False, recursive=True, user_profile=None, **kwargs): r""" Args: regexpr (?): repl (?): force (bool): (default = False) recursive (bool): (default = True) user_profile (None): (default = None) CommandLine: python -m utool...
[ "def", "sed_projects", "(", "regexpr", ",", "repl", ",", "force", "=", "False", ",", "recursive", "=", "True", ",", "user_profile", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# FIXME: finishme", "import", "utool", "as", "ut", "user_profile", "=", "...
r""" Args: regexpr (?): repl (?): force (bool): (default = False) recursive (bool): (default = True) user_profile (None): (default = None) CommandLine: python -m utool.util_project --exec-sed_projects Example: >>> # DISABLE_DOCTEST >>> from ...
[ "r" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_project.py#L851-L907
train
r Sed projects.
Erotemic/utool
utool/util_project.py
SetupRepo.main
def main(self): """ python -m utool SetupRepo.main --modname=sklearn --repo=scikit-learn --codedir=~/code -w python -m utool SetupRepo.main --repo=ubelt --codedir=~/code --modname=ubelt -w Example: >>> # DISABLE_DOCTEST >>> # SCRIPT >>> from utool.util_pr...
python
def main(self): """ python -m utool SetupRepo.main --modname=sklearn --repo=scikit-learn --codedir=~/code -w python -m utool SetupRepo.main --repo=ubelt --codedir=~/code --modname=ubelt -w Example: >>> # DISABLE_DOCTEST >>> # SCRIPT >>> from utool.util_pr...
[ "def", "main", "(", "self", ")", ":", "self", ".", "regencmd", "=", "self", ".", "regenfmt", ".", "format", "(", "cmd", "=", "'main'", ",", "*", "*", "self", ".", "__dict__", ")", "import", "utool", "as", "ut", "self", ".", "ensure_text", "(", "fna...
python -m utool SetupRepo.main --modname=sklearn --repo=scikit-learn --codedir=~/code -w python -m utool SetupRepo.main --repo=ubelt --codedir=~/code --modname=ubelt -w Example: >>> # DISABLE_DOCTEST >>> # SCRIPT >>> from utool.util_project import * # NOQA >...
[ "python", "-", "m", "utool", "SetupRepo", ".", "main", "--", "modname", "=", "sklearn", "--", "repo", "=", "scikit", "-", "learn", "--", "codedir", "=", "~", "/", "code", "-", "w", "python", "-", "m", "utool", "SetupRepo", ".", "main", "--", "repo", ...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_project.py#L96-L140
train
Main function for the base class
crdoconnor/faketime
setup.py
CustomInstall.run
def run(self): """Compile libfaketime.""" if sys.platform == "linux" or sys.platform == "linux2": libname = 'libfaketime.so.1' libnamemt = 'libfaketimeMT.so.1' elif sys.platform == "darwin": libname = 'libfaketime.1.dylib' libnamemt = 'libfaketimeM...
python
def run(self): """Compile libfaketime.""" if sys.platform == "linux" or sys.platform == "linux2": libname = 'libfaketime.so.1' libnamemt = 'libfaketimeMT.so.1' elif sys.platform == "darwin": libname = 'libfaketime.1.dylib' libnamemt = 'libfaketimeM...
[ "def", "run", "(", "self", ")", ":", "if", "sys", ".", "platform", "==", "\"linux\"", "or", "sys", ".", "platform", "==", "\"linux2\"", ":", "libname", "=", "'libfaketime.so.1'", "libnamemt", "=", "'libfaketimeMT.so.1'", "elif", "sys", ".", "platform", "==",...
Compile libfaketime.
[ "Compile", "libfaketime", "." ]
6e81ca070c0e601a52507b945ed45d5d42576b21
https://github.com/crdoconnor/faketime/blob/6e81ca070c0e601a52507b945ed45d5d42576b21/setup.py#L14-L62
train
Compile libfaketime.
Erotemic/utool
utool/util_parallel.py
generate2
def generate2(func, args_gen, kw_gen=None, ntasks=None, ordered=True, force_serial=False, use_pool=False, chunksize=None, nprocs=None, progkw={}, nTasks=None, verbose=None): r""" Interfaces to either multiprocessing or futures. Esentially maps ``args_gen`` onto ``func`` using poo...
python
def generate2(func, args_gen, kw_gen=None, ntasks=None, ordered=True, force_serial=False, use_pool=False, chunksize=None, nprocs=None, progkw={}, nTasks=None, verbose=None): r""" Interfaces to either multiprocessing or futures. Esentially maps ``args_gen`` onto ``func`` using poo...
[ "def", "generate2", "(", "func", ",", "args_gen", ",", "kw_gen", "=", "None", ",", "ntasks", "=", "None", ",", "ordered", "=", "True", ",", "force_serial", "=", "False", ",", "use_pool", "=", "False", ",", "chunksize", "=", "None", ",", "nprocs", "=", ...
r""" Interfaces to either multiprocessing or futures. Esentially maps ``args_gen`` onto ``func`` using pool.imap. However, args_gen must be a tuple of args that will be unpacked and send to the function. Thus, the function can take multiple args. Also specifing keyword args is supported. Useful...
[ "r", "Interfaces", "to", "either", "multiprocessing", "or", "futures", ".", "Esentially", "maps", "args_gen", "onto", "func", "using", "pool", ".", "imap", ".", "However", "args_gen", "must", "be", "a", "tuple", "of", "args", "that", "will", "be", "unpacked"...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_parallel.py#L51-L279
train
r Generate a new entry - point for a new node.
Erotemic/utool
utool/util_parallel.py
_generate_serial2
def _generate_serial2(func, args_gen, kw_gen=None, ntasks=None, progkw={}, verbose=None, nTasks=None): """ internal serial generator """ if verbose is None: verbose = 2 if ntasks is None: ntasks = nTasks if ntasks is None: ntasks = len(args_gen) if verb...
python
def _generate_serial2(func, args_gen, kw_gen=None, ntasks=None, progkw={}, verbose=None, nTasks=None): """ internal serial generator """ if verbose is None: verbose = 2 if ntasks is None: ntasks = nTasks if ntasks is None: ntasks = len(args_gen) if verb...
[ "def", "_generate_serial2", "(", "func", ",", "args_gen", ",", "kw_gen", "=", "None", ",", "ntasks", "=", "None", ",", "progkw", "=", "{", "}", ",", "verbose", "=", "None", ",", "nTasks", "=", "None", ")", ":", "if", "verbose", "is", "None", ":", "...
internal serial generator
[ "internal", "serial", "generator" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_parallel.py#L287-L316
train
internal serial generator
Erotemic/utool
utool/util_parallel.py
buffered_generator
def buffered_generator(source_gen, buffer_size=2, use_multiprocessing=False): r""" Generator that runs a slow source generator in a separate process. My generate function still seems faster on test cases. However, this function is more flexible in its compatability. Args: source_gen (itera...
python
def buffered_generator(source_gen, buffer_size=2, use_multiprocessing=False): r""" Generator that runs a slow source generator in a separate process. My generate function still seems faster on test cases. However, this function is more flexible in its compatability. Args: source_gen (itera...
[ "def", "buffered_generator", "(", "source_gen", ",", "buffer_size", "=", "2", ",", "use_multiprocessing", "=", "False", ")", ":", "if", "buffer_size", "<", "2", ":", "raise", "RuntimeError", "(", "\"Minimal buffer_ size is 2!\"", ")", "if", "use_multiprocessing", ...
r""" Generator that runs a slow source generator in a separate process. My generate function still seems faster on test cases. However, this function is more flexible in its compatability. Args: source_gen (iterable): slow generator buffer_size (int): the maximal number of items to pre...
[ "r", "Generator", "that", "runs", "a", "slow", "source", "generator", "in", "a", "separate", "process", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_parallel.py#L669-L769
train
r A slow generator that runs a slow source generator in a separate process.
Erotemic/utool
utool/util_parallel.py
_buffered_generation_thread
def _buffered_generation_thread(source_gen, buffer_, sentinal): """ helper for buffered_generator """ for data in source_gen: buffer_.put(data, block=True) # sentinel: signal the end of the iterator buffer_.put(sentinal)
python
def _buffered_generation_thread(source_gen, buffer_, sentinal): """ helper for buffered_generator """ for data in source_gen: buffer_.put(data, block=True) # sentinel: signal the end of the iterator buffer_.put(sentinal)
[ "def", "_buffered_generation_thread", "(", "source_gen", ",", "buffer_", ",", "sentinal", ")", ":", "for", "data", "in", "source_gen", ":", "buffer_", ".", "put", "(", "data", ",", "block", "=", "True", ")", "# sentinel: signal the end of the iterator", "buffer_",...
helper for buffered_generator
[ "helper", "for", "buffered_generator" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_parallel.py#L778-L783
train
helper for buffered_generator
Erotemic/utool
utool/util_parallel.py
_buffered_generation_process
def _buffered_generation_process(source_gen, buffer_, sentinal): """ helper for buffered_generator """ for data in source_gen: buffer_.put(data, block=True) # sentinel: signal the end of the iterator buffer_.put(sentinal) # unfortunately this does not suffice as a signal: if buffer_.get() wa...
python
def _buffered_generation_process(source_gen, buffer_, sentinal): """ helper for buffered_generator """ for data in source_gen: buffer_.put(data, block=True) # sentinel: signal the end of the iterator buffer_.put(sentinal) # unfortunately this does not suffice as a signal: if buffer_.get() wa...
[ "def", "_buffered_generation_process", "(", "source_gen", ",", "buffer_", ",", "sentinal", ")", ":", "for", "data", "in", "source_gen", ":", "buffer_", ".", "put", "(", "data", ",", "block", "=", "True", ")", "# sentinel: signal the end of the iterator", "buffer_"...
helper for buffered_generator
[ "helper", "for", "buffered_generator" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_parallel.py#L786-L794
train
process the buffered generator
Erotemic/utool
utool/util_parallel.py
spawn_background_process
def spawn_background_process(func, *args, **kwargs): """ Run a function in the background (like rebuilding some costly data structure) References: http://stackoverflow.com/questions/2046603/is-it-possible-to-run-function-in-a-subprocess-without-threading-or-writing-a-se http://stackover...
python
def spawn_background_process(func, *args, **kwargs): """ Run a function in the background (like rebuilding some costly data structure) References: http://stackoverflow.com/questions/2046603/is-it-possible-to-run-function-in-a-subprocess-without-threading-or-writing-a-se http://stackover...
[ "def", "spawn_background_process", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "import", "utool", "as", "ut", "func_name", "=", "ut", ".", "get_funcname", "(", "func", ")", "name", "=", "'mp.Progress-'", "+", "func_name", "#proc_obj =...
Run a function in the background (like rebuilding some costly data structure) References: http://stackoverflow.com/questions/2046603/is-it-possible-to-run-function-in-a-subprocess-without-threading-or-writing-a-se http://stackoverflow.com/questions/1196074/starting-a-background-process-in-pytho...
[ "Run", "a", "function", "in", "the", "background", "(", "like", "rebuilding", "some", "costly", "data", "structure", ")" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_parallel.py#L797-L863
train
Spawns a background process in the background.
Erotemic/utool
_broken/util_distances.py
nearest_point
def nearest_point(x, y, pts, mode='random'): """ finds the nearest point(s) in pts to (x, y) FIXME VIZ FEATROW """ dists = (pts.T[0] - x) ** 2 + (pts.T[1] - y) ** 2 fx = dists.argmin() mindist = dists[fx] other_fx = np.where(mindist == dists)[0] if len(other_fx) > 0: if mode == '...
python
def nearest_point(x, y, pts, mode='random'): """ finds the nearest point(s) in pts to (x, y) FIXME VIZ FEATROW """ dists = (pts.T[0] - x) ** 2 + (pts.T[1] - y) ** 2 fx = dists.argmin() mindist = dists[fx] other_fx = np.where(mindist == dists)[0] if len(other_fx) > 0: if mode == '...
[ "def", "nearest_point", "(", "x", ",", "y", ",", "pts", ",", "mode", "=", "'random'", ")", ":", "dists", "=", "(", "pts", ".", "T", "[", "0", "]", "-", "x", ")", "**", "2", "+", "(", "pts", ".", "T", "[", "1", "]", "-", "y", ")", "**", ...
finds the nearest point(s) in pts to (x, y) FIXME VIZ FEATROW
[ "finds", "the", "nearest", "point", "(", "s", ")", "in", "pts", "to", "(", "x", "y", ")", "FIXME", "VIZ", "FEATROW" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/_broken/util_distances.py#L18-L34
train
finds the nearest point in pts to x y
Erotemic/utool
utool/util_ubuntu.py
add_new_mimetype_association
def add_new_mimetype_association(ext, mime_name, exe_fpath=None, dry=True): """ TODO: move to external manager and generalize Args: ext (str): extension to associate mime_name (str): the name of the mime_name to create (defaults to ext) exe_fpath (str): executable location if this i...
python
def add_new_mimetype_association(ext, mime_name, exe_fpath=None, dry=True): """ TODO: move to external manager and generalize Args: ext (str): extension to associate mime_name (str): the name of the mime_name to create (defaults to ext) exe_fpath (str): executable location if this i...
[ "def", "add_new_mimetype_association", "(", "ext", ",", "mime_name", ",", "exe_fpath", "=", "None", ",", "dry", "=", "True", ")", ":", "import", "utool", "as", "ut", "terminal", "=", "True", "mime_codeblock", "=", "ut", ".", "codeblock", "(", "'''\n <...
TODO: move to external manager and generalize Args: ext (str): extension to associate mime_name (str): the name of the mime_name to create (defaults to ext) exe_fpath (str): executable location if this is for one specific file References: https://wiki.archlinux.org/index.php/De...
[ "TODO", ":", "move", "to", "external", "manager", "and", "generalize" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_ubuntu.py#L8-L120
train
This function will add a new mimetype association to the internal manager.
Erotemic/utool
utool/util_ubuntu.py
make_application_icon
def make_application_icon(exe_fpath, dry=True, props={}): r""" CommandLine: python -m utool.util_ubuntu --exec-make_application_icon --exe=cockatrice --icon=/home/joncrall/code/Cockatrice/cockatrice/resources/cockatrice.png python -m utool.util_ubuntu --exec-make_application_icon --exe=cockatric...
python
def make_application_icon(exe_fpath, dry=True, props={}): r""" CommandLine: python -m utool.util_ubuntu --exec-make_application_icon --exe=cockatrice --icon=/home/joncrall/code/Cockatrice/cockatrice/resources/cockatrice.png python -m utool.util_ubuntu --exec-make_application_icon --exe=cockatric...
[ "def", "make_application_icon", "(", "exe_fpath", ",", "dry", "=", "True", ",", "props", "=", "{", "}", ")", ":", "import", "utool", "as", "ut", "exe_fname_noext", "=", "splitext", "(", "basename", "(", "exe_fpath", ")", ")", "[", "0", "]", "app_name", ...
r""" CommandLine: python -m utool.util_ubuntu --exec-make_application_icon --exe=cockatrice --icon=/home/joncrall/code/Cockatrice/cockatrice/resources/cockatrice.png python -m utool.util_ubuntu --exec-make_application_icon --exe=cockatrice --icon=/home/joncrall/code/Cockatrice/cockatrice/resources/c...
[ "r", "CommandLine", ":", "python", "-", "m", "utool", ".", "util_ubuntu", "--", "exec", "-", "make_application_icon", "--", "exe", "=", "cockatrice", "--", "icon", "=", "/", "home", "/", "joncrall", "/", "code", "/", "Cockatrice", "/", "cockatrice", "/", ...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_ubuntu.py#L123-L197
train
A function that creates a new application icon
Erotemic/utool
utool/util_ubuntu.py
monitor_mouse
def monitor_mouse(): """ CommandLine: python -m utool.util_ubuntu monitor_mouse Example: >>> # DISABLE_DOCTEST >>> # SCRIPT >>> from utool.util_ubuntu import * # NOQA >>> import utool as ut >>> monitor_mouse() """ import utool as ut import re ...
python
def monitor_mouse(): """ CommandLine: python -m utool.util_ubuntu monitor_mouse Example: >>> # DISABLE_DOCTEST >>> # SCRIPT >>> from utool.util_ubuntu import * # NOQA >>> import utool as ut >>> monitor_mouse() """ import utool as ut import re ...
[ "def", "monitor_mouse", "(", ")", ":", "import", "utool", "as", "ut", "import", "re", "import", "parse", "mouse_ids", "=", "ut", ".", "cmd", "(", "'xinput --list '", ",", "verbose", "=", "False", ",", "quiet", "=", "True", ")", "[", "0", "]", "x", "=...
CommandLine: python -m utool.util_ubuntu monitor_mouse Example: >>> # DISABLE_DOCTEST >>> # SCRIPT >>> from utool.util_ubuntu import * # NOQA >>> import utool as ut >>> monitor_mouse()
[ "CommandLine", ":", "python", "-", "m", "utool", ".", "util_ubuntu", "monitor_mouse" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_ubuntu.py#L687-L714
train
A CLI for managing the state of a mouse.
Erotemic/utool
utool/util_ubuntu.py
XCtrl.move_window
def move_window(win_key, bbox): """ CommandLine: # List windows wmctrl -l # List desktops wmctrl -d # Window info xwininfo -id 60817412 python -m utool.util_ubuntu XCtrl.move_window joncrall 0+1920,680,400,600,400 ...
python
def move_window(win_key, bbox): """ CommandLine: # List windows wmctrl -l # List desktops wmctrl -d # Window info xwininfo -id 60817412 python -m utool.util_ubuntu XCtrl.move_window joncrall 0+1920,680,400,600,400 ...
[ "def", "move_window", "(", "win_key", ",", "bbox", ")", ":", "import", "utool", "as", "ut", "import", "plottool", "as", "pt", "# NOQA", "import", "plottool", ".", "screeninfo", "as", "screeninfo", "monitor_infos", "=", "{", "i", "+", "1", ":", "screeninfo"...
CommandLine: # List windows wmctrl -l # List desktops wmctrl -d # Window info xwininfo -id 60817412 python -m utool.util_ubuntu XCtrl.move_window joncrall 0+1920,680,400,600,400 python -m utool.util_ubuntu XCtrl.move_windo...
[ "CommandLine", ":", "#", "List", "windows", "wmctrl", "-", "l", "#", "List", "desktops", "wmctrl", "-", "d" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_ubuntu.py#L277-L356
train
Move a window to a new bounding box
Erotemic/utool
utool/util_ubuntu.py
XCtrl.findall_window_ids
def findall_window_ids(pattern): """ CommandLine: wmctrl -l python -m utool.util_ubuntu XCtrl.findall_window_ids gvim --src python -m utool.util_ubuntu XCtrl.findall_window_ids gvim --src python -m utool.util_ubuntu XCtrl.findall_window_ids joncrall --src...
python
def findall_window_ids(pattern): """ CommandLine: wmctrl -l python -m utool.util_ubuntu XCtrl.findall_window_ids gvim --src python -m utool.util_ubuntu XCtrl.findall_window_ids gvim --src python -m utool.util_ubuntu XCtrl.findall_window_ids joncrall --src...
[ "def", "findall_window_ids", "(", "pattern", ")", ":", "import", "utool", "as", "ut", "cmdkw", "=", "dict", "(", "verbose", "=", "False", ",", "quiet", "=", "True", ",", "silence", "=", "True", ")", "command", "=", "\"wmctrl -lx | grep '%s' | awk '{print $1}'\...
CommandLine: wmctrl -l python -m utool.util_ubuntu XCtrl.findall_window_ids gvim --src python -m utool.util_ubuntu XCtrl.findall_window_ids gvim --src python -m utool.util_ubuntu XCtrl.findall_window_ids joncrall --src xprop -id wmctrl -l | awk '{print ...
[ "CommandLine", ":", "wmctrl", "-", "l", "python", "-", "m", "utool", ".", "util_ubuntu", "XCtrl", ".", "findall_window_ids", "gvim", "--", "src", "python", "-", "m", "utool", ".", "util_ubuntu", "XCtrl", ".", "findall_window_ids", "gvim", "--", "src", "pytho...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_ubuntu.py#L359-L381
train
Return a list of window IDs that match a pattern
Erotemic/utool
utool/util_ubuntu.py
XCtrl.sort_window_ids
def sort_window_ids(winid_list, order='mru'): """ Orders window ids by most recently used """ import utool as ut winid_order = XCtrl.sorted_window_ids(order) sorted_win_ids = ut.isect(winid_order, winid_list) return sorted_win_ids
python
def sort_window_ids(winid_list, order='mru'): """ Orders window ids by most recently used """ import utool as ut winid_order = XCtrl.sorted_window_ids(order) sorted_win_ids = ut.isect(winid_order, winid_list) return sorted_win_ids
[ "def", "sort_window_ids", "(", "winid_list", ",", "order", "=", "'mru'", ")", ":", "import", "utool", "as", "ut", "winid_order", "=", "XCtrl", ".", "sorted_window_ids", "(", "order", ")", "sorted_win_ids", "=", "ut", ".", "isect", "(", "winid_order", ",", ...
Orders window ids by most recently used
[ "Orders", "window", "ids", "by", "most", "recently", "used" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_ubuntu.py#L384-L391
train
Sorts the list of window ids by most recently used
Erotemic/utool
utool/util_ubuntu.py
XCtrl.killold
def killold(pattern, num=4): """ Leaves no more than `num` instances of a program alive. Ordering is determined by most recent usage. CommandLine: python -m utool.util_ubuntu XCtrl.killold gvim 2 >>> import utool as ut >>> from utool import util_ubuntu ...
python
def killold(pattern, num=4): """ Leaves no more than `num` instances of a program alive. Ordering is determined by most recent usage. CommandLine: python -m utool.util_ubuntu XCtrl.killold gvim 2 >>> import utool as ut >>> from utool import util_ubuntu ...
[ "def", "killold", "(", "pattern", ",", "num", "=", "4", ")", ":", "import", "utool", "as", "ut", "cmdkw", "=", "dict", "(", "verbose", "=", "False", ",", "quiet", "=", "True", ",", "silence", "=", "True", ")", "num", "=", "int", "(", "num", ")", ...
Leaves no more than `num` instances of a program alive. Ordering is determined by most recent usage. CommandLine: python -m utool.util_ubuntu XCtrl.killold gvim 2 >>> import utool as ut >>> from utool import util_ubuntu >>> XCtrl = util_ubuntu.XCtrl >>> pat...
[ "Leaves", "no", "more", "than", "num", "instances", "of", "a", "program", "alive", ".", "Ordering", "is", "determined", "by", "most", "recent", "usage", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_ubuntu.py#L394-L423
train
Kill old window with pattern.
Erotemic/utool
utool/util_ubuntu.py
XCtrl.sorted_window_ids
def sorted_window_ids(order='mru'): """ Returns window ids orderd by criteria default is mru (most recently used) CommandLine: xprop -root | grep "^_NET_CLIENT_LIST_STACKING" | tr "," " " python -m utool.util_ubuntu XCtrl.sorted_window_ids """ imp...
python
def sorted_window_ids(order='mru'): """ Returns window ids orderd by criteria default is mru (most recently used) CommandLine: xprop -root | grep "^_NET_CLIENT_LIST_STACKING" | tr "," " " python -m utool.util_ubuntu XCtrl.sorted_window_ids """ imp...
[ "def", "sorted_window_ids", "(", "order", "=", "'mru'", ")", ":", "import", "utool", "as", "ut", "if", "order", "in", "[", "'mru'", ",", "'lru'", "]", ":", "cmdkw", "=", "dict", "(", "verbose", "=", "False", ",", "quiet", "=", "True", ",", "silence",...
Returns window ids orderd by criteria default is mru (most recently used) CommandLine: xprop -root | grep "^_NET_CLIENT_LIST_STACKING" | tr "," " " python -m utool.util_ubuntu XCtrl.sorted_window_ids
[ "Returns", "window", "ids", "orderd", "by", "criteria", "default", "is", "mru", "(", "most", "recently", "used", ")" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_ubuntu.py#L426-L446
train
Return a list of window ids ordered by criteria
Erotemic/utool
utool/util_ubuntu.py
XCtrl.find_window_id
def find_window_id(pattern, method='mru', error='raise'): """ xprop -id 0x00a00007 | grep "WM_CLASS(STRING)" """ import utool as ut winid_candidates = XCtrl.findall_window_ids(pattern) if len(winid_candidates) == 0: if error == 'raise': availab...
python
def find_window_id(pattern, method='mru', error='raise'): """ xprop -id 0x00a00007 | grep "WM_CLASS(STRING)" """ import utool as ut winid_candidates = XCtrl.findall_window_ids(pattern) if len(winid_candidates) == 0: if error == 'raise': availab...
[ "def", "find_window_id", "(", "pattern", ",", "method", "=", "'mru'", ",", "error", "=", "'raise'", ")", ":", "import", "utool", "as", "ut", "winid_candidates", "=", "XCtrl", ".", "findall_window_ids", "(", "pattern", ")", "if", "len", "(", "winid_candidates...
xprop -id 0x00a00007 | grep "WM_CLASS(STRING)"
[ "xprop", "-", "id", "0x00a00007", "|", "grep", "WM_CLASS", "(", "STRING", ")" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_ubuntu.py#L449-L470
train
Find the most recently used window with the given pattern.
Erotemic/utool
utool/util_ubuntu.py
XCtrl.current_gvim_edit
def current_gvim_edit(op='e', fpath=''): r""" CommandLine: python -m utool.util_ubuntu XCtrl.current_gvim_edit sp ~/.bashrc """ import utool as ut fpath = ut.unexpanduser(ut.truepath(fpath)) # print('fpath = %r' % (fpath,)) ut.copy_text_to_clipboard(fp...
python
def current_gvim_edit(op='e', fpath=''): r""" CommandLine: python -m utool.util_ubuntu XCtrl.current_gvim_edit sp ~/.bashrc """ import utool as ut fpath = ut.unexpanduser(ut.truepath(fpath)) # print('fpath = %r' % (fpath,)) ut.copy_text_to_clipboard(fp...
[ "def", "current_gvim_edit", "(", "op", "=", "'e'", ",", "fpath", "=", "''", ")", ":", "import", "utool", "as", "ut", "fpath", "=", "ut", ".", "unexpanduser", "(", "ut", ".", "truepath", "(", "fpath", ")", ")", "# print('fpath = %r' % (fpath,))", "ut", "....
r""" CommandLine: python -m utool.util_ubuntu XCtrl.current_gvim_edit sp ~/.bashrc
[ "r", "CommandLine", ":", "python", "-", "m", "utool", ".", "util_ubuntu", "XCtrl", ".", "current_gvim_edit", "sp", "~", "/", ".", "bashrc" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_ubuntu.py#L473-L491
train
r A command line for editing the current gvim file.
Erotemic/utool
utool/util_ubuntu.py
XCtrl.copy_gvim_to_terminal_script
def copy_gvim_to_terminal_script(text, return_to_win="1", verbose=0, sleeptime=.02): """ import utool.util_ubuntu utool.util_ubuntu.XCtrl.copy_gvim_to_terminal_script('print("hi")', verbose=1) python -m utool.util_ubuntu XCtrl.copy_gvim_to_terminal_script "echo hi" 1 1 If this d...
python
def copy_gvim_to_terminal_script(text, return_to_win="1", verbose=0, sleeptime=.02): """ import utool.util_ubuntu utool.util_ubuntu.XCtrl.copy_gvim_to_terminal_script('print("hi")', verbose=1) python -m utool.util_ubuntu XCtrl.copy_gvim_to_terminal_script "echo hi" 1 1 If this d...
[ "def", "copy_gvim_to_terminal_script", "(", "text", ",", "return_to_win", "=", "\"1\"", ",", "verbose", "=", "0", ",", "sleeptime", "=", ".02", ")", ":", "# Prepare to send text to xdotool", "import", "utool", "as", "ut", "import", "utool", ".", "util_ubuntu", "...
import utool.util_ubuntu utool.util_ubuntu.XCtrl.copy_gvim_to_terminal_script('print("hi")', verbose=1) python -m utool.util_ubuntu XCtrl.copy_gvim_to_terminal_script "echo hi" 1 1 If this doesn't work make sure pyperclip is installed and set to xsel print('foobar') echo hi
[ "import", "utool", ".", "util_ubuntu", "utool", ".", "util_ubuntu", ".", "XCtrl", ".", "copy_gvim_to_terminal_script", "(", "print", "(", "hi", ")", "verbose", "=", "1", ")", "python", "-", "m", "utool", ".", "util_ubuntu", "XCtrl", ".", "copy_gvim_to_terminal...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_ubuntu.py#L494-L541
train
Copy a text to a terminal script
Erotemic/utool
utool/util_ubuntu.py
XCtrl.focus_window
def focus_window(winhandle, path=None, name=None, sleeptime=.01): """ sudo apt-get install xautomation apt-get install autokey-gtk wmctrl -xa gnome-terminal.Gnome-terminal wmctrl -xl """ import utool as ut import time print('focus: ' + winhandle) ...
python
def focus_window(winhandle, path=None, name=None, sleeptime=.01): """ sudo apt-get install xautomation apt-get install autokey-gtk wmctrl -xa gnome-terminal.Gnome-terminal wmctrl -xl """ import utool as ut import time print('focus: ' + winhandle) ...
[ "def", "focus_window", "(", "winhandle", ",", "path", "=", "None", ",", "name", "=", "None", ",", "sleeptime", "=", ".01", ")", ":", "import", "utool", "as", "ut", "import", "time", "print", "(", "'focus: '", "+", "winhandle", ")", "args", "=", "[", ...
sudo apt-get install xautomation apt-get install autokey-gtk wmctrl -xa gnome-terminal.Gnome-terminal wmctrl -xl
[ "sudo", "apt", "-", "get", "install", "xautomation", "apt", "-", "get", "install", "autokey", "-", "gtk" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_ubuntu.py#L668-L681
train
focus a window
Erotemic/utool
utool/util_setup.py
setup_chmod
def setup_chmod(setup_fpath, setup_dir, chmod_patterns): """ Gives files matching pattern the same chmod flags as setup.py """ #st_mode = os.stat(setup_fpath).st_mode st_mode = 33277 for pattern in chmod_patterns: for fpath in util_path.glob(setup_dir, pattern, recursive=True): print...
python
def setup_chmod(setup_fpath, setup_dir, chmod_patterns): """ Gives files matching pattern the same chmod flags as setup.py """ #st_mode = os.stat(setup_fpath).st_mode st_mode = 33277 for pattern in chmod_patterns: for fpath in util_path.glob(setup_dir, pattern, recursive=True): print...
[ "def", "setup_chmod", "(", "setup_fpath", ",", "setup_dir", ",", "chmod_patterns", ")", ":", "#st_mode = os.stat(setup_fpath).st_mode", "st_mode", "=", "33277", "for", "pattern", "in", "chmod_patterns", ":", "for", "fpath", "in", "util_path", ".", "glob", "(", "se...
Gives files matching pattern the same chmod flags as setup.py
[ "Gives", "files", "matching", "pattern", "the", "same", "chmod", "flags", "as", "setup", ".", "py" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_setup.py#L103-L110
train
Sets the chmod flags of the files in the setup. py directory.
Erotemic/utool
utool/util_setup.py
assert_in_setup_repo
def assert_in_setup_repo(setup_fpath, name=''): """ pass in __file__ from setup.py """ setup_dir, setup_fname = split(setup_fpath) cwd = os.getcwd() #repo_dname = split(setup_dir)[1] #print('cwd = %r' % (cwd)) #print('repo_dname = %r' % repo_dname) #print('setup_dir = %r' % (setup_dir)...
python
def assert_in_setup_repo(setup_fpath, name=''): """ pass in __file__ from setup.py """ setup_dir, setup_fname = split(setup_fpath) cwd = os.getcwd() #repo_dname = split(setup_dir)[1] #print('cwd = %r' % (cwd)) #print('repo_dname = %r' % repo_dname) #print('setup_dir = %r' % (setup_dir)...
[ "def", "assert_in_setup_repo", "(", "setup_fpath", ",", "name", "=", "''", ")", ":", "setup_dir", ",", "setup_fname", "=", "split", "(", "setup_fpath", ")", "cwd", "=", "os", ".", "getcwd", "(", ")", "#repo_dname = split(setup_dir)[1]", "#print('cwd = %r' % ...
pass in __file__ from setup.py
[ "pass", "in", "__file__", "from", "setup", ".", "py" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_setup.py#L113-L131
train
assert that setup. py is in repository root
Erotemic/utool
utool/util_setup.py
find_packages
def find_packages(recursive=True, maxdepth=None): """ Finds all directories with an __init__.py file in them """ import utool if utool.VERBOSE: print('[util_setup] find_packages(recursive=%r, maxdepth=%r)' % (recursive, maxdepth)) from os.path import relpath cwd = os.getcwd() ini...
python
def find_packages(recursive=True, maxdepth=None): """ Finds all directories with an __init__.py file in them """ import utool if utool.VERBOSE: print('[util_setup] find_packages(recursive=%r, maxdepth=%r)' % (recursive, maxdepth)) from os.path import relpath cwd = os.getcwd() ini...
[ "def", "find_packages", "(", "recursive", "=", "True", ",", "maxdepth", "=", "None", ")", ":", "import", "utool", "if", "utool", ".", "VERBOSE", ":", "print", "(", "'[util_setup] find_packages(recursive=%r, maxdepth=%r)'", "%", "(", "recursive", ",", "maxdepth", ...
Finds all directories with an __init__.py file in them
[ "Finds", "all", "directories", "with", "an", "__init__", ".", "py", "file", "in", "them" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_setup.py#L216-L235
train
Find all packages in the current directory
Erotemic/utool
utool/util_setup.py
get_cmdclass
def get_cmdclass(): """ DEPRICATE """ try: from Cython.Distutils import build_ext cmdclass = {'build_ext': build_ext} return cmdclass except Exception as ex: print(ex) print('WARNING: Cython is not installed. This is only a problem if you are building C extensions') ...
python
def get_cmdclass(): """ DEPRICATE """ try: from Cython.Distutils import build_ext cmdclass = {'build_ext': build_ext} return cmdclass except Exception as ex: print(ex) print('WARNING: Cython is not installed. This is only a problem if you are building C extensions') ...
[ "def", "get_cmdclass", "(", ")", ":", "try", ":", "from", "Cython", ".", "Distutils", "import", "build_ext", "cmdclass", "=", "{", "'build_ext'", ":", "build_ext", "}", "return", "cmdclass", "except", "Exception", "as", "ex", ":", "print", "(", "ex", ")", ...
DEPRICATE
[ "DEPRICATE" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_setup.py#L238-L247
train
DEPRICATE Cython is not installed
Erotemic/utool
utool/util_setup.py
autogen_sphinx_apidoc
def autogen_sphinx_apidoc(): r""" autogen_sphinx_docs.py Ignore: C:\Python27\Scripts\autogen_sphinx_docs.py autogen_sphinx_docs.py pip uninstall sphinx pip install sphinx pip install sphinxcontrib-napoleon pip install sphinx --upgrade pip install sph...
python
def autogen_sphinx_apidoc(): r""" autogen_sphinx_docs.py Ignore: C:\Python27\Scripts\autogen_sphinx_docs.py autogen_sphinx_docs.py pip uninstall sphinx pip install sphinx pip install sphinxcontrib-napoleon pip install sphinx --upgrade pip install sph...
[ "def", "autogen_sphinx_apidoc", "(", ")", ":", "# TODO: assert sphinx-apidoc exe is found", "# TODO: make find_exe work?", "import", "utool", "as", "ut", "def", "build_sphinx_apidoc_cmdstr", "(", ")", ":", "print", "(", "''", ")", "print", "(", "'if this fails try: sudo p...
r""" autogen_sphinx_docs.py Ignore: C:\Python27\Scripts\autogen_sphinx_docs.py autogen_sphinx_docs.py pip uninstall sphinx pip install sphinx pip install sphinxcontrib-napoleon pip install sphinx --upgrade pip install sphinxcontrib-napoleon --upgrade ...
[ "r", "autogen_sphinx_docs", ".", "py" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_setup.py#L257-L445
train
A simple version of sphinx - apidoc.
Erotemic/utool
utool/util_setup.py
parse_package_for_version
def parse_package_for_version(name): """ Searches for a variable named __version__ in name's __init__.py file and returns the value. This function parses the source text. It does not load the module. """ from utool import util_regex init_fpath = join(name, '__init__.py') version_errmsg ...
python
def parse_package_for_version(name): """ Searches for a variable named __version__ in name's __init__.py file and returns the value. This function parses the source text. It does not load the module. """ from utool import util_regex init_fpath = join(name, '__init__.py') version_errmsg ...
[ "def", "parse_package_for_version", "(", "name", ")", ":", "from", "utool", "import", "util_regex", "init_fpath", "=", "join", "(", "name", ",", "'__init__.py'", ")", "version_errmsg", "=", "textwrap", ".", "dedent", "(", "'''\n You must include a __version__ v...
Searches for a variable named __version__ in name's __init__.py file and returns the value. This function parses the source text. It does not load the module.
[ "Searches", "for", "a", "variable", "named", "__version__", "in", "name", "s", "__init__", ".", "py", "file", "and", "returns", "the", "value", ".", "This", "function", "parses", "the", "source", "text", ".", "It", "does", "not", "load", "the", "module", ...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_setup.py#L570-L602
train
This function parses the source text of a module and returns the value of the variable named __version__ in the module.
Erotemic/utool
utool/util_setup.py
__infer_setup_kwargs
def __infer_setup_kwargs(module, kwargs): """ Implicitly build kwargs based on standard info """ # Get project name from the module #if 'name' not in kwargs: # kwargs['name'] = module.__name__ #else: # raise AssertionError('must specify module name!') name = kwargs['name'] # Our pr...
python
def __infer_setup_kwargs(module, kwargs): """ Implicitly build kwargs based on standard info """ # Get project name from the module #if 'name' not in kwargs: # kwargs['name'] = module.__name__ #else: # raise AssertionError('must specify module name!') name = kwargs['name'] # Our pr...
[ "def", "__infer_setup_kwargs", "(", "module", ",", "kwargs", ")", ":", "# Get project name from the module", "#if 'name' not in kwargs:", "# kwargs['name'] = module.__name__", "#else:", "# raise AssertionError('must specify module name!')", "name", "=", "kwargs", "[", "'name'...
Implicitly build kwargs based on standard info
[ "Implicitly", "build", "kwargs", "based", "on", "standard", "info" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_setup.py#L605-L643
train
Infer kwargs based on standard info
Erotemic/utool
utool/util_setup.py
setuptools_setup
def setuptools_setup(setup_fpath=None, module=None, **kwargs): # TODO: Learn this better # https://docs.python.org/3.1/distutils/apiref.html # https://pythonhosted.org/an_example_pypi_project/setuptools.html # https://docs.python.org/2/distutils/setupscript.html https://docs.python.org/2/distutils/setup...
python
def setuptools_setup(setup_fpath=None, module=None, **kwargs): # TODO: Learn this better # https://docs.python.org/3.1/distutils/apiref.html # https://pythonhosted.org/an_example_pypi_project/setuptools.html # https://docs.python.org/2/distutils/setupscript.html https://docs.python.org/2/distutils/setup...
[ "def", "setuptools_setup", "(", "setup_fpath", "=", "None", ",", "module", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# TODO: Learn this better", "# https://docs.python.org/3.1/distutils/apiref.html", "# https://pythonhosted.org/an_example_pypi_project/setuptools.html", "...
Arguments which can be passed to setuptools:: ============ ===== =========== Install-Data Value Description ------------ ----- ----------- *packages strlist a list of packages modules to be distributed py_modul...
[ "Arguments", "which", "can", "be", "passed", "to", "setuptools", "::" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_setup.py#L651-L699
train
This function is called by setuptools to create a new setuptools - specific version of the package.
Thermondo/django-heroku-connect
heroku_connect/admin.py
_replaced
def _replaced(__values, **__replacements): """ Replace elements in iterable with values from an alias dict, suppressing empty values. Used to consistently enhance how certain fields are displayed in list and detail pages. """ return tuple(o for o in (__replacements.get(name, name) for name in __val...
python
def _replaced(__values, **__replacements): """ Replace elements in iterable with values from an alias dict, suppressing empty values. Used to consistently enhance how certain fields are displayed in list and detail pages. """ return tuple(o for o in (__replacements.get(name, name) for name in __val...
[ "def", "_replaced", "(", "__values", ",", "*", "*", "__replacements", ")", ":", "return", "tuple", "(", "o", "for", "o", "in", "(", "__replacements", ".", "get", "(", "name", ",", "name", ")", "for", "name", "in", "__values", ")", "if", "o", ")" ]
Replace elements in iterable with values from an alias dict, suppressing empty values. Used to consistently enhance how certain fields are displayed in list and detail pages.
[ "Replace", "elements", "in", "iterable", "with", "values", "from", "an", "alias", "dict", "suppressing", "empty", "values", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/admin.py#L14-L20
train
Return a tuple of elements that are replaced with values from an alias dict suppressing empty values.
Thermondo/django-heroku-connect
heroku_connect/admin.py
_get_admin_route_name
def _get_admin_route_name(model_or_instance): """ Get the base name of the admin route for a model or model instance. For use with :func:`django.urls.reverse`, although it still needs the specific route suffix appended, for example ``_changelist``. """ model = model_or_instance if isinstance(mo...
python
def _get_admin_route_name(model_or_instance): """ Get the base name of the admin route for a model or model instance. For use with :func:`django.urls.reverse`, although it still needs the specific route suffix appended, for example ``_changelist``. """ model = model_or_instance if isinstance(mo...
[ "def", "_get_admin_route_name", "(", "model_or_instance", ")", ":", "model", "=", "model_or_instance", "if", "isinstance", "(", "model_or_instance", ",", "type", ")", "else", "type", "(", "model_or_instance", ")", "return", "'admin:{meta.app_label}_{meta.model_name}'", ...
Get the base name of the admin route for a model or model instance. For use with :func:`django.urls.reverse`, although it still needs the specific route suffix appended, for example ``_changelist``.
[ "Get", "the", "base", "name", "of", "the", "admin", "route", "for", "a", "model", "or", "model", "instance", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/admin.py#L23-L31
train
Returns the base name of the admin route for a model or model instance.
Thermondo/django-heroku-connect
heroku_connect/admin.py
_build_admin_filter_url
def _build_admin_filter_url(model, filters): """Build a filter URL to an admin changelist of all objects with similar field values.""" url = reverse(_get_admin_route_name(model) + '_changelist') parts = urlsplit(url) query = parse_qs(parts.query) query.update(filters) parts_with_filter = parts._...
python
def _build_admin_filter_url(model, filters): """Build a filter URL to an admin changelist of all objects with similar field values.""" url = reverse(_get_admin_route_name(model) + '_changelist') parts = urlsplit(url) query = parse_qs(parts.query) query.update(filters) parts_with_filter = parts._...
[ "def", "_build_admin_filter_url", "(", "model", ",", "filters", ")", ":", "url", "=", "reverse", "(", "_get_admin_route_name", "(", "model", ")", "+", "'_changelist'", ")", "parts", "=", "urlsplit", "(", "url", ")", "query", "=", "parse_qs", "(", "parts", ...
Build a filter URL to an admin changelist of all objects with similar field values.
[ "Build", "a", "filter", "URL", "to", "an", "admin", "changelist", "of", "all", "objects", "with", "similar", "field", "values", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/admin.py#L34-L41
train
Build a filter URL to an admin changelist of all objects with similar field values.
Thermondo/django-heroku-connect
heroku_connect/admin.py
_make_admin_link_to_similar
def _make_admin_link_to_similar(primary_field, *fields, name=None): """Create a function that links to a changelist of all objects with similar field values.""" fields = (primary_field,) + fields url_template = '<a href="{url}">{name_or_value}</a>' def field_link(self, obj): value = getattr(obj...
python
def _make_admin_link_to_similar(primary_field, *fields, name=None): """Create a function that links to a changelist of all objects with similar field values.""" fields = (primary_field,) + fields url_template = '<a href="{url}">{name_or_value}</a>' def field_link(self, obj): value = getattr(obj...
[ "def", "_make_admin_link_to_similar", "(", "primary_field", ",", "*", "fields", ",", "name", "=", "None", ")", ":", "fields", "=", "(", "primary_field", ",", ")", "+", "fields", "url_template", "=", "'<a href=\"{url}\">{name_or_value}</a>'", "def", "field_link", "...
Create a function that links to a changelist of all objects with similar field values.
[ "Create", "a", "function", "that", "links", "to", "a", "changelist", "of", "all", "objects", "with", "similar", "field", "values", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/admin.py#L44-L60
train
Create a function that links to a changelist of all objects with similar field values.
Thermondo/django-heroku-connect
heroku_connect/admin.py
_retry_failed_log
def _retry_failed_log(failed_trigger_log): """ Try to re-apply a failed trigger log action. Makes sure the argument trigger log is in a FAILED state and acquires a row lock on it. Returns: True if the operation succeeded """ model = type(failed_trigger_log) try: failed_t...
python
def _retry_failed_log(failed_trigger_log): """ Try to re-apply a failed trigger log action. Makes sure the argument trigger log is in a FAILED state and acquires a row lock on it. Returns: True if the operation succeeded """ model = type(failed_trigger_log) try: failed_t...
[ "def", "_retry_failed_log", "(", "failed_trigger_log", ")", ":", "model", "=", "type", "(", "failed_trigger_log", ")", "try", ":", "failed_trigger_log", "=", "(", "model", ".", "objects", ".", "select_for_update", "(", ")", ".", "get", "(", "id", "=", "faile...
Try to re-apply a failed trigger log action. Makes sure the argument trigger log is in a FAILED state and acquires a row lock on it. Returns: True if the operation succeeded
[ "Try", "to", "re", "-", "apply", "a", "failed", "trigger", "log", "action", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/admin.py#L69-L92
train
Try to re - apply a failed trigger log action.
Thermondo/django-heroku-connect
heroku_connect/admin.py
TriggerLogAdmin.ignore_failed_logs_action
def ignore_failed_logs_action(self, request, queryset): """Set FAILED trigger logs in queryset to IGNORED.""" count = _ignore_failed_logs(queryset) self.message_user( request, _('{count} failed trigger logs marked as ignored.').format(count=count), )
python
def ignore_failed_logs_action(self, request, queryset): """Set FAILED trigger logs in queryset to IGNORED.""" count = _ignore_failed_logs(queryset) self.message_user( request, _('{count} failed trigger logs marked as ignored.').format(count=count), )
[ "def", "ignore_failed_logs_action", "(", "self", ",", "request", ",", "queryset", ")", ":", "count", "=", "_ignore_failed_logs", "(", "queryset", ")", "self", ".", "message_user", "(", "request", ",", "_", "(", "'{count} failed trigger logs marked as ignored.'", ")"...
Set FAILED trigger logs in queryset to IGNORED.
[ "Set", "FAILED", "trigger", "logs", "in", "queryset", "to", "IGNORED", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/admin.py#L156-L162
train
Set FAILED trigger logs in queryset to IGNORED.
Thermondo/django-heroku-connect
heroku_connect/admin.py
TriggerLogAdmin.retry_failed_logs_action
def retry_failed_logs_action(self, request, queryset): """Try to re-apply FAILED trigger log actions in the queryset.""" count = 0 for trigger_log in queryset: retried = _retry_failed_log(trigger_log) if retried: count += 1 self.message_user( ...
python
def retry_failed_logs_action(self, request, queryset): """Try to re-apply FAILED trigger log actions in the queryset.""" count = 0 for trigger_log in queryset: retried = _retry_failed_log(trigger_log) if retried: count += 1 self.message_user( ...
[ "def", "retry_failed_logs_action", "(", "self", ",", "request", ",", "queryset", ")", ":", "count", "=", "0", "for", "trigger_log", "in", "queryset", ":", "retried", "=", "_retry_failed_log", "(", "trigger_log", ")", "if", "retried", ":", "count", "+=", "1",...
Try to re-apply FAILED trigger log actions in the queryset.
[ "Try", "to", "re", "-", "apply", "FAILED", "trigger", "log", "actions", "in", "the", "queryset", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/admin.py#L165-L175
train
Try to re - apply FAILED trigger log actions in the queryset.
glormph/msstitch
src/app/actions/mslookup/psms.py
create_psm_lookup
def create_psm_lookup(fn, fastafn, mapfn, header, pgdb, unroll=False, specfncol=None, decoy=False, fastadelim=None, genefield=None): """Reads PSMs from file, stores them to a database backend in chunked PSMs. """ proteins = store_proteins_descriptions(pgdb, fastaf...
python
def create_psm_lookup(fn, fastafn, mapfn, header, pgdb, unroll=False, specfncol=None, decoy=False, fastadelim=None, genefield=None): """Reads PSMs from file, stores them to a database backend in chunked PSMs. """ proteins = store_proteins_descriptions(pgdb, fastaf...
[ "def", "create_psm_lookup", "(", "fn", ",", "fastafn", ",", "mapfn", ",", "header", ",", "pgdb", ",", "unroll", "=", "False", ",", "specfncol", "=", "None", ",", "decoy", "=", "False", ",", "fastadelim", "=", "None", ",", "genefield", "=", "None", ")",...
Reads PSMs from file, stores them to a database backend in chunked PSMs.
[ "Reads", "PSMs", "from", "file", "stores", "them", "to", "a", "database", "backend", "in", "chunked", "PSMs", "." ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mslookup/psms.py#L9-L40
train
Reads PSMs from file stores them to a database backend in chunked PSMs.
glormph/msstitch
src/app/actions/mslookup/psms.py
store_psm_protein_relations
def store_psm_protein_relations(fn, header, pgdb, proteins): """Reads PSMs from file, extracts their proteins and peptides and passes them to a database backend in chunks. """ # TODO do we need an OrderedDict or is regular dict enough? # Sorting for psm_id useful? allpsms = OrderedDict() las...
python
def store_psm_protein_relations(fn, header, pgdb, proteins): """Reads PSMs from file, extracts their proteins and peptides and passes them to a database backend in chunks. """ # TODO do we need an OrderedDict or is regular dict enough? # Sorting for psm_id useful? allpsms = OrderedDict() las...
[ "def", "store_psm_protein_relations", "(", "fn", ",", "header", ",", "pgdb", ",", "proteins", ")", ":", "# TODO do we need an OrderedDict or is regular dict enough?", "# Sorting for psm_id useful?", "allpsms", "=", "OrderedDict", "(", ")", "last_id", ",", "psmids_to_store",...
Reads PSMs from file, extracts their proteins and peptides and passes them to a database backend in chunks.
[ "Reads", "PSMs", "from", "file", "extracts", "their", "proteins", "and", "peptides", "and", "passes", "them", "to", "a", "database", "backend", "in", "chunks", "." ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mslookup/psms.py#L92-L120
train
Reads PSMs from file extracts their proteins and peptides and passes them to a database backend in chunks.
EnigmaBridge/jbossply
jbossply/main.py
main
def main(): """ Reads stdin jboss output, writes json on output :return: """ buff = '' for line in fileinput.input(): buff += line parser = jbossparser.JbossParser() result = parser.parse(buff) print(json.dumps(result))
python
def main(): """ Reads stdin jboss output, writes json on output :return: """ buff = '' for line in fileinput.input(): buff += line parser = jbossparser.JbossParser() result = parser.parse(buff) print(json.dumps(result))
[ "def", "main", "(", ")", ":", "buff", "=", "''", "for", "line", "in", "fileinput", ".", "input", "(", ")", ":", "buff", "+=", "line", "parser", "=", "jbossparser", ".", "JbossParser", "(", ")", "result", "=", "parser", ".", "parse", "(", "buff", ")...
Reads stdin jboss output, writes json on output :return:
[ "Reads", "stdin", "jboss", "output", "writes", "json", "on", "output", ":", "return", ":" ]
44b30b15982cae781f0c356fab7263751b20b4d0
https://github.com/EnigmaBridge/jbossply/blob/44b30b15982cae781f0c356fab7263751b20b4d0/jbossply/main.py#L12-L23
train
Reads stdin jboss output writes json on output
Erotemic/utool
utool/util_decor.py
on_exception_report_input
def on_exception_report_input(func_=None, force=False, keys=None): """ If an error is thrown in the scope of this function's stack frame then the decorated function name and the arguments passed to it will be printed to the utool print function. """ def _closure_onexceptreport(func): if ...
python
def on_exception_report_input(func_=None, force=False, keys=None): """ If an error is thrown in the scope of this function's stack frame then the decorated function name and the arguments passed to it will be printed to the utool print function. """ def _closure_onexceptreport(func): if ...
[ "def", "on_exception_report_input", "(", "func_", "=", "None", ",", "force", "=", "False", ",", "keys", "=", "None", ")", ":", "def", "_closure_onexceptreport", "(", "func", ")", ":", "if", "not", "ONEX_REPORT_INPUT", "and", "not", "force", ":", "return", ...
If an error is thrown in the scope of this function's stack frame then the decorated function name and the arguments passed to it will be printed to the utool print function.
[ "If", "an", "error", "is", "thrown", "in", "the", "scope", "of", "this", "function", "s", "stack", "frame", "then", "the", "decorated", "function", "name", "and", "the", "arguments", "passed", "to", "it", "will", "be", "printed", "to", "the", "utool", "p...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L211-L270
train
This is a wrapper function that wraps a function and prints out the input of the function.
Erotemic/utool
utool/util_decor.py
_indent_decor
def _indent_decor(lbl): """ does the actual work of indent_func """ def closure_indent(func): if util_arg.TRACE: @ignores_exc_tb(outer_wrapper=False) #@wraps(func) def wrp_indent(*args, **kwargs): with util_print.Indenter(lbl): ...
python
def _indent_decor(lbl): """ does the actual work of indent_func """ def closure_indent(func): if util_arg.TRACE: @ignores_exc_tb(outer_wrapper=False) #@wraps(func) def wrp_indent(*args, **kwargs): with util_print.Indenter(lbl): ...
[ "def", "_indent_decor", "(", "lbl", ")", ":", "def", "closure_indent", "(", "func", ")", ":", "if", "util_arg", ".", "TRACE", ":", "@", "ignores_exc_tb", "(", "outer_wrapper", "=", "False", ")", "#@wraps(func)", "def", "wrp_indent", "(", "*", "args", ",", ...
does the actual work of indent_func
[ "does", "the", "actual", "work", "of", "indent_func" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L305-L329
train
Decorator that returns a function that indents the given function.
Erotemic/utool
utool/util_decor.py
indent_func
def indent_func(input_): """ Takes either no arguments or an alias label """ if isinstance(input_, six.string_types): # A label was specified lbl = input_ return _indent_decor(lbl) elif isinstance(input_, (bool, tuple)): # Allow individually turning of of this decorat...
python
def indent_func(input_): """ Takes either no arguments or an alias label """ if isinstance(input_, six.string_types): # A label was specified lbl = input_ return _indent_decor(lbl) elif isinstance(input_, (bool, tuple)): # Allow individually turning of of this decorat...
[ "def", "indent_func", "(", "input_", ")", ":", "if", "isinstance", "(", "input_", ",", "six", ".", "string_types", ")", ":", "# A label was specified", "lbl", "=", "input_", "return", "_indent_decor", "(", "lbl", ")", "elif", "isinstance", "(", "input_", ","...
Takes either no arguments or an alias label
[ "Takes", "either", "no", "arguments", "or", "an", "alias", "label" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L332-L348
train
Indent a function in the tree tree.
Erotemic/utool
utool/util_decor.py
tracefunc_xml
def tracefunc_xml(func): """ Causes output of function to be printed in an XML style block """ funcname = meta_util_six.get_funcname(func) def wrp_tracefunc2(*args, **kwargs): verbose = kwargs.get('verbose', True) if verbose: print('<%s>' % (funcname,)) with util_...
python
def tracefunc_xml(func): """ Causes output of function to be printed in an XML style block """ funcname = meta_util_six.get_funcname(func) def wrp_tracefunc2(*args, **kwargs): verbose = kwargs.get('verbose', True) if verbose: print('<%s>' % (funcname,)) with util_...
[ "def", "tracefunc_xml", "(", "func", ")", ":", "funcname", "=", "meta_util_six", ".", "get_funcname", "(", "func", ")", "def", "wrp_tracefunc2", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "verbose", "=", "kwargs", ".", "get", "(", "'verbose'", ...
Causes output of function to be printed in an XML style block
[ "Causes", "output", "of", "function", "to", "be", "printed", "in", "an", "XML", "style", "block" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L351-L367
train
Trace a function in an XML style block.
Erotemic/utool
utool/util_decor.py
accepts_scalar_input
def accepts_scalar_input(func): """ DEPRICATE in favor of accepts_scalar_input2 only accepts one input as vector accepts_scalar_input is a decorator which expects to be used on class methods. It lets the user pass either a vector or a scalar to a function, as long as the function treats everyt...
python
def accepts_scalar_input(func): """ DEPRICATE in favor of accepts_scalar_input2 only accepts one input as vector accepts_scalar_input is a decorator which expects to be used on class methods. It lets the user pass either a vector or a scalar to a function, as long as the function treats everyt...
[ "def", "accepts_scalar_input", "(", "func", ")", ":", "#@on_exception_report_input", "@", "ignores_exc_tb", "(", "outer_wrapper", "=", "False", ")", "#@wraps(func)", "def", "wrp_asi", "(", "self", ",", "input_", ",", "*", "args", ",", "*", "*", "kwargs", ")", ...
DEPRICATE in favor of accepts_scalar_input2 only accepts one input as vector accepts_scalar_input is a decorator which expects to be used on class methods. It lets the user pass either a vector or a scalar to a function, as long as the function treats everything like a vector. Input and output is ...
[ "DEPRICATE", "in", "favor", "of", "accepts_scalar_input2", "only", "accepts", "one", "input", "as", "vector" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L372-L418
train
Decorator for classical entry point accepts_scalar_input2
Erotemic/utool
utool/util_decor.py
accepts_scalar_input2
def accepts_scalar_input2(argx_list=[0], outer_wrapper=True): r""" FIXME: change to better name. Complete implementation. used in IBEIS setters accepts_scalar_input2 is a decorator which expects to be used on class methods. It lets the user pass either a vector or a scalar to a function, as l...
python
def accepts_scalar_input2(argx_list=[0], outer_wrapper=True): r""" FIXME: change to better name. Complete implementation. used in IBEIS setters accepts_scalar_input2 is a decorator which expects to be used on class methods. It lets the user pass either a vector or a scalar to a function, as l...
[ "def", "accepts_scalar_input2", "(", "argx_list", "=", "[", "0", "]", ",", "outer_wrapper", "=", "True", ")", ":", "assert", "isinstance", "(", "argx_list", ",", "(", "list", ",", "tuple", ")", ")", ",", "(", "'accepts_scalar_input2 must be called with argument ...
r""" FIXME: change to better name. Complete implementation. used in IBEIS setters accepts_scalar_input2 is a decorator which expects to be used on class methods. It lets the user pass either a vector or a scalar to a function, as long as the function treats everything like a vector. Input and out...
[ "r", "FIXME", ":", "change", "to", "better", "name", ".", "Complete", "implementation", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L421-L460
train
r Decorator for classical accepts_scalar_input2.
Erotemic/utool
utool/util_decor.py
__assert_param_consistency
def __assert_param_consistency(args, argx_list_): """ debugging function for accepts_scalar_input2 checks to make sure all the iterable inputs are of the same length """ if util_arg.NO_ASSERTS: return if len(argx_list_) == 0: return True argx_flags = [util_iter.isiterable(arg...
python
def __assert_param_consistency(args, argx_list_): """ debugging function for accepts_scalar_input2 checks to make sure all the iterable inputs are of the same length """ if util_arg.NO_ASSERTS: return if len(argx_list_) == 0: return True argx_flags = [util_iter.isiterable(arg...
[ "def", "__assert_param_consistency", "(", "args", ",", "argx_list_", ")", ":", "if", "util_arg", ".", "NO_ASSERTS", ":", "return", "if", "len", "(", "argx_list_", ")", "==", "0", ":", "return", "True", "argx_flags", "=", "[", "util_iter", ".", "isiterable", ...
debugging function for accepts_scalar_input2 checks to make sure all the iterable inputs are of the same length
[ "debugging", "function", "for", "accepts_scalar_input2", "checks", "to", "make", "sure", "all", "the", "iterable", "inputs", "are", "of", "the", "same", "length" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L463-L480
train
debugging function for accepts_scalar_input2 checks to make sure all the iterable inputs are of the same length
Erotemic/utool
utool/util_decor.py
accepts_scalar_input_vector_output
def accepts_scalar_input_vector_output(func): """ DEPRICATE IN FAVOR OF accepts_scalar_input2 accepts_scalar_input_vector_output Notes: Input: Excpeted Output 1to1 Expected Output 1toM scalar : 1 x [X] n...
python
def accepts_scalar_input_vector_output(func): """ DEPRICATE IN FAVOR OF accepts_scalar_input2 accepts_scalar_input_vector_output Notes: Input: Excpeted Output 1to1 Expected Output 1toM scalar : 1 x [X] n...
[ "def", "accepts_scalar_input_vector_output", "(", "func", ")", ":", "@", "ignores_exc_tb", "(", "outer_wrapper", "=", "False", ")", "#@wraps(func)", "def", "wrp_asivo", "(", "self", ",", "input_", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "#import...
DEPRICATE IN FAVOR OF accepts_scalar_input2 accepts_scalar_input_vector_output Notes: Input: Excpeted Output 1to1 Expected Output 1toM scalar : 1 x [X] n element list : [1, 2, 3] [x, y, z] [[X], [...
[ "DEPRICATE", "IN", "FAVOR", "OF", "accepts_scalar_input2" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L483-L521
train
A wrapper for the function that accepts_scalar_input2
Erotemic/utool
utool/util_decor.py
accepts_numpy
def accepts_numpy(func): """ Allows the first input to be a numpy array and get result in numpy form """ #@ignores_exc_tb #@wraps(func) def wrp_accepts_numpy(self, input_, *args, **kwargs): if not (util_type.HAVE_NUMPY and isinstance(input_, np.ndarray)): # If the input is not numpy,...
python
def accepts_numpy(func): """ Allows the first input to be a numpy array and get result in numpy form """ #@ignores_exc_tb #@wraps(func) def wrp_accepts_numpy(self, input_, *args, **kwargs): if not (util_type.HAVE_NUMPY and isinstance(input_, np.ndarray)): # If the input is not numpy,...
[ "def", "accepts_numpy", "(", "func", ")", ":", "#@ignores_exc_tb", "#@wraps(func)", "def", "wrp_accepts_numpy", "(", "self", ",", "input_", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "(", "util_type", ".", "HAVE_NUMPY", "and", "isins...
Allows the first input to be a numpy array and get result in numpy form
[ "Allows", "the", "first", "input", "to", "be", "a", "numpy", "array", "and", "get", "result", "in", "numpy", "form" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L529-L559
train
Allows the first input to be a numpy array and get result in numpy form
Erotemic/utool
utool/util_decor.py
memoize_nonzero
def memoize_nonzero(func): """ Memoization decorator for functions taking a nonzero number of arguments. References: http://code.activestate.com/recipes/578231-fastest-memoization-decorator """ class _memorizer(dict): def __init__(self, func): self.func = func de...
python
def memoize_nonzero(func): """ Memoization decorator for functions taking a nonzero number of arguments. References: http://code.activestate.com/recipes/578231-fastest-memoization-decorator """ class _memorizer(dict): def __init__(self, func): self.func = func de...
[ "def", "memoize_nonzero", "(", "func", ")", ":", "class", "_memorizer", "(", "dict", ")", ":", "def", "__init__", "(", "self", ",", "func", ")", ":", "self", ".", "func", "=", "func", "def", "__call__", "(", "self", ",", "*", "args", ")", ":", "ret...
Memoization decorator for functions taking a nonzero number of arguments. References: http://code.activestate.com/recipes/578231-fastest-memoization-decorator
[ "Memoization", "decorator", "for", "functions", "taking", "a", "nonzero", "number", "of", "arguments", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L562-L577
train
Memoization decorator for functions taking a nonzero number of arguments.
Erotemic/utool
utool/util_decor.py
memoize_single
def memoize_single(func): """ Memoization decorator for a function taking a single argument References: http://code.activestate.com/recipes/578231-fastest-memoization-decorator """ class memodict_single(dict): def __missing__(self, key): ret = self[key] = func(key) ...
python
def memoize_single(func): """ Memoization decorator for a function taking a single argument References: http://code.activestate.com/recipes/578231-fastest-memoization-decorator """ class memodict_single(dict): def __missing__(self, key): ret = self[key] = func(key) ...
[ "def", "memoize_single", "(", "func", ")", ":", "class", "memodict_single", "(", "dict", ")", ":", "def", "__missing__", "(", "self", ",", "key", ")", ":", "ret", "=", "self", "[", "key", "]", "=", "func", "(", "key", ")", "return", "ret", "return", ...
Memoization decorator for a function taking a single argument References: http://code.activestate.com/recipes/578231-fastest-memoization-decorator
[ "Memoization", "decorator", "for", "a", "function", "taking", "a", "single", "argument" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L580-L590
train
Memoization decorator for a function taking a single argument.
Erotemic/utool
utool/util_decor.py
memoize
def memoize(func): """ simple memoization decorator References: https://wiki.python.org/moin/PythonDecoratorLibrary#Memoize Args: func (function): live python function Returns: func: CommandLine: python -m utool.util_decor memoize Example: >>> # ...
python
def memoize(func): """ simple memoization decorator References: https://wiki.python.org/moin/PythonDecoratorLibrary#Memoize Args: func (function): live python function Returns: func: CommandLine: python -m utool.util_decor memoize Example: >>> # ...
[ "def", "memoize", "(", "func", ")", ":", "cache", "=", "func", ".", "_util_decor_memoize_cache", "=", "{", "}", "# @functools.wraps(func)", "def", "memoizer", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "key", "=", "str", "(", "args", ")", "+"...
simple memoization decorator References: https://wiki.python.org/moin/PythonDecoratorLibrary#Memoize Args: func (function): live python function Returns: func: CommandLine: python -m utool.util_decor memoize Example: >>> # ENABLE_DOCTEST >>> from...
[ "simple", "memoization", "decorator" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L601-L651
train
A decorator that memoizes a live python function
Erotemic/utool
utool/util_decor.py
lazyfunc
def lazyfunc(func): """ Returns a memcached version of a function """ closuremem_ = [{}] def wrapper(*args, **kwargs): mem = closuremem_[0] key = (repr(args), repr(kwargs)) try: return mem[key] except KeyError: mem[key] = func(*args, **kwargs) ...
python
def lazyfunc(func): """ Returns a memcached version of a function """ closuremem_ = [{}] def wrapper(*args, **kwargs): mem = closuremem_[0] key = (repr(args), repr(kwargs)) try: return mem[key] except KeyError: mem[key] = func(*args, **kwargs) ...
[ "def", "lazyfunc", "(", "func", ")", ":", "closuremem_", "=", "[", "{", "}", "]", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "mem", "=", "closuremem_", "[", "0", "]", "key", "=", "(", "repr", "(", "args", ")", ",", ...
Returns a memcached version of a function
[ "Returns", "a", "memcached", "version", "of", "a", "function" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L752-L765
train
Returns a memcached version of a function
Erotemic/utool
utool/util_decor.py
apply_docstr
def apply_docstr(docstr_func): """ Changes docstr of one functio to that of another """ def docstr_applier(func): #docstr = meta_util_six.get_funcdoc(docstr_func) #meta_util_six.set_funcdoc(func, docstr) if isinstance(docstr_func, six.string_types): olddoc = meta_util...
python
def apply_docstr(docstr_func): """ Changes docstr of one functio to that of another """ def docstr_applier(func): #docstr = meta_util_six.get_funcdoc(docstr_func) #meta_util_six.set_funcdoc(func, docstr) if isinstance(docstr_func, six.string_types): olddoc = meta_util...
[ "def", "apply_docstr", "(", "docstr_func", ")", ":", "def", "docstr_applier", "(", "func", ")", ":", "#docstr = meta_util_six.get_funcdoc(docstr_func)", "#meta_util_six.set_funcdoc(func, docstr)", "if", "isinstance", "(", "docstr_func", ",", "six", ".", "string_types", ")...
Changes docstr of one functio to that of another
[ "Changes", "docstr", "of", "one", "functio", "to", "that", "of", "another" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L768-L785
train
Returns a function that applies a docstr to the current functio.
Erotemic/utool
utool/util_decor.py
preserve_sig
def preserve_sig(wrapper, orig_func, force=False): """ Decorates a wrapper function. It seems impossible to presever signatures in python 2 without eval (Maybe another option is to write to a temporary module?) Args: wrapper: the function wrapping orig_func to change the signature of ...
python
def preserve_sig(wrapper, orig_func, force=False): """ Decorates a wrapper function. It seems impossible to presever signatures in python 2 without eval (Maybe another option is to write to a temporary module?) Args: wrapper: the function wrapping orig_func to change the signature of ...
[ "def", "preserve_sig", "(", "wrapper", ",", "orig_func", ",", "force", "=", "False", ")", ":", "#if True:", "# import functools", "# return functools.wraps(orig_func)(wrapper)", "from", "utool", ".", "_internal", "import", "meta_util_six", "from", "utool", "import...
Decorates a wrapper function. It seems impossible to presever signatures in python 2 without eval (Maybe another option is to write to a temporary module?) Args: wrapper: the function wrapping orig_func to change the signature of orig_func: the original function to take the signature from ...
[ "Decorates", "a", "wrapper", "function", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_decor.py#L788-L935
train
Decorator to preserve the signature of a function in python 2
kurtbrose/faststat
faststat/faststat.py
_sigfigs
def _sigfigs(n, sigfigs=3): 'helper function to round a number to significant figures' n = float(n) if n == 0 or math.isnan(n): # avoid math domain errors return n return round(n, -int(math.floor(math.log10(abs(n))) - sigfigs + 1))
python
def _sigfigs(n, sigfigs=3): 'helper function to round a number to significant figures' n = float(n) if n == 0 or math.isnan(n): # avoid math domain errors return n return round(n, -int(math.floor(math.log10(abs(n))) - sigfigs + 1))
[ "def", "_sigfigs", "(", "n", ",", "sigfigs", "=", "3", ")", ":", "n", "=", "float", "(", "n", ")", "if", "n", "==", "0", "or", "math", ".", "isnan", "(", "n", ")", ":", "# avoid math domain errors\r", "return", "n", "return", "round", "(", "n", "...
helper function to round a number to significant figures
[ "helper", "function", "to", "round", "a", "number", "to", "significant", "figures" ]
5060c0e10acaafd4a48de3f16869bfccc1deb44a
https://github.com/kurtbrose/faststat/blob/5060c0e10acaafd4a48de3f16869bfccc1deb44a/faststat/faststat.py#L408-L413
train
helper function to round a number to significant figures
kurtbrose/faststat
faststat/faststat.py
merge_moments
def merge_moments(m_a, m_a2, m_a3, m_a4, n_a, m_b, m_b2, m_b3, m_b4, n_b): ''' Merge moments of two samples A and B. parameters are m_a, ..., m_a4 = first through fourth moment of sample A n_a = size of sample A m_b, ..., m_b4 = first through fourth moment of sample B n_b = size of s...
python
def merge_moments(m_a, m_a2, m_a3, m_a4, n_a, m_b, m_b2, m_b3, m_b4, n_b): ''' Merge moments of two samples A and B. parameters are m_a, ..., m_a4 = first through fourth moment of sample A n_a = size of sample A m_b, ..., m_b4 = first through fourth moment of sample B n_b = size of s...
[ "def", "merge_moments", "(", "m_a", ",", "m_a2", ",", "m_a3", ",", "m_a4", ",", "n_a", ",", "m_b", ",", "m_b2", ",", "m_b3", ",", "m_b4", ",", "n_b", ")", ":", "delta", "=", "m_b", "-", "m_a", "delta_2", "=", "delta", "*", "delta", "delta_3", "="...
Merge moments of two samples A and B. parameters are m_a, ..., m_a4 = first through fourth moment of sample A n_a = size of sample A m_b, ..., m_b4 = first through fourth moment of sample B n_b = size of sample B
[ "Merge", "moments", "of", "two", "samples", "A", "and", "B", ".", "parameters", "are", "m_a", "...", "m_a4", "=", "first", "through", "fourth", "moment", "of", "sample", "A", "n_a", "=", "size", "of", "sample", "A", "m_b", "...", "m_b4", "=", "first", ...
5060c0e10acaafd4a48de3f16869bfccc1deb44a
https://github.com/kurtbrose/faststat/blob/5060c0e10acaafd4a48de3f16869bfccc1deb44a/faststat/faststat.py#L416-L436
train
Merge moments of two samples A and B.
kurtbrose/faststat
faststat/faststat.py
_BaseStats.lag_avgs
def lag_avgs(self): ''' same data as expo_avgs, but with keys as the average age of the data -- assuming evenly spaced data points -- rather than decay rates ''' if not self.interval: return interval = self.interval.mean return dict([(...
python
def lag_avgs(self): ''' same data as expo_avgs, but with keys as the average age of the data -- assuming evenly spaced data points -- rather than decay rates ''' if not self.interval: return interval = self.interval.mean return dict([(...
[ "def", "lag_avgs", "(", "self", ")", ":", "if", "not", "self", ".", "interval", ":", "return", "interval", "=", "self", ".", "interval", ".", "mean", "return", "dict", "(", "[", "(", "interval", "/", "alpha", ",", "val", ")", "for", "alpha", ",", "...
same data as expo_avgs, but with keys as the average age of the data -- assuming evenly spaced data points -- rather than decay rates
[ "same", "data", "as", "expo_avgs", "but", "with", "keys", "as", "the", "average", "age", "of", "the", "data", "--", "assuming", "evenly", "spaced", "data", "points", "--", "rather", "than", "decay", "rates" ]
5060c0e10acaafd4a48de3f16869bfccc1deb44a
https://github.com/kurtbrose/faststat/blob/5060c0e10acaafd4a48de3f16869bfccc1deb44a/faststat/faststat.py#L133-L143
train
Returns a dictionary of the lagged expo avgs with the average age as the average age of the data points and the decay rates as the decay rates.
kurtbrose/faststat
faststat/faststat.py
Markov._transition
def _transition(self, nxt, cur=None, since=None): ''' Register that a transition has taken place. nxt is an identifier for the state being entered. cur is an identifier for the state being left. since is the time at which the previous state was entered. ''' ...
python
def _transition(self, nxt, cur=None, since=None): ''' Register that a transition has taken place. nxt is an identifier for the state being entered. cur is an identifier for the state being left. since is the time at which the previous state was entered. ''' ...
[ "def", "_transition", "(", "self", ",", "nxt", ",", "cur", "=", "None", ",", "since", "=", "None", ")", ":", "self", ".", "transition_intervals", "[", "(", "cur", ",", "nxt", ")", "]", ".", "tick", "(", ")", "if", "since", ":", "self", ".", "stat...
Register that a transition has taken place. nxt is an identifier for the state being entered. cur is an identifier for the state being left. since is the time at which the previous state was entered.
[ "Register", "that", "a", "transition", "has", "taken", "place", ".", "nxt", "is", "an", "identifier", "for", "the", "state", "being", "entered", ".", "cur", "is", "an", "identifier", "for", "the", "state", "being", "left", ".", "since", "is", "the", "tim...
5060c0e10acaafd4a48de3f16869bfccc1deb44a
https://github.com/kurtbrose/faststat/blob/5060c0e10acaafd4a48de3f16869bfccc1deb44a/faststat/faststat.py#L235-L244
train
Register that a transition has taken place.
kurtbrose/faststat
faststat/faststat.py
Markov._cleanup
def _cleanup(self, ref): 'cleanup after a transitor weakref fires' self.transitor_states[self._weakref_holder[ref]] -= 1 del self._weakref_holder[ref]
python
def _cleanup(self, ref): 'cleanup after a transitor weakref fires' self.transitor_states[self._weakref_holder[ref]] -= 1 del self._weakref_holder[ref]
[ "def", "_cleanup", "(", "self", ",", "ref", ")", ":", "self", ".", "transitor_states", "[", "self", ".", "_weakref_holder", "[", "ref", "]", "]", "-=", "1", "del", "self", ".", "_weakref_holder", "[", "ref", "]" ]
cleanup after a transitor weakref fires
[ "cleanup", "after", "a", "transitor", "weakref", "fires" ]
5060c0e10acaafd4a48de3f16869bfccc1deb44a
https://github.com/kurtbrose/faststat/blob/5060c0e10acaafd4a48de3f16869bfccc1deb44a/faststat/faststat.py#L252-L255
train
cleanup after a transitor weakref fires
kurtbrose/faststat
faststat/faststat.py
PathStats._commit
def _commit(self, ref): 'commit a walkers data after it is collected' path_times = self._weakref_path_map[ref] path_times.append(nanotime()) del self._weakref_path_map[ref] path = tuple(path_times[1::2]) times = path_times[::2] if path not in self.path_stat...
python
def _commit(self, ref): 'commit a walkers data after it is collected' path_times = self._weakref_path_map[ref] path_times.append(nanotime()) del self._weakref_path_map[ref] path = tuple(path_times[1::2]) times = path_times[::2] if path not in self.path_stat...
[ "def", "_commit", "(", "self", ",", "ref", ")", ":", "path_times", "=", "self", ".", "_weakref_path_map", "[", "ref", "]", "path_times", ".", "append", "(", "nanotime", "(", ")", ")", "del", "self", ".", "_weakref_path_map", "[", "ref", "]", "path", "=...
commit a walkers data after it is collected
[ "commit", "a", "walkers", "data", "after", "it", "is", "collected" ]
5060c0e10acaafd4a48de3f16869bfccc1deb44a
https://github.com/kurtbrose/faststat/blob/5060c0e10acaafd4a48de3f16869bfccc1deb44a/faststat/faststat.py#L310-L323
train
commit a walkers data after it is collected
kurtbrose/faststat
faststat/faststat.py
PathStats.pformat
def pformat(self, prefix=()): ''' Makes a pretty ASCII format of the data, suitable for displaying in a console or saving to a text file. Returns a list of lines. ''' nan = float("nan") def sformat(segment, stat): FMT = "n={0}, mean={1}, p50/...
python
def pformat(self, prefix=()): ''' Makes a pretty ASCII format of the data, suitable for displaying in a console or saving to a text file. Returns a list of lines. ''' nan = float("nan") def sformat(segment, stat): FMT = "n={0}, mean={1}, p50/...
[ "def", "pformat", "(", "self", ",", "prefix", "=", "(", ")", ")", ":", "nan", "=", "float", "(", "\"nan\"", ")", "def", "sformat", "(", "segment", ",", "stat", ")", ":", "FMT", "=", "\"n={0}, mean={1}, p50/95={2}/{3}, max={4}\"", "line_segs", "=", "[", "...
Makes a pretty ASCII format of the data, suitable for displaying in a console or saving to a text file. Returns a list of lines.
[ "Makes", "a", "pretty", "ASCII", "format", "of", "the", "data", "suitable", "for", "displaying", "in", "a", "console", "or", "saving", "to", "a", "text", "file", ".", "Returns", "a", "list", "of", "lines", "." ]
5060c0e10acaafd4a48de3f16869bfccc1deb44a
https://github.com/kurtbrose/faststat/blob/5060c0e10acaafd4a48de3f16869bfccc1deb44a/faststat/faststat.py#L325-L347
train
Returns a list of lines suitable for printing to a text file.
neithere/monk
monk/helpers.py
walk_dict
def walk_dict(data): """ Generates pairs ``(keys, value)`` for each item in given dictionary, including nested dictionaries. Each pair contains: `keys` a tuple of 1..n keys, e.g. ``('foo',)`` for a key on root level or ``('foo', 'bar')`` for a key in a nested dictionary. `value` ...
python
def walk_dict(data): """ Generates pairs ``(keys, value)`` for each item in given dictionary, including nested dictionaries. Each pair contains: `keys` a tuple of 1..n keys, e.g. ``('foo',)`` for a key on root level or ``('foo', 'bar')`` for a key in a nested dictionary. `value` ...
[ "def", "walk_dict", "(", "data", ")", ":", "assert", "hasattr", "(", "data", ",", "'__getitem__'", ")", "for", "key", ",", "value", "in", "data", ".", "items", "(", ")", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "yield", "(", "k...
Generates pairs ``(keys, value)`` for each item in given dictionary, including nested dictionaries. Each pair contains: `keys` a tuple of 1..n keys, e.g. ``('foo',)`` for a key on root level or ``('foo', 'bar')`` for a key in a nested dictionary. `value` the value of given key or ``...
[ "Generates", "pairs", "(", "keys", "value", ")", "for", "each", "item", "in", "given", "dictionary", "including", "nested", "dictionaries", ".", "Each", "pair", "contains", ":" ]
4b2ee5152b081ac288ce8568422a027b5e7d2b1c
https://github.com/neithere/monk/blob/4b2ee5152b081ac288ce8568422a027b5e7d2b1c/monk/helpers.py#L70-L89
train
Recursively walks a dictionary and yields pairs of keys value.
chibisov/cli-bdd
tasks.py
deploy_docs
def deploy_docs(): """ Based on https://gist.github.com/domenic/ec8b0fc8ab45f39403dd """ run('rm -rf ./site/') build_docs() with util.cd('./site/'): run('git init') run('echo ".*pyc" > .gitignore') run('git config user.name "Travis CI"') run('git config user.email...
python
def deploy_docs(): """ Based on https://gist.github.com/domenic/ec8b0fc8ab45f39403dd """ run('rm -rf ./site/') build_docs() with util.cd('./site/'): run('git init') run('echo ".*pyc" > .gitignore') run('git config user.name "Travis CI"') run('git config user.email...
[ "def", "deploy_docs", "(", ")", ":", "run", "(", "'rm -rf ./site/'", ")", "build_docs", "(", ")", "with", "util", ".", "cd", "(", "'./site/'", ")", ":", "run", "(", "'git init'", ")", "run", "(", "'echo \".*pyc\" > .gitignore'", ")", "run", "(", "'git conf...
Based on https://gist.github.com/domenic/ec8b0fc8ab45f39403dd
[ "Based", "on", "https", ":", "//", "gist", ".", "github", ".", "com", "/", "domenic", "/", "ec8b0fc8ab45f39403dd" ]
579e2d9a07f9985b268aa9aaba42dee33021e163
https://github.com/chibisov/cli-bdd/blob/579e2d9a07f9985b268aa9aaba42dee33021e163/tasks.py#L8-L27
train
Deploy the docs to GitHub Pages
glormph/msstitch
src/app/readers/openms.py
specfn_quant_generator
def specfn_quant_generator(specfiles, quantfiles, tag, ignore_tags): """Generates tuples of specfile and quant element for general formats""" for specfn, qfn in zip(specfiles, quantfiles): for quant_el in basereader.generate_xmltags(qfn, tag, ignore_tags): yield os.path.basename(specfn), qua...
python
def specfn_quant_generator(specfiles, quantfiles, tag, ignore_tags): """Generates tuples of specfile and quant element for general formats""" for specfn, qfn in zip(specfiles, quantfiles): for quant_el in basereader.generate_xmltags(qfn, tag, ignore_tags): yield os.path.basename(specfn), qua...
[ "def", "specfn_quant_generator", "(", "specfiles", ",", "quantfiles", ",", "tag", ",", "ignore_tags", ")", ":", "for", "specfn", ",", "qfn", "in", "zip", "(", "specfiles", ",", "quantfiles", ")", ":", "for", "quant_el", "in", "basereader", ".", "generate_xml...
Generates tuples of specfile and quant element for general formats
[ "Generates", "tuples", "of", "specfile", "and", "quant", "element", "for", "general", "formats" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/readers/openms.py#L5-L9
train
Generates tuples of specfile and quant element for general formats
glormph/msstitch
src/app/readers/openms.py
get_feature_info
def get_feature_info(feature): """Returns a dict with feature information""" dimensions = feature.findall('position') for dim in dimensions: if dim.attrib['dim'] == '0': rt = dim.text elif dim.attrib['dim'] == '1': mz = dim.text return {'rt': float(rt), 'mz': floa...
python
def get_feature_info(feature): """Returns a dict with feature information""" dimensions = feature.findall('position') for dim in dimensions: if dim.attrib['dim'] == '0': rt = dim.text elif dim.attrib['dim'] == '1': mz = dim.text return {'rt': float(rt), 'mz': floa...
[ "def", "get_feature_info", "(", "feature", ")", ":", "dimensions", "=", "feature", ".", "findall", "(", "'position'", ")", "for", "dim", "in", "dimensions", ":", "if", "dim", ".", "attrib", "[", "'dim'", "]", "==", "'0'", ":", "rt", "=", "dim", ".", ...
Returns a dict with feature information
[ "Returns", "a", "dict", "with", "feature", "information" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/readers/openms.py#L31-L42
train
Returns a dict with feature information
glormph/msstitch
src/app/readers/openms.py
get_quantmap
def get_quantmap(consfile): """Returns map of isobaric quant channel names as keys, channel numbers values from consensus XML. E.g. {'113': '0', '114': '1',} """ quantmap = {} maplist = basereader.get_element(consfile, 'mapList') for mapitem in maplist: quantmap[mapitem.att...
python
def get_quantmap(consfile): """Returns map of isobaric quant channel names as keys, channel numbers values from consensus XML. E.g. {'113': '0', '114': '1',} """ quantmap = {} maplist = basereader.get_element(consfile, 'mapList') for mapitem in maplist: quantmap[mapitem.att...
[ "def", "get_quantmap", "(", "consfile", ")", ":", "quantmap", "=", "{", "}", "maplist", "=", "basereader", ".", "get_element", "(", "consfile", ",", "'mapList'", ")", "for", "mapitem", "in", "maplist", ":", "quantmap", "[", "mapitem", ".", "attrib", "[", ...
Returns map of isobaric quant channel names as keys, channel numbers values from consensus XML. E.g. {'113': '0', '114': '1',}
[ "Returns", "map", "of", "isobaric", "quant", "channel", "names", "as", "keys", "channel", "numbers", "values", "from", "consensus", "XML", ".", "E", ".", "g", ".", "{", "113", ":", "0", "114", ":", "1", "}" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/readers/openms.py#L45-L55
train
Returns a dictionary of isobaric quant channel names as keys channel numbers values from consensus XML.
quikmile/trellio
trellio/host.py
Host.configure
def configure(cls, host_name: str = '', service_name: str = '', service_version='', http_host: str = '127.0.0.1', http_port: int = 8000, tcp_host: str = '127.0.0.1', tcp_port: int = 8001, ssl_context=None, registry_host: str = "0.0.0.0", registry_port: int = 4500, ...
python
def configure(cls, host_name: str = '', service_name: str = '', service_version='', http_host: str = '127.0.0.1', http_port: int = 8000, tcp_host: str = '127.0.0.1', tcp_port: int = 8001, ssl_context=None, registry_host: str = "0.0.0.0", registry_port: int = 4500, ...
[ "def", "configure", "(", "cls", ",", "host_name", ":", "str", "=", "''", ",", "service_name", ":", "str", "=", "''", ",", "service_version", "=", "''", ",", "http_host", ":", "str", "=", "'127.0.0.1'", ",", "http_port", ":", "int", "=", "8000", ",", ...
A convenience method for providing registry and pubsub(redis) endpoints :param host_name: Used for process name :param registry_host: IP Address for trellio-registry; default = 0.0.0.0 :param registry_port: Port for trellio-registry; default = 4500 :param pubsub_host: IP Address for pub...
[ "A", "convenience", "method", "for", "providing", "registry", "and", "pubsub", "(", "redis", ")", "endpoints" ]
e8b050077562acf32805fcbb9c0c162248a23c62
https://github.com/quikmile/trellio/blob/e8b050077562acf32805fcbb9c0c162248a23c62/trellio/host.py#L55-L81
train
Configure the trellio - registry and pubsub endpoints.
quikmile/trellio
trellio/host.py
Host.attach_service
def attach_service(cls, service): """ Allows you to attach one TCP and one HTTP service deprecated:: 2.1.73 use http and tcp specific methods :param service: A trellio TCP or HTTP service that needs to be hosted """ if isinstance(service, HTTPService): cls._http_serv...
python
def attach_service(cls, service): """ Allows you to attach one TCP and one HTTP service deprecated:: 2.1.73 use http and tcp specific methods :param service: A trellio TCP or HTTP service that needs to be hosted """ if isinstance(service, HTTPService): cls._http_serv...
[ "def", "attach_service", "(", "cls", ",", "service", ")", ":", "if", "isinstance", "(", "service", ",", "HTTPService", ")", ":", "cls", ".", "_http_service", "=", "service", "elif", "isinstance", "(", "service", ",", "TCPService", ")", ":", "cls", ".", "...
Allows you to attach one TCP and one HTTP service deprecated:: 2.1.73 use http and tcp specific methods :param service: A trellio TCP or HTTP service that needs to be hosted
[ "Allows", "you", "to", "attach", "one", "TCP", "and", "one", "HTTP", "service" ]
e8b050077562acf32805fcbb9c0c162248a23c62
https://github.com/quikmile/trellio/blob/e8b050077562acf32805fcbb9c0c162248a23c62/trellio/host.py#L115-L127
train
Allows you to attach one TCP or HTTP service to the current instance of this class.
quikmile/trellio
trellio/host.py
Host.attach_http_service
def attach_http_service(cls, http_service: HTTPService): """ Attaches a service for hosting :param http_service: A HTTPService instance """ if cls._http_service is None: cls._http_service = http_service cls._set_bus(http_service) else: warnings...
python
def attach_http_service(cls, http_service: HTTPService): """ Attaches a service for hosting :param http_service: A HTTPService instance """ if cls._http_service is None: cls._http_service = http_service cls._set_bus(http_service) else: warnings...
[ "def", "attach_http_service", "(", "cls", ",", "http_service", ":", "HTTPService", ")", ":", "if", "cls", ".", "_http_service", "is", "None", ":", "cls", ".", "_http_service", "=", "http_service", "cls", ".", "_set_bus", "(", "http_service", ")", "else", ":"...
Attaches a service for hosting :param http_service: A HTTPService instance
[ "Attaches", "a", "service", "for", "hosting", ":", "param", "http_service", ":", "A", "HTTPService", "instance" ]
e8b050077562acf32805fcbb9c0c162248a23c62
https://github.com/quikmile/trellio/blob/e8b050077562acf32805fcbb9c0c162248a23c62/trellio/host.py#L130-L138
train
Attaches a service for hosting to the class.
quikmile/trellio
trellio/host.py
Host.attach_tcp_service
def attach_tcp_service(cls, tcp_service: TCPService): """ Attaches a service for hosting :param tcp_service: A TCPService instance """ if cls._tcp_service is None: cls._tcp_service = tcp_service cls._set_bus(tcp_service) else: warnings.warn('TC...
python
def attach_tcp_service(cls, tcp_service: TCPService): """ Attaches a service for hosting :param tcp_service: A TCPService instance """ if cls._tcp_service is None: cls._tcp_service = tcp_service cls._set_bus(tcp_service) else: warnings.warn('TC...
[ "def", "attach_tcp_service", "(", "cls", ",", "tcp_service", ":", "TCPService", ")", ":", "if", "cls", ".", "_tcp_service", "is", "None", ":", "cls", ".", "_tcp_service", "=", "tcp_service", "cls", ".", "_set_bus", "(", "tcp_service", ")", "else", ":", "wa...
Attaches a service for hosting :param tcp_service: A TCPService instance
[ "Attaches", "a", "service", "for", "hosting", ":", "param", "tcp_service", ":", "A", "TCPService", "instance" ]
e8b050077562acf32805fcbb9c0c162248a23c62
https://github.com/quikmile/trellio/blob/e8b050077562acf32805fcbb9c0c162248a23c62/trellio/host.py#L141-L149
train
Attaches a service for hosting to the class.
quikmile/trellio
trellio/host.py
Host.run
def run(cls): """ Fires up the event loop and starts serving attached services """ if cls._tcp_service or cls._http_service or cls._http_views or cls._tcp_views: cls._set_host_id() cls._setup_logging() cls._set_process_name() cls._set_signal_handle...
python
def run(cls): """ Fires up the event loop and starts serving attached services """ if cls._tcp_service or cls._http_service or cls._http_views or cls._tcp_views: cls._set_host_id() cls._setup_logging() cls._set_process_name() cls._set_signal_handle...
[ "def", "run", "(", "cls", ")", ":", "if", "cls", ".", "_tcp_service", "or", "cls", ".", "_http_service", "or", "cls", ".", "_http_views", "or", "cls", ".", "_tcp_views", ":", "cls", ".", "_set_host_id", "(", ")", "cls", ".", "_setup_logging", "(", ")",...
Fires up the event loop and starts serving attached services
[ "Fires", "up", "the", "event", "loop", "and", "starts", "serving", "attached", "services" ]
e8b050077562acf32805fcbb9c0c162248a23c62
https://github.com/quikmile/trellio/blob/e8b050077562acf32805fcbb9c0c162248a23c62/trellio/host.py#L185-L196
train
Starts serving attached services and sets up logging and process name.
LEMS/pylems
lems/base/util.py
merge_maps
def merge_maps(m, base): """ Merge in undefined map entries from given map. @param m: Map to be merged into. @type m: lems.util.Map @param base: Map to be merged into. @type base: lems.util.Map """ for k in base.keys(): if k not in m: m[k] = base[k]
python
def merge_maps(m, base): """ Merge in undefined map entries from given map. @param m: Map to be merged into. @type m: lems.util.Map @param base: Map to be merged into. @type base: lems.util.Map """ for k in base.keys(): if k not in m: m[k] = base[k]
[ "def", "merge_maps", "(", "m", ",", "base", ")", ":", "for", "k", "in", "base", ".", "keys", "(", ")", ":", "if", "k", "not", "in", "m", ":", "m", "[", "k", "]", "=", "base", "[", "k", "]" ]
Merge in undefined map entries from given map. @param m: Map to be merged into. @type m: lems.util.Map @param base: Map to be merged into. @type base: lems.util.Map
[ "Merge", "in", "undefined", "map", "entries", "from", "given", "map", "." ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/base/util.py#L16-L29
train
Merge in undefined map entries from given map.
LEMS/pylems
lems/base/util.py
merge_lists
def merge_lists(l, base): """ Merge in undefined list entries from given list. @param l: List to be merged into. @type l: list @param base: List to be merged into. @type base: list """ for i in base: if i not in l: l.append(i)
python
def merge_lists(l, base): """ Merge in undefined list entries from given list. @param l: List to be merged into. @type l: list @param base: List to be merged into. @type base: list """ for i in base: if i not in l: l.append(i)
[ "def", "merge_lists", "(", "l", ",", "base", ")", ":", "for", "i", "in", "base", ":", "if", "i", "not", "in", "l", ":", "l", ".", "append", "(", "i", ")" ]
Merge in undefined list entries from given list. @param l: List to be merged into. @type l: list @param base: List to be merged into. @type base: list
[ "Merge", "in", "undefined", "list", "entries", "from", "given", "list", "." ]
4eeb719d2f23650fe16c38626663b69b5c83818b
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/base/util.py#L31-L44
train
Merge in undefined list entries from given list.
glormph/msstitch
src/app/actions/prottable/precursorarea.py
generate_top_psms
def generate_top_psms(psms, protcol): """Fed with a psms generator, this returns the 3 PSMs with the highest precursor intensities (or areas, or whatever is given in the HEADER_PRECURSOR_QUANT""" top_ms1_psms = {} for psm in psms: protacc = psm[protcol] precursor_amount = psm[mzidtsv...
python
def generate_top_psms(psms, protcol): """Fed with a psms generator, this returns the 3 PSMs with the highest precursor intensities (or areas, or whatever is given in the HEADER_PRECURSOR_QUANT""" top_ms1_psms = {} for psm in psms: protacc = psm[protcol] precursor_amount = psm[mzidtsv...
[ "def", "generate_top_psms", "(", "psms", ",", "protcol", ")", ":", "top_ms1_psms", "=", "{", "}", "for", "psm", "in", "psms", ":", "protacc", "=", "psm", "[", "protcol", "]", "precursor_amount", "=", "psm", "[", "mzidtsvdata", ".", "HEADER_PRECURSOR_QUANT", ...
Fed with a psms generator, this returns the 3 PSMs with the highest precursor intensities (or areas, or whatever is given in the HEADER_PRECURSOR_QUANT
[ "Fed", "with", "a", "psms", "generator", "this", "returns", "the", "3", "PSMs", "with", "the", "highest", "precursor", "intensities", "(", "or", "areas", "or", "whatever", "is", "given", "in", "the", "HEADER_PRECURSOR_QUANT" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/prottable/precursorarea.py#L5-L27
train
Fed with a psms generator this returns the 3 PSMs with the highest precursor intensities or area of the top - level precursor intensities or whatever is given in the HEADER_PRECURSOR_QUANT.
glormph/msstitch
src/app/actions/prottable/precursorarea.py
add_ms1_quant_from_top3_mzidtsv
def add_ms1_quant_from_top3_mzidtsv(proteins, psms, headerfields, protcol): """Collects PSMs with the highes precursor quant values, adds sum of the top 3 of these to a protein table""" if not protcol: protcol = mzidtsvdata.HEADER_MASTER_PROT top_ms1_psms = generate_top_psms(psms, protcol) f...
python
def add_ms1_quant_from_top3_mzidtsv(proteins, psms, headerfields, protcol): """Collects PSMs with the highes precursor quant values, adds sum of the top 3 of these to a protein table""" if not protcol: protcol = mzidtsvdata.HEADER_MASTER_PROT top_ms1_psms = generate_top_psms(psms, protcol) f...
[ "def", "add_ms1_quant_from_top3_mzidtsv", "(", "proteins", ",", "psms", ",", "headerfields", ",", "protcol", ")", ":", "if", "not", "protcol", ":", "protcol", "=", "mzidtsvdata", ".", "HEADER_MASTER_PROT", "top_ms1_psms", "=", "generate_top_psms", "(", "psms", ","...
Collects PSMs with the highes precursor quant values, adds sum of the top 3 of these to a protein table
[ "Collects", "PSMs", "with", "the", "highes", "precursor", "quant", "values", "adds", "sum", "of", "the", "top", "3", "of", "these", "to", "a", "protein", "table" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/prottable/precursorarea.py#L40-L52
train
Adds the sum of the top 3 precursor quant values to a protein table
Erotemic/utool
utool/util_time.py
toc
def toc(tt, return_msg=False, write_msg=True, verbose=None): """ similar to matlab toc SeeAlso: ut.tic """ if verbose is not None: write_msg = verbose (msg, start_time) = tt ellapsed = (default_timer() - start_time) if (not return_msg) and write_msg and msg is not None: ...
python
def toc(tt, return_msg=False, write_msg=True, verbose=None): """ similar to matlab toc SeeAlso: ut.tic """ if verbose is not None: write_msg = verbose (msg, start_time) = tt ellapsed = (default_timer() - start_time) if (not return_msg) and write_msg and msg is not None: ...
[ "def", "toc", "(", "tt", ",", "return_msg", "=", "False", ",", "write_msg", "=", "True", ",", "verbose", "=", "None", ")", ":", "if", "verbose", "is", "not", "None", ":", "write_msg", "=", "verbose", "(", "msg", ",", "start_time", ")", "=", "tt", "...
similar to matlab toc SeeAlso: ut.tic
[ "similar", "to", "matlab", "toc" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_time.py#L42-L58
train
toc - Print the time elapsed since the last time
Erotemic/utool
utool/util_time.py
get_timestamp
def get_timestamp(format_='iso', use_second=False, delta_seconds=None, isutc=False, timezone=False): """ get_timestamp Args: format_ (str): (tag, printable, filename, other) use_second (bool): delta_seconds (None): Returns: str: stamp Example: ...
python
def get_timestamp(format_='iso', use_second=False, delta_seconds=None, isutc=False, timezone=False): """ get_timestamp Args: format_ (str): (tag, printable, filename, other) use_second (bool): delta_seconds (None): Returns: str: stamp Example: ...
[ "def", "get_timestamp", "(", "format_", "=", "'iso'", ",", "use_second", "=", "False", ",", "delta_seconds", "=", "None", ",", "isutc", "=", "False", ",", "timezone", "=", "False", ")", ":", "# TODO: time.timezone", "if", "format_", "==", "'int'", ":", "if...
get_timestamp Args: format_ (str): (tag, printable, filename, other) use_second (bool): delta_seconds (None): Returns: str: stamp Example: >>> # ENABLE_DOCTEST >>> from utool.util_time import * # NOQA >>> format_ = 'printable' >>> use_secon...
[ "get_timestamp" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_time.py#L61-L132
train
get_timestamp - Returns a string representation of the current time in the specified format
Erotemic/utool
utool/util_time.py
determine_timestamp_format
def determine_timestamp_format(datetime_str, warn=True): r""" Args: datetime_str (str): Returns: str: References: https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior CommandLine: python -m utool.util_time --exec-determine_timestamp_format...
python
def determine_timestamp_format(datetime_str, warn=True): r""" Args: datetime_str (str): Returns: str: References: https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior CommandLine: python -m utool.util_time --exec-determine_timestamp_format...
[ "def", "determine_timestamp_format", "(", "datetime_str", ",", "warn", "=", "True", ")", ":", "import", "re", "# try to determine the format", "clean_datetime_str", "=", "datetime_str", ".", "replace", "(", "'\\x00'", ",", "' '", ")", ".", "strip", "(", "';'", "...
r""" Args: datetime_str (str): Returns: str: References: https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior CommandLine: python -m utool.util_time --exec-determine_timestamp_format Example: >>> # ENABLE_DOCTEST >>> from ...
[ "r", "Args", ":", "datetime_str", "(", "str", ")", ":" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_time.py#L336-L432
train
r This function will determine the format of the datetime_str in the ISO 8601 format.
Erotemic/utool
utool/util_time.py
parse_timestamp
def parse_timestamp(timestamp, zone='UTC', timestamp_format=None): r""" pip install delorean Args: timestamp (str): timestampe string zone (bool): assumes input is zone (only if not specified) and gives output in zone. CommandLine: python -m utool.util_time --test-p...
python
def parse_timestamp(timestamp, zone='UTC', timestamp_format=None): r""" pip install delorean Args: timestamp (str): timestampe string zone (bool): assumes input is zone (only if not specified) and gives output in zone. CommandLine: python -m utool.util_time --test-p...
[ "def", "parse_timestamp", "(", "timestamp", ",", "zone", "=", "'UTC'", ",", "timestamp_format", "=", "None", ")", ":", "if", "timestamp", "is", "None", ":", "return", "None", "use_delorean", "=", "True", "or", "six", ".", "PY2", "if", "use_delorean", ":", ...
r""" pip install delorean Args: timestamp (str): timestampe string zone (bool): assumes input is zone (only if not specified) and gives output in zone. CommandLine: python -m utool.util_time --test-parse_timestamp python -m utool.util_time parse_timestamp E...
[ "r", "pip", "install", "delorean" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_time.py#L447-L563
train
r Parse a timestamp string into a single object.
Erotemic/utool
utool/util_time.py
exiftime_to_unixtime
def exiftime_to_unixtime(datetime_str, timestamp_format=None, strict=None): r""" converts a datetime string to posixtime (unixtime) Use parse timestamp instead Args: datetime_str (str): timestamp_format (int): Returns: int: unixtime seconds from 1970 (currently not UTC;...
python
def exiftime_to_unixtime(datetime_str, timestamp_format=None, strict=None): r""" converts a datetime string to posixtime (unixtime) Use parse timestamp instead Args: datetime_str (str): timestamp_format (int): Returns: int: unixtime seconds from 1970 (currently not UTC;...
[ "def", "exiftime_to_unixtime", "(", "datetime_str", ",", "timestamp_format", "=", "None", ",", "strict", "=", "None", ")", ":", "invalid_value", "=", "-", "1", "if", "isinstance", "(", "datetime_str", ",", "int", ")", ":", "if", "datetime_str", "==", "-", ...
r""" converts a datetime string to posixtime (unixtime) Use parse timestamp instead Args: datetime_str (str): timestamp_format (int): Returns: int: unixtime seconds from 1970 (currently not UTC; this will change) CommandLine: python -m utool.util_time --test-ex...
[ "r", "converts", "a", "datetime", "string", "to", "posixtime", "(", "unixtime", ")", "Use", "parse", "timestamp", "instead" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_time.py#L567-L722
train
r Converts a datetime string to unixtime
Erotemic/utool
utool/util_time.py
parse_timedelta_str
def parse_timedelta_str(str_): r""" Args: str_ (str): Returns: float: timedelta CommandLine: python -m utool.util_time --exec-parse_timedelta_str Example: >>> # ENABLE_DOCTEST >>> from utool.util_time import * # NOQA >>> str_ = '24h' >>> ti...
python
def parse_timedelta_str(str_): r""" Args: str_ (str): Returns: float: timedelta CommandLine: python -m utool.util_time --exec-parse_timedelta_str Example: >>> # ENABLE_DOCTEST >>> from utool.util_time import * # NOQA >>> str_ = '24h' >>> ti...
[ "def", "parse_timedelta_str", "(", "str_", ")", ":", "if", "str_", ".", "endswith", "(", "'m'", ")", ":", "timedelta", "=", "float", "(", "str_", "[", "0", ":", "-", "1", "]", ")", "*", "60", "elif", "str_", ".", "endswith", "(", "'h'", ")", ":",...
r""" Args: str_ (str): Returns: float: timedelta CommandLine: python -m utool.util_time --exec-parse_timedelta_str Example: >>> # ENABLE_DOCTEST >>> from utool.util_time import * # NOQA >>> str_ = '24h' >>> timedelta = parse_timedelta_str(str_)...
[ "r", "Args", ":", "str_", "(", "str", ")", ":" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_time.py#L725-L753
train
r Parse a timedelta string into a timedelta object
Erotemic/utool
utool/util_time.py
unixtime_to_datetimestr
def unixtime_to_datetimestr(unixtime, timefmt='%Y/%m/%d %H:%M:%S', isutc=True): """ TODO: ranme to datetimestr """ try: if unixtime == -1: return 'NA' if unixtime is None: return None if isutc: return datetime.datetime.utcfromtimestamp(unixtime...
python
def unixtime_to_datetimestr(unixtime, timefmt='%Y/%m/%d %H:%M:%S', isutc=True): """ TODO: ranme to datetimestr """ try: if unixtime == -1: return 'NA' if unixtime is None: return None if isutc: return datetime.datetime.utcfromtimestamp(unixtime...
[ "def", "unixtime_to_datetimestr", "(", "unixtime", ",", "timefmt", "=", "'%Y/%m/%d %H:%M:%S'", ",", "isutc", "=", "True", ")", ":", "try", ":", "if", "unixtime", "==", "-", "1", ":", "return", "'NA'", "if", "unixtime", "is", "None", ":", "return", "None", ...
TODO: ranme to datetimestr
[ "TODO", ":", "ranme", "to", "datetimestr" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_time.py#L763-L777
train
Convert a Unix timestamp to a datetimestr.
Erotemic/utool
utool/util_time.py
get_timedelta_str
def get_timedelta_str(timedelta, exclude_zeros=False): """ get_timedelta_str Returns: str: timedelta_str, formated time string References: http://stackoverflow.com/questions/8906926/formatting-python-timedelta-objects Example: >>> # ENABLE_DOCTEST >>> from utool.ut...
python
def get_timedelta_str(timedelta, exclude_zeros=False): """ get_timedelta_str Returns: str: timedelta_str, formated time string References: http://stackoverflow.com/questions/8906926/formatting-python-timedelta-objects Example: >>> # ENABLE_DOCTEST >>> from utool.ut...
[ "def", "get_timedelta_str", "(", "timedelta", ",", "exclude_zeros", "=", "False", ")", ":", "if", "timedelta", "==", "datetime", ".", "timedelta", "(", "0", ")", ":", "return", "'0 seconds'", "days", "=", "timedelta", ".", "days", "hours", ",", "rem", "=",...
get_timedelta_str Returns: str: timedelta_str, formated time string References: http://stackoverflow.com/questions/8906926/formatting-python-timedelta-objects Example: >>> # ENABLE_DOCTEST >>> from utool.util_time import * # NOQA >>> timedelta = get_unix_timedelta...
[ "get_timedelta_str" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_time.py#L840-L885
train
Returns a string representation of a datetime. timedelta object
Erotemic/utool
utool/util_time.py
get_posix_timedelta_str
def get_posix_timedelta_str(posixtime, year=False, approx=True): """ get_timedelta_str TODO: rectify this function with get_unix_timedelta_str (unix_timedelta_str probably has better implementation) Returns: str: timedelta_str, formated time string CommandLine: python -m utool.uti...
python
def get_posix_timedelta_str(posixtime, year=False, approx=True): """ get_timedelta_str TODO: rectify this function with get_unix_timedelta_str (unix_timedelta_str probably has better implementation) Returns: str: timedelta_str, formated time string CommandLine: python -m utool.uti...
[ "def", "get_posix_timedelta_str", "(", "posixtime", ",", "year", "=", "False", ",", "approx", "=", "True", ")", ":", "import", "numpy", "as", "np", "if", "np", ".", "isnan", "(", "posixtime", ")", ":", "return", "'NaN'", "sign", ",", "posixtime_", "=", ...
get_timedelta_str TODO: rectify this function with get_unix_timedelta_str (unix_timedelta_str probably has better implementation) Returns: str: timedelta_str, formated time string CommandLine: python -m utool.util_time --test-get_posix_timedelta_str Example: >>> # ENABLE_DOCT...
[ "get_timedelta_str" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_time.py#L888-L953
train
Get the timedelta_str of a set of posix times
Erotemic/utool
utool/util_time.py
get_timestats_str
def get_timestats_str(unixtime_list, newlines=1, full=True, isutc=True): r""" Args: unixtime_list (list): newlines (bool): Returns: str: timestat_str CommandLine: python -m utool.util_time --test-get_timestats_str Example: >>> # ENABLE_DOCTEST >>> f...
python
def get_timestats_str(unixtime_list, newlines=1, full=True, isutc=True): r""" Args: unixtime_list (list): newlines (bool): Returns: str: timestat_str CommandLine: python -m utool.util_time --test-get_timestats_str Example: >>> # ENABLE_DOCTEST >>> f...
[ "def", "get_timestats_str", "(", "unixtime_list", ",", "newlines", "=", "1", ",", "full", "=", "True", ",", "isutc", "=", "True", ")", ":", "import", "utool", "as", "ut", "datetime_stats", "=", "get_timestats_dict", "(", "unixtime_list", ",", "full", "=", ...
r""" Args: unixtime_list (list): newlines (bool): Returns: str: timestat_str CommandLine: python -m utool.util_time --test-get_timestats_str Example: >>> # ENABLE_DOCTEST >>> from utool.util_time import * # NOQA >>> import utool as ut >...
[ "r", "Args", ":", "unixtime_list", "(", "list", ")", ":", "newlines", "(", "bool", ")", ":" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_time.py#L1015-L1070
train
r Get the timestat string for a list of unixtime
Erotemic/utool
utool/util_time.py
date_to_datetime
def date_to_datetime(date, fraction=0.0): """ fraction is how much through the day you are. 0=start of the day, 1=end of the day. """ day_seconds = (60 * 60 * 24) - 1 total_seconds = int(day_seconds * fraction) delta = datetime.timedelta(seconds=total_seconds) time = datetime.time() dt =...
python
def date_to_datetime(date, fraction=0.0): """ fraction is how much through the day you are. 0=start of the day, 1=end of the day. """ day_seconds = (60 * 60 * 24) - 1 total_seconds = int(day_seconds * fraction) delta = datetime.timedelta(seconds=total_seconds) time = datetime.time() dt =...
[ "def", "date_to_datetime", "(", "date", ",", "fraction", "=", "0.0", ")", ":", "day_seconds", "=", "(", "60", "*", "60", "*", "24", ")", "-", "1", "total_seconds", "=", "int", "(", "day_seconds", "*", "fraction", ")", "delta", "=", "datetime", ".", "...
fraction is how much through the day you are. 0=start of the day, 1=end of the day.
[ "fraction", "is", "how", "much", "through", "the", "day", "you", "are", ".", "0", "=", "start", "of", "the", "day", "1", "=", "end", "of", "the", "day", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_time.py#L1115-L1124
train
Converts a date to a datetime object.
garethr/cloth
src/cloth/utils.py
ec2_instances
def ec2_instances(): "Use the EC2 API to get a list of all machines" region = boto.ec2.get_region(REGION) reservations = region.connect().get_all_instances() instances = [] for reservation in reservations: instances += reservation.instances return instances
python
def ec2_instances(): "Use the EC2 API to get a list of all machines" region = boto.ec2.get_region(REGION) reservations = region.connect().get_all_instances() instances = [] for reservation in reservations: instances += reservation.instances return instances
[ "def", "ec2_instances", "(", ")", ":", "region", "=", "boto", ".", "ec2", ".", "get_region", "(", "REGION", ")", "reservations", "=", "region", ".", "connect", "(", ")", ".", "get_all_instances", "(", ")", "instances", "=", "[", "]", "for", "reservation"...
Use the EC2 API to get a list of all machines
[ "Use", "the", "EC2", "API", "to", "get", "a", "list", "of", "all", "machines" ]
b50c7cd6b03f49a931ee55ec94212760c50694a9
https://github.com/garethr/cloth/blob/b50c7cd6b03f49a931ee55ec94212760c50694a9/src/cloth/utils.py#L12-L19
train
Use the EC2 API to get a list of all machines
garethr/cloth
src/cloth/utils.py
instances
def instances(exp=".*"): "Filter list of machines matching an expression" expression = re.compile(exp) instances = [] for node in ec2_instances(): if node.tags and ip(node): try: if expression.match(node.tags.get("Name")): instances.append(node) ...
python
def instances(exp=".*"): "Filter list of machines matching an expression" expression = re.compile(exp) instances = [] for node in ec2_instances(): if node.tags and ip(node): try: if expression.match(node.tags.get("Name")): instances.append(node) ...
[ "def", "instances", "(", "exp", "=", "\".*\"", ")", ":", "expression", "=", "re", ".", "compile", "(", "exp", ")", "instances", "=", "[", "]", "for", "node", "in", "ec2_instances", "(", ")", ":", "if", "node", ".", "tags", "and", "ip", "(", "node",...
Filter list of machines matching an expression
[ "Filter", "list", "of", "machines", "matching", "an", "expression" ]
b50c7cd6b03f49a931ee55ec94212760c50694a9
https://github.com/garethr/cloth/blob/b50c7cd6b03f49a931ee55ec94212760c50694a9/src/cloth/utils.py#L27-L38
train
Filter list of machines matching an expression
garethr/cloth
src/cloth/utils.py
use
def use(node): "Set the fabric environment for the specifed node" try: role = node.tags.get("Name").split('-')[1] env.roledefs[role] += [ip(node)] except IndexError: pass env.nodes += [node] env.hosts += [ip(node)]
python
def use(node): "Set the fabric environment for the specifed node" try: role = node.tags.get("Name").split('-')[1] env.roledefs[role] += [ip(node)] except IndexError: pass env.nodes += [node] env.hosts += [ip(node)]
[ "def", "use", "(", "node", ")", ":", "try", ":", "role", "=", "node", ".", "tags", ".", "get", "(", "\"Name\"", ")", ".", "split", "(", "'-'", ")", "[", "1", "]", "env", ".", "roledefs", "[", "role", "]", "+=", "[", "ip", "(", "node", ")", ...
Set the fabric environment for the specifed node
[ "Set", "the", "fabric", "environment", "for", "the", "specifed", "node" ]
b50c7cd6b03f49a931ee55ec94212760c50694a9
https://github.com/garethr/cloth/blob/b50c7cd6b03f49a931ee55ec94212760c50694a9/src/cloth/utils.py#L40-L48
train
Set the fabric environment for the specifed node
Erotemic/utool
utool/util_tags.py
build_alias_map
def build_alias_map(regex_map, tag_vocab): """ Constructs explicit mapping. Order of items in regex map matters. Items at top are given preference. Example: >>> # DISABLE_DOCTEST >>> tags_list = [['t1', 't2'], [], ['t3'], ['t4', 't5']] >>> tag_vocab = ut.flat_unique(*tags_list) ...
python
def build_alias_map(regex_map, tag_vocab): """ Constructs explicit mapping. Order of items in regex map matters. Items at top are given preference. Example: >>> # DISABLE_DOCTEST >>> tags_list = [['t1', 't2'], [], ['t3'], ['t4', 't5']] >>> tag_vocab = ut.flat_unique(*tags_list) ...
[ "def", "build_alias_map", "(", "regex_map", ",", "tag_vocab", ")", ":", "import", "utool", "as", "ut", "import", "re", "alias_map", "=", "ut", ".", "odict", "(", "[", "]", ")", "for", "pats", ",", "new_tag", "in", "reversed", "(", "regex_map", ")", ":"...
Constructs explicit mapping. Order of items in regex map matters. Items at top are given preference. Example: >>> # DISABLE_DOCTEST >>> tags_list = [['t1', 't2'], [], ['t3'], ['t4', 't5']] >>> tag_vocab = ut.flat_unique(*tags_list) >>> regex_map = [('t[3-4]', 'A9'), ('t0', 'a0')...
[ "Constructs", "explicit", "mapping", ".", "Order", "of", "items", "in", "regex", "map", "matters", ".", "Items", "at", "top", "are", "given", "preference", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_tags.py#L65-L89
train
Constructs explicit mapping of items in regex_map.
Erotemic/utool
utool/util_tags.py
alias_tags
def alias_tags(tags_list, alias_map): """ update tags to new values Args: tags_list (list): alias_map (list): list of 2-tuples with regex, value Returns: list: updated tags CommandLine: python -m utool.util_tags alias_tags --show Example: >>> # DISABLE...
python
def alias_tags(tags_list, alias_map): """ update tags to new values Args: tags_list (list): alias_map (list): list of 2-tuples with regex, value Returns: list: updated tags CommandLine: python -m utool.util_tags alias_tags --show Example: >>> # DISABLE...
[ "def", "alias_tags", "(", "tags_list", ",", "alias_map", ")", ":", "def", "_alias_dict", "(", "tags", ")", ":", "tags_", "=", "[", "alias_map", ".", "get", "(", "t", ",", "t", ")", "for", "t", "in", "tags", "]", "return", "list", "(", "set", "(", ...
update tags to new values Args: tags_list (list): alias_map (list): list of 2-tuples with regex, value Returns: list: updated tags CommandLine: python -m utool.util_tags alias_tags --show Example: >>> # DISABLE_DOCTEST >>> from utool.util_tags import *...
[ "update", "tags", "to", "new", "values" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_tags.py#L92-L119
train
This function updates the tags of a node in a list of tags with the ones from the original tags.
Erotemic/utool
utool/util_tags.py
filterflags_general_tags
def filterflags_general_tags(tags_list, has_any=None, has_all=None, has_none=None, min_num=None, max_num=None, any_startswith=None, any_endswith=None, in_any=None, any_match=None, none_match=None, logic='...
python
def filterflags_general_tags(tags_list, has_any=None, has_all=None, has_none=None, min_num=None, max_num=None, any_startswith=None, any_endswith=None, in_any=None, any_match=None, none_match=None, logic='...
[ "def", "filterflags_general_tags", "(", "tags_list", ",", "has_any", "=", "None", ",", "has_all", "=", "None", ",", "has_none", "=", "None", ",", "min_num", "=", "None", ",", "max_num", "=", "None", ",", "any_startswith", "=", "None", ",", "any_endswith", ...
r""" maybe integrate into utool? Seems pretty general Args: tags_list (list): has_any (None): (default = None) has_all (None): (default = None) min_num (None): (default = None) max_num (None): (default = None) Notes: in_any should probably be ni_any TOD...
[ "r", "maybe", "integrate", "into", "utool?", "Seems", "pretty", "general" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_tags.py#L141-L300
train
r Filter the tags in a list of tags
ThreatResponse/aws_ir_plugins
aws_ir_plugins/examineracl_host.py
Plugin.setup
def setup(self): self.client = self._get_client() sg = self._create_isolation_security_group() if self.exists is not True: acl = self._create_network_acl() self._add_network_acl_entries(acl) self._add_security_group_rule(sg) self._add_security_group_to...
python
def setup(self): self.client = self._get_client() sg = self._create_isolation_security_group() if self.exists is not True: acl = self._create_network_acl() self._add_network_acl_entries(acl) self._add_security_group_rule(sg) self._add_security_group_to...
[ "def", "setup", "(", "self", ")", ":", "self", ".", "client", "=", "self", ".", "_get_client", "(", ")", "sg", "=", "self", ".", "_create_isolation_security_group", "(", ")", "if", "self", ".", "exists", "is", "not", "True", ":", "acl", "=", "self", ...
Conditions that can not be dry_run
[ "Conditions", "that", "can", "not", "be", "dry_run" ]
b5128ef5cbd91fc0b5d55615f1c14cb036ae7c73
https://github.com/ThreatResponse/aws_ir_plugins/blob/b5128ef5cbd91fc0b5d55615f1c14cb036ae7c73/aws_ir_plugins/examineracl_host.py#L23-L35
train
Setup the object.
Erotemic/utool
utool/util_cache.py
text_dict_write
def text_dict_write(fpath, dict_): """ Very naive, but readable way of storing a dictionary on disk FIXME: This broke on RoseMary's big dataset. Not sure why. It gave bad syntax. And the SyntaxError did not seem to be excepted. """ #dict_ = text_dict_read(fpath) #dict_[key] = val dict_te...
python
def text_dict_write(fpath, dict_): """ Very naive, but readable way of storing a dictionary on disk FIXME: This broke on RoseMary's big dataset. Not sure why. It gave bad syntax. And the SyntaxError did not seem to be excepted. """ #dict_ = text_dict_read(fpath) #dict_[key] = val dict_te...
[ "def", "text_dict_write", "(", "fpath", ",", "dict_", ")", ":", "#dict_ = text_dict_read(fpath)", "#dict_[key] = val", "dict_text2", "=", "util_str", ".", "repr4", "(", "dict_", ",", "strvals", "=", "False", ")", "if", "VERBOSE", ":", "print", "(", "'[cache] '",...
Very naive, but readable way of storing a dictionary on disk FIXME: This broke on RoseMary's big dataset. Not sure why. It gave bad syntax. And the SyntaxError did not seem to be excepted.
[ "Very", "naive", "but", "readable", "way", "of", "storing", "a", "dictionary", "on", "disk", "FIXME", ":", "This", "broke", "on", "RoseMary", "s", "big", "dataset", ".", "Not", "sure", "why", ".", "It", "gave", "bad", "syntax", ".", "And", "the", "Synt...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L134-L145
train
Write a dictionary to a file
Erotemic/utool
utool/util_cache.py
_args2_fpath
def _args2_fpath(dpath, fname, cfgstr, ext): r""" Ensures that the filename is not too long Internal util_cache helper function Windows MAX_PATH=260 characters Absolute length is limited to 32,000 characters Each filename component is limited to 255 characters Args: dpath (str): ...
python
def _args2_fpath(dpath, fname, cfgstr, ext): r""" Ensures that the filename is not too long Internal util_cache helper function Windows MAX_PATH=260 characters Absolute length is limited to 32,000 characters Each filename component is limited to 255 characters Args: dpath (str): ...
[ "def", "_args2_fpath", "(", "dpath", ",", "fname", ",", "cfgstr", ",", "ext", ")", ":", "if", "len", "(", "ext", ")", ">", "0", "and", "ext", "[", "0", "]", "!=", "'.'", ":", "raise", "ValueError", "(", "'Please be explicit and use a dot in ext'", ")", ...
r""" Ensures that the filename is not too long Internal util_cache helper function Windows MAX_PATH=260 characters Absolute length is limited to 32,000 characters Each filename component is limited to 255 characters Args: dpath (str): fname (str): cfgstr (str): ...
[ "r", "Ensures", "that", "the", "filename", "is", "not", "too", "long" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L161-L207
train
r This function is used to test the length of the file in the cache
Erotemic/utool
utool/util_cache.py
save_cache
def save_cache(dpath, fname, cfgstr, data, ext='.cPkl', verbose=None): """ Saves data using util_io, but smartly constructs a filename """ fpath = _args2_fpath(dpath, fname, cfgstr, ext) util_io.save_data(fpath, data, verbose=verbose) return fpath
python
def save_cache(dpath, fname, cfgstr, data, ext='.cPkl', verbose=None): """ Saves data using util_io, but smartly constructs a filename """ fpath = _args2_fpath(dpath, fname, cfgstr, ext) util_io.save_data(fpath, data, verbose=verbose) return fpath
[ "def", "save_cache", "(", "dpath", ",", "fname", ",", "cfgstr", ",", "data", ",", "ext", "=", "'.cPkl'", ",", "verbose", "=", "None", ")", ":", "fpath", "=", "_args2_fpath", "(", "dpath", ",", "fname", ",", "cfgstr", ",", "ext", ")", "util_io", ".", ...
Saves data using util_io, but smartly constructs a filename
[ "Saves", "data", "using", "util_io", "but", "smartly", "constructs", "a", "filename" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L210-L216
train
Save data to a file in a directory.
Erotemic/utool
utool/util_cache.py
load_cache
def load_cache(dpath, fname, cfgstr, ext='.cPkl', verbose=None, enabled=True): """ Loads data using util_io, but smartly constructs a filename """ if verbose is None: verbose = VERBOSE_CACHE if not USE_CACHE or not enabled: if verbose > 1: print('[util_cache] ... cache di...
python
def load_cache(dpath, fname, cfgstr, ext='.cPkl', verbose=None, enabled=True): """ Loads data using util_io, but smartly constructs a filename """ if verbose is None: verbose = VERBOSE_CACHE if not USE_CACHE or not enabled: if verbose > 1: print('[util_cache] ... cache di...
[ "def", "load_cache", "(", "dpath", ",", "fname", ",", "cfgstr", ",", "ext", "=", "'.cPkl'", ",", "verbose", "=", "None", ",", "enabled", "=", "True", ")", ":", "if", "verbose", "is", "None", ":", "verbose", "=", "VERBOSE_CACHE", "if", "not", "USE_CACHE...
Loads data using util_io, but smartly constructs a filename
[ "Loads", "data", "using", "util_io", "but", "smartly", "constructs", "a", "filename" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L219-L260
train
Loads a single file from a cache file.
Erotemic/utool
utool/util_cache.py
tryload_cache
def tryload_cache(dpath, fname, cfgstr, verbose=None): """ returns None if cache cannot be loaded """ try: return load_cache(dpath, fname, cfgstr, verbose=verbose) except IOError: return None
python
def tryload_cache(dpath, fname, cfgstr, verbose=None): """ returns None if cache cannot be loaded """ try: return load_cache(dpath, fname, cfgstr, verbose=verbose) except IOError: return None
[ "def", "tryload_cache", "(", "dpath", ",", "fname", ",", "cfgstr", ",", "verbose", "=", "None", ")", ":", "try", ":", "return", "load_cache", "(", "dpath", ",", "fname", ",", "cfgstr", ",", "verbose", "=", "verbose", ")", "except", "IOError", ":", "ret...
returns None if cache cannot be loaded
[ "returns", "None", "if", "cache", "cannot", "be", "loaded" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L263-L270
train
Try to load a single file from a cache.