repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
Erotemic/utool
utool/util_cache.py
tryload_cache_list
def tryload_cache_list(dpath, fname, cfgstr_list, verbose=False): """ loads a list of similar cached datas. Returns flags that needs to be computed """ data_list = [tryload_cache(dpath, fname, cfgstr, verbose) for cfgstr in cfgstr_list] ismiss_list = [data is None for data in data_list] return d...
python
def tryload_cache_list(dpath, fname, cfgstr_list, verbose=False): """ loads a list of similar cached datas. Returns flags that needs to be computed """ data_list = [tryload_cache(dpath, fname, cfgstr, verbose) for cfgstr in cfgstr_list] ismiss_list = [data is None for data in data_list] return d...
[ "def", "tryload_cache_list", "(", "dpath", ",", "fname", ",", "cfgstr_list", ",", "verbose", "=", "False", ")", ":", "data_list", "=", "[", "tryload_cache", "(", "dpath", ",", "fname", ",", "cfgstr", ",", "verbose", ")", "for", "cfgstr", "in", "cfgstr_list...
loads a list of similar cached datas. Returns flags that needs to be computed
[ "loads", "a", "list", "of", "similar", "cached", "datas", ".", "Returns", "flags", "that", "needs", "to", "be", "computed" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L274-L280
train
Loads a list of similar cached datas. Returns a list of similar cached datas. Returns a list of ismiss_list.
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", ")", ":", "# Load precomputed values", "if", "use_cache", "is", "False", ":", "data_list", "=", "[", "None", "]", "...
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
Try to load data from a list of CFG strings and compute it if it can t give a compute function.
Erotemic/utool
utool/util_cache.py
make_utool_json_encoder
def make_utool_json_encoder(allow_pickle=False): """ References: http://stackoverflow.com/questions/8230315/python-sets-are http://stackoverflow.com/questions/11561932/why-does-json https://github.com/jsonpickle/jsonpickle http://stackoverflow.com/questions/24369666/typeerror-b1 ...
python
def make_utool_json_encoder(allow_pickle=False): """ References: http://stackoverflow.com/questions/8230315/python-sets-are http://stackoverflow.com/questions/11561932/why-does-json https://github.com/jsonpickle/jsonpickle http://stackoverflow.com/questions/24369666/typeerror-b1 ...
[ "def", "make_utool_json_encoder", "(", "allow_pickle", "=", "False", ")", ":", "import", "utool", "as", "ut", "PYOBJECT_TAG", "=", "'__PYTHON_OBJECT__'", "UUID_TAG", "=", "'__UUID__'", "SLICE_TAG", "=", "'__SLICE__'", "def", "decode_pickle", "(", "text", ")", ":",...
References: http://stackoverflow.com/questions/8230315/python-sets-are http://stackoverflow.com/questions/11561932/why-does-json https://github.com/jsonpickle/jsonpickle http://stackoverflow.com/questions/24369666/typeerror-b1 http://stackoverflow.com/questions/30469575/how-to-pi...
[ "References", ":", "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "8230315", "/", "python", "-", "sets", "-", "are", "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "11561932", "/", "why", "-", "does", "-"...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L425-L529
train
Make a json encoder for the current utool object
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", ")", ":", "UtoolJSONEncoder", "=", "make_utool_json_encoder", "(", "allow_pickle", ")", "json_kw", "=", "{", "}", "json_kw", "[", "'cls'", "]", "=", "UtoolJSONEncod...
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
r Converts a python object to a JSON string using the utool convention
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
Returns a utool object specified in the utool convention
Erotemic/utool
utool/util_cache.py
get_func_result_cachekey
def get_func_result_cachekey(func_, args_=tuple(), kwargs_={}): """ TODO: recursive partial definitions kwargs = {} args = ([],) """ import utool as ut # Rectify partials and whatnot true_args = args_ true_kwargs = kwargs_ true_func = func_ if isinstance(func_, partial): ...
python
def get_func_result_cachekey(func_, args_=tuple(), kwargs_={}): """ TODO: recursive partial definitions kwargs = {} args = ([],) """ import utool as ut # Rectify partials and whatnot true_args = args_ true_kwargs = kwargs_ true_func = func_ if isinstance(func_, partial): ...
[ "def", "get_func_result_cachekey", "(", "func_", ",", "args_", "=", "tuple", "(", ")", ",", "kwargs_", "=", "{", "}", ")", ":", "import", "utool", "as", "ut", "# Rectify partials and whatnot", "true_args", "=", "args_", "true_kwargs", "=", "kwargs_", "true_fun...
TODO: recursive partial definitions kwargs = {} args = ([],)
[ "TODO", ":", "recursive", "partial", "definitions", "kwargs", "=", "{}", "args", "=", "(", "[]", ")" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L637-L675
train
This function returns the cachekey for the function result
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
Return a string representation of an object as a cache string.
Erotemic/utool
utool/util_cache.py
get_cfgstr_from_args
def get_cfgstr_from_args(func, args, kwargs, key_argx, key_kwds, kwdefaults, argnames, use_hash=None): """ Dev: argx = ['fdsf', '432443432432', 43423432, 'fdsfsd', 3.2, True] memlist = list(map(cachestr_repr, argx)) Ignore: argx = key_argx[0] argval ...
python
def get_cfgstr_from_args(func, args, kwargs, key_argx, key_kwds, kwdefaults, argnames, use_hash=None): """ Dev: argx = ['fdsf', '432443432432', 43423432, 'fdsfsd', 3.2, True] memlist = list(map(cachestr_repr, argx)) Ignore: argx = key_argx[0] argval ...
[ "def", "get_cfgstr_from_args", "(", "func", ",", "args", ",", "kwargs", ",", "key_argx", ",", "key_kwds", ",", "kwdefaults", ",", "argnames", ",", "use_hash", "=", "None", ")", ":", "#try:", "#fmt_str = '%s(%s)'", "import", "utool", "as", "ut", "hashstr_", "...
Dev: argx = ['fdsf', '432443432432', 43423432, 'fdsfsd', 3.2, True] memlist = list(map(cachestr_repr, argx)) Ignore: argx = key_argx[0] argval = args[argx] val = argval %timeit repr(argval) %timeit to_json(argval) %timeit utool.hashstr(to_json(argval)...
[ "Dev", ":", "argx", "=", "[", "fdsf", "432443432432", "43423432", "fdsfsd", "3", ".", "2", "True", "]", "memlist", "=", "list", "(", "map", "(", "cachestr_repr", "argx", "))" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L694-L775
train
This function returns a CFG string from the given arguments.
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", ")", ":", "if",...
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
r A wrapper for ut. cached_func that returns a Cacher object that uses a hash of arguments as input
Erotemic/utool
utool/util_cache.py
get_global_cache_dir
def get_global_cache_dir(appname='default', ensure=False): """ Returns (usually) writable directory for an application cache """ if appname is None or appname == 'default': appname = get_default_appname() global_cache_dir = util_cplat.get_app_resource_dir(appname, ...
python
def get_global_cache_dir(appname='default', ensure=False): """ Returns (usually) writable directory for an application cache """ if appname is None or appname == 'default': appname = get_default_appname() global_cache_dir = util_cplat.get_app_resource_dir(appname, ...
[ "def", "get_global_cache_dir", "(", "appname", "=", "'default'", ",", "ensure", "=", "False", ")", ":", "if", "appname", "is", "None", "or", "appname", "==", "'default'", ":", "appname", "=", "get_default_appname", "(", ")", "global_cache_dir", "=", "util_cpla...
Returns (usually) writable directory for an application cache
[ "Returns", "(", "usually", ")", "writable", "directory", "for", "an", "application", "cache" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L895-L903
train
Returns the directory where the application cache is stored.
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
Returns the filepath to the global shelf
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
Writes a value to a safe place in each operating system s cache files.
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'", ")", ":", "#close_global_shelf(appname)", "shelf_fpath", "=", "get_global_shelf_fpath", "(", "appname", ")", "util_path", ".", "remove_file", "(", "shelf_fpath", ",", "verbose", "=", "True", ",", "dryru...
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
Reads and deletes the global cache files to a safe place in each operating system
Erotemic/utool
utool/util_cache.py
get_lru_cache
def get_lru_cache(max_size=5): """ Args: max_size (int): References: https://github.com/amitdev/lru-dict CommandLine: python -m utool.util_cache --test-get_lru_cache Example: >>> # DISABLE_DOCTEST >>> # UNSTABLE_DOCTEST >>> from utool.util_cache imp...
python
def get_lru_cache(max_size=5): """ Args: max_size (int): References: https://github.com/amitdev/lru-dict CommandLine: python -m utool.util_cache --test-get_lru_cache Example: >>> # DISABLE_DOCTEST >>> # UNSTABLE_DOCTEST >>> from utool.util_cache imp...
[ "def", "get_lru_cache", "(", "max_size", "=", "5", ")", ":", "USE_C_LRU", "=", "False", "if", "USE_C_LRU", ":", "import", "lru", "cache_obj", "=", "lru", ".", "LRU", "(", "max_size", ")", "else", ":", "cache_obj", "=", "LRUDict", "(", "max_size", ")", ...
Args: max_size (int): References: https://github.com/amitdev/lru-dict CommandLine: python -m utool.util_cache --test-get_lru_cache Example: >>> # DISABLE_DOCTEST >>> # UNSTABLE_DOCTEST >>> from utool.util_cache import * # NOQA >>> import utool as u...
[ "Args", ":", "max_size", "(", "int", ")", ":" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L1172-L1208
train
Get a LRU cache of the given size
Erotemic/utool
utool/util_cache.py
time_different_diskstores
def time_different_diskstores(): """ %timeit shelf_write_test() # 15.1 ms per loop %timeit cPickle_write_test() # 1.26 ms per loop %timeit shelf_read_test() # 8.77 ms per loop %timeit cPickle_read_test() # 2.4 ms per loop %timeit cPickle_read_test2() # 2.35 ms per loop %timeit j...
python
def time_different_diskstores(): """ %timeit shelf_write_test() # 15.1 ms per loop %timeit cPickle_write_test() # 1.26 ms per loop %timeit shelf_read_test() # 8.77 ms per loop %timeit cPickle_read_test() # 2.4 ms per loop %timeit cPickle_read_test2() # 2.35 ms per loop %timeit j...
[ "def", "time_different_diskstores", "(", ")", ":", "import", "utool", "as", "ut", "import", "simplejson", "as", "json", "shelf_path", "=", "'test.shelf'", "json_path", "=", "'test.json'", "cpkl_path", "=", "'test.pkl'", "size", "=", "1000", "dict_", "=", "{", ...
%timeit shelf_write_test() # 15.1 ms per loop %timeit cPickle_write_test() # 1.26 ms per loop %timeit shelf_read_test() # 8.77 ms per loop %timeit cPickle_read_test() # 2.4 ms per loop %timeit cPickle_read_test2() # 2.35 ms per loop %timeit json_read_test() %timeit json_write_test()
[ "%timeit", "shelf_write_test", "()", "#", "15", ".", "1", "ms", "per", "loop", "%timeit", "cPickle_write_test", "()", "#", "1", ".", "26", "ms", "per", "loop" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L1317-L1373
train
Time different diskstores.
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
Returns data with different cfgstr values that were previously computed with this cacher.
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
Like load but returns None if the load fails
Erotemic/utool
utool/util_cache.py
Cachable.get_fpath
def get_fpath(self, cachedir=None, cfgstr=None, ext=None): """ Ignore: fname = _fname cfgstr = _cfgstr """ _dpath = self.get_cachedir(cachedir) _fname = self.get_prefix() _cfgstr = self.get_cfgstr() if cfgstr is None else cfgstr _ext = se...
python
def get_fpath(self, cachedir=None, cfgstr=None, ext=None): """ Ignore: fname = _fname cfgstr = _cfgstr """ _dpath = self.get_cachedir(cachedir) _fname = self.get_prefix() _cfgstr = self.get_cfgstr() if cfgstr is None else cfgstr _ext = se...
[ "def", "get_fpath", "(", "self", ",", "cachedir", "=", "None", ",", "cfgstr", "=", "None", ",", "ext", "=", "None", ")", ":", "_dpath", "=", "self", ".", "get_cachedir", "(", "cachedir", ")", "_fname", "=", "self", ".", "get_prefix", "(", ")", "_cfgs...
Ignore: fname = _fname cfgstr = _cfgstr
[ "Ignore", ":", "fname", "=", "_fname", "cfgstr", "=", "_cfgstr" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L1036-L1047
train
Get the full path of the cache file.
Erotemic/utool
utool/util_cache.py
Cachable.delete
def delete(self, cachedir=None, cfgstr=None, verbose=True or VERBOSE or util_arg.VERBOSE): """ saves query result to directory """ fpath = self.get_fpath(cachedir, cfgstr=cfgstr) if verbose: print('[Cachable] cache delete: %r' % (basename(fpath),)) os.remove(f...
python
def delete(self, cachedir=None, cfgstr=None, verbose=True or VERBOSE or util_arg.VERBOSE): """ saves query result to directory """ fpath = self.get_fpath(cachedir, cfgstr=cfgstr) if verbose: print('[Cachable] cache delete: %r' % (basename(fpath),)) os.remove(f...
[ "def", "delete", "(", "self", ",", "cachedir", "=", "None", ",", "cfgstr", "=", "None", ",", "verbose", "=", "True", "or", "VERBOSE", "or", "util_arg", ".", "VERBOSE", ")", ":", "fpath", "=", "self", ".", "get_fpath", "(", "cachedir", ",", "cfgstr", ...
saves query result to directory
[ "saves", "query", "result", "to", "directory" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L1049-L1056
train
Delete the cache entry.
Erotemic/utool
utool/util_cache.py
Cachable.save
def save(self, cachedir=None, cfgstr=None, verbose=VERBOSE, quiet=QUIET, ignore_keys=None): """ saves query result to directory """ fpath = self.get_fpath(cachedir, cfgstr=cfgstr) if verbose: print('[Cachable] cache save: %r' % (basename(fpath),)) ...
python
def save(self, cachedir=None, cfgstr=None, verbose=VERBOSE, quiet=QUIET, ignore_keys=None): """ saves query result to directory """ fpath = self.get_fpath(cachedir, cfgstr=cfgstr) if verbose: print('[Cachable] cache save: %r' % (basename(fpath),)) ...
[ "def", "save", "(", "self", ",", "cachedir", "=", "None", ",", "cfgstr", "=", "None", ",", "verbose", "=", "VERBOSE", ",", "quiet", "=", "QUIET", ",", "ignore_keys", "=", "None", ")", ":", "fpath", "=", "self", ".", "get_fpath", "(", "cachedir", ",",...
saves query result to directory
[ "saves", "query", "result", "to", "directory" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L1059-L1081
train
Saves the current state of the object to a file.
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", "(", "v...
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
Try and load from a partially specified configuration string
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
Loads the result from the given database and returns the object.
Erotemic/utool
utool/util_path.py
ensure_ext
def ensure_ext(fpath, ext, replace=False): r""" Args: fpath (str): file name or path ext (str or list): valid extensions replace (bool): if true all other extensions are removed. this removes all nonstarting characters including and after the first period. Other...
python
def ensure_ext(fpath, ext, replace=False): r""" Args: fpath (str): file name or path ext (str or list): valid extensions replace (bool): if true all other extensions are removed. this removes all nonstarting characters including and after the first period. Other...
[ "def", "ensure_ext", "(", "fpath", ",", "ext", ",", "replace", "=", "False", ")", ":", "import", "utool", "as", "ut", "dpath", ",", "fname", "=", "split", "(", "fpath", ")", "fname_", "=", "fname", ".", "lstrip", "(", "'.'", ")", "n_leading_dots", "=...
r""" Args: fpath (str): file name or path ext (str or list): valid extensions replace (bool): if true all other extensions are removed. this removes all nonstarting characters including and after the first period. Otherwise only the trailing extension is kept R...
[ "r", "Args", ":", "fpath", "(", "str", ")", ":", "file", "name", "or", "path", "ext", "(", "str", "or", "list", ")", ":", "valid", "extensions", "replace", "(", "bool", ")", ":", "if", "true", "all", "other", "extensions", "are", "removed", ".", "t...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L59-L102
train
r This function will ensure that the file name or path is in the specified extensions.
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
Normalizes and returns absolute path with so specs
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
Returns the last n directories in a file.
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", ")", ":", "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
r Removes home directory from path
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", ")", ":", "if", "not", "isinstance", "(", "path_", ",", "six", ".", "string_types", ")", ":", "# Probably given a...
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
r Splits a path into n top - level directories
Erotemic/utool
utool/util_path.py
remove_file
def remove_file(fpath, verbose=None, ignore_errors=True, dryrun=False, quiet=QUIET): """ Removes a file """ if verbose is None: verbose = not quiet if dryrun: if verbose: print('[util_path] Dryrem %r' % fpath) return else: try: os.r...
python
def remove_file(fpath, verbose=None, ignore_errors=True, dryrun=False, quiet=QUIET): """ Removes a file """ if verbose is None: verbose = not quiet if dryrun: if verbose: print('[util_path] Dryrem %r' % fpath) return else: try: os.r...
[ "def", "remove_file", "(", "fpath", ",", "verbose", "=", "None", ",", "ignore_errors", "=", "True", ",", "dryrun", "=", "False", ",", "quiet", "=", "QUIET", ")", ":", "if", "verbose", "is", "None", ":", "verbose", "=", "not", "quiet", "if", "dryrun", ...
Removes a file
[ "Removes", "a", "file" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L237-L257
train
Removes a file from the nunjucks tree.
Erotemic/utool
utool/util_path.py
remove_dirs
def remove_dirs(dpath, verbose=None, ignore_errors=True, dryrun=False, quiet=QUIET): r""" Recursively removes a single directory (need to change function name) DEPRICATE Args: dpath (str): directory path dryrun (bool): (default = False) ignore_errors (bool): (d...
python
def remove_dirs(dpath, verbose=None, ignore_errors=True, dryrun=False, quiet=QUIET): r""" Recursively removes a single directory (need to change function name) DEPRICATE Args: dpath (str): directory path dryrun (bool): (default = False) ignore_errors (bool): (d...
[ "def", "remove_dirs", "(", "dpath", ",", "verbose", "=", "None", ",", "ignore_errors", "=", "True", ",", "dryrun", "=", "False", ",", "quiet", "=", "QUIET", ")", ":", "if", "verbose", "is", "None", ":", "verbose", "=", "not", "quiet", "if", "verbose", ...
r""" Recursively removes a single directory (need to change function name) DEPRICATE Args: dpath (str): directory path dryrun (bool): (default = False) ignore_errors (bool): (default = True) quiet (bool): (default = False) Returns: bool: False CommandLine...
[ "r", "Recursively", "removes", "a", "single", "directory", "(", "need", "to", "change", "function", "name", ")" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L260-L303
train
r Recursively removes a single directory
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
Augments end of path before the extension.
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
Removes files matching a pattern from a directory.
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
Removes a file directory or symlink from the tree tree.
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
remove existing file paths
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
Removes multiple file paths in a single tree tree
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", ")", ":", "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
r Returns the longest root of _path that exists
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_", ")", ":", "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
r Returns if a path is a file directory link or mount
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", ")", ":", "assert", "isinstance", "(", "path_", ",", "six", ".", "string_types", ")", ",", "(", "'path_=%r is not a string. type(pat...
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
r Tests if a path exists on the filesystem show only the top n directories
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
Ensures that path_ is a valid directory.
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", ")", ":", "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
r Ensures that the directory exists. creates new dir with sticky bits by Taxonomy default.
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", ")", ":", "try", ":", "if", "verbose", ":", "print", "(", "'[util_path] touching %r'", "%", "fpath", ")", "with", "open", "(", "fpath", ",", "'a'", ")", ":", "os", ...
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
r Creates file if it does not exist
Erotemic/utool
utool/util_path.py
copy_files_to
def copy_files_to(src_fpath_list, dst_dpath=None, dst_fpath_list=None, overwrite=False, verbose=True, veryverbose=False): """ parallel copier Example: >>> # DISABLE_DOCTEST >>> from utool.util_path import * >>> import utool as ut >>> overwrite = False ...
python
def copy_files_to(src_fpath_list, dst_dpath=None, dst_fpath_list=None, overwrite=False, verbose=True, veryverbose=False): """ parallel copier Example: >>> # DISABLE_DOCTEST >>> from utool.util_path import * >>> import utool as ut >>> overwrite = False ...
[ "def", "copy_files_to", "(", "src_fpath_list", ",", "dst_dpath", "=", "None", ",", "dst_fpath_list", "=", "None", ",", "overwrite", "=", "False", ",", "verbose", "=", "True", ",", "veryverbose", "=", "False", ")", ":", "from", "utool", "import", "util_list",...
parallel copier Example: >>> # DISABLE_DOCTEST >>> from utool.util_path import * >>> import utool as ut >>> overwrite = False >>> veryverbose = False >>> verbose = True >>> src_fpath_list = [ut.grab_test_imgpath(key) >>> for key in u...
[ "parallel", "copier" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L720-L775
train
Copy files from one list to another.
Erotemic/utool
utool/util_path.py
copy_single
def copy_single(src, dst, overwrite=True, verbose=True, deeplink=True, dryrun=False): r""" Args: src (str): file or directory to copy dst (str): directory or new file to copy to Copies src file or folder to dst. If src is a folder this copy is recursive. """ try...
python
def copy_single(src, dst, overwrite=True, verbose=True, deeplink=True, dryrun=False): r""" Args: src (str): file or directory to copy dst (str): directory or new file to copy to Copies src file or folder to dst. If src is a folder this copy is recursive. """ try...
[ "def", "copy_single", "(", "src", ",", "dst", ",", "overwrite", "=", "True", ",", "verbose", "=", "True", ",", "deeplink", "=", "True", ",", "dryrun", "=", "False", ")", ":", "try", ":", "if", "exists", "(", "src", ")", ":", "if", "not", "isdir", ...
r""" Args: src (str): file or directory to copy dst (str): directory or new file to copy to Copies src file or folder to dst. If src is a folder this copy is recursive.
[ "r", "Args", ":", "src", "(", "str", ")", ":", "file", "or", "directory", "to", "copy", "dst", "(", "str", ")", ":", "directory", "or", "new", "file", "to", "copy", "to" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L793-L847
train
r Copy a single file or folder to another file or folder.
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", ")", ":", "# Feb - 6 - 2014 Copy function", "task_iter", "=", "zip", "(", "src...
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
Copy a list of files to another list.
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
r glob - globs the directory tree for a specific pattern
Erotemic/utool
utool/util_path.py
iglob
def iglob(dpath, pattern=None, recursive=False, with_files=True, with_dirs=True, maxdepth=None, exclude_dirs=[], fullpath=True, **kwargs): r""" Iteratively globs directory for pattern FIXME: This function has a speed issue Args: dpath (str): directory path pattern (s...
python
def iglob(dpath, pattern=None, recursive=False, with_files=True, with_dirs=True, maxdepth=None, exclude_dirs=[], fullpath=True, **kwargs): r""" Iteratively globs directory for pattern FIXME: This function has a speed issue Args: dpath (str): directory path pattern (s...
[ "def", "iglob", "(", "dpath", ",", "pattern", "=", "None", ",", "recursive", "=", "False", ",", "with_files", "=", "True", ",", "with_dirs", "=", "True", ",", "maxdepth", "=", "None", ",", "exclude_dirs", "=", "[", "]", ",", "fullpath", "=", "True", ...
r""" Iteratively globs directory for pattern FIXME: This function has a speed issue Args: dpath (str): directory path pattern (str): recursive (bool): (default = False) with_files (bool): (default = True) with_dirs (bool): (default = True) maxdepth ...
[ "r", "Iteratively", "globs", "directory", "for", "pattern" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L1027-L1145
train
r globs the directory tree for the specified pattern
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
returns the number of images in a directory
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
returns true if the filename has any of the given extensions
Erotemic/utool
utool/util_path.py
dirsplit
def dirsplit(path): r""" Args: path (str): Returns: list: components of the path CommandLine: python -m utool.util_path --exec-dirsplit Example: >>> # DISABLE_DOCTEST >>> from utool.util_path import * # NOQA >>> paths = [] >>> paths.append(...
python
def dirsplit(path): r""" Args: path (str): Returns: list: components of the path CommandLine: python -m utool.util_path --exec-dirsplit Example: >>> # DISABLE_DOCTEST >>> from utool.util_path import * # NOQA >>> paths = [] >>> paths.append(...
[ "def", "dirsplit", "(", "path", ")", ":", "#return path.split(os.sep)", "parts", "=", "[", "]", "remain", "=", "path", "part", "=", "True", "#while True:", "while", "part", "!=", "''", "and", "remain", "!=", "''", ":", "remain", ",", "part", "=", "split"...
r""" Args: path (str): Returns: list: components of the path CommandLine: python -m utool.util_path --exec-dirsplit Example: >>> # DISABLE_DOCTEST >>> from utool.util_path import * # NOQA >>> paths = [] >>> paths.append('E:/window file/foo') ...
[ "r", "Args", ":", "path", "(", "str", ")", ":" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L1177-L1214
train
r Dirsplit for the base directory
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", ")", ":", "import", "importlib", "if", "isinstance", "(", "modname", ",", "six", ".", "string_types", ")", ":", "module", "=", "importlib", ".", "impor...
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
r Returns the path to the module containing the n - grams in the module.
Erotemic/utool
utool/util_path.py
ensure_crossplat_path
def ensure_crossplat_path(path, winroot='C:'): r""" ensure_crossplat_path Args: path (str): Returns: str: crossplat_path Example(DOCTEST): >>> # ENABLE_DOCTEST >>> from utool.util_path import * # NOQA >>> path = r'C:\somedir' >>> cplat_path = ensur...
python
def ensure_crossplat_path(path, winroot='C:'): r""" ensure_crossplat_path Args: path (str): Returns: str: crossplat_path Example(DOCTEST): >>> # ENABLE_DOCTEST >>> from utool.util_path import * # NOQA >>> path = r'C:\somedir' >>> cplat_path = ensur...
[ "def", "ensure_crossplat_path", "(", "path", ",", "winroot", "=", "'C:'", ")", ":", "cplat_path", "=", "path", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", "if", "cplat_path", "==", "winroot", ":", "cplat_path", "+=", "'/'", "return", "cplat_path" ]
r""" ensure_crossplat_path Args: path (str): Returns: str: crossplat_path Example(DOCTEST): >>> # ENABLE_DOCTEST >>> from utool.util_path import * # NOQA >>> path = r'C:\somedir' >>> cplat_path = ensure_crossplat_path(path) >>> result = cplat_p...
[ "r", "ensure_crossplat_path" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L1319-L1341
train
r Ensure that the path is in the cross - platform directory.
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
Returns path to module relative to the package root
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
returns importable name from file path
Erotemic/utool
utool/util_path.py
get_module_subdir_list
def get_module_subdir_list(module_fpath): """ get_module_subdir_list Args: module_fpath (str): Example: >>> # ENABLE_DOCTEST >>> from utool.util_path import * # NOQA >>> import utool as ut >>> module_fpath = ut.util_path.__file__ >>> modsubdir_list = ge...
python
def get_module_subdir_list(module_fpath): """ get_module_subdir_list Args: module_fpath (str): Example: >>> # ENABLE_DOCTEST >>> from utool.util_path import * # NOQA >>> import utool as ut >>> module_fpath = ut.util_path.__file__ >>> modsubdir_list = ge...
[ "def", "get_module_subdir_list", "(", "module_fpath", ")", ":", "module_fpath", "=", "truepath", "(", "module_fpath", ")", "dpath", ",", "fname_ext", "=", "split", "(", "module_fpath", ")", "fname", ",", "ext", "=", "splitext", "(", "fname_ext", ")", "full_dpa...
get_module_subdir_list Args: module_fpath (str): Example: >>> # ENABLE_DOCTEST >>> from utool.util_path import * # NOQA >>> import utool as ut >>> module_fpath = ut.util_path.__file__ >>> modsubdir_list = get_module_subdir_list(module_fpath) >>> result ...
[ "get_module_subdir_list" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L1407-L1434
train
Function to get a list of all sub - directories of a module
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
like unix ls - lists all files and dirs in path
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
lists all python modules in path
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
Assert that a path exists.
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", ")", ":", "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
r Returns a list of file paths that match the requested include_patterns and exclude_patterns.
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
This function returns a new version of the sed function that searches for text in files in the specified directories and replaces them with text in files in the specified directories.
Erotemic/utool
utool/util_path.py
sedfile
def sedfile(fpath, regexpr, repl, force=False, verbose=True, veryverbose=False): """ Executes sed on a specific file Args: fpath (str): file path string regexpr (str): repl (str): force (bool): (default = False) verbose (bool): verbosity flag(default = True) ...
python
def sedfile(fpath, regexpr, repl, force=False, verbose=True, veryverbose=False): """ Executes sed on a specific file Args: fpath (str): file path string regexpr (str): repl (str): force (bool): (default = False) verbose (bool): verbosity flag(default = True) ...
[ "def", "sedfile", "(", "fpath", ",", "regexpr", ",", "repl", ",", "force", "=", "False", ",", "verbose", "=", "True", ",", "veryverbose", "=", "False", ")", ":", "# TODO: move to util_edit", "path", ",", "name", "=", "split", "(", "fpath", ")", "new_file...
Executes sed on a specific file Args: fpath (str): file path string regexpr (str): repl (str): force (bool): (default = False) verbose (bool): verbosity flag(default = True) veryverbose (bool): (default = False) Returns: list: changed_lines Comman...
[ "Executes", "sed", "on", "a", "specific", "file" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L1726-L1816
train
A function that executes sed on a specific file and returns a list of changed lines
Erotemic/utool
utool/util_path.py
grepfile
def grepfile(fpath, regexpr_list, reflags=0, cache=None): """ grepfile - greps a specific file Args: fpath (str): regexpr_list (list or str): pattern or list of patterns Returns: tuple (list, list): list of lines and list of line numbers CommandLine: python -m utoo...
python
def grepfile(fpath, regexpr_list, reflags=0, cache=None): """ grepfile - greps a specific file Args: fpath (str): regexpr_list (list or str): pattern or list of patterns Returns: tuple (list, list): list of lines and list of line numbers CommandLine: python -m utoo...
[ "def", "grepfile", "(", "fpath", ",", "regexpr_list", ",", "reflags", "=", "0", ",", "cache", "=", "None", ")", ":", "found_lines", "=", "[", "]", "found_lxs", "=", "[", "]", "# Ensure a list", "islist", "=", "isinstance", "(", "regexpr_list", ",", "(", ...
grepfile - greps a specific file Args: fpath (str): regexpr_list (list or str): pattern or list of patterns Returns: tuple (list, list): list of lines and list of line numbers CommandLine: python -m utool.util_path --exec-grepfile Example: >>> # DISABLE_DOCTES...
[ "grepfile", "-", "greps", "a", "specific", "file" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L1820-L1904
train
Grep a specific file and return a tuple of lines and line numbers
Erotemic/utool
utool/util_path.py
greplines
def greplines(lines, regexpr_list, reflags=0): """ grepfile - greps a specific file TODO: move to util_str, rework to be core of grepfile """ found_lines = [] found_lxs = [] # Ensure a list islist = isinstance(regexpr_list, (list, tuple)) islist2 = isinstance(reflags, (list, tuple))...
python
def greplines(lines, regexpr_list, reflags=0): """ grepfile - greps a specific file TODO: move to util_str, rework to be core of grepfile """ found_lines = [] found_lxs = [] # Ensure a list islist = isinstance(regexpr_list, (list, tuple)) islist2 = isinstance(reflags, (list, tuple))...
[ "def", "greplines", "(", "lines", ",", "regexpr_list", ",", "reflags", "=", "0", ")", ":", "found_lines", "=", "[", "]", "found_lxs", "=", "[", "]", "# Ensure a list", "islist", "=", "isinstance", "(", "regexpr_list", ",", "(", "list", ",", "tuple", ")",...
grepfile - greps a specific file TODO: move to util_str, rework to be core of grepfile
[ "grepfile", "-", "greps", "a", "specific", "file" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L1907-L1946
train
greps a specific file and returns a list of lines and a list of lists of lists of lists of regexps
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
r Grep for patterns Python implementation of grep. NOT FINISHED
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
Get the short path name of a given long path.
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", ")", ":", "try", ":", "if", "path", "==", "''", ":", "raise", "ValueError", "(", "'path cannot be the empty string'", ")", "# get path relative to cwd", "path1", "=", "truepath_relative", "(", "path", ")", "if", "sys", ".", ...
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
r Returns the path for the platform specific file
Erotemic/utool
utool/util_path.py
existing_subpath
def existing_subpath(root_path, valid_subpaths, tiebreaker='first', verbose=VERYVERBOSE): """ Returns join(root_path, subpath) where subpath in valid_subpath ane exists(subpath) """ # Find the oxford_style groundtruth directory for subpath in valid_subpaths: path = ...
python
def existing_subpath(root_path, valid_subpaths, tiebreaker='first', verbose=VERYVERBOSE): """ Returns join(root_path, subpath) where subpath in valid_subpath ane exists(subpath) """ # Find the oxford_style groundtruth directory for subpath in valid_subpaths: path = ...
[ "def", "existing_subpath", "(", "root_path", ",", "valid_subpaths", ",", "tiebreaker", "=", "'first'", ",", "verbose", "=", "VERYVERBOSE", ")", ":", "# Find the oxford_style groundtruth directory", "for", "subpath", "in", "valid_subpaths", ":", "path", "=", "join", ...
Returns join(root_path, subpath) where subpath in valid_subpath ane exists(subpath)
[ "Returns", "join", "(", "root_path", "subpath", ")", "where", "subpath", "in", "valid_subpath", "ane", "exists", "(", "subpath", ")" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L2241-L2254
train
Returns the path of the ane archive that exists in the root_path.
Erotemic/utool
utool/util_path.py
search_in_dirs
def search_in_dirs(fname, search_dpaths=[], shortcircuit=True, return_tried=False, strict=False): """ search_in_dirs Args: fname (str): file name search_dpaths (list): shortcircuit (bool): return_tried (bool): return tried paths strict (bool): (de...
python
def search_in_dirs(fname, search_dpaths=[], shortcircuit=True, return_tried=False, strict=False): """ search_in_dirs Args: fname (str): file name search_dpaths (list): shortcircuit (bool): return_tried (bool): return tried paths strict (bool): (de...
[ "def", "search_in_dirs", "(", "fname", ",", "search_dpaths", "=", "[", "]", ",", "shortcircuit", "=", "True", ",", "return_tried", "=", "False", ",", "strict", "=", "False", ")", ":", "fpath_list", "=", "[", "]", "tried_list", "=", "[", "]", "for", "dp...
search_in_dirs Args: fname (str): file name search_dpaths (list): shortcircuit (bool): return_tried (bool): return tried paths strict (bool): (default = False) Returns: fpath: None Example: >>> # DISABLE_DOCTEST >>> import utool as ut ...
[ "search_in_dirs" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L2267-L2317
train
Search in a list of directories
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", ")", ":", "\"\"\"\n input <libname>: library name (e...
Search for the library
[ "Search", "for", "the", "library" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L2320-L2379
train
Search for a library in a tree.
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", ")", ":", "win32_drive", ",", "_path", "=", "splitdrive", "(", "win32_path", ")", "mingw_drive", "=", "'/'", "+", "win32_drive", "[", ":", "-", "1", "]", ".", "lower", "(", ")", "mingw_path", "=", "mingw_driv...
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
r This function ensures that the windows drives are mingw style drives.
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
Yields all paths above you
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
This function searches for existing paths that meed a requirement and returns the full path of the existing ones.
Erotemic/utool
utool/util_path.py
win_shortcut
def win_shortcut(source, link_name): """ Attempt to create windows shortcut TODO: TEST / FIXME References: http://stackoverflow.com/questions/1447575/symlinks-on-windows """ if True: import ctypes kdll = ctypes.windll.LoadLibrary("kernel32.dll") code = 1 if isdir...
python
def win_shortcut(source, link_name): """ Attempt to create windows shortcut TODO: TEST / FIXME References: http://stackoverflow.com/questions/1447575/symlinks-on-windows """ if True: import ctypes kdll = ctypes.windll.LoadLibrary("kernel32.dll") code = 1 if isdir...
[ "def", "win_shortcut", "(", "source", ",", "link_name", ")", ":", "if", "True", ":", "import", "ctypes", "kdll", "=", "ctypes", ".", "windll", ".", "LoadLibrary", "(", "\"kernel32.dll\"", ")", "code", "=", "1", "if", "isdir", "(", "source", ")", "else", ...
Attempt to create windows shortcut TODO: TEST / FIXME References: http://stackoverflow.com/questions/1447575/symlinks-on-windows
[ "Attempt", "to", "create", "windows", "shortcut", "TODO", ":", "TEST", "/", "FIXME" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L2538-L2564
train
Create a Windows shortcut on a given path.
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
This function creates a symbolic link in the tree of the current language.
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
This function removes all broken links in a directory.
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", ")", ":", "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
r Searches for and finds a path garuenteed to not exist.
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", ")", ":", "# store quantchannels in lookup and generate a db_id vs channel map", "channels_store", "=", "(", "(", "name", ",", ")", "for", "name", ",", "c_id", "in", "...
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
Creates an sqlite lookup table of scannrs with quant data.
glormph/msstitch
src/app/actions/mslookup/quant.py
create_precursor_quant_lookup
def create_precursor_quant_lookup(quantdb, mzmlfn_feats, quanttype, rttol, mztol, mztoltype): """Fills quant sqlite with precursor quant from: features - generator of xml features from openms """ featparsermap = {'kronik': kronik_featparser, 'op...
python
def create_precursor_quant_lookup(quantdb, mzmlfn_feats, quanttype, rttol, mztol, mztoltype): """Fills quant sqlite with precursor quant from: features - generator of xml features from openms """ featparsermap = {'kronik': kronik_featparser, 'op...
[ "def", "create_precursor_quant_lookup", "(", "quantdb", ",", "mzmlfn_feats", ",", "quanttype", ",", "rttol", ",", "mztol", ",", "mztoltype", ")", ":", "featparsermap", "=", "{", "'kronik'", ":", "kronik_featparser", ",", "'openms'", ":", "openms_featparser", ",", ...
Fills quant sqlite with precursor quant from: features - generator of xml features from openms
[ "Fills", "quant", "sqlite", "with", "precursor", "quant", "from", ":", "features", "-", "generator", "of", "xml", "features", "from", "openms" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mslookup/quant.py#L37-L57
train
Fills quant sqlite with precursor quant from mzmlfn_feats
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
Returns a dict of a specified amount of features from the ms1 quant database and the highest mz of those features
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
Gets quant data from consensusXML element
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", "# NOQA", "import", "distutils", "plat_name", "=", "distutils", ".", "util", ".", "get_platform", "(", ")", "plat_specifier", "=", "\".%s-%s\"", "%", "(", "plat_name", ",", "sys", ".", "versio...
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
Returns the platform specifier used by distutils
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
Get the path to the system python library.
Erotemic/utool
utool/util_cplat.py
get_free_diskbytes
def get_free_diskbytes(dir_): r""" Args: dir_ (str): Returns: int: bytes_ folder/drive free space (in bytes) References:: http://stackoverflow.com/questions/51658/cross-platform-space-remaining-on-volume-using-python http://linux.die.net/man/2/statvfs CommandLine: ...
python
def get_free_diskbytes(dir_): r""" Args: dir_ (str): Returns: int: bytes_ folder/drive free space (in bytes) References:: http://stackoverflow.com/questions/51658/cross-platform-space-remaining-on-volume-using-python http://linux.die.net/man/2/statvfs CommandLine: ...
[ "def", "get_free_diskbytes", "(", "dir_", ")", ":", "if", "WIN32", ":", "import", "ctypes", "free_bytes", "=", "ctypes", ".", "c_ulonglong", "(", "0", ")", "outvar", "=", "ctypes", ".", "pointer", "(", "free_bytes", ")", "dir_ptr", "=", "ctypes", ".", "c...
r""" Args: dir_ (str): Returns: int: bytes_ folder/drive free space (in bytes) References:: http://stackoverflow.com/questions/51658/cross-platform-space-remaining-on-volume-using-python http://linux.die.net/man/2/statvfs CommandLine: python -m utool.util_cplat...
[ "r", "Args", ":", "dir_", "(", "str", ")", ":" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L105-L146
train
r Returns the amount of free disk space in a single resource set.
Erotemic/utool
utool/util_cplat.py
chmod_add_executable
def chmod_add_executable(fpath, group=True, user=True): """ References: http://stackoverflow.com/questions/15607903/python-module-os-chmodfile-664-does-not-change-the-permission-to-rw-rw-r-bu http://www.tutorialspoint.com/python/os_chmod.htm https://en.wikipedia.org/wiki/Chmod """ ...
python
def chmod_add_executable(fpath, group=True, user=True): """ References: http://stackoverflow.com/questions/15607903/python-module-os-chmodfile-664-does-not-change-the-permission-to-rw-rw-r-bu http://www.tutorialspoint.com/python/os_chmod.htm https://en.wikipedia.org/wiki/Chmod """ ...
[ "def", "chmod_add_executable", "(", "fpath", ",", "group", "=", "True", ",", "user", "=", "True", ")", ":", "import", "stat", "orig_mode", "=", "os", ".", "stat", "(", "fpath", ")", ".", "st_mode", "new_mode", "=", "orig_mode", "if", "group", ":", "new...
References: http://stackoverflow.com/questions/15607903/python-module-os-chmodfile-664-does-not-change-the-permission-to-rw-rw-r-bu http://www.tutorialspoint.com/python/os_chmod.htm https://en.wikipedia.org/wiki/Chmod
[ "References", ":", "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "15607903", "/", "python", "-", "module", "-", "os", "-", "chmodfile", "-", "664", "-", "does", "-", "not", "-", "change", "-", "the", "-", "permission", "-", "...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L166-L181
train
Add an executable file to the current directory.
Erotemic/utool
utool/util_cplat.py
get_disk_space
def get_disk_space(start_path='.'): """ References: http://stackoverflow.com/questions/1392413/calculating-a-directory-size-using-python """ total_size = 0 for root, dname_list, fname_list in os.walk(start_path): for fname in fname_list: fpath = os.path.join(root, fname) ...
python
def get_disk_space(start_path='.'): """ References: http://stackoverflow.com/questions/1392413/calculating-a-directory-size-using-python """ total_size = 0 for root, dname_list, fname_list in os.walk(start_path): for fname in fname_list: fpath = os.path.join(root, fname) ...
[ "def", "get_disk_space", "(", "start_path", "=", "'.'", ")", ":", "total_size", "=", "0", "for", "root", ",", "dname_list", ",", "fname_list", "in", "os", ".", "walk", "(", "start_path", ")", ":", "for", "fname", "in", "fname_list", ":", "fpath", "=", ...
References: http://stackoverflow.com/questions/1392413/calculating-a-directory-size-using-python
[ "References", ":", "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "1392413", "/", "calculating", "-", "a", "-", "directory", "-", "size", "-", "using", "-", "python" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L242-L255
train
Returns the total size of the disk space of the current directory.
Erotemic/utool
utool/util_cplat.py
python_executable
def python_executable(check=True, short=False): r""" Args: short (bool): (default = False) Returns: str: Example: >>> # ENABLE_DOCTEST >>> from utool.util_cplat import * # NOQA >>> short = False >>> result = python_executable(short) >>> print(re...
python
def python_executable(check=True, short=False): r""" Args: short (bool): (default = False) Returns: str: Example: >>> # ENABLE_DOCTEST >>> from utool.util_cplat import * # NOQA >>> short = False >>> result = python_executable(short) >>> print(re...
[ "def", "python_executable", "(", "check", "=", "True", ",", "short", "=", "False", ")", ":", "if", "not", "check", ":", "python_exe", "=", "'python'", "else", ":", "from", "os", ".", "path", "import", "isdir", "python_exe_long", "=", "unixpath", "(", "sy...
r""" Args: short (bool): (default = False) Returns: str: Example: >>> # ENABLE_DOCTEST >>> from utool.util_cplat import * # NOQA >>> short = False >>> result = python_executable(short) >>> print(result)
[ "r", "Args", ":", "short", "(", "bool", ")", ":", "(", "default", "=", "False", ")" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L287-L317
train
r Returns the name of the python executable that is available in the environment
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
Returns the dynamic library dependencies for the current platform.
Erotemic/utool
utool/util_cplat.py
get_dynlib_exports
def get_dynlib_exports(lib_path): """ Executes tools for inspecting dynamic library dependencies depending on the current platform. Returns the names of callable functions. Args: lib_path (str): Returns: str: depend_out CommandLine: python -m utool.util_cplat --test-ge...
python
def get_dynlib_exports(lib_path): """ Executes tools for inspecting dynamic library dependencies depending on the current platform. Returns the names of callable functions. Args: lib_path (str): Returns: str: depend_out CommandLine: python -m utool.util_cplat --test-ge...
[ "def", "get_dynlib_exports", "(", "lib_path", ")", ":", "if", "LINUX", ":", "'''\n nm_fpath = '/usr/bin/nm'\n exportssout, err, ret = cmd(nm_fpath, '-D', lib_path, '|', 'c++filt', verbose=False)\n lines = exportssout.split('\\n')\n #lines = [line[19:] for line in line]\...
Executes tools for inspecting dynamic library dependencies depending on the current platform. Returns the names of callable functions. Args: lib_path (str): Returns: str: depend_out CommandLine: python -m utool.util_cplat --test-get_dynlib_exports Example: >>> # D...
[ "Executes", "tools", "for", "inspecting", "dynamic", "library", "dependencies", "depending", "on", "the", "current", "platform", ".", "Returns", "the", "names", "of", "callable", "functions", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L352-L432
train
Returns the names of the functions that are exported by the dynamic library.
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
Starts a new file in the current directory.
Erotemic/utool
utool/util_cplat.py
editfile
def editfile(fpath): """ Runs gvim. Can also accept a module / class / function """ if not isinstance(fpath, six.string_types): from six import types print('Rectify to module fpath = %r' % (fpath,)) if isinstance(fpath, types.ModuleType): fpath = fpath.__file__ else: ...
python
def editfile(fpath): """ Runs gvim. Can also accept a module / class / function """ if not isinstance(fpath, six.string_types): from six import types print('Rectify to module fpath = %r' % (fpath,)) if isinstance(fpath, types.ModuleType): fpath = fpath.__file__ else: ...
[ "def", "editfile", "(", "fpath", ")", ":", "if", "not", "isinstance", "(", "fpath", ",", "six", ".", "string_types", ")", ":", "from", "six", "import", "types", "print", "(", "'Rectify to module fpath = %r'", "%", "(", "fpath", ",", ")", ")", "if", "isin...
Runs gvim. Can also accept a module / class / function
[ "Runs", "gvim", ".", "Can", "also", "accept", "a", "module", "/", "class", "/", "function" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L502-L531
train
Runs gvim. Can also accept a module or class or function.
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", "# from utool.util_str import ...
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
View a directory in the operating system file browser.
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", ":", "# nocover", "dpath_", "=", "'~/AppData/Local'", "elif", "LINUX", ":", "# nocover", "dpath_", "=", "'~/.cache'", "elif", "DARWIN", ":", "# nocover", "dpath_", "=", "'~/Library/Caches'", "else", ":",...
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
Returns a directory which should be writable for any application
Erotemic/utool
utool/util_cplat.py
ensure_app_cache_dir
def ensure_app_cache_dir(appname, *args): """ Example: >>> # DISABLE_DOCTEST >>> from utool.util_cplat import * # NOQA >>> import utool as ut >>> dpath = ut.ensure_app_cache_dir('utool') >>> assert exists(dpath) """ import utool as ut dpath = get_app_cache_di...
python
def ensure_app_cache_dir(appname, *args): """ Example: >>> # DISABLE_DOCTEST >>> from utool.util_cplat import * # NOQA >>> import utool as ut >>> dpath = ut.ensure_app_cache_dir('utool') >>> assert exists(dpath) """ import utool as ut dpath = get_app_cache_di...
[ "def", "ensure_app_cache_dir", "(", "appname", ",", "*", "args", ")", ":", "import", "utool", "as", "ut", "dpath", "=", "get_app_cache_dir", "(", "appname", ",", "*", "args", ")", "ut", ".", "ensuredir", "(", "dpath", ")", "return", "dpath" ]
Example: >>> # DISABLE_DOCTEST >>> from utool.util_cplat import * # NOQA >>> import utool as ut >>> dpath = ut.ensure_app_cache_dir('utool') >>> assert exists(dpath)
[ "Example", ":", ">>>", "#", "DISABLE_DOCTEST", ">>>", "from", "utool", ".", "util_cplat", "import", "*", "#", "NOQA", ">>>", "import", "utool", "as", "ut", ">>>", "dpath", "=", "ut", ".", "ensure_app_cache_dir", "(", "utool", ")", ">>>", "assert", "exists"...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L666-L678
train
This function creates a directory for the app cache.
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", ")", ":", "# Case where tuple is passed in as only argument", "if", "isinstance", "(", "args", ",", "tuple", ")", "and", "len", "(", "args", ")", "==", "1", "and", "isinstance", "(", "args", ...
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
Parse command line arguments.
Erotemic/utool
utool/util_cplat.py
cmd
def cmd(*args, **kwargs): r""" A really roundabout way to issue a system call # FIXME: This function needs some work # It should work without a hitch on windows or unix. # It should be able to spit out stdout in realtime. # Should be able to configure detatchment, shell, and sudo. FIXME: ...
python
def cmd(*args, **kwargs): r""" A really roundabout way to issue a system call # FIXME: This function needs some work # It should work without a hitch on windows or unix. # It should be able to spit out stdout in realtime. # Should be able to configure detatchment, shell, and sudo. FIXME: ...
[ "def", "cmd", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "# Parse the keyword arguments", "verbose", ",", "detatch", ",", "shell", ",", "sudo", ",", "pad_stdout", "=", "__parse_cmd_kwargs", "(", "kwargs", ")", "quiet", "=", "kwargs", ...
r""" A really roundabout way to issue a system call # FIXME: This function needs some work # It should work without a hitch on windows or unix. # It should be able to spit out stdout in realtime. # Should be able to configure detatchment, shell, and sudo. FIXME: on a mac ut.cmd('/Users/jon...
[ "r", "A", "really", "roundabout", "way", "to", "issue", "a", "system", "call" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L825-L1002
train
r A really roundabout way to issue a system call to get a new version of the current version of the current version of the current version of the version of the version of the version of the version of the version of the version of the version of the version
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
Runs a command and returns the status of the command
Erotemic/utool
utool/util_cplat.py
get_flops
def get_flops(): """ # DOESNT WORK """ from sys import stdout from re import compile filename = "linpack.out" fpnum = r'\d+\.\d+E[+-]\d\d' fpnum_1 = fpnum + r' +' pattern = compile(r'^ *' + fpnum_1 + fpnum_1 + fpnum_1 + r'(' + fpnum + r') +' + fpnum_1 + fpnum + r' *\n$') speeds = [0.0, ...
python
def get_flops(): """ # DOESNT WORK """ from sys import stdout from re import compile filename = "linpack.out" fpnum = r'\d+\.\d+E[+-]\d\d' fpnum_1 = fpnum + r' +' pattern = compile(r'^ *' + fpnum_1 + fpnum_1 + fpnum_1 + r'(' + fpnum + r') +' + fpnum_1 + fpnum + r' *\n$') speeds = [0.0, ...
[ "def", "get_flops", "(", ")", ":", "from", "sys", "import", "stdout", "from", "re", "import", "compile", "filename", "=", "\"linpack.out\"", "fpnum", "=", "r'\\d+\\.\\d+E[+-]\\d\\d'", "fpnum_1", "=", "fpnum", "+", "r' +'", "pattern", "=", "compile", "(", "r'^ ...
# DOESNT WORK
[ "#", "DOESNT", "WORK" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L1075-L1104
train
Get the total fan from the last one.
Erotemic/utool
utool/util_cplat.py
get_python_dynlib
def get_python_dynlib(): """ python -c "import utool; print(utool.get_python_dynlib())" get_python_dynlib Returns: ?: dynlib Example: >>> # DISABLE_DOCTEST >>> # DOCTEST_DISABLE >>> from utool.util_cplat import * # NOQA >>> dynlib = get_python_dynlib() ...
python
def get_python_dynlib(): """ python -c "import utool; print(utool.get_python_dynlib())" get_python_dynlib Returns: ?: dynlib Example: >>> # DISABLE_DOCTEST >>> # DOCTEST_DISABLE >>> from utool.util_cplat import * # NOQA >>> dynlib = get_python_dynlib() ...
[ "def", "get_python_dynlib", "(", ")", ":", "import", "sysconfig", "cfgvars", "=", "sysconfig", ".", "get_config_vars", "(", ")", "dynlib", "=", "os", ".", "path", ".", "join", "(", "cfgvars", "[", "'LIBDIR'", "]", ",", "cfgvars", "[", "'MULTIARCH'", "]", ...
python -c "import utool; print(utool.get_python_dynlib())" get_python_dynlib Returns: ?: dynlib Example: >>> # DISABLE_DOCTEST >>> # DOCTEST_DISABLE >>> from utool.util_cplat import * # NOQA >>> dynlib = get_python_dynlib() >>> print(dynlib) /usr/l...
[ "python", "-", "c", "import", "utool", ";", "print", "(", "utool", ".", "get_python_dynlib", "()", ")" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L1130-L1153
train
get_python_dynlib returns the path to the Python dynamic library
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", ")", ":", "import", "utool", "as", "ut", "# from os.path import join", "if", "key_list", "is", "None", ":", "key_list", "=", "[", "key", "for", "key", "in",...
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
r Searches your PATH to see if fname exists in the environment
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", ":", "# Disabled", "return", "if", "not", "WIN32", ":", "#print(\"CHANGE TERM TITLE to %r\" % (title,))", "if", "title", ":", "#os.environ['PS1'] = os.environ['PS1'] + '''\"\\e]2;\\\"''' + title + '''\\\"\\a\"'''...
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
Change the terminal title for identifying debugging tasks
Erotemic/utool
utool/util_cplat.py
send_keyboard_input
def send_keyboard_input(text=None, key_list=None): """ Args: text (None): key_list (list): References: http://stackoverflow.com/questions/14788036/python-win32api-sendmesage http://www.pinvoke.net/default.aspx/user32.sendinput CommandLine: python -m utool.util_c...
python
def send_keyboard_input(text=None, key_list=None): """ Args: text (None): key_list (list): References: http://stackoverflow.com/questions/14788036/python-win32api-sendmesage http://www.pinvoke.net/default.aspx/user32.sendinput CommandLine: python -m utool.util_c...
[ "def", "send_keyboard_input", "(", "text", "=", "None", ",", "key_list", "=", "None", ")", ":", "#key_mapping = {", "# 'enter':", "#}", "if", "WIN32", ":", "#raise NotImplementedError()", "#import win32api", "#import win32gui", "#import win32con", "#hwnd = win32gui.Get...
Args: text (None): key_list (list): References: http://stackoverflow.com/questions/14788036/python-win32api-sendmesage http://www.pinvoke.net/default.aspx/user32.sendinput CommandLine: python -m utool.util_cplat --test-send_keyboard_input Example: >>> # DIS...
[ "Args", ":", "text", "(", "None", ")", ":", "key_list", "(", "list", ")", ":" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L1303-L1370
train
Send keyboard input to the current user.
Erotemic/utool
utool/util_cplat.py
ipython_paste
def ipython_paste(*args, **kwargs): """ pastes for me FIXME: make something like this work on unix and windows""" if WIN32: pass else: winhandle = 'joncrall@Hyrule' args1 = ['wmctrl', '-a', winhandle] args2 = ['xdotool', 'key', 'shift+5', 'p', 'a', 's', 't', 'e', 'enter'] ...
python
def ipython_paste(*args, **kwargs): """ pastes for me FIXME: make something like this work on unix and windows""" if WIN32: pass else: winhandle = 'joncrall@Hyrule' args1 = ['wmctrl', '-a', winhandle] args2 = ['xdotool', 'key', 'shift+5', 'p', 'a', 's', 't', 'e', 'enter'] ...
[ "def", "ipython_paste", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "WIN32", ":", "pass", "else", ":", "winhandle", "=", "'joncrall@Hyrule'", "args1", "=", "[", "'wmctrl'", ",", "'-a'", ",", "winhandle", "]", "args2", "=", "[", "'xdotool...
pastes for me FIXME: make something like this work on unix and windows
[ "pastes", "for", "me", "FIXME", ":", "make", "something", "like", "this", "work", "on", "unix", "and", "windows" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L1373-L1382
train
Paste the current page of the current page.