mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-04 11:00:07 +01:00
Merge pull request #2354 from komoto48g/introspection
Fix wx.py.shell.Shell calltip
This commit is contained in:
@@ -3,6 +3,7 @@ things like call tips and command auto completion."""
|
|||||||
|
|
||||||
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
|
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
|
||||||
|
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
import inspect
|
import inspect
|
||||||
import tokenize
|
import tokenize
|
||||||
@@ -175,6 +176,9 @@ def getCallTip(command='', locals=None):
|
|||||||
pass
|
pass
|
||||||
elif inspect.isfunction(obj):
|
elif inspect.isfunction(obj):
|
||||||
# tip1 is a string like: "getCallTip(command='', locals=None)"
|
# tip1 is a string like: "getCallTip(command='', locals=None)"
|
||||||
|
try:
|
||||||
|
argspec = str(inspect.signature(obj)) # PY35 or later
|
||||||
|
except AttributeError:
|
||||||
argspec = inspect.getargspec(obj) if not PY3 else inspect.getfullargspec(obj)
|
argspec = inspect.getargspec(obj) if not PY3 else inspect.getfullargspec(obj)
|
||||||
argspec = inspect.formatargspec(*argspec)
|
argspec = inspect.formatargspec(*argspec)
|
||||||
if dropSelf:
|
if dropSelf:
|
||||||
@@ -211,7 +215,11 @@ def getCallTip(command='', locals=None):
|
|||||||
tip = '%s%s\n\n%s' % (tip1, tip2, tip3)
|
tip = '%s%s\n\n%s' % (tip1, tip2, tip3)
|
||||||
else:
|
else:
|
||||||
tip = tip1
|
tip = tip1
|
||||||
calltip = (name, argspec[1:-1], tip.strip())
|
# Extract argspec from the signature e.g., (x, /, *, ...) -> int
|
||||||
|
m = re.search(r'\((.*)\)', argspec)
|
||||||
|
if m:
|
||||||
|
argspec = m.group(1)
|
||||||
|
calltip = (name, argspec, tip.strip())
|
||||||
return calltip
|
return calltip
|
||||||
|
|
||||||
def getRoot(command, terminator=None):
|
def getRoot(command, terminator=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user