diff --git a/inspect/inspect.py b/inspect/inspect.py new file mode 100644 index 00000000..0865517d --- /dev/null +++ b/inspect/inspect.py @@ -0,0 +1,59 @@ +import sys + + +def getmembers(obj, pred=None): + res = [] + for name in dir(obj): + val = getattr(obj, name) + if pred is None or pred(val): + res.append((name, val)) + res.sort() + return res + +def isfunction(obj): + return isinstance(obj, type(isfunction)) + +def isgeneratorfunction(obj): + return isinstance(obj, type(lambda:(yield))) + +def isgenerator(obj): + return isinstance(obj, type(lambda:(yield)())) + +class _Class: + def meth(): pass +_Instance = _Class() + +def ismethod(obj): + return isinstance(obj, type(_Instance.meth)) + +def isclass(obj): + return isinstance(object, type) + +def ismodule(obj): + return isinstance(obj, type(sys)) + + +def getargspec(func): + raise NotImplementedError("This is over-dynamic function, not supported by MicroPython") + +def getmodule(obj, _filename=None): + return None # Not known + +def getmro(cls): + return [cls] + +def getsourcefile(obj): + return None # Not known + +def getfile(obj): + return "" + +def getsource(obj): + return "" + + +def currentframe(): + return None + +def getframeinfo(frame, context=1): + return ("", -1, "", [""], 0)