repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
Erotemic/utool
utool/util_cache.py
tryload_cache_list_with_compute
def tryload_cache_list_with_compute(use_cache, dpath, fname, cfgstr_list, compute_fn, *args): """ tries to load data, but computes it if it can't give a compute function """ # Load precomputed values if use_cache is False: data_list = [None] * len(cfgstr_l...
python
def tryload_cache_list_with_compute(use_cache, dpath, fname, cfgstr_list, compute_fn, *args): """ tries to load data, but computes it if it can't give a compute function """ # Load precomputed values if use_cache is False: data_list = [None] * len(cfgstr_l...
[ "def", "tryload_cache_list_with_compute", "(", "use_cache", ",", "dpath", ",", "fname", ",", "cfgstr_list", ",", "compute_fn", ",", "*", "args", ")", ":", "if", "use_cache", "is", "False", ":", "data_list", "=", "[", "None", "]", "*", "len", "(", "cfgstr_l...
tries to load data, but computes it if it can't give a compute function
[ "tries", "to", "load", "data", "but", "computes", "it", "if", "it", "can", "t", "give", "a", "compute", "function" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L284-L319
train
Erotemic/utool
utool/util_cache.py
to_json
def to_json(val, allow_pickle=False, pretty=False): r""" Converts a python object to a JSON string using the utool convention Args: val (object): Returns: str: json_str References: http://stackoverflow.com/questions/11561932/why-does-json-dumpslistnp CommandLine: ...
python
def to_json(val, allow_pickle=False, pretty=False): r""" Converts a python object to a JSON string using the utool convention Args: val (object): Returns: str: json_str References: http://stackoverflow.com/questions/11561932/why-does-json-dumpslistnp CommandLine: ...
[ "def", "to_json", "(", "val", ",", "allow_pickle", "=", "False", ",", "pretty", "=", "False", ")", ":", "r", "UtoolJSONEncoder", "=", "make_utool_json_encoder", "(", "allow_pickle", ")", "json_kw", "=", "{", "}", "json_kw", "[", "'cls'", "]", "=", "UtoolJS...
r""" Converts a python object to a JSON string using the utool convention Args: val (object): Returns: str: json_str References: http://stackoverflow.com/questions/11561932/why-does-json-dumpslistnp CommandLine: python -m utool.util_cache --test-to_json py...
[ "r", "Converts", "a", "python", "object", "to", "a", "JSON", "string", "using", "the", "utool", "convention" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L532-L600
train
Erotemic/utool
utool/util_cache.py
from_json
def from_json(json_str, allow_pickle=False): """ Decodes a JSON object specified in the utool convention Args: json_str (str): allow_pickle (bool): (default = False) Returns: object: val CommandLine: python -m utool.util_cache from_json --show Example: ...
python
def from_json(json_str, allow_pickle=False): """ Decodes a JSON object specified in the utool convention Args: json_str (str): allow_pickle (bool): (default = False) Returns: object: val CommandLine: python -m utool.util_cache from_json --show Example: ...
[ "def", "from_json", "(", "json_str", ",", "allow_pickle", "=", "False", ")", ":", "if", "six", ".", "PY3", ":", "if", "isinstance", "(", "json_str", ",", "bytes", ")", ":", "json_str", "=", "json_str", ".", "decode", "(", "'utf-8'", ")", "UtoolJSONEncode...
Decodes a JSON object specified in the utool convention Args: json_str (str): allow_pickle (bool): (default = False) Returns: object: val CommandLine: python -m utool.util_cache from_json --show Example: >>> # ENABLE_DOCTEST >>> from utool.util_cache i...
[ "Decodes", "a", "JSON", "object", "specified", "in", "the", "utool", "convention" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L603-L634
train
Erotemic/utool
utool/util_cache.py
cachestr_repr
def cachestr_repr(val): """ Representation of an object as a cache string. """ try: memview = memoryview(val) return memview.tobytes() except Exception: try: return to_json(val) except Exception: # SUPER HACK if repr(val.__class__) ...
python
def cachestr_repr(val): """ Representation of an object as a cache string. """ try: memview = memoryview(val) return memview.tobytes() except Exception: try: return to_json(val) except Exception: # SUPER HACK if repr(val.__class__) ...
[ "def", "cachestr_repr", "(", "val", ")", ":", "try", ":", "memview", "=", "memoryview", "(", "val", ")", "return", "memview", ".", "tobytes", "(", ")", "except", "Exception", ":", "try", ":", "return", "to_json", "(", "val", ")", "except", "Exception", ...
Representation of an object as a cache string.
[ "Representation", "of", "an", "object", "as", "a", "cache", "string", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L678-L691
train
Erotemic/utool
utool/util_cache.py
cached_func
def cached_func(fname=None, cache_dir='default', appname='utool', key_argx=None, key_kwds=None, use_cache=None, verbose=None): r""" Wraps a function with a Cacher object uses a hash of arguments as input Args: fname (str): file name (defaults to function name) cache_di...
python
def cached_func(fname=None, cache_dir='default', appname='utool', key_argx=None, key_kwds=None, use_cache=None, verbose=None): r""" Wraps a function with a Cacher object uses a hash of arguments as input Args: fname (str): file name (defaults to function name) cache_di...
[ "def", "cached_func", "(", "fname", "=", "None", ",", "cache_dir", "=", "'default'", ",", "appname", "=", "'utool'", ",", "key_argx", "=", "None", ",", "key_kwds", "=", "None", ",", "use_cache", "=", "None", ",", "verbose", "=", "None", ")", ":", "r", ...
r""" Wraps a function with a Cacher object uses a hash of arguments as input Args: fname (str): file name (defaults to function name) cache_dir (unicode): (default = u'default') appname (unicode): (default = u'utool') key_argx (None): (default = None) key_kwds (Non...
[ "r", "Wraps", "a", "function", "with", "a", "Cacher", "object" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L778-L884
train
Erotemic/utool
utool/util_cache.py
get_global_shelf_fpath
def get_global_shelf_fpath(appname='default', ensure=False): """ Returns the filepath to the global shelf """ global_cache_dir = get_global_cache_dir(appname, ensure=ensure) shelf_fpath = join(global_cache_dir, meta_util_constants.global_cache_fname) return shelf_fpath
python
def get_global_shelf_fpath(appname='default', ensure=False): """ Returns the filepath to the global shelf """ global_cache_dir = get_global_cache_dir(appname, ensure=ensure) shelf_fpath = join(global_cache_dir, meta_util_constants.global_cache_fname) return shelf_fpath
[ "def", "get_global_shelf_fpath", "(", "appname", "=", "'default'", ",", "ensure", "=", "False", ")", ":", "global_cache_dir", "=", "get_global_cache_dir", "(", "appname", ",", "ensure", "=", "ensure", ")", "shelf_fpath", "=", "join", "(", "global_cache_dir", ","...
Returns the filepath to the global shelf
[ "Returns", "the", "filepath", "to", "the", "global", "shelf" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L906-L910
train
Erotemic/utool
utool/util_cache.py
global_cache_write
def global_cache_write(key, val, appname='default'): """ Writes cache files to a safe place in each operating system """ with GlobalShelfContext(appname) as shelf: shelf[key] = val
python
def global_cache_write(key, val, appname='default'): """ Writes cache files to a safe place in each operating system """ with GlobalShelfContext(appname) as shelf: shelf[key] = val
[ "def", "global_cache_write", "(", "key", ",", "val", ",", "appname", "=", "'default'", ")", ":", "with", "GlobalShelfContext", "(", "appname", ")", "as", "shelf", ":", "shelf", "[", "key", "]", "=", "val" ]
Writes cache files to a safe place in each operating system
[ "Writes", "cache", "files", "to", "a", "safe", "place", "in", "each", "operating", "system" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L983-L986
train
Erotemic/utool
utool/util_cache.py
delete_global_cache
def delete_global_cache(appname='default'): """ Reads cache files to a safe place in each operating system """ #close_global_shelf(appname) shelf_fpath = get_global_shelf_fpath(appname) util_path.remove_file(shelf_fpath, verbose=True, dryrun=False)
python
def delete_global_cache(appname='default'): """ Reads cache files to a safe place in each operating system """ #close_global_shelf(appname) shelf_fpath = get_global_shelf_fpath(appname) util_path.remove_file(shelf_fpath, verbose=True, dryrun=False)
[ "def", "delete_global_cache", "(", "appname", "=", "'default'", ")", ":", "shelf_fpath", "=", "get_global_shelf_fpath", "(", "appname", ")", "util_path", ".", "remove_file", "(", "shelf_fpath", ",", "verbose", "=", "True", ",", "dryrun", "=", "False", ")" ]
Reads cache files to a safe place in each operating system
[ "Reads", "cache", "files", "to", "a", "safe", "place", "in", "each", "operating", "system" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L989-L993
train
Erotemic/utool
utool/util_cache.py
Cacher.existing_versions
def existing_versions(self): """ Returns data with different cfgstr values that were previously computed with this cacher. """ import glob pattern = self.fname + '_*' + self.ext for fname in glob.glob1(self.dpath, pattern): fpath = join(self.dpath, fna...
python
def existing_versions(self): """ Returns data with different cfgstr values that were previously computed with this cacher. """ import glob pattern = self.fname + '_*' + self.ext for fname in glob.glob1(self.dpath, pattern): fpath = join(self.dpath, fna...
[ "def", "existing_versions", "(", "self", ")", ":", "import", "glob", "pattern", "=", "self", ".", "fname", "+", "'_*'", "+", "self", ".", "ext", "for", "fname", "in", "glob", ".", "glob1", "(", "self", ".", "dpath", ",", "pattern", ")", ":", "fpath",...
Returns data with different cfgstr values that were previously computed with this cacher.
[ "Returns", "data", "with", "different", "cfgstr", "values", "that", "were", "previously", "computed", "with", "this", "cacher", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L345-L354
train
Erotemic/utool
utool/util_cache.py
Cacher.tryload
def tryload(self, cfgstr=None): """ Like load, but returns None if the load fails """ if cfgstr is None: cfgstr = self.cfgstr if cfgstr is None: import warnings warnings.warn('No cfgstr given in Cacher constructor or call') cfgstr =...
python
def tryload(self, cfgstr=None): """ Like load, but returns None if the load fails """ if cfgstr is None: cfgstr = self.cfgstr if cfgstr is None: import warnings warnings.warn('No cfgstr given in Cacher constructor or call') cfgstr =...
[ "def", "tryload", "(", "self", ",", "cfgstr", "=", "None", ")", ":", "if", "cfgstr", "is", "None", ":", "cfgstr", "=", "self", ".", "cfgstr", "if", "cfgstr", "is", "None", ":", "import", "warnings", "warnings", ".", "warn", "(", "'No cfgstr given in Cach...
Like load, but returns None if the load fails
[ "Like", "load", "but", "returns", "None", "if", "the", "load", "fails" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L375-L399
train
Erotemic/utool
utool/util_cache.py
Cachable.fuzzyload
def fuzzyload(self, cachedir=None, partial_cfgstr='', **kwargs): """ Try and load from a partially specified configuration string """ valid_targets = self.glob_valid_targets(cachedir, partial_cfgstr) if len(valid_targets) != 1: import utool as ut msg = 'ne...
python
def fuzzyload(self, cachedir=None, partial_cfgstr='', **kwargs): """ Try and load from a partially specified configuration string """ valid_targets = self.glob_valid_targets(cachedir, partial_cfgstr) if len(valid_targets) != 1: import utool as ut msg = 'ne...
[ "def", "fuzzyload", "(", "self", ",", "cachedir", "=", "None", ",", "partial_cfgstr", "=", "''", ",", "**", "kwargs", ")", ":", "valid_targets", "=", "self", ".", "glob_valid_targets", "(", "cachedir", ",", "partial_cfgstr", ")", "if", "len", "(", "valid_t...
Try and load from a partially specified configuration string
[ "Try", "and", "load", "from", "a", "partially", "specified", "configuration", "string" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L1108-L1118
train
Erotemic/utool
utool/util_cache.py
Cachable.load
def load(self, cachedir=None, cfgstr=None, fpath=None, verbose=None, quiet=QUIET, ignore_keys=None): """ Loads the result from the given database """ if verbose is None: verbose = getattr(self, 'verbose', VERBOSE) if fpath is None: fpath = sel...
python
def load(self, cachedir=None, cfgstr=None, fpath=None, verbose=None, quiet=QUIET, ignore_keys=None): """ Loads the result from the given database """ if verbose is None: verbose = getattr(self, 'verbose', VERBOSE) if fpath is None: fpath = sel...
[ "def", "load", "(", "self", ",", "cachedir", "=", "None", ",", "cfgstr", "=", "None", ",", "fpath", "=", "None", ",", "verbose", "=", "None", ",", "quiet", "=", "QUIET", ",", "ignore_keys", "=", "None", ")", ":", "if", "verbose", "is", "None", ":",...
Loads the result from the given database
[ "Loads", "the", "result", "from", "the", "given", "database" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L1121-L1169
train
Erotemic/utool
utool/util_path.py
truepath_relative
def truepath_relative(path, otherpath=None): """ Normalizes and returns absolute path with so specs Args: path (str): path to file or directory otherpath (None): (default = None) Returns: str: path_ CommandLine: python -m utool.util_path --exec-truepath_relative --sho...
python
def truepath_relative(path, otherpath=None): """ Normalizes and returns absolute path with so specs Args: path (str): path to file or directory otherpath (None): (default = None) Returns: str: path_ CommandLine: python -m utool.util_path --exec-truepath_relative --sho...
[ "def", "truepath_relative", "(", "path", ",", "otherpath", "=", "None", ")", ":", "if", "otherpath", "is", "None", ":", "otherpath", "=", "os", ".", "getcwd", "(", ")", "otherpath", "=", "truepath", "(", "otherpath", ")", "path_", "=", "normpath", "(", ...
Normalizes and returns absolute path with so specs Args: path (str): path to file or directory otherpath (None): (default = None) Returns: str: path_ CommandLine: python -m utool.util_path --exec-truepath_relative --show Example: >>> # ENABLE_DOCTEST ...
[ "Normalizes", "and", "returns", "absolute", "path", "with", "so", "specs" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L109-L137
train
Erotemic/utool
utool/util_path.py
tail
def tail(fpath, n=2, trailing=True): """ Alias for path_ndir_split """ return path_ndir_split(fpath, n=n, trailing=trailing)
python
def tail(fpath, n=2, trailing=True): """ Alias for path_ndir_split """ return path_ndir_split(fpath, n=n, trailing=trailing)
[ "def", "tail", "(", "fpath", ",", "n", "=", "2", ",", "trailing", "=", "True", ")", ":", "return", "path_ndir_split", "(", "fpath", ",", "n", "=", "n", ",", "trailing", "=", "trailing", ")" ]
Alias for path_ndir_split
[ "Alias", "for", "path_ndir_split" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L140-L142
train
Erotemic/utool
utool/util_path.py
unexpanduser
def unexpanduser(path): r""" Replaces home directory with '~' """ homedir = expanduser('~') if path.startswith(homedir): path = '~' + path[len(homedir):] return path
python
def unexpanduser(path): r""" Replaces home directory with '~' """ homedir = expanduser('~') if path.startswith(homedir): path = '~' + path[len(homedir):] return path
[ "def", "unexpanduser", "(", "path", ")", ":", "r", "homedir", "=", "expanduser", "(", "'~'", ")", "if", "path", ".", "startswith", "(", "homedir", ")", ":", "path", "=", "'~'", "+", "path", "[", "len", "(", "homedir", ")", ":", "]", "return", "path...
r""" Replaces home directory with '~'
[ "r", "Replaces", "home", "directory", "with", "~" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L145-L152
train
Erotemic/utool
utool/util_path.py
path_ndir_split
def path_ndir_split(path_, n, force_unix=True, winroot='C:', trailing=True): r""" Shows only a little bit of the path. Up to the n bottom-level directories TODO: rename to path_tail? ndir_split? Returns: (str) the trailing n paths of path. CommandLine: python3 -m utool.util_path -...
python
def path_ndir_split(path_, n, force_unix=True, winroot='C:', trailing=True): r""" Shows only a little bit of the path. Up to the n bottom-level directories TODO: rename to path_tail? ndir_split? Returns: (str) the trailing n paths of path. CommandLine: python3 -m utool.util_path -...
[ "def", "path_ndir_split", "(", "path_", ",", "n", ",", "force_unix", "=", "True", ",", "winroot", "=", "'C:'", ",", "trailing", "=", "True", ")", ":", "r", "if", "not", "isinstance", "(", "path_", ",", "six", ".", "string_types", ")", ":", "return", ...
r""" Shows only a little bit of the path. Up to the n bottom-level directories TODO: rename to path_tail? ndir_split? Returns: (str) the trailing n paths of path. CommandLine: python3 -m utool.util_path --test-path_ndir_split python3 -m utool --tf path_ndir_split pytho...
[ "r", "Shows", "only", "a", "little", "bit", "of", "the", "path", ".", "Up", "to", "the", "n", "bottom", "-", "level", "directories" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L155-L234
train
Erotemic/utool
utool/util_path.py
augpath
def augpath(path, augsuf='', augext='', augpref='', augdir=None, newext=None, newfname=None, ensure=False, prefix=None, suffix=None): """ augments end of path before the extension. augpath Args: path (str): augsuf (str): augment filename before extension Returns: ...
python
def augpath(path, augsuf='', augext='', augpref='', augdir=None, newext=None, newfname=None, ensure=False, prefix=None, suffix=None): """ augments end of path before the extension. augpath Args: path (str): augsuf (str): augment filename before extension Returns: ...
[ "def", "augpath", "(", "path", ",", "augsuf", "=", "''", ",", "augext", "=", "''", ",", "augpref", "=", "''", ",", "augdir", "=", "None", ",", "newext", "=", "None", ",", "newfname", "=", "None", ",", "ensure", "=", "False", ",", "prefix", "=", "...
augments end of path before the extension. augpath Args: path (str): augsuf (str): augment filename before extension Returns: str: newpath Example: >>> # DISABLE_DOCTEST >>> from utool.util_path import * # NOQA >>> path = 'somefile.txt' >>> au...
[ "augments", "end", "of", "path", "before", "the", "extension", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L308-L368
train
Erotemic/utool
utool/util_path.py
remove_files_in_dir
def remove_files_in_dir(dpath, fname_pattern_list='*', recursive=False, verbose=VERBOSE, dryrun=False, ignore_errors=False): """ Removes files matching a pattern from a directory """ if isinstance(fname_pattern_list, six.string_types): fname_pattern_list = [fname_pattern_list] ...
python
def remove_files_in_dir(dpath, fname_pattern_list='*', recursive=False, verbose=VERBOSE, dryrun=False, ignore_errors=False): """ Removes files matching a pattern from a directory """ if isinstance(fname_pattern_list, six.string_types): fname_pattern_list = [fname_pattern_list] ...
[ "def", "remove_files_in_dir", "(", "dpath", ",", "fname_pattern_list", "=", "'*'", ",", "recursive", "=", "False", ",", "verbose", "=", "VERBOSE", ",", "dryrun", "=", "False", ",", "ignore_errors", "=", "False", ")", ":", "if", "isinstance", "(", "fname_patt...
Removes files matching a pattern from a directory
[ "Removes", "files", "matching", "a", "pattern", "from", "a", "directory" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L371-L399
train
Erotemic/utool
utool/util_path.py
delete
def delete(path, dryrun=False, recursive=True, verbose=None, print_exists=True, ignore_errors=True): """ Removes a file, directory, or symlink """ if verbose is None: verbose = VERBOSE if not QUIET: verbose = 1 if verbose > 0: print('[util_path] Deleting path=%...
python
def delete(path, dryrun=False, recursive=True, verbose=None, print_exists=True, ignore_errors=True): """ Removes a file, directory, or symlink """ if verbose is None: verbose = VERBOSE if not QUIET: verbose = 1 if verbose > 0: print('[util_path] Deleting path=%...
[ "def", "delete", "(", "path", ",", "dryrun", "=", "False", ",", "recursive", "=", "True", ",", "verbose", "=", "None", ",", "print_exists", "=", "True", ",", "ignore_errors", "=", "True", ")", ":", "if", "verbose", "is", "None", ":", "verbose", "=", ...
Removes a file, directory, or symlink
[ "Removes", "a", "file", "directory", "or", "symlink" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L402-L434
train
Erotemic/utool
utool/util_path.py
remove_existing_fpaths
def remove_existing_fpaths(fpath_list, verbose=VERBOSE, quiet=QUIET, strict=False, print_caller=PRINT_CALLER, lbl='files'): """ checks existance before removing. then tries to remove exisint paths """ import utool as ut if print_caller: print(uti...
python
def remove_existing_fpaths(fpath_list, verbose=VERBOSE, quiet=QUIET, strict=False, print_caller=PRINT_CALLER, lbl='files'): """ checks existance before removing. then tries to remove exisint paths """ import utool as ut if print_caller: print(uti...
[ "def", "remove_existing_fpaths", "(", "fpath_list", ",", "verbose", "=", "VERBOSE", ",", "quiet", "=", "QUIET", ",", "strict", "=", "False", ",", "print_caller", "=", "PRINT_CALLER", ",", "lbl", "=", "'files'", ")", ":", "import", "utool", "as", "ut", "if"...
checks existance before removing. then tries to remove exisint paths
[ "checks", "existance", "before", "removing", ".", "then", "tries", "to", "remove", "exisint", "paths" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L437-L461
train
Erotemic/utool
utool/util_path.py
remove_fpaths
def remove_fpaths(fpaths, verbose=VERBOSE, quiet=QUIET, strict=False, print_caller=PRINT_CALLER, lbl='files'): """ Removes multiple file paths """ import utool as ut if print_caller: print(util_dbg.get_caller_name(range(1, 4)) + ' called remove_fpaths') n_total = len(fp...
python
def remove_fpaths(fpaths, verbose=VERBOSE, quiet=QUIET, strict=False, print_caller=PRINT_CALLER, lbl='files'): """ Removes multiple file paths """ import utool as ut if print_caller: print(util_dbg.get_caller_name(range(1, 4)) + ' called remove_fpaths') n_total = len(fp...
[ "def", "remove_fpaths", "(", "fpaths", ",", "verbose", "=", "VERBOSE", ",", "quiet", "=", "QUIET", ",", "strict", "=", "False", ",", "print_caller", "=", "PRINT_CALLER", ",", "lbl", "=", "'files'", ")", ":", "import", "utool", "as", "ut", "if", "print_ca...
Removes multiple file paths
[ "Removes", "multiple", "file", "paths" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L464-L502
train
Erotemic/utool
utool/util_path.py
longest_existing_path
def longest_existing_path(_path): r""" Returns the longest root of _path that exists Args: _path (str): path string Returns: str: _path - path string CommandLine: python -m utool.util_path --exec-longest_existing_path Example: >>> # ENABLE_DOCTEST >>...
python
def longest_existing_path(_path): r""" Returns the longest root of _path that exists Args: _path (str): path string Returns: str: _path - path string CommandLine: python -m utool.util_path --exec-longest_existing_path Example: >>> # ENABLE_DOCTEST >>...
[ "def", "longest_existing_path", "(", "_path", ")", ":", "r", "existing_path", "=", "_path", "while", "True", ":", "_path_new", "=", "os", ".", "path", ".", "dirname", "(", "existing_path", ")", "if", "exists", "(", "_path_new", ")", ":", "existing_path", "...
r""" Returns the longest root of _path that exists Args: _path (str): path string Returns: str: _path - path string CommandLine: python -m utool.util_path --exec-longest_existing_path Example: >>> # ENABLE_DOCTEST >>> from utool.util_path import * # NOQ...
[ "r", "Returns", "the", "longest", "root", "of", "_path", "that", "exists" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L508-L543
train
Erotemic/utool
utool/util_path.py
get_path_type
def get_path_type(path_): r""" returns if a path is a file, directory, link, or mount """ path_type = '' if isfile(path_): path_type += 'file' if isdir(path_): path_type += 'directory' if islink(path_): path_type += 'link' if ismount(path_): path_type += '...
python
def get_path_type(path_): r""" returns if a path is a file, directory, link, or mount """ path_type = '' if isfile(path_): path_type += 'file' if isdir(path_): path_type += 'directory' if islink(path_): path_type += 'link' if ismount(path_): path_type += '...
[ "def", "get_path_type", "(", "path_", ")", ":", "r", "path_type", "=", "''", "if", "isfile", "(", "path_", ")", ":", "path_type", "+=", "'file'", "if", "isdir", "(", "path_", ")", ":", "path_type", "+=", "'directory'", "if", "islink", "(", "path_", ")"...
r""" returns if a path is a file, directory, link, or mount
[ "r", "returns", "if", "a", "path", "is", "a", "file", "directory", "link", "or", "mount" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L546-L559
train
Erotemic/utool
utool/util_path.py
checkpath
def checkpath(path_, verbose=VERYVERBOSE, n=None, info=VERYVERBOSE): r""" verbose wrapper around ``os.path.exists`` Returns: true if ``path_`` exists on the filesystem show only the top `n` directories Args: path_ (str): path string verbose (bool): verbosity flag(default = ...
python
def checkpath(path_, verbose=VERYVERBOSE, n=None, info=VERYVERBOSE): r""" verbose wrapper around ``os.path.exists`` Returns: true if ``path_`` exists on the filesystem show only the top `n` directories Args: path_ (str): path string verbose (bool): verbosity flag(default = ...
[ "def", "checkpath", "(", "path_", ",", "verbose", "=", "VERYVERBOSE", ",", "n", "=", "None", ",", "info", "=", "VERYVERBOSE", ")", ":", "r", "assert", "isinstance", "(", "path_", ",", "six", ".", "string_types", ")", ",", "(", "'path_=%r is not a string. t...
r""" verbose wrapper around ``os.path.exists`` Returns: true if ``path_`` exists on the filesystem show only the top `n` directories Args: path_ (str): path string verbose (bool): verbosity flag(default = False) n (int): (default = None) info (bool): (default =...
[ "r", "verbose", "wrapper", "around", "os", ".", "path", ".", "exists" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L562-L628
train
Erotemic/utool
utool/util_path.py
ensurepath
def ensurepath(path_, verbose=None): """ DEPRICATE - alias - use ensuredir instead """ if verbose is None: verbose = VERYVERBOSE return ensuredir(path_, verbose=verbose)
python
def ensurepath(path_, verbose=None): """ DEPRICATE - alias - use ensuredir instead """ if verbose is None: verbose = VERYVERBOSE return ensuredir(path_, verbose=verbose)
[ "def", "ensurepath", "(", "path_", ",", "verbose", "=", "None", ")", ":", "if", "verbose", "is", "None", ":", "verbose", "=", "VERYVERBOSE", "return", "ensuredir", "(", "path_", ",", "verbose", "=", "verbose", ")" ]
DEPRICATE - alias - use ensuredir instead
[ "DEPRICATE", "-", "alias", "-", "use", "ensuredir", "instead" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L631-L635
train
Erotemic/utool
utool/util_path.py
ensuredir
def ensuredir(path_, verbose=None, info=False, mode=0o1777): r""" Ensures that directory will exist. creates new dir with sticky bits by default Args: path (str): dpath to ensure. Can also be a tuple to send to join info (bool): if True prints extra information mode (int): octal...
python
def ensuredir(path_, verbose=None, info=False, mode=0o1777): r""" Ensures that directory will exist. creates new dir with sticky bits by default Args: path (str): dpath to ensure. Can also be a tuple to send to join info (bool): if True prints extra information mode (int): octal...
[ "def", "ensuredir", "(", "path_", ",", "verbose", "=", "None", ",", "info", "=", "False", ",", "mode", "=", "0o1777", ")", ":", "r", "if", "verbose", "is", "None", ":", "verbose", "=", "VERYVERBOSE", "if", "isinstance", "(", "path_", ",", "(", "list"...
r""" Ensures that directory will exist. creates new dir with sticky bits by default Args: path (str): dpath to ensure. Can also be a tuple to send to join info (bool): if True prints extra information mode (int): octal mode of directory (default 0o1777) Returns: str: pa...
[ "r", "Ensures", "that", "directory", "will", "exist", ".", "creates", "new", "dir", "with", "sticky", "bits", "by", "default" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L638-L669
train
Erotemic/utool
utool/util_path.py
touch
def touch(fpath, times=None, verbose=True): r""" Creates file if it doesnt exist Args: fpath (str): file path times (None): verbose (bool): Example: >>> # DISABLE_DOCTEST >>> from utool.util_path import * # NOQA >>> fpath = '?' >>> times = None ...
python
def touch(fpath, times=None, verbose=True): r""" Creates file if it doesnt exist Args: fpath (str): file path times (None): verbose (bool): Example: >>> # DISABLE_DOCTEST >>> from utool.util_path import * # NOQA >>> fpath = '?' >>> times = None ...
[ "def", "touch", "(", "fpath", ",", "times", "=", "None", ",", "verbose", "=", "True", ")", ":", "r", "try", ":", "if", "verbose", ":", "print", "(", "'[util_path] touching %r'", "%", "fpath", ")", "with", "open", "(", "fpath", ",", "'a'", ")", ":", ...
r""" Creates file if it doesnt exist Args: fpath (str): file path times (None): verbose (bool): Example: >>> # DISABLE_DOCTEST >>> from utool.util_path import * # NOQA >>> fpath = '?' >>> times = None >>> verbose = True >>> result = ...
[ "r", "Creates", "file", "if", "it", "doesnt", "exist" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L672-L702
train
Erotemic/utool
utool/util_path.py
copy_list
def copy_list(src_list, dst_list, lbl='Copying', ioerr_ok=False, sherro_ok=False, oserror_ok=False): """ Copies all data and stat info """ # Feb - 6 - 2014 Copy function task_iter = zip(src_list, dst_list) def docopy(src, dst): try: shutil.copy2(src, dst) except...
python
def copy_list(src_list, dst_list, lbl='Copying', ioerr_ok=False, sherro_ok=False, oserror_ok=False): """ Copies all data and stat info """ # Feb - 6 - 2014 Copy function task_iter = zip(src_list, dst_list) def docopy(src, dst): try: shutil.copy2(src, dst) except...
[ "def", "copy_list", "(", "src_list", ",", "dst_list", ",", "lbl", "=", "'Copying'", ",", "ioerr_ok", "=", "False", ",", "sherro_ok", "=", "False", ",", "oserror_ok", "=", "False", ")", ":", "task_iter", "=", "zip", "(", "src_list", ",", "dst_list", ")", ...
Copies all data and stat info
[ "Copies", "all", "data", "and", "stat", "info" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L871-L894
train
Erotemic/utool
utool/util_path.py
glob
def glob(dpath, pattern=None, recursive=False, with_files=True, with_dirs=True, maxdepth=None, exclude_dirs=[], fullpath=True, **kwargs): r""" Globs directory for pattern DEPRICATED: use pathlib.glob instead Args: dpath (str): directory path or pattern pattern (str or ...
python
def glob(dpath, pattern=None, recursive=False, with_files=True, with_dirs=True, maxdepth=None, exclude_dirs=[], fullpath=True, **kwargs): r""" Globs directory for pattern DEPRICATED: use pathlib.glob instead Args: dpath (str): directory path or pattern pattern (str or ...
[ "def", "glob", "(", "dpath", ",", "pattern", "=", "None", ",", "recursive", "=", "False", ",", "with_files", "=", "True", ",", "with_dirs", "=", "True", ",", "maxdepth", "=", "None", ",", "exclude_dirs", "=", "[", "]", ",", "fullpath", "=", "True", "...
r""" Globs directory for pattern DEPRICATED: use pathlib.glob instead Args: dpath (str): directory path or pattern pattern (str or list): pattern or list of patterns (use only if pattern is not in dpath) recursive (bool): (default = False) with_files (bo...
[ "r", "Globs", "directory", "for", "pattern" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L957-L1024
train
Erotemic/utool
utool/util_path.py
num_images_in_dir
def num_images_in_dir(path): """ returns the number of images in a directory """ num_imgs = 0 for root, dirs, files in os.walk(path): for fname in files: if fpath_has_imgext(fname): num_imgs += 1 return num_imgs
python
def num_images_in_dir(path): """ returns the number of images in a directory """ num_imgs = 0 for root, dirs, files in os.walk(path): for fname in files: if fpath_has_imgext(fname): num_imgs += 1 return num_imgs
[ "def", "num_images_in_dir", "(", "path", ")", ":", "num_imgs", "=", "0", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "path", ")", ":", "for", "fname", "in", "files", ":", "if", "fpath_has_imgext", "(", "fname", ")", ":", ...
returns the number of images in a directory
[ "returns", "the", "number", "of", "images", "in", "a", "directory" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L1150-L1159
train
Erotemic/utool
utool/util_path.py
fpath_has_ext
def fpath_has_ext(fname, exts, case_sensitive=False): """ returns true if the filename has any of the given extensions """ fname_ = fname.lower() if not case_sensitive else fname if case_sensitive: ext_pats = ['*' + ext for ext in exts] else: ext_pats = ['*' + ext.lower() for ext in exts...
python
def fpath_has_ext(fname, exts, case_sensitive=False): """ returns true if the filename has any of the given extensions """ fname_ = fname.lower() if not case_sensitive else fname if case_sensitive: ext_pats = ['*' + ext for ext in exts] else: ext_pats = ['*' + ext.lower() for ext in exts...
[ "def", "fpath_has_ext", "(", "fname", ",", "exts", ",", "case_sensitive", "=", "False", ")", ":", "fname_", "=", "fname", ".", "lower", "(", ")", "if", "not", "case_sensitive", "else", "fname", "if", "case_sensitive", ":", "ext_pats", "=", "[", "'*'", "+...
returns true if the filename has any of the given extensions
[ "returns", "true", "if", "the", "filename", "has", "any", "of", "the", "given", "extensions" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L1167-L1174
train
Erotemic/utool
utool/util_path.py
get_modpath
def get_modpath(modname, prefer_pkg=False, prefer_main=False): r""" Returns path to module Args: modname (str or module): module name or actual module Returns: str: module_dir CommandLine: python -m utool.util_path --test-get_modpath Setup: >>> from utool.util...
python
def get_modpath(modname, prefer_pkg=False, prefer_main=False): r""" Returns path to module Args: modname (str or module): module name or actual module Returns: str: module_dir CommandLine: python -m utool.util_path --test-get_modpath Setup: >>> from utool.util...
[ "def", "get_modpath", "(", "modname", ",", "prefer_pkg", "=", "False", ",", "prefer_main", "=", "False", ")", ":", "r", "import", "importlib", "if", "isinstance", "(", "modname", ",", "six", ".", "string_types", ")", ":", "module", "=", "importlib", ".", ...
r""" Returns path to module Args: modname (str or module): module name or actual module Returns: str: module_dir CommandLine: python -m utool.util_path --test-get_modpath Setup: >>> from utool.util_path import * # NOQA >>> import utool as ut >>> u...
[ "r", "Returns", "path", "to", "module" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L1233-L1305
train
Erotemic/utool
utool/util_path.py
get_relative_modpath
def get_relative_modpath(module_fpath): """ Returns path to module relative to the package root Args: module_fpath (str): module filepath Returns: str: modname Example: >>> # ENABLE_DOCTEST >>> from utool.util_path import * # NOQA >>> import utool as ut ...
python
def get_relative_modpath(module_fpath): """ Returns path to module relative to the package root Args: module_fpath (str): module filepath Returns: str: modname Example: >>> # ENABLE_DOCTEST >>> from utool.util_path import * # NOQA >>> import utool as ut ...
[ "def", "get_relative_modpath", "(", "module_fpath", ")", ":", "modsubdir_list", "=", "get_module_subdir_list", "(", "module_fpath", ")", "_", ",", "ext", "=", "splitext", "(", "module_fpath", ")", "rel_modpath", "=", "join", "(", "*", "modsubdir_list", ")", "+",...
Returns path to module relative to the package root Args: module_fpath (str): module filepath Returns: str: modname Example: >>> # ENABLE_DOCTEST >>> from utool.util_path import * # NOQA >>> import utool as ut >>> module_fpath = ut.util_path.__file__ ...
[ "Returns", "path", "to", "module", "relative", "to", "the", "package", "root" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L1350-L1375
train
Erotemic/utool
utool/util_path.py
get_modname_from_modpath
def get_modname_from_modpath(module_fpath): """ returns importable name from file path get_modname_from_modpath Args: module_fpath (str): module filepath Returns: str: modname Example: >>> # ENABLE_DOCTEST >>> from utool.util_path import * # NOQA >>> ...
python
def get_modname_from_modpath(module_fpath): """ returns importable name from file path get_modname_from_modpath Args: module_fpath (str): module filepath Returns: str: modname Example: >>> # ENABLE_DOCTEST >>> from utool.util_path import * # NOQA >>> ...
[ "def", "get_modname_from_modpath", "(", "module_fpath", ")", ":", "modsubdir_list", "=", "get_module_subdir_list", "(", "module_fpath", ")", "modname", "=", "'.'", ".", "join", "(", "modsubdir_list", ")", "modname", "=", "modname", ".", "replace", "(", "'.__init__...
returns importable name from file path get_modname_from_modpath Args: module_fpath (str): module filepath Returns: str: modname Example: >>> # ENABLE_DOCTEST >>> from utool.util_path import * # NOQA >>> import utool as ut >>> module_fpath = ut.util_pa...
[ "returns", "importable", "name", "from", "file", "path" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L1378-L1404
train
Erotemic/utool
utool/util_path.py
ls
def ls(path, pattern='*'): """ like unix ls - lists all files and dirs in path""" path_iter = glob(path, pattern, recursive=False) return sorted(list(path_iter))
python
def ls(path, pattern='*'): """ like unix ls - lists all files and dirs in path""" path_iter = glob(path, pattern, recursive=False) return sorted(list(path_iter))
[ "def", "ls", "(", "path", ",", "pattern", "=", "'*'", ")", ":", "path_iter", "=", "glob", "(", "path", ",", "pattern", ",", "recursive", "=", "False", ")", "return", "sorted", "(", "list", "(", "path_iter", ")", ")" ]
like unix ls - lists all files and dirs in path
[ "like", "unix", "ls", "-", "lists", "all", "files", "and", "dirs", "in", "path" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L1437-L1440
train
Erotemic/utool
utool/util_path.py
ls_moduledirs
def ls_moduledirs(path, private=True, full=True): """ lists all dirs which are python modules in path """ dir_list = ls_dirs(path) module_dir_iter = filter(is_module_dir, dir_list) if not private: module_dir_iter = filterfalse(is_private_module, module_dir_iter) if not full: module_d...
python
def ls_moduledirs(path, private=True, full=True): """ lists all dirs which are python modules in path """ dir_list = ls_dirs(path) module_dir_iter = filter(is_module_dir, dir_list) if not private: module_dir_iter = filterfalse(is_private_module, module_dir_iter) if not full: module_d...
[ "def", "ls_moduledirs", "(", "path", ",", "private", "=", "True", ",", "full", "=", "True", ")", ":", "dir_list", "=", "ls_dirs", "(", "path", ")", "module_dir_iter", "=", "filter", "(", "is_module_dir", ",", "dir_list", ")", "if", "not", "private", ":",...
lists all dirs which are python modules in path
[ "lists", "all", "dirs", "which", "are", "python", "modules", "in", "path" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L1460-L1468
train
Erotemic/utool
utool/util_path.py
list_images
def list_images(img_dpath_, ignore_list=[], recursive=False, fullpath=False, full=None, sort=True): r""" Returns a list of images in a directory. By default returns relative paths. TODO: rename to ls_images TODO: Change all instances of fullpath to full Args: img_dpath_ (st...
python
def list_images(img_dpath_, ignore_list=[], recursive=False, fullpath=False, full=None, sort=True): r""" Returns a list of images in a directory. By default returns relative paths. TODO: rename to ls_images TODO: Change all instances of fullpath to full Args: img_dpath_ (st...
[ "def", "list_images", "(", "img_dpath_", ",", "ignore_list", "=", "[", "]", ",", "recursive", "=", "False", ",", "fullpath", "=", "False", ",", "full", "=", "None", ",", "sort", "=", "True", ")", ":", "r", "if", "full", "is", "not", "None", ":", "f...
r""" Returns a list of images in a directory. By default returns relative paths. TODO: rename to ls_images TODO: Change all instances of fullpath to full Args: img_dpath_ (str): ignore_list (list): (default = []) recursive (bool): (default = False) fullpath (bool): (def...
[ "r", "Returns", "a", "list", "of", "images", "in", "a", "directory", ".", "By", "default", "returns", "relative", "paths", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L1502-L1573
train
Erotemic/utool
utool/util_path.py
assertpath
def assertpath(path_, msg='', **kwargs): """ Asserts that a patha exists """ if NO_ASSERTS: return if path_ is None: raise AssertionError('path is None! %s' % (path_, msg)) if path_ == '': raise AssertionError('path=%r is the empty string! %s' % (path_, msg)) if not checkpath...
python
def assertpath(path_, msg='', **kwargs): """ Asserts that a patha exists """ if NO_ASSERTS: return if path_ is None: raise AssertionError('path is None! %s' % (path_, msg)) if path_ == '': raise AssertionError('path=%r is the empty string! %s' % (path_, msg)) if not checkpath...
[ "def", "assertpath", "(", "path_", ",", "msg", "=", "''", ",", "**", "kwargs", ")", ":", "if", "NO_ASSERTS", ":", "return", "if", "path_", "is", "None", ":", "raise", "AssertionError", "(", "'path is None! %s'", "%", "(", "path_", ",", "msg", ")", ")",...
Asserts that a patha exists
[ "Asserts", "that", "a", "patha", "exists" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L1579-L1588
train
Erotemic/utool
utool/util_path.py
matching_fpaths
def matching_fpaths(dpath_list, include_patterns, exclude_dirs=[], greater_exclude_dirs=[], exclude_patterns=[], recursive=True): r""" walks dpath lists returning all directories that match the requested pattern. Args: dpath_list (list): inc...
python
def matching_fpaths(dpath_list, include_patterns, exclude_dirs=[], greater_exclude_dirs=[], exclude_patterns=[], recursive=True): r""" walks dpath lists returning all directories that match the requested pattern. Args: dpath_list (list): inc...
[ "def", "matching_fpaths", "(", "dpath_list", ",", "include_patterns", ",", "exclude_dirs", "=", "[", "]", ",", "greater_exclude_dirs", "=", "[", "]", ",", "exclude_patterns", "=", "[", "]", ",", "recursive", "=", "True", ")", ":", "r", "if", "isinstance", ...
r""" walks dpath lists returning all directories that match the requested pattern. Args: dpath_list (list): include_patterns (str): exclude_dirs (None): recursive (bool): References: # TODO: fix names and behavior of exclude_dirs and greater_exc...
[ "r", "walks", "dpath", "lists", "returning", "all", "directories", "that", "match", "the", "requested", "pattern", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L1608-L1660
train
Erotemic/utool
utool/util_path.py
sed
def sed(regexpr, repl, force=False, recursive=False, dpath_list=None, fpath_list=None, verbose=None, include_patterns=None, exclude_patterns=[]): """ Python implementation of sed. NOT FINISHED searches and replaces text in files Args: regexpr (str): regx patterns to find ...
python
def sed(regexpr, repl, force=False, recursive=False, dpath_list=None, fpath_list=None, verbose=None, include_patterns=None, exclude_patterns=[]): """ Python implementation of sed. NOT FINISHED searches and replaces text in files Args: regexpr (str): regx patterns to find ...
[ "def", "sed", "(", "regexpr", ",", "repl", ",", "force", "=", "False", ",", "recursive", "=", "False", ",", "dpath_list", "=", "None", ",", "fpath_list", "=", "None", ",", "verbose", "=", "None", ",", "include_patterns", "=", "None", ",", "exclude_patter...
Python implementation of sed. NOT FINISHED searches and replaces text in files Args: regexpr (str): regx patterns to find repl (str): text to replace force (bool): recursive (bool): dpath_list (list): directories to search (defaults to cwd)
[ "Python", "implementation", "of", "sed", ".", "NOT", "FINISHED" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L1663-L1723
train
Erotemic/utool
utool/util_path.py
grep
def grep(regex_list, recursive=True, dpath_list=None, include_patterns=None, exclude_dirs=[], greater_exclude_dirs=None, inverse=False, exclude_patterns=[], verbose=VERBOSE, fpath_list=None, reflags=0, cache=None): r""" greps for patterns Python implementation of grep. NOT FINISHE...
python
def grep(regex_list, recursive=True, dpath_list=None, include_patterns=None, exclude_dirs=[], greater_exclude_dirs=None, inverse=False, exclude_patterns=[], verbose=VERBOSE, fpath_list=None, reflags=0, cache=None): r""" greps for patterns Python implementation of grep. NOT FINISHE...
[ "def", "grep", "(", "regex_list", ",", "recursive", "=", "True", ",", "dpath_list", "=", "None", ",", "include_patterns", "=", "None", ",", "exclude_dirs", "=", "[", "]", ",", "greater_exclude_dirs", "=", "None", ",", "inverse", "=", "False", ",", "exclude...
r""" greps for patterns Python implementation of grep. NOT FINISHED Args: regex_list (str or list): one or more patterns to find recursive (bool): dpath_list (list): directories to search (defaults to cwd) include_patterns (list) : defaults to standard file extensions R...
[ "r", "greps", "for", "patterns", "Python", "implementation", "of", "grep", ".", "NOT", "FINISHED" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L1974-L2101
train
Erotemic/utool
utool/util_path.py
get_win32_short_path_name
def get_win32_short_path_name(long_name): """ Gets the short path name of a given long path. References: http://stackoverflow.com/a/23598461/200291 http://stackoverflow.com/questions/23598289/get-win-short-fname-python Example: >>> # DISABLE_DOCTEST >>> from utool.util_...
python
def get_win32_short_path_name(long_name): """ Gets the short path name of a given long path. References: http://stackoverflow.com/a/23598461/200291 http://stackoverflow.com/questions/23598289/get-win-short-fname-python Example: >>> # DISABLE_DOCTEST >>> from utool.util_...
[ "def", "get_win32_short_path_name", "(", "long_name", ")", ":", "import", "ctypes", "from", "ctypes", "import", "wintypes", "_GetShortPathNameW", "=", "ctypes", ".", "windll", ".", "kernel32", ".", "GetShortPathNameW", "_GetShortPathNameW", ".", "argtypes", "=", "["...
Gets the short path name of a given long path. References: http://stackoverflow.com/a/23598461/200291 http://stackoverflow.com/questions/23598289/get-win-short-fname-python Example: >>> # DISABLE_DOCTEST >>> from utool.util_path import * # NOQA >>> import utool as ut ...
[ "Gets", "the", "short", "path", "name", "of", "a", "given", "long", "path", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L2129-L2166
train
Erotemic/utool
utool/util_path.py
platform_path
def platform_path(path): r""" Returns platform specific path for pyinstaller usage Args: path (str): Returns: str: path2 CommandLine: python -m utool.util_path --test-platform_path Example: >>> # ENABLE_DOCTEST >>> # FIXME: find examples of the wird pa...
python
def platform_path(path): r""" Returns platform specific path for pyinstaller usage Args: path (str): Returns: str: path2 CommandLine: python -m utool.util_path --test-platform_path Example: >>> # ENABLE_DOCTEST >>> # FIXME: find examples of the wird pa...
[ "def", "platform_path", "(", "path", ")", ":", "r", "try", ":", "if", "path", "==", "''", ":", "raise", "ValueError", "(", "'path cannot be the empty string'", ")", "path1", "=", "truepath_relative", "(", "path", ")", "if", "sys", ".", "platform", ".", "st...
r""" Returns platform specific path for pyinstaller usage Args: path (str): Returns: str: path2 CommandLine: python -m utool.util_path --test-platform_path Example: >>> # ENABLE_DOCTEST >>> # FIXME: find examples of the wird paths this fixes (mostly on win...
[ "r", "Returns", "platform", "specific", "path", "for", "pyinstaller", "usage" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L2191-L2238
train
Erotemic/utool
utool/util_path.py
find_lib_fpath
def find_lib_fpath(libname, root_dir, recurse_down=True, verbose=False, debug=False): """ Search for the library """ def get_lib_fname_list(libname): """ input <libname>: library name (e.g. 'hesaff', not 'libhesaff') returns <libnames>: list of plausible library file names """ ...
python
def find_lib_fpath(libname, root_dir, recurse_down=True, verbose=False, debug=False): """ Search for the library """ def get_lib_fname_list(libname): """ input <libname>: library name (e.g. 'hesaff', not 'libhesaff') returns <libnames>: list of plausible library file names """ ...
[ "def", "find_lib_fpath", "(", "libname", ",", "root_dir", ",", "recurse_down", "=", "True", ",", "verbose", "=", "False", ",", "debug", "=", "False", ")", ":", "def", "get_lib_fname_list", "(", "libname", ")", ":", "if", "sys", ".", "platform", ".", "sta...
Search for the library
[ "Search", "for", "the", "library" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L2320-L2379
train
Erotemic/utool
utool/util_path.py
ensure_mingw_drive
def ensure_mingw_drive(win32_path): r""" replaces windows drives with mingw style drives Args: win32_path (str): CommandLine: python -m utool.util_path --test-ensure_mingw_drive Example: >>> # DISABLE_DOCTEST >>> from utool.util_path import * # NOQA >>> win32_...
python
def ensure_mingw_drive(win32_path): r""" replaces windows drives with mingw style drives Args: win32_path (str): CommandLine: python -m utool.util_path --test-ensure_mingw_drive Example: >>> # DISABLE_DOCTEST >>> from utool.util_path import * # NOQA >>> win32_...
[ "def", "ensure_mingw_drive", "(", "win32_path", ")", ":", "r", "win32_drive", ",", "_path", "=", "splitdrive", "(", "win32_path", ")", "mingw_drive", "=", "'/'", "+", "win32_drive", "[", ":", "-", "1", "]", ".", "lower", "(", ")", "mingw_path", "=", "min...
r""" replaces windows drives with mingw style drives Args: win32_path (str): CommandLine: python -m utool.util_path --test-ensure_mingw_drive Example: >>> # DISABLE_DOCTEST >>> from utool.util_path import * # NOQA >>> win32_path = r'C:/Program Files/Foobar' ...
[ "r", "replaces", "windows", "drives", "with", "mingw", "style", "drives" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L2382-L2402
train
Erotemic/utool
utool/util_path.py
ancestor_paths
def ancestor_paths(start=None, limit={}): """ All paths above you """ import utool as ut limit = ut.ensure_iterable(limit) limit = {expanduser(p) for p in limit}.union(set(limit)) if start is None: start = os.getcwd() path = start prev = None while path != prev and prev n...
python
def ancestor_paths(start=None, limit={}): """ All paths above you """ import utool as ut limit = ut.ensure_iterable(limit) limit = {expanduser(p) for p in limit}.union(set(limit)) if start is None: start = os.getcwd() path = start prev = None while path != prev and prev n...
[ "def", "ancestor_paths", "(", "start", "=", "None", ",", "limit", "=", "{", "}", ")", ":", "import", "utool", "as", "ut", "limit", "=", "ut", ".", "ensure_iterable", "(", "limit", ")", "limit", "=", "{", "expanduser", "(", "p", ")", "for", "p", "in...
All paths above you
[ "All", "paths", "above", "you" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L2436-L2450
train
Erotemic/utool
utool/util_path.py
search_candidate_paths
def search_candidate_paths(candidate_path_list, candidate_name_list=None, priority_paths=None, required_subpaths=[], verbose=None): """ searches for existing paths that meed a requirement Args: candidate_path_list (list): list of paths to check....
python
def search_candidate_paths(candidate_path_list, candidate_name_list=None, priority_paths=None, required_subpaths=[], verbose=None): """ searches for existing paths that meed a requirement Args: candidate_path_list (list): list of paths to check....
[ "def", "search_candidate_paths", "(", "candidate_path_list", ",", "candidate_name_list", "=", "None", ",", "priority_paths", "=", "None", ",", "required_subpaths", "=", "[", "]", ",", "verbose", "=", "None", ")", ":", "import", "utool", "as", "ut", "if", "verb...
searches for existing paths that meed a requirement Args: candidate_path_list (list): list of paths to check. If candidate_name_list is specified this is the dpath list instead candidate_name_list (list): specifies several names to check (default = None) priority_pat...
[ "searches", "for", "existing", "paths", "that", "meed", "a", "requirement" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L2453-L2525
train
Erotemic/utool
utool/util_path.py
symlink
def symlink(real_path, link_path, overwrite=False, on_error='raise', verbose=2): """ Attempt to create a symbolic link. TODO: Can this be fixed on windows? Args: path (str): path to real file or directory link_path (str): path to desired location for symlink ...
python
def symlink(real_path, link_path, overwrite=False, on_error='raise', verbose=2): """ Attempt to create a symbolic link. TODO: Can this be fixed on windows? Args: path (str): path to real file or directory link_path (str): path to desired location for symlink ...
[ "def", "symlink", "(", "real_path", ",", "link_path", ",", "overwrite", "=", "False", ",", "on_error", "=", "'raise'", ",", "verbose", "=", "2", ")", ":", "path", "=", "normpath", "(", "real_path", ")", "link", "=", "normpath", "(", "link_path", ")", "...
Attempt to create a symbolic link. TODO: Can this be fixed on windows? Args: path (str): path to real file or directory link_path (str): path to desired location for symlink overwrite (bool): overwrite existing symlinks (default = False) on_error (str): strategy for dea...
[ "Attempt", "to", "create", "a", "symbolic", "link", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L2567-L2656
train
Erotemic/utool
utool/util_path.py
remove_broken_links
def remove_broken_links(dpath, verbose=True): """ Removes all broken links in a directory Args: dpath (str): directory path Returns: int: num removed References: http://stackoverflow.com/questions/20794/find-broken-symlinks-with-python CommandLine: python -m ...
python
def remove_broken_links(dpath, verbose=True): """ Removes all broken links in a directory Args: dpath (str): directory path Returns: int: num removed References: http://stackoverflow.com/questions/20794/find-broken-symlinks-with-python CommandLine: python -m ...
[ "def", "remove_broken_links", "(", "dpath", ",", "verbose", "=", "True", ")", ":", "fname_list", "=", "[", "join", "(", "dpath", ",", "fname", ")", "for", "fname", "in", "os", ".", "listdir", "(", "dpath", ")", "]", "broken_links", "=", "list", "(", ...
Removes all broken links in a directory Args: dpath (str): directory path Returns: int: num removed References: http://stackoverflow.com/questions/20794/find-broken-symlinks-with-python CommandLine: python -m utool remove_broken_links:0 Example: >>> # DI...
[ "Removes", "all", "broken", "links", "in", "a", "directory" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L2659-L2707
train
Erotemic/utool
utool/util_path.py
non_existing_path
def non_existing_path(path_, dpath=None, offset=0, suffix=None, force_fmt=False): r""" Searches for and finds a path garuenteed to not exist. Args: path_ (str): path string. If may include a "%" formatstr. dpath (str): directory path(default = None) off...
python
def non_existing_path(path_, dpath=None, offset=0, suffix=None, force_fmt=False): r""" Searches for and finds a path garuenteed to not exist. Args: path_ (str): path string. If may include a "%" formatstr. dpath (str): directory path(default = None) off...
[ "def", "non_existing_path", "(", "path_", ",", "dpath", "=", "None", ",", "offset", "=", "0", ",", "suffix", "=", "None", ",", "force_fmt", "=", "False", ")", ":", "r", "import", "utool", "as", "ut", "from", "os", ".", "path", "import", "basename", "...
r""" Searches for and finds a path garuenteed to not exist. Args: path_ (str): path string. If may include a "%" formatstr. dpath (str): directory path(default = None) offset (int): (default = 0) suffix (None): (default = None) Returns: str: path_ - path string ...
[ "r", "Searches", "for", "and", "finds", "a", "path", "garuenteed", "to", "not", "exist", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L2710-L2779
train
glormph/msstitch
src/app/actions/mslookup/quant.py
create_isobaric_quant_lookup
def create_isobaric_quant_lookup(quantdb, specfn_consensus_els, channelmap): """Creates an sqlite lookup table of scannrs with quant data. spectra - an iterable of tupled (filename, spectra) consensus_els - a iterable with consensusElements""" # store quantchannels in lookup and generate a db_id vs cha...
python
def create_isobaric_quant_lookup(quantdb, specfn_consensus_els, channelmap): """Creates an sqlite lookup table of scannrs with quant data. spectra - an iterable of tupled (filename, spectra) consensus_els - a iterable with consensusElements""" # store quantchannels in lookup and generate a db_id vs cha...
[ "def", "create_isobaric_quant_lookup", "(", "quantdb", ",", "specfn_consensus_els", ",", "channelmap", ")", ":", "channels_store", "=", "(", "(", "name", ",", ")", "for", "name", ",", "c_id", "in", "sorted", "(", "channelmap", ".", "items", "(", ")", ",", ...
Creates an sqlite lookup table of scannrs with quant data. spectra - an iterable of tupled (filename, spectra) consensus_els - a iterable with consensusElements
[ "Creates", "an", "sqlite", "lookup", "table", "of", "scannrs", "with", "quant", "data", "." ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mslookup/quant.py#L9-L34
train
glormph/msstitch
src/app/actions/mslookup/quant.py
get_precursors_from_window
def get_precursors_from_window(quantdb, minmz): """Returns a dict of a specified amount of features from the ms1 quant database, and the highest mz of those features""" featmap = {} mz = False features = quantdb.get_precursor_quant_window(FEATURE_ALIGN_WINDOW_AMOUNT, ...
python
def get_precursors_from_window(quantdb, minmz): """Returns a dict of a specified amount of features from the ms1 quant database, and the highest mz of those features""" featmap = {} mz = False features = quantdb.get_precursor_quant_window(FEATURE_ALIGN_WINDOW_AMOUNT, ...
[ "def", "get_precursors_from_window", "(", "quantdb", ",", "minmz", ")", ":", "featmap", "=", "{", "}", "mz", "=", "False", "features", "=", "quantdb", ".", "get_precursor_quant_window", "(", "FEATURE_ALIGN_WINDOW_AMOUNT", ",", "minmz", ")", "for", "feat_id", ","...
Returns a dict of a specified amount of features from the ms1 quant database, and the highest mz of those features
[ "Returns", "a", "dict", "of", "a", "specified", "amount", "of", "features", "from", "the", "ms1", "quant", "database", "and", "the", "highest", "mz", "of", "those", "features" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mslookup/quant.py#L105-L120
train
glormph/msstitch
src/app/actions/mslookup/quant.py
get_quant_data
def get_quant_data(cons_el): """Gets quant data from consensusXML element""" quant_out = {} for reporter in cons_el.findall('.//element'): quant_out[reporter.attrib['map']] = reporter.attrib['it'] return quant_out
python
def get_quant_data(cons_el): """Gets quant data from consensusXML element""" quant_out = {} for reporter in cons_el.findall('.//element'): quant_out[reporter.attrib['map']] = reporter.attrib['it'] return quant_out
[ "def", "get_quant_data", "(", "cons_el", ")", ":", "quant_out", "=", "{", "}", "for", "reporter", "in", "cons_el", ".", "findall", "(", "'.//element'", ")", ":", "quant_out", "[", "reporter", ".", "attrib", "[", "'map'", "]", "]", "=", "reporter", ".", ...
Gets quant data from consensusXML element
[ "Gets", "quant", "data", "from", "consensusXML", "element" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mslookup/quant.py#L139-L144
train
Erotemic/utool
utool/util_cplat.py
get_plat_specifier
def get_plat_specifier(): """ Standard platform specifier used by distutils """ import setuptools # NOQA import distutils plat_name = distutils.util.get_platform() plat_specifier = ".%s-%s" % (plat_name, sys.version[0:3]) if hasattr(sys, 'gettotalrefcount'): plat_specifier += '-...
python
def get_plat_specifier(): """ Standard platform specifier used by distutils """ import setuptools # NOQA import distutils plat_name = distutils.util.get_platform() plat_specifier = ".%s-%s" % (plat_name, sys.version[0:3]) if hasattr(sys, 'gettotalrefcount'): plat_specifier += '-...
[ "def", "get_plat_specifier", "(", ")", ":", "import", "setuptools", "import", "distutils", "plat_name", "=", "distutils", ".", "util", ".", "get_platform", "(", ")", "plat_specifier", "=", "\".%s-%s\"", "%", "(", "plat_name", ",", "sys", ".", "version", "[", ...
Standard platform specifier used by distutils
[ "Standard", "platform", "specifier", "used", "by", "distutils" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L66-L76
train
Erotemic/utool
utool/util_cplat.py
get_system_python_library
def get_system_python_library(): """ FIXME; hacky way of finding python library. Not cross platform yet. """ import os import utool as ut from os.path import basename, realpath pyname = basename(realpath(sys.executable)) ld_library_path = os.environ['LD_LIBRARY_PATH'] libdirs = [x fo...
python
def get_system_python_library(): """ FIXME; hacky way of finding python library. Not cross platform yet. """ import os import utool as ut from os.path import basename, realpath pyname = basename(realpath(sys.executable)) ld_library_path = os.environ['LD_LIBRARY_PATH'] libdirs = [x fo...
[ "def", "get_system_python_library", "(", ")", ":", "import", "os", "import", "utool", "as", "ut", "from", "os", ".", "path", "import", "basename", ",", "realpath", "pyname", "=", "basename", "(", "realpath", "(", "sys", ".", "executable", ")", ")", "ld_lib...
FIXME; hacky way of finding python library. Not cross platform yet.
[ "FIXME", ";", "hacky", "way", "of", "finding", "python", "library", ".", "Not", "cross", "platform", "yet", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L88-L102
train
Erotemic/utool
utool/util_cplat.py
get_dynlib_dependencies
def get_dynlib_dependencies(lib_path): """ Executes tools for inspecting dynamic library dependencies depending on the current platform. """ if LINUX: ldd_fpath = '/usr/bin/ldd' depend_out, depend_err, ret = cmd(ldd_fpath, lib_path, verbose=False) elif DARWIN: otool_fpath...
python
def get_dynlib_dependencies(lib_path): """ Executes tools for inspecting dynamic library dependencies depending on the current platform. """ if LINUX: ldd_fpath = '/usr/bin/ldd' depend_out, depend_err, ret = cmd(ldd_fpath, lib_path, verbose=False) elif DARWIN: otool_fpath...
[ "def", "get_dynlib_dependencies", "(", "lib_path", ")", ":", "if", "LINUX", ":", "ldd_fpath", "=", "'/usr/bin/ldd'", "depend_out", ",", "depend_err", ",", "ret", "=", "cmd", "(", "ldd_fpath", ",", "lib_path", ",", "verbose", "=", "False", ")", "elif", "DARWI...
Executes tools for inspecting dynamic library dependencies depending on the current platform.
[ "Executes", "tools", "for", "inspecting", "dynamic", "library", "dependencies", "depending", "on", "the", "current", "platform", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L329-L346
train
Erotemic/utool
utool/util_cplat.py
startfile
def startfile(fpath, detatch=True, quote=False, verbose=False, quiet=True): """ Uses default program defined by the system to open a file. References: http://stackoverflow.com/questions/2692873/quote-posix-shell-special-characters-in-python-output """ print('[cplat] startfile(%r)' % fpath) ...
python
def startfile(fpath, detatch=True, quote=False, verbose=False, quiet=True): """ Uses default program defined by the system to open a file. References: http://stackoverflow.com/questions/2692873/quote-posix-shell-special-characters-in-python-output """ print('[cplat] startfile(%r)' % fpath) ...
[ "def", "startfile", "(", "fpath", ",", "detatch", "=", "True", ",", "quote", "=", "False", ",", "verbose", "=", "False", ",", "quiet", "=", "True", ")", ":", "print", "(", "'[cplat] startfile(%r)'", "%", "fpath", ")", "fpath", "=", "normpath", "(", "fp...
Uses default program defined by the system to open a file. References: http://stackoverflow.com/questions/2692873/quote-posix-shell-special-characters-in-python-output
[ "Uses", "default", "program", "defined", "by", "the", "system", "to", "open", "a", "file", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L465-L495
train
Erotemic/utool
utool/util_cplat.py
view_directory
def view_directory(dname=None, fname=None, verbose=True): """ View a directory in the operating system file browser. Currently supports windows explorer, mac open, and linux nautlius. Args: dname (str): directory name fname (str): a filename to select in the directory (nautlius only) ...
python
def view_directory(dname=None, fname=None, verbose=True): """ View a directory in the operating system file browser. Currently supports windows explorer, mac open, and linux nautlius. Args: dname (str): directory name fname (str): a filename to select in the directory (nautlius only) ...
[ "def", "view_directory", "(", "dname", "=", "None", ",", "fname", "=", "None", ",", "verbose", "=", "True", ")", ":", "from", "utool", ".", "util_arg", "import", "STRICT", "from", "utool", ".", "util_path", "import", "checkpath", "if", "HAVE_PATHLIB", "and...
View a directory in the operating system file browser. Currently supports windows explorer, mac open, and linux nautlius. Args: dname (str): directory name fname (str): a filename to select in the directory (nautlius only) verbose (bool): CommandLine: python -m utool.util_c...
[ "View", "a", "directory", "in", "the", "operating", "system", "file", "browser", ".", "Currently", "supports", "windows", "explorer", "mac", "open", "and", "linux", "nautlius", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L544-L622
train
Erotemic/utool
utool/util_cplat.py
platform_cache_dir
def platform_cache_dir(): """ Returns a directory which should be writable for any application This should be used for temporary deletable data. """ if WIN32: # nocover dpath_ = '~/AppData/Local' elif LINUX: # nocover dpath_ = '~/.cache' elif DARWIN: # nocover dpat...
python
def platform_cache_dir(): """ Returns a directory which should be writable for any application This should be used for temporary deletable data. """ if WIN32: # nocover dpath_ = '~/AppData/Local' elif LINUX: # nocover dpath_ = '~/.cache' elif DARWIN: # nocover dpat...
[ "def", "platform_cache_dir", "(", ")", ":", "if", "WIN32", ":", "dpath_", "=", "'~/AppData/Local'", "elif", "LINUX", ":", "dpath_", "=", "'~/.cache'", "elif", "DARWIN", ":", "dpath_", "=", "'~/Library/Caches'", "else", ":", "raise", "NotImplementedError", "(", ...
Returns a directory which should be writable for any application This should be used for temporary deletable data.
[ "Returns", "a", "directory", "which", "should", "be", "writable", "for", "any", "application", "This", "should", "be", "used", "for", "temporary", "deletable", "data", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L633-L647
train
Erotemic/utool
utool/util_cplat.py
__parse_cmd_args
def __parse_cmd_args(args, sudo, shell): """ When shell is True, Popen will only accept strings. No tuples Shell really should not be true. Returns: args suitable for subprocess.Popen I'm not quite sure what those are yet. Plain old string seem to work well? But I remember need...
python
def __parse_cmd_args(args, sudo, shell): """ When shell is True, Popen will only accept strings. No tuples Shell really should not be true. Returns: args suitable for subprocess.Popen I'm not quite sure what those are yet. Plain old string seem to work well? But I remember need...
[ "def", "__parse_cmd_args", "(", "args", ",", "sudo", ",", "shell", ")", ":", "if", "isinstance", "(", "args", ",", "tuple", ")", "and", "len", "(", "args", ")", "==", "1", "and", "isinstance", "(", "args", "[", "0", "]", ",", "tuple", ")", ":", "...
When shell is True, Popen will only accept strings. No tuples Shell really should not be true. Returns: args suitable for subprocess.Popen I'm not quite sure what those are yet. Plain old string seem to work well? But I remember needing shlex at some point. CommandLine: py...
[ "When", "shell", "is", "True", "Popen", "will", "only", "accept", "strings", ".", "No", "tuples", "Shell", "really", "should", "not", "be", "true", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L714-L790
train
Erotemic/utool
utool/util_cplat.py
cmd2
def cmd2(command, shell=False, detatch=False, verbose=False, verbout=None): """ Trying to clean up cmd Args: command (str): string command shell (bool): if True, process is run in shell detatch (bool): if True, process is run in background verbose (int): verbosity mode ...
python
def cmd2(command, shell=False, detatch=False, verbose=False, verbout=None): """ Trying to clean up cmd Args: command (str): string command shell (bool): if True, process is run in shell detatch (bool): if True, process is run in background verbose (int): verbosity mode ...
[ "def", "cmd2", "(", "command", ",", "shell", "=", "False", ",", "detatch", "=", "False", ",", "verbose", "=", "False", ",", "verbout", "=", "None", ")", ":", "import", "shlex", "if", "isinstance", "(", "command", ",", "(", "list", ",", "tuple", ")", ...
Trying to clean up cmd Args: command (str): string command shell (bool): if True, process is run in shell detatch (bool): if True, process is run in background verbose (int): verbosity mode verbout (bool): if True, `command` writes to stdout in realtime. defaults...
[ "Trying", "to", "clean", "up", "cmd" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L1005-L1072
train
Erotemic/utool
utool/util_cplat.py
search_env_paths
def search_env_paths(fname, key_list=None, verbose=None): r""" Searches your PATH to see if fname exists Args: fname (str): file name to search for (can be glob pattern) CommandLine: python -m utool search_env_paths --fname msvcr*.dll python -m utool search_env_paths --fname '*...
python
def search_env_paths(fname, key_list=None, verbose=None): r""" Searches your PATH to see if fname exists Args: fname (str): file name to search for (can be glob pattern) CommandLine: python -m utool search_env_paths --fname msvcr*.dll python -m utool search_env_paths --fname '*...
[ "def", "search_env_paths", "(", "fname", ",", "key_list", "=", "None", ",", "verbose", "=", "None", ")", ":", "r", "import", "utool", "as", "ut", "if", "key_list", "is", "None", ":", "key_list", "=", "[", "key", "for", "key", "in", "os", ".", "enviro...
r""" Searches your PATH to see if fname exists Args: fname (str): file name to search for (can be glob pattern) CommandLine: python -m utool search_env_paths --fname msvcr*.dll python -m utool search_env_paths --fname '*flann*' Example: >>> # DISABLE_DOCTEST >>...
[ "r", "Searches", "your", "PATH", "to", "see", "if", "fname", "exists" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L1187-L1238
train
Erotemic/utool
utool/util_cplat.py
change_term_title
def change_term_title(title): """ only works on unix systems only tested on Ubuntu GNOME changes text on terminal title for identifying debugging tasks. The title will remain until python exists Args: title (str): References: http://stackoverflow.com/questions/5343265/setting-...
python
def change_term_title(title): """ only works on unix systems only tested on Ubuntu GNOME changes text on terminal title for identifying debugging tasks. The title will remain until python exists Args: title (str): References: http://stackoverflow.com/questions/5343265/setting-...
[ "def", "change_term_title", "(", "title", ")", ":", "if", "True", ":", "return", "if", "not", "WIN32", ":", "if", "title", ":", "cmd_str", "=", "r", "+", "title", "+", "os", ".", "system", "(", "cmd_str", ")" ]
only works on unix systems only tested on Ubuntu GNOME changes text on terminal title for identifying debugging tasks. The title will remain until python exists Args: title (str): References: http://stackoverflow.com/questions/5343265/setting-title-for-tabs-in-terminator-console-appli...
[ "only", "works", "on", "unix", "systems", "only", "tested", "on", "Ubuntu", "GNOME", "changes", "text", "on", "terminal", "title", "for", "identifying", "debugging", "tasks", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L1264-L1300
train
Erotemic/utool
utool/util_cplat.py
unload_module
def unload_module(modname): """ WARNING POTENTIALLY DANGEROUS AND MAY NOT WORK References: http://stackoverflow.com/questions/437589/how-do-i-unload-reload-a-python-module CommandLine: python -m utool.util_cplat --test-unload_module Example: >>> # DISABLE_DOCTEST >...
python
def unload_module(modname): """ WARNING POTENTIALLY DANGEROUS AND MAY NOT WORK References: http://stackoverflow.com/questions/437589/how-do-i-unload-reload-a-python-module CommandLine: python -m utool.util_cplat --test-unload_module Example: >>> # DISABLE_DOCTEST >...
[ "def", "unload_module", "(", "modname", ")", ":", "import", "sys", "import", "gc", "if", "modname", "in", "sys", ".", "modules", ":", "referrer_list", "=", "gc", ".", "get_referrers", "(", "sys", ".", "modules", "[", "modname", "]", ")", "for", "referer"...
WARNING POTENTIALLY DANGEROUS AND MAY NOT WORK References: http://stackoverflow.com/questions/437589/how-do-i-unload-reload-a-python-module CommandLine: python -m utool.util_cplat --test-unload_module Example: >>> # DISABLE_DOCTEST >>> import sys, gc # NOQA >>> im...
[ "WARNING", "POTENTIALLY", "DANGEROUS", "AND", "MAY", "NOT", "WORK" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L1450-L1486
train
glormph/msstitch
src/app/actions/shared/pepprot_isoquant.py
base_add_isoquant_data
def base_add_isoquant_data(features, quantfeatures, acc_col, quantacc_col, quantfields): """Generic function that takes a peptide or protein table and adds quant data from ANOTHER such table.""" quant_map = get_quantmap(quantfeatures, quantacc_col, quantfields) for feature in ...
python
def base_add_isoquant_data(features, quantfeatures, acc_col, quantacc_col, quantfields): """Generic function that takes a peptide or protein table and adds quant data from ANOTHER such table.""" quant_map = get_quantmap(quantfeatures, quantacc_col, quantfields) for feature in ...
[ "def", "base_add_isoquant_data", "(", "features", ",", "quantfeatures", ",", "acc_col", ",", "quantacc_col", ",", "quantfields", ")", ":", "quant_map", "=", "get_quantmap", "(", "quantfeatures", ",", "quantacc_col", ",", "quantfields", ")", "for", "feature", "in",...
Generic function that takes a peptide or protein table and adds quant data from ANOTHER such table.
[ "Generic", "function", "that", "takes", "a", "peptide", "or", "protein", "table", "and", "adds", "quant", "data", "from", "ANOTHER", "such", "table", "." ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/shared/pepprot_isoquant.py#L4-L16
train
glormph/msstitch
src/app/actions/shared/pepprot_isoquant.py
get_quantmap
def get_quantmap(features, acc_col, quantfields): """Runs through proteins that are in a quanted protein table, extracts and maps their information based on the quantfields list input. Map is a dict with protein_accessions as keys.""" qmap = {} for feature in features: feat_acc = feature.pop...
python
def get_quantmap(features, acc_col, quantfields): """Runs through proteins that are in a quanted protein table, extracts and maps their information based on the quantfields list input. Map is a dict with protein_accessions as keys.""" qmap = {} for feature in features: feat_acc = feature.pop...
[ "def", "get_quantmap", "(", "features", ",", "acc_col", ",", "quantfields", ")", ":", "qmap", "=", "{", "}", "for", "feature", "in", "features", ":", "feat_acc", "=", "feature", ".", "pop", "(", "acc_col", ")", "qmap", "[", "feat_acc", "]", "=", "{", ...
Runs through proteins that are in a quanted protein table, extracts and maps their information based on the quantfields list input. Map is a dict with protein_accessions as keys.
[ "Runs", "through", "proteins", "that", "are", "in", "a", "quanted", "protein", "table", "extracts", "and", "maps", "their", "information", "based", "on", "the", "quantfields", "list", "input", ".", "Map", "is", "a", "dict", "with", "protein_accessions", "as", ...
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/shared/pepprot_isoquant.py#L19-L27
train
Erotemic/utool
utool/util_gridsearch.py
partition_varied_cfg_list
def partition_varied_cfg_list(cfg_list, default_cfg=None, recursive=False): r""" Separates varied from non-varied parameters in a list of configs TODO: partition nested configs CommandLine: python -m utool.util_gridsearch --exec-partition_varied_cfg_list:0 Example: >>> # ENABLE_DO...
python
def partition_varied_cfg_list(cfg_list, default_cfg=None, recursive=False): r""" Separates varied from non-varied parameters in a list of configs TODO: partition nested configs CommandLine: python -m utool.util_gridsearch --exec-partition_varied_cfg_list:0 Example: >>> # ENABLE_DO...
[ "def", "partition_varied_cfg_list", "(", "cfg_list", ",", "default_cfg", "=", "None", ",", "recursive", "=", "False", ")", ":", "r", "import", "utool", "as", "ut", "if", "default_cfg", "is", "None", ":", "nonvaried_cfg", "=", "reduce", "(", "ut", ".", "dic...
r""" Separates varied from non-varied parameters in a list of configs TODO: partition nested configs CommandLine: python -m utool.util_gridsearch --exec-partition_varied_cfg_list:0 Example: >>> # ENABLE_DOCTEST >>> from utool.util_gridsearch import * # NOQA >>> import...
[ "r", "Separates", "varied", "from", "non", "-", "varied", "parameters", "in", "a", "list", "of", "configs" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_gridsearch.py#L210-L264
train
Erotemic/utool
utool/util_gridsearch.py
get_cfg_lbl
def get_cfg_lbl(cfg, name=None, nonlbl_keys=INTERNAL_CFGKEYS, key_order=None, with_name=True, default_cfg=None, sep=''): r""" Formats a flat configuration dict into a short string label. This is useful for re-creating command line strings. Args: cfg (dict): name (str): (...
python
def get_cfg_lbl(cfg, name=None, nonlbl_keys=INTERNAL_CFGKEYS, key_order=None, with_name=True, default_cfg=None, sep=''): r""" Formats a flat configuration dict into a short string label. This is useful for re-creating command line strings. Args: cfg (dict): name (str): (...
[ "def", "get_cfg_lbl", "(", "cfg", ",", "name", "=", "None", ",", "nonlbl_keys", "=", "INTERNAL_CFGKEYS", ",", "key_order", "=", "None", ",", "with_name", "=", "True", ",", "default_cfg", "=", "None", ",", "sep", "=", "''", ")", ":", "r", "import", "uto...
r""" Formats a flat configuration dict into a short string label. This is useful for re-creating command line strings. Args: cfg (dict): name (str): (default = None) nonlbl_keys (list): (default = INTERNAL_CFGKEYS) Returns: str: cfg_lbl CommandLine: python ...
[ "r", "Formats", "a", "flat", "configuration", "dict", "into", "a", "short", "string", "label", ".", "This", "is", "useful", "for", "re", "-", "creating", "command", "line", "strings", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_gridsearch.py#L267-L356
train
Erotemic/utool
utool/util_gridsearch.py
parse_cfgstr_list2
def parse_cfgstr_list2(cfgstr_list, named_defaults_dict=None, cfgtype=None, alias_keys=None, valid_keys=None, expand_nested=True, strict=True, special_join_dict=None, is_nestedcfgtype=False, metadata=None): r""" Parses config strings. By looki...
python
def parse_cfgstr_list2(cfgstr_list, named_defaults_dict=None, cfgtype=None, alias_keys=None, valid_keys=None, expand_nested=True, strict=True, special_join_dict=None, is_nestedcfgtype=False, metadata=None): r""" Parses config strings. By looki...
[ "def", "parse_cfgstr_list2", "(", "cfgstr_list", ",", "named_defaults_dict", "=", "None", ",", "cfgtype", "=", "None", ",", "alias_keys", "=", "None", ",", "valid_keys", "=", "None", ",", "expand_nested", "=", "True", ",", "strict", "=", "True", ",", "specia...
r""" Parses config strings. By looking up name in a dict of configs Args: cfgstr_list (list): named_defaults_dict (dict): (default = None) cfgtype (None): (default = None) alias_keys (None): (default = None) valid_keys (None): (default = None) expand_nested (bool...
[ "r", "Parses", "config", "strings", ".", "By", "looking", "up", "name", "in", "a", "dict", "of", "configs" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_gridsearch.py#L1078-L1294
train
Erotemic/utool
utool/util_gridsearch.py
grid_search_generator
def grid_search_generator(grid_basis=[], *args, **kwargs): r""" Iteratively yeilds individual configuration points inside a defined basis. Args: grid_basis (list): a list of 2-component tuple. The named tuple looks like this: CommandLine: python -m utool.util_gridsearch...
python
def grid_search_generator(grid_basis=[], *args, **kwargs): r""" Iteratively yeilds individual configuration points inside a defined basis. Args: grid_basis (list): a list of 2-component tuple. The named tuple looks like this: CommandLine: python -m utool.util_gridsearch...
[ "def", "grid_search_generator", "(", "grid_basis", "=", "[", "]", ",", "*", "args", ",", "**", "kwargs", ")", ":", "r", "grid_basis_", "=", "grid_basis", "+", "list", "(", "args", ")", "+", "list", "(", "kwargs", ".", "items", "(", ")", ")", "grid_ba...
r""" Iteratively yeilds individual configuration points inside a defined basis. Args: grid_basis (list): a list of 2-component tuple. The named tuple looks like this: CommandLine: python -m utool.util_gridsearch --test-grid_search_generator Example: >>> # ENABL...
[ "r", "Iteratively", "yeilds", "individual", "configuration", "points", "inside", "a", "defined", "basis", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_gridsearch.py#L1837-L1882
train
Erotemic/utool
utool/util_gridsearch.py
get_cfgdict_list_subset
def get_cfgdict_list_subset(cfgdict_list, keys): r""" returns list of unique dictionaries only with keys specified in keys Args: cfgdict_list (list): keys (list): Returns: list: cfglbl_list CommandLine: python -m utool.util_gridsearch --test-get_cfgdict_list_subset...
python
def get_cfgdict_list_subset(cfgdict_list, keys): r""" returns list of unique dictionaries only with keys specified in keys Args: cfgdict_list (list): keys (list): Returns: list: cfglbl_list CommandLine: python -m utool.util_gridsearch --test-get_cfgdict_list_subset...
[ "def", "get_cfgdict_list_subset", "(", "cfgdict_list", ",", "keys", ")", ":", "r", "import", "utool", "as", "ut", "cfgdict_sublist_", "=", "[", "ut", ".", "dict_subset", "(", "cfgdict", ",", "keys", ")", "for", "cfgdict", "in", "cfgdict_list", "]", "cfgtups_...
r""" returns list of unique dictionaries only with keys specified in keys Args: cfgdict_list (list): keys (list): Returns: list: cfglbl_list CommandLine: python -m utool.util_gridsearch --test-get_cfgdict_list_subset Example: >>> # ENABLE_DOCTEST >...
[ "r", "returns", "list", "of", "unique", "dictionaries", "only", "with", "keys", "specified", "in", "keys" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_gridsearch.py#L1944-L1988
train
Erotemic/utool
utool/util_gridsearch.py
constrain_cfgdict_list
def constrain_cfgdict_list(cfgdict_list_, constraint_func): """ constrains configurations and removes duplicates """ cfgdict_list = [] for cfg_ in cfgdict_list_: cfg = cfg_.copy() if constraint_func(cfg) is not False and len(cfg) > 0: if cfg not in cfgdict_list: c...
python
def constrain_cfgdict_list(cfgdict_list_, constraint_func): """ constrains configurations and removes duplicates """ cfgdict_list = [] for cfg_ in cfgdict_list_: cfg = cfg_.copy() if constraint_func(cfg) is not False and len(cfg) > 0: if cfg not in cfgdict_list: c...
[ "def", "constrain_cfgdict_list", "(", "cfgdict_list_", ",", "constraint_func", ")", ":", "cfgdict_list", "=", "[", "]", "for", "cfg_", "in", "cfgdict_list_", ":", "cfg", "=", "cfg_", ".", "copy", "(", ")", "if", "constraint_func", "(", "cfg", ")", "is", "n...
constrains configurations and removes duplicates
[ "constrains", "configurations", "and", "removes", "duplicates" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_gridsearch.py#L1991-L1999
train
Erotemic/utool
utool/util_gridsearch.py
make_cfglbls
def make_cfglbls(cfgdict_list, varied_dict): """ Show only the text in labels that mater from the cfgdict """ import textwrap wrapper = textwrap.TextWrapper(width=50) cfglbl_list = [] for cfgdict_ in cfgdict_list: cfgdict = cfgdict_.copy() for key in six.iterkeys(cfgdict_): ...
python
def make_cfglbls(cfgdict_list, varied_dict): """ Show only the text in labels that mater from the cfgdict """ import textwrap wrapper = textwrap.TextWrapper(width=50) cfglbl_list = [] for cfgdict_ in cfgdict_list: cfgdict = cfgdict_.copy() for key in six.iterkeys(cfgdict_): ...
[ "def", "make_cfglbls", "(", "cfgdict_list", ",", "varied_dict", ")", ":", "import", "textwrap", "wrapper", "=", "textwrap", ".", "TextWrapper", "(", "width", "=", "50", ")", "cfglbl_list", "=", "[", "]", "for", "cfgdict_", "in", "cfgdict_list", ":", "cfgdict...
Show only the text in labels that mater from the cfgdict
[ "Show", "only", "the", "text", "in", "labels", "that", "mater", "from", "the", "cfgdict" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_gridsearch.py#L2002-L2030
train
Erotemic/utool
utool/util_gridsearch.py
gridsearch_timer
def gridsearch_timer(func_list, args_list, niters=None, **searchkw): """ Times a series of functions on a series of inputs args_list is a list should vary the input sizes can also be a func that take a count param items in args_list list or returned by the func should be a tuple so it can be u...
python
def gridsearch_timer(func_list, args_list, niters=None, **searchkw): """ Times a series of functions on a series of inputs args_list is a list should vary the input sizes can also be a func that take a count param items in args_list list or returned by the func should be a tuple so it can be u...
[ "def", "gridsearch_timer", "(", "func_list", ",", "args_list", ",", "niters", "=", "None", ",", "**", "searchkw", ")", ":", "import", "utool", "as", "ut", "timings", "=", "ut", ".", "ddict", "(", "list", ")", "if", "niters", "is", "None", ":", "niters"...
Times a series of functions on a series of inputs args_list is a list should vary the input sizes can also be a func that take a count param items in args_list list or returned by the func should be a tuple so it can be unpacked CommandLine: python -m ibeis.annotmatch_funcs --exec-get_ann...
[ "Times", "a", "series", "of", "functions", "on", "a", "series", "of", "inputs" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_gridsearch.py#L2120-L2227
train
Thermondo/django-heroku-connect
heroku_connect/utils.py
get_mapping
def get_mapping(version=1, exported_at=None, app_name=None): """ Return Heroku Connect mapping for the entire project. Args: version (int): Version of the Heroku Connect mapping, default: ``1``. exported_at (datetime.datetime): Time the export was created, default is ``now()``. app_...
python
def get_mapping(version=1, exported_at=None, app_name=None): """ Return Heroku Connect mapping for the entire project. Args: version (int): Version of the Heroku Connect mapping, default: ``1``. exported_at (datetime.datetime): Time the export was created, default is ``now()``. app_...
[ "def", "get_mapping", "(", "version", "=", "1", ",", "exported_at", "=", "None", ",", "app_name", "=", "None", ")", ":", "if", "exported_at", "is", "None", ":", "exported_at", "=", "timezone", ".", "now", "(", ")", "app_name", "=", "app_name", "or", "s...
Return Heroku Connect mapping for the entire project. Args: version (int): Version of the Heroku Connect mapping, default: ``1``. exported_at (datetime.datetime): Time the export was created, default is ``now()``. app_name (str): Name of Heroku application associated with Heroku Connect the...
[ "Return", "Heroku", "Connect", "mapping", "for", "the", "entire", "project", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/utils.py#L30-L61
train
Thermondo/django-heroku-connect
heroku_connect/utils.py
get_heroku_connect_models
def get_heroku_connect_models(): """ Return all registered Heroku Connect Models. Returns: (Iterator): All registered models that are subclasses of `.HerokuConnectModel`. Abstract models are excluded, since they are not registered. """ from django.apps import apps ...
python
def get_heroku_connect_models(): """ Return all registered Heroku Connect Models. Returns: (Iterator): All registered models that are subclasses of `.HerokuConnectModel`. Abstract models are excluded, since they are not registered. """ from django.apps import apps ...
[ "def", "get_heroku_connect_models", "(", ")", ":", "from", "django", ".", "apps", "import", "apps", "apps", ".", "check_models_ready", "(", ")", "from", "heroku_connect", ".", "db", ".", "models", "import", "HerokuConnectModel", "return", "(", "model", "for", ...
Return all registered Heroku Connect Models. Returns: (Iterator): All registered models that are subclasses of `.HerokuConnectModel`. Abstract models are excluded, since they are not registered.
[ "Return", "all", "registered", "Heroku", "Connect", "Models", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/utils.py#L64-L84
train
Thermondo/django-heroku-connect
heroku_connect/utils.py
create_heroku_connect_schema
def create_heroku_connect_schema(using=DEFAULT_DB_ALIAS): """ Create Heroku Connect schema. Note: This function is only meant to be used for local development. In a production environment the schema will be created by Heroku Connect. Args: using (str): Alias for databas...
python
def create_heroku_connect_schema(using=DEFAULT_DB_ALIAS): """ Create Heroku Connect schema. Note: This function is only meant to be used for local development. In a production environment the schema will be created by Heroku Connect. Args: using (str): Alias for databas...
[ "def", "create_heroku_connect_schema", "(", "using", "=", "DEFAULT_DB_ALIAS", ")", ":", "connection", "=", "connections", "[", "using", "]", "with", "connection", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor", ".", "execute", "(", "_SCHEMA_EXISTS_QUERY"...
Create Heroku Connect schema. Note: This function is only meant to be used for local development. In a production environment the schema will be created by Heroku Connect. Args: using (str): Alias for database connection. Returns: bool: ``True`` if the schema was c...
[ "Create", "Heroku", "Connect", "schema", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/utils.py#L105-L142
train
Thermondo/django-heroku-connect
heroku_connect/utils.py
get_connections
def get_connections(app): """ Return all Heroku Connect connections setup with the given application. For more details check the link - https://devcenter.heroku.com/articles/heroku-connect-api#step-4-retrieve-the-new-connection-s-id Sample response from the API call is below:: { ...
python
def get_connections(app): """ Return all Heroku Connect connections setup with the given application. For more details check the link - https://devcenter.heroku.com/articles/heroku-connect-api#step-4-retrieve-the-new-connection-s-id Sample response from the API call is below:: { ...
[ "def", "get_connections", "(", "app", ")", ":", "payload", "=", "{", "'app'", ":", "app", "}", "url", "=", "os", ".", "path", ".", "join", "(", "settings", ".", "HEROKU_CONNECT_API_ENDPOINT", ",", "'connections'", ")", "response", "=", "requests", ".", "...
Return all Heroku Connect connections setup with the given application. For more details check the link - https://devcenter.heroku.com/articles/heroku-connect-api#step-4-retrieve-the-new-connection-s-id Sample response from the API call is below:: { "count": 1, "results":[...
[ "Return", "all", "Heroku", "Connect", "connections", "setup", "with", "the", "given", "application", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/utils.py#L151-L186
train
Thermondo/django-heroku-connect
heroku_connect/utils.py
get_connection
def get_connection(connection_id, deep=False): """ Get Heroku Connection connection information. For more details check the link - https://devcenter.heroku.com/articles/heroku-connect-api#step-8-monitor-the-connection-and-mapping-status Sample response from API call is below:: { ...
python
def get_connection(connection_id, deep=False): """ Get Heroku Connection connection information. For more details check the link - https://devcenter.heroku.com/articles/heroku-connect-api#step-8-monitor-the-connection-and-mapping-status Sample response from API call is below:: { ...
[ "def", "get_connection", "(", "connection_id", ",", "deep", "=", "False", ")", ":", "url", "=", "os", ".", "path", ".", "join", "(", "settings", ".", "HEROKU_CONNECT_API_ENDPOINT", ",", "'connections'", ",", "connection_id", ")", "payload", "=", "{", "'deep'...
Get Heroku Connection connection information. For more details check the link - https://devcenter.heroku.com/articles/heroku-connect-api#step-8-monitor-the-connection-and-mapping-status Sample response from API call is below:: { "id": "<connection_id>", "name": "<app_name>...
[ "Get", "Heroku", "Connection", "connection", "information", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/utils.py#L189-L240
train
Thermondo/django-heroku-connect
heroku_connect/utils.py
import_mapping
def import_mapping(connection_id, mapping): """ Import Heroku Connection mapping for given connection. Args: connection_id (str): Heroku Connection connection ID. mapping (dict): Heroku Connect mapping. Raises: requests.HTTPError: If an error occurs uploading the mapping. ...
python
def import_mapping(connection_id, mapping): """ Import Heroku Connection mapping for given connection. Args: connection_id (str): Heroku Connection connection ID. mapping (dict): Heroku Connect mapping. Raises: requests.HTTPError: If an error occurs uploading the mapping. ...
[ "def", "import_mapping", "(", "connection_id", ",", "mapping", ")", ":", "url", "=", "os", ".", "path", ".", "join", "(", "settings", ".", "HEROKU_CONNECT_API_ENDPOINT", ",", "'connections'", ",", "connection_id", ",", "'actions'", ",", "'import'", ")", "respo...
Import Heroku Connection mapping for given connection. Args: connection_id (str): Heroku Connection connection ID. mapping (dict): Heroku Connect mapping. Raises: requests.HTTPError: If an error occurs uploading the mapping. ValueError: If the mapping is not JSON serializable.
[ "Import", "Heroku", "Connection", "mapping", "for", "given", "connection", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/utils.py#L243-L264
train
Thermondo/django-heroku-connect
heroku_connect/utils.py
link_connection_to_account
def link_connection_to_account(app): """ Link the connection to your Heroku user account. https://devcenter.heroku.com/articles/heroku-connect-api#step-3-link-the-connection-to-your-heroku-user-account """ url = os.path.join(settings.HEROKU_CONNECT_API_ENDPOINT, 'users', 'me', 'apps', app, 'auth') ...
python
def link_connection_to_account(app): """ Link the connection to your Heroku user account. https://devcenter.heroku.com/articles/heroku-connect-api#step-3-link-the-connection-to-your-heroku-user-account """ url = os.path.join(settings.HEROKU_CONNECT_API_ENDPOINT, 'users', 'me', 'apps', app, 'auth') ...
[ "def", "link_connection_to_account", "(", "app", ")", ":", "url", "=", "os", ".", "path", ".", "join", "(", "settings", ".", "HEROKU_CONNECT_API_ENDPOINT", ",", "'users'", ",", "'me'", ",", "'apps'", ",", "app", ",", "'auth'", ")", "response", "=", "reques...
Link the connection to your Heroku user account. https://devcenter.heroku.com/articles/heroku-connect-api#step-3-link-the-connection-to-your-heroku-user-account
[ "Link", "the", "connection", "to", "your", "Heroku", "user", "account", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/utils.py#L267-L278
train
glormph/msstitch
src/app/readers/spectra.py
fetch_cvparams_values_from_subel
def fetch_cvparams_values_from_subel(base, subelname, paramnames, ns): """Searches a base element for subelement by name, then takes the cvParams of that subelement and returns the values as a list for the paramnames that match. Value order in list equals input paramnames order.""" sub_el = baseread...
python
def fetch_cvparams_values_from_subel(base, subelname, paramnames, ns): """Searches a base element for subelement by name, then takes the cvParams of that subelement and returns the values as a list for the paramnames that match. Value order in list equals input paramnames order.""" sub_el = baseread...
[ "def", "fetch_cvparams_values_from_subel", "(", "base", ",", "subelname", ",", "paramnames", ",", "ns", ")", ":", "sub_el", "=", "basereader", ".", "find_element_xpath", "(", "base", ",", "subelname", ",", "ns", ")", "cvparams", "=", "get_all_cvparams", "(", "...
Searches a base element for subelement by name, then takes the cvParams of that subelement and returns the values as a list for the paramnames that match. Value order in list equals input paramnames order.
[ "Searches", "a", "base", "element", "for", "subelement", "by", "name", "then", "takes", "the", "cvParams", "of", "that", "subelement", "and", "returns", "the", "values", "as", "a", "list", "for", "the", "paramnames", "that", "match", ".", "Value", "order", ...
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/readers/spectra.py#L39-L49
train
glormph/msstitch
src/app/lookups/sqlite/base.py
DatabaseConnection.create_tables
def create_tables(self, tables): """Creates database tables in sqlite lookup db""" cursor = self.get_cursor() for table in tables: columns = mslookup_tables[table] try: cursor.execute('CREATE TABLE {0}({1})'.format( table, ', '.join(col...
python
def create_tables(self, tables): """Creates database tables in sqlite lookup db""" cursor = self.get_cursor() for table in tables: columns = mslookup_tables[table] try: cursor.execute('CREATE TABLE {0}({1})'.format( table, ', '.join(col...
[ "def", "create_tables", "(", "self", ",", "tables", ")", ":", "cursor", "=", "self", ".", "get_cursor", "(", ")", "for", "table", "in", "tables", ":", "columns", "=", "mslookup_tables", "[", "table", "]", "try", ":", "cursor", ".", "execute", "(", "'CR...
Creates database tables in sqlite lookup db
[ "Creates", "database", "tables", "in", "sqlite", "lookup", "db" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/lookups/sqlite/base.py#L368-L382
train
glormph/msstitch
src/app/lookups/sqlite/base.py
DatabaseConnection.connect
def connect(self, fn): """SQLite connect method initialize db""" self.conn = sqlite3.connect(fn) cur = self.get_cursor() cur.execute('PRAGMA page_size=4096') cur.execute('PRAGMA FOREIGN_KEYS=ON') cur.execute('PRAGMA cache_size=10000') cur.execute('PRAGMA journal_m...
python
def connect(self, fn): """SQLite connect method initialize db""" self.conn = sqlite3.connect(fn) cur = self.get_cursor() cur.execute('PRAGMA page_size=4096') cur.execute('PRAGMA FOREIGN_KEYS=ON') cur.execute('PRAGMA cache_size=10000') cur.execute('PRAGMA journal_m...
[ "def", "connect", "(", "self", ",", "fn", ")", ":", "self", ".", "conn", "=", "sqlite3", ".", "connect", "(", "fn", ")", "cur", "=", "self", ".", "get_cursor", "(", ")", "cur", ".", "execute", "(", "'PRAGMA page_size=4096'", ")", "cur", ".", "execute...
SQLite connect method initialize db
[ "SQLite", "connect", "method", "initialize", "db" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/lookups/sqlite/base.py#L384-L391
train
glormph/msstitch
src/app/lookups/sqlite/base.py
DatabaseConnection.index_column
def index_column(self, index_name, table, column): """Called by interfaces to index specific column in table""" cursor = self.get_cursor() try: cursor.execute( 'CREATE INDEX {0} on {1}({2})'.format(index_name, table, column)) except sqlite3.OperationalError as...
python
def index_column(self, index_name, table, column): """Called by interfaces to index specific column in table""" cursor = self.get_cursor() try: cursor.execute( 'CREATE INDEX {0} on {1}({2})'.format(index_name, table, column)) except sqlite3.OperationalError as...
[ "def", "index_column", "(", "self", ",", "index_name", ",", "table", ",", "column", ")", ":", "cursor", "=", "self", ".", "get_cursor", "(", ")", "try", ":", "cursor", ".", "execute", "(", "'CREATE INDEX {0} on {1}({2})'", ".", "format", "(", "index_name", ...
Called by interfaces to index specific column in table
[ "Called", "by", "interfaces", "to", "index", "specific", "column", "in", "table" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/lookups/sqlite/base.py#L401-L411
train
glormph/msstitch
src/app/lookups/sqlite/base.py
DatabaseConnection.get_sql_select
def get_sql_select(self, columns, table, distinct=False): """Creates and returns an SQL SELECT statement""" sql = 'SELECT {0} {1} FROM {2}' dist = {True: 'DISTINCT', False: ''}[distinct] return sql.format(dist, ', '.join(columns), table)
python
def get_sql_select(self, columns, table, distinct=False): """Creates and returns an SQL SELECT statement""" sql = 'SELECT {0} {1} FROM {2}' dist = {True: 'DISTINCT', False: ''}[distinct] return sql.format(dist, ', '.join(columns), table)
[ "def", "get_sql_select", "(", "self", ",", "columns", ",", "table", ",", "distinct", "=", "False", ")", ":", "sql", "=", "'SELECT {0} {1} FROM {2}'", "dist", "=", "{", "True", ":", "'DISTINCT'", ",", "False", ":", "''", "}", "[", "distinct", "]", "return...
Creates and returns an SQL SELECT statement
[ "Creates", "and", "returns", "an", "SQL", "SELECT", "statement" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/lookups/sqlite/base.py#L417-L421
train
glormph/msstitch
src/app/lookups/sqlite/base.py
DatabaseConnection.store_many
def store_many(self, sql, values): """Abstraction over executemany method""" cursor = self.get_cursor() cursor.executemany(sql, values) self.conn.commit()
python
def store_many(self, sql, values): """Abstraction over executemany method""" cursor = self.get_cursor() cursor.executemany(sql, values) self.conn.commit()
[ "def", "store_many", "(", "self", ",", "sql", ",", "values", ")", ":", "cursor", "=", "self", ".", "get_cursor", "(", ")", "cursor", ".", "executemany", "(", "sql", ",", "values", ")", "self", ".", "conn", ".", "commit", "(", ")" ]
Abstraction over executemany method
[ "Abstraction", "over", "executemany", "method" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/lookups/sqlite/base.py#L423-L427
train
glormph/msstitch
src/app/lookups/sqlite/base.py
DatabaseConnection.execute_sql
def execute_sql(self, sql): """Executes SQL and returns cursor for it""" cursor = self.get_cursor() cursor.execute(sql) return cursor
python
def execute_sql(self, sql): """Executes SQL and returns cursor for it""" cursor = self.get_cursor() cursor.execute(sql) return cursor
[ "def", "execute_sql", "(", "self", ",", "sql", ")", ":", "cursor", "=", "self", ".", "get_cursor", "(", ")", "cursor", ".", "execute", "(", "sql", ")", "return", "cursor" ]
Executes SQL and returns cursor for it
[ "Executes", "SQL", "and", "returns", "cursor", "for", "it" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/lookups/sqlite/base.py#L429-L433
train
glormph/msstitch
src/app/lookups/sqlite/base.py
ResultLookupInterface.get_mzmlfile_map
def get_mzmlfile_map(self): """Returns dict of mzmlfilenames and their db ids""" cursor = self.get_cursor() cursor.execute('SELECT mzmlfile_id, mzmlfilename FROM mzmlfiles') return {fn: fnid for fnid, fn in cursor.fetchall()}
python
def get_mzmlfile_map(self): """Returns dict of mzmlfilenames and their db ids""" cursor = self.get_cursor() cursor.execute('SELECT mzmlfile_id, mzmlfilename FROM mzmlfiles') return {fn: fnid for fnid, fn in cursor.fetchall()}
[ "def", "get_mzmlfile_map", "(", "self", ")", ":", "cursor", "=", "self", ".", "get_cursor", "(", ")", "cursor", ".", "execute", "(", "'SELECT mzmlfile_id, mzmlfilename FROM mzmlfiles'", ")", "return", "{", "fn", ":", "fnid", "for", "fnid", ",", "fn", "in", "...
Returns dict of mzmlfilenames and their db ids
[ "Returns", "dict", "of", "mzmlfilenames", "and", "their", "db", "ids" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/lookups/sqlite/base.py#L440-L444
train
glormph/msstitch
src/app/lookups/sqlite/base.py
ResultLookupInterface.get_spectra_id
def get_spectra_id(self, fn_id, retention_time=None, scan_nr=None): """Returns spectra id for spectra filename and retention time""" cursor = self.get_cursor() sql = 'SELECT spectra_id FROM mzml WHERE mzmlfile_id=? ' values = [fn_id] if retention_time is not None: sql...
python
def get_spectra_id(self, fn_id, retention_time=None, scan_nr=None): """Returns spectra id for spectra filename and retention time""" cursor = self.get_cursor() sql = 'SELECT spectra_id FROM mzml WHERE mzmlfile_id=? ' values = [fn_id] if retention_time is not None: sql...
[ "def", "get_spectra_id", "(", "self", ",", "fn_id", ",", "retention_time", "=", "None", ",", "scan_nr", "=", "None", ")", ":", "cursor", "=", "self", ".", "get_cursor", "(", ")", "sql", "=", "'SELECT spectra_id FROM mzml WHERE mzmlfile_id=? '", "values", "=", ...
Returns spectra id for spectra filename and retention time
[ "Returns", "spectra", "id", "for", "spectra", "filename", "and", "retention", "time" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/lookups/sqlite/base.py#L446-L458
train
Erotemic/utool
utool/experimental/pandas_highlight.py
to_string_monkey
def to_string_monkey(df, highlight_cols=None, latex=False): """ monkey patch to pandas to highlight the maximum value in specified cols of a row Example: >>> from utool.experimental.pandas_highlight import * >>> import pandas as pd >>> df = pd.DataFrame( >>> np.array([[...
python
def to_string_monkey(df, highlight_cols=None, latex=False): """ monkey patch to pandas to highlight the maximum value in specified cols of a row Example: >>> from utool.experimental.pandas_highlight import * >>> import pandas as pd >>> df = pd.DataFrame( >>> np.array([[...
[ "def", "to_string_monkey", "(", "df", ",", "highlight_cols", "=", "None", ",", "latex", "=", "False", ")", ":", "try", ":", "import", "pandas", "as", "pd", "import", "utool", "as", "ut", "import", "numpy", "as", "np", "import", "six", "if", "isinstance",...
monkey patch to pandas to highlight the maximum value in specified cols of a row Example: >>> from utool.experimental.pandas_highlight import * >>> import pandas as pd >>> df = pd.DataFrame( >>> np.array([[ 0.9, 0.86886931, 0.86842073, 0.9 ], >>> ...
[ "monkey", "patch", "to", "pandas", "to", "highlight", "the", "maximum", "value", "in", "specified", "cols", "of", "a", "row" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/pandas_highlight.py#L131-L214
train
neithere/monk
monk/validators.py
translate
def translate(value): """ Translates given schema from "pythonic" syntax to a validator. Usage:: >>> translate(str) IsA(str) >>> translate('hello') IsA(str, default='hello') """ if isinstance(value, BaseValidator): return value if value is None: ...
python
def translate(value): """ Translates given schema from "pythonic" syntax to a validator. Usage:: >>> translate(str) IsA(str) >>> translate('hello') IsA(str, default='hello') """ if isinstance(value, BaseValidator): return value if value is None: ...
[ "def", "translate", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "BaseValidator", ")", ":", "return", "value", "if", "value", "is", "None", ":", "return", "Anything", "(", ")", "if", "isinstance", "(", "value", ",", "type", ")", ":", ...
Translates given schema from "pythonic" syntax to a validator. Usage:: >>> translate(str) IsA(str) >>> translate('hello') IsA(str, default='hello')
[ "Translates", "given", "schema", "from", "pythonic", "syntax", "to", "a", "validator", "." ]
4b2ee5152b081ac288ce8568422a027b5e7d2b1c
https://github.com/neithere/monk/blob/4b2ee5152b081ac288ce8568422a027b5e7d2b1c/monk/validators.py#L699-L753
train
neithere/monk
monk/validators.py
DictOf._merge
def _merge(self, value): """ Returns a dictionary based on `value` with each value recursively merged with `spec`. """ if value is not None and not isinstance(value, dict): # bogus value; will not pass validation but should be preserved return value ...
python
def _merge(self, value): """ Returns a dictionary based on `value` with each value recursively merged with `spec`. """ if value is not None and not isinstance(value, dict): # bogus value; will not pass validation but should be preserved return value ...
[ "def", "_merge", "(", "self", ",", "value", ")", ":", "if", "value", "is", "not", "None", "and", "not", "isinstance", "(", "value", ",", "dict", ")", ":", "return", "value", "if", "not", "self", ".", "_pairs", ":", "return", "{", "}", "collected", ...
Returns a dictionary based on `value` with each value recursively merged with `spec`.
[ "Returns", "a", "dictionary", "based", "on", "value", "with", "each", "value", "recursively", "merged", "with", "spec", "." ]
4b2ee5152b081ac288ce8568422a027b5e7d2b1c
https://github.com/neithere/monk/blob/4b2ee5152b081ac288ce8568422a027b5e7d2b1c/monk/validators.py#L589-L622
train
Erotemic/utool
utool/_internal/win32_send_keys.py
handle_code
def handle_code(code): "Handle a key or sequence of keys in braces" code_keys = [] # it is a known code (e.g. {DOWN}, {ENTER}, etc) if code in CODES: code_keys.append(VirtualKeyAction(CODES[code])) # it is an escaped modifier e.g. {%}, {^}, {+} elif len(code) == 1: code_keys.ap...
python
def handle_code(code): "Handle a key or sequence of keys in braces" code_keys = [] # it is a known code (e.g. {DOWN}, {ENTER}, etc) if code in CODES: code_keys.append(VirtualKeyAction(CODES[code])) # it is an escaped modifier e.g. {%}, {^}, {+} elif len(code) == 1: code_keys.ap...
[ "def", "handle_code", "(", "code", ")", ":", "\"Handle a key or sequence of keys in braces\"", "code_keys", "=", "[", "]", "if", "code", "in", "CODES", ":", "code_keys", ".", "append", "(", "VirtualKeyAction", "(", "CODES", "[", "code", "]", ")", ")", "elif", ...
Handle a key or sequence of keys in braces
[ "Handle", "a", "key", "or", "sequence", "of", "keys", "in", "braces" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/win32_send_keys.py#L478-L523
train
Erotemic/utool
utool/_internal/win32_send_keys.py
parse_keys
def parse_keys(string, with_spaces = False, with_tabs = False, with_newlines = False, modifiers = None): "Return the parsed keys" keys = [] if not modifiers: modifiers = [] index = 0 while index < len(string): c = stri...
python
def parse_keys(string, with_spaces = False, with_tabs = False, with_newlines = False, modifiers = None): "Return the parsed keys" keys = [] if not modifiers: modifiers = [] index = 0 while index < len(string): c = stri...
[ "def", "parse_keys", "(", "string", ",", "with_spaces", "=", "False", ",", "with_tabs", "=", "False", ",", "with_newlines", "=", "False", ",", "modifiers", "=", "None", ")", ":", "\"Return the parsed keys\"", "keys", "=", "[", "]", "if", "not", "modifiers", ...
Return the parsed keys
[ "Return", "the", "parsed", "keys" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/win32_send_keys.py#L526-L614
train
Erotemic/utool
utool/_internal/win32_send_keys.py
SendKeys
def SendKeys(keys, pause=0.05, with_spaces=False, with_tabs=False, with_newlines=False, turn_off_numlock=True): "Parse the keys and type them" keys = parse_keys(keys, with_spaces, with_tabs, with_newlines) for k in keys: k.Run() ...
python
def SendKeys(keys, pause=0.05, with_spaces=False, with_tabs=False, with_newlines=False, turn_off_numlock=True): "Parse the keys and type them" keys = parse_keys(keys, with_spaces, with_tabs, with_newlines) for k in keys: k.Run() ...
[ "def", "SendKeys", "(", "keys", ",", "pause", "=", "0.05", ",", "with_spaces", "=", "False", ",", "with_tabs", "=", "False", ",", "with_newlines", "=", "False", ",", "turn_off_numlock", "=", "True", ")", ":", "\"Parse the keys and type them\"", "keys", "=", ...
Parse the keys and type them
[ "Parse", "the", "keys", "and", "type", "them" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/win32_send_keys.py#L624-L635
train
Erotemic/utool
utool/_internal/win32_send_keys.py
main
def main(): "Send some test strings" actions = """ {LWIN} {PAUSE .25} r {PAUSE .25} Notepad.exe{ENTER} {PAUSE 1} Hello{SPACE}World! {PAUSE 1} %{F4} {PAUSE .25} n """ SendKeys(actions, pause = .1) keys = par...
python
def main(): "Send some test strings" actions = """ {LWIN} {PAUSE .25} r {PAUSE .25} Notepad.exe{ENTER} {PAUSE 1} Hello{SPACE}World! {PAUSE 1} %{F4} {PAUSE .25} n """ SendKeys(actions, pause = .1) keys = par...
[ "def", "main", "(", ")", ":", "\"Send some test strings\"", "actions", "=", "SendKeys", "(", "actions", ",", "pause", "=", ".1", ")", "keys", "=", "parse_keys", "(", "actions", ")", "for", "k", "in", "keys", ":", "print", "(", "k", ")", "k", ".", "Ru...
Send some test strings
[ "Send", "some", "test", "strings" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/win32_send_keys.py#L638-L688
train
Erotemic/utool
utool/_internal/win32_send_keys.py
KeyAction.GetInput
def GetInput(self): "Build the INPUT structure for the action" actions = 1 # if both up and down if self.up and self.down: actions = 2 inputs = (INPUT * actions)() vk, scan, flags = self._get_key_info() for inp in inputs: inp.type = INPU...
python
def GetInput(self): "Build the INPUT structure for the action" actions = 1 # if both up and down if self.up and self.down: actions = 2 inputs = (INPUT * actions)() vk, scan, flags = self._get_key_info() for inp in inputs: inp.type = INPU...
[ "def", "GetInput", "(", "self", ")", ":", "\"Build the INPUT structure for the action\"", "actions", "=", "1", "if", "self", ".", "up", "and", "self", ".", "down", ":", "actions", "=", "2", "inputs", "=", "(", "INPUT", "*", "actions", ")", "(", ")", "vk"...
Build the INPUT structure for the action
[ "Build", "the", "INPUT", "structure", "for", "the", "action" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/win32_send_keys.py#L312-L334
train
Erotemic/utool
utool/_internal/win32_send_keys.py
KeyAction.Run
def Run(self): "Execute the action" inputs = self.GetInput() return SendInput( len(inputs), ctypes.byref(inputs), ctypes.sizeof(INPUT))
python
def Run(self): "Execute the action" inputs = self.GetInput() return SendInput( len(inputs), ctypes.byref(inputs), ctypes.sizeof(INPUT))
[ "def", "Run", "(", "self", ")", ":", "\"Execute the action\"", "inputs", "=", "self", ".", "GetInput", "(", ")", "return", "SendInput", "(", "len", "(", "inputs", ")", ",", "ctypes", ".", "byref", "(", "inputs", ")", ",", "ctypes", ".", "sizeof", "(", ...
Execute the action
[ "Execute", "the", "action" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/win32_send_keys.py#L336-L342
train
Erotemic/utool
utool/_internal/win32_send_keys.py
KeyAction._get_down_up_string
def _get_down_up_string(self): """Return a string that will show whether the string is up or down return 'down' if the key is a press only return 'up' if the key is up only return '' if the key is up & down (as default) """ down_up = "" if not (self.down and self...
python
def _get_down_up_string(self): """Return a string that will show whether the string is up or down return 'down' if the key is a press only return 'up' if the key is up only return '' if the key is up & down (as default) """ down_up = "" if not (self.down and self...
[ "def", "_get_down_up_string", "(", "self", ")", ":", "down_up", "=", "\"\"", "if", "not", "(", "self", ".", "down", "and", "self", ".", "up", ")", ":", "if", "self", ".", "down", ":", "down_up", "=", "\"down\"", "elif", "self", ".", "up", ":", "dow...
Return a string that will show whether the string is up or down return 'down' if the key is a press only return 'up' if the key is up only return '' if the key is up & down (as default)
[ "Return", "a", "string", "that", "will", "show", "whether", "the", "string", "is", "up", "or", "down" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/win32_send_keys.py#L344-L357
train