diff options
author | Jan Pokorný <jpokorny@redhat.com> | 2014-06-16 22:58:23 +0200 |
---|---|---|
committer | Jan Pokorný <jpokorny@redhat.com> | 2014-06-16 23:00:33 +0200 |
commit | 47241126e77f5b9f11a1b045005aa447d08b28db (patch) | |
tree | 8678ed0fb318eb12754d33aec3d29629263c92e6 /utils_prog.py | |
parent | 671a4975391af70127fcc9ecb59beb0638efd2f8 (diff) | |
download | clufter-47241126e77f5b9f11a1b045005aa447d08b28db.tar.gz clufter-47241126e77f5b9f11a1b045005aa447d08b28db.tar.xz clufter-47241126e77f5b9f11a1b045005aa447d08b28db.zip |
utils_prog: cosmetics and comment polishing
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to 'utils_prog.py')
-rw-r--r-- | utils_prog.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/utils_prog.py b/utils_prog.py index 860acdf..58215d5 100644 --- a/utils_prog.py +++ b/utils_prog.py @@ -38,7 +38,7 @@ cli_undecor = lambda x: x.replace('-', '_') # XXX could eventually also resort to using upper-case chars longopt_letters_reprio = \ lambda longopt: \ - (lambda lo: \ + (lambda lo: lo[0] + ''.join(sorted(lo[1:], key=lambda x: int(x.lower() in 'aeiouy'))) )(filter(lambda c: c.isalpha(), longopt)) @@ -89,20 +89,20 @@ OneoffWrappedStdinPopen = OneoffWrappedStdinPopen() def which(name, single='', *paths, **redefine_check): """Mimic `which' UNIX utility - Both `single` and `paths` denotes paths to be tried for `name` - lookup, which includes positive result of `check` keyword argument, - filtering function (by default, a simple test if file exists). + Both `single` and `paths` denotes paths to be tried for `name` lookup, + which includes a decision from the perspective of a filter function given + by `check` keyword argument (default: a test if the file exists at all). - What is special about `single` is that it can be defined either + What is special about `single` is that it can be defined as either plain one-path string, PATH-like-separated list of paths, or an iterable. It is decomposed into a list of paths and then - `paths` items are appended. + `paths` items appended. Apparently, when `name` is provided as an absolute path, only the `check` (i.e., no lookup) phase is performed. If nothing matching the criteria is found, `None` is returned, - complete nominal path corresponding to `name` and `check` otherwise. + nominal path as per `name` (and `check` for that matter) otherwise. Empty string instructs code to use environment's PATH instead. """ @@ -145,6 +145,7 @@ def defer_common(me, fnc, skip=0): fnc_varnames = list(fnc_varnames) fnc_varnames.remove('_common') # but we could rely on last argument fnc_varnames = tuple(fnc_varnames) + common_varnames + def wrapfnc(cmd_ctxt, **kwargs): common(cmd_ctxt, **filterdict_pop(kwargs, common_varnames)) kwargs.pop('_common', None) |