summaryrefslogtreecommitdiff
path: root/helpers/python
diff options
context:
space:
mode:
authorGabriel F. T. Gomes <gabriel@inconstante.eti.br>2018-03-18 12:02:11 -0300
committerGabriel F. T. Gomes <gabriel@inconstante.eti.br>2018-03-18 12:02:11 -0300
commit9cd22d1df8f0f5b554858471c86faa9f37b8fed4 (patch)
tree6399b936aecc388506ec32cfc10fdb06cfc1949f /helpers/python
parent6d88f1055806932d9291f96847d2b691cccda2cd (diff)
downloadbash-completion-9cd22d1df8f0f5b554858471c86faa9f37b8fed4.tar.gz
New upstream version 2.8upstream/2.8
Diffstat (limited to 'helpers/python')
-rw-r--r--helpers/python10
1 files changed, 9 insertions, 1 deletions
diff --git a/helpers/python b/helpers/python
index 23c14bde..b6c4d5ed 100644
--- a/helpers/python
+++ b/helpers/python
@@ -1,6 +1,14 @@
# -*- python -*-
import pkgutil
+import sys
-for mod in pkgutil.iter_modules():
+# walk_packages() is much slower than iter_modules(), use it only when
+# completing something with a dot in it.
+if len(sys.argv) > 1 and "." in sys.argv[1]:
+ walker = pkgutil.walk_packages
+else:
+ walker = pkgutil.iter_modules
+
+for mod in walker():
print(mod[1])