示例#1
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
示例#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
 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