summaryrefslogtreecommitdiff
path: root/python/bncompleter.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/bncompleter.py')
-rw-r--r--python/bncompleter.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/python/bncompleter.py b/python/bncompleter.py
index e1dfab1a..d5adfbc1 100644
--- a/python/bncompleter.py
+++ b/python/bncompleter.py
@@ -41,9 +41,27 @@ Notes:
import atexit
import __main__
import inspect
+import sys
__all__ = ["Completer"]
+def fnsignature(obj):
+ if sys.version_info[0:2] >= (3, 5):
+ try:
+ sig = str(inspect.signature(obj))
+ except:
+ sig = "()"
+ return sig
+ else:
+ try:
+ args = inspect.getargspec(obj).args
+ args.remove('self')
+ sig = "(" + ','.join(args) + ")"
+ except:
+ sig = "()"
+ return sig
+
+
class Completer:
def __init__(self, namespace = None):
"""Create a new completer for the command line.
@@ -100,7 +118,7 @@ class Completer:
def _callable_postfix(self, val, word):
if callable(val) and not inspect.isclass(val):
- word = word + str(inspect.signature(val))
+ word = word + fnsignature(val)
return word
def global_matches(self, text):