コード例 #1
0
ファイル: pdef.py プロジェクト: melviso/python2-trepan
    def run(self, args):
        if len(args) != 2: return
        obj_name = args[1]
        try:
            obj = self.proc.eval(obj_name)
        except:
            return
        if not callable(obj):
            self.errmsg('Object %s is not callable.' % obj_name)
            return

        if inspect.isclass(obj):
            self.msg('Class constructor information:')
            obj = obj.__init__
        elif isinstance(type(obj), types.InstanceType):
            obj = obj.__call__
            pass

        output = Mprint.print_argspec(obj, obj_name)
        if output is None:
            self.errmsg('No definition header found for %s' % obj_name)
        else:
            self.msg(output)
            pass
        return
コード例 #2
0
    def run(self, args):
        if len(args) != 2: return
        obj_name = args[1]
        try:
            obj = self.proc.eval(obj_name)
        except:
            return
        if not callable(obj):
            self.errmsg('Object %s is not callable.' % obj_name)
            return

        if inspect.isclass(obj):
            self.msg('Class constructor information:')
            obj = obj.__init__
        elif isinstance(type(obj), types.InstanceType):
            obj = obj.__call__
            pass

        output = Mprint.print_argspec(obj, obj_name)
        if output is None:
            self.errmsg('No definition header found for %s' % obj_name)
        else:
            self.msg(output)
            pass
        return
コード例 #3
0
 def test_lib_argspec(self):
     self.assertEqual(
         'test_lib_argspec(self)',
         Mprint.print_argspec(self.test_lib_argspec, 'test_lib_argspec'))
     self.assertFalse(Mprint.print_argspec(None, 'invalid_fn'))
     return
コード例 #4
0
 def test_lib_argspec(self):
     self.assertEqual('test_lib_argspec(self)',
                      Mprint.print_argspec(self.test_lib_argspec,
                                           'test_lib_argspec'))
     self.assertFalse(Mprint.print_argspec(None, 'invalid_fn'))
     return