summaryrefslogtreecommitdiffstats
path: root/utils.py
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2014-02-26 14:25:13 +0100
committerJan Pokorný <jpokorny@redhat.com>2014-02-26 14:25:13 +0100
commit5fc1a74d0b484eb1a2d28689a294e9eebcd97c78 (patch)
tree5cef69c43e7913de330c6fa355a696ec5af89550 /utils.py
parentcde3067d6cbad0491aa9d8d153aca043b5163f3b (diff)
downloadclufter-5fc1a74d0b484eb1a2d28689a294e9eebcd97c78.tar.gz
clufter-5fc1a74d0b484eb1a2d28689a294e9eebcd97c78.tar.xz
clufter-5fc1a74d0b484eb1a2d28689a294e9eebcd97c78.zip
command: automagically figure out the short opts for long ones
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/utils.py b/utils.py
index 47fc806..cc06b6d 100644
--- a/utils.py
+++ b/utils.py
@@ -139,6 +139,14 @@ def which(name, *where):
else:
return None
+# prioritize consonants, deprioritize vowels (except for the first letter
+# overall), which seems to be widely adopted technique for selecting short
+# options based on their long counterparts :)
+longopt_letters_reprio = \
+ lambda longopt: \
+ longopt[0] + ''.join(sorted(longopt[1:],
+ key=lambda x: int(x.lower() in 'aeiouy')))
+
# extrapolate optparse.make_option to specifically-encoded "plural"
make_options = lambda opt_decl: [make_option(*a, **kw) for a, kw in opt_decl]