예제 #1
0
 def testBuiltinFunction(self):
     method = 'len('
     print introspect.getCallTip(method, locals())
     
     (name, argspec, tip) = introspect.getCallTip(method, locals())
     
     self.assertEquals('len', name)
     # next 2 assertions fail in Jython!
     self.assertEquals('len(object) -> integer', argspec)
     self.assertEquals('len(object) -> integer\n\nReturn the number of items of a sequence or mapping', tip)
예제 #2
0
파일: testcase.py 프로젝트: omusico/siga
 def testBuiltinFunction(self):
     method = 'len('
     print introspect.getCallTip(method, locals())
     
     (name, argspec, tip) = introspect.getCallTip(method, locals())
     
     self.assertEquals('len', name)
     # next 2 assertions fail in Jython!
     self.assertEquals('len(object) -> integer', argspec)
     self.assertEquals('len(object) -> integer\n\nReturn the number of items of a sequence or mapping', tip)
예제 #3
0
 def autoCompleteFunction(self, linePart):
     element = introspect.getRoot(linePart)
     funcName, funcParam, funcHelp = introspect.getCallTip(
         element, locals=self.interp.locals)
     self.fullCallTip = funcName, funcHelp
     callTip = self.maxCallTip(funcHelp)
     return len(funcName) - 1, funcParam, callTip
예제 #4
0
파일: testcase.py 프로젝트: omusico/siga
    def testUnboundMethod(self):
        import string
        method = 'string.index('
        (name, argspec, tip) = introspect.getCallTip(method, locals())

        self.assertEquals('index', name)
        self.assertEquals('s, *args', argspec)
        self.assertEquals('index(s, *args)\n\nindex(s, sub [,start [,end]]) -> int\n\nLike find but raises ValueError when the substring is not found.', tip)
예제 #5
0
    def testUnboundMethod(self):
        import string
        method = 'string.index('
        (name, argspec, tip) = introspect.getCallTip(method, locals())

        self.assertEquals('index', name)
        self.assertEquals('s, *args', argspec)
        self.assertEquals('index(s, *args)\n\nindex(s, sub [,start [,end]]) -> int\n\nLike find but raises ValueError when the substring is not found.', tip)
예제 #6
0
    def getCallTip(self, line, var, truncate=True):
        if not line:
            element = var
        else:
            element = introspect.getRoot(line)
        if len(element) < len(var): return
        try:
            object = eval(element, self.interp.locals)
        except:
            return
        if var in element:
            if line:
                try:
                    funcName, funcParam, funcHelp = introspect.getCallTip(
                        element, locals=self.interp.locals)
                except:
                    funcHelp = ''
            else:
                funcHelp = ''
            typ = str(type(object))
            if typ.startswith("<type '") and typ.endswith("'>"):
                typ = typ[7:-2]
            if funcHelp:
                textFull = funcHelp
                if truncate: funcHelp = self.maxCallTip(textFull)
                calltip = 'type: ', typ, '\ndoc: ', funcHelp
            else:
                textFull = str(object)
                if isinstance(object, ModuleType):
                    try:
                        textFull = textFull + '\nhelp:\n' + object.__doc__
                    except:
                        pass
                    value = textFull
                    if truncate: value = self.maxCallTip(textFull)
                    calltip = 'type: ', typ, '\nstr: ', ('\n' if '\n' in value
                                                         else '') + value
                else:
                    value = textFull
                    if truncate: value = self.maxCallTip(textFull)
                    if hasattr(object, '__len__'):
                        calltip = 'type: ', typ + ', len: %i' % len(
                            object), '\nstr: ', ('\n' if '\n' in value else
                                                 '') + value
                    else:
                        calltip = 'type: ', typ, '\nstr: ', (
                            '\n' if '\n' in value else '') + value
            self.fullCallTip = var, calltip[:-1] + (textFull, )
        nHighlight = 0
        for ct in calltip[:3]:
            nHighlight += len(ct)

        return element, str(nHighlight), calltip
예제 #7
0
 def testBuiltinFunction(self):
     """Builtin types don't work, like they do in PyCrust.  This is because they have a null __doc__ string in Jython."""
     method = 'len('
     
     (name, argspec, tip) = introspect.getCallTip(method, locals())
     
     self.assertEquals('len', name)
     
     if not sys.platform.startswith('java'):
         # next line worked with Python 2.2, fails with Python 2.3 and 2.5 on OS X, probably need newer introspect, inspect or dis
         # self.assertEquals('len(object) -> integer', argspec)
         self.assertEquals('', argspec)
         self.assertEquals('len(object) -> integer\n\nReturn the number of items of a sequence or mapping.', tip)
예제 #8
0
    def testBuiltinFunction(self):
        """Builtin types don't work, like they do in PyCrust.  This is because they have a null __doc__ string in Jython."""
        method = 'len('

        (name, argspec, tip) = introspect.getCallTip(method, locals())

        self.assertEquals('len', name)

        if not sys.platform.startswith('java'):
            # next line worked with Python 2.2, fails with Python 2.3 and 2.5 on OS X, probably need newer introspect, inspect or dis
            # self.assertEquals('len(object) -> integer', argspec)
            self.assertEquals('', argspec)
            self.assertEquals(
                'len(object) -> integer\n\nReturn the number of items of a sequence or mapping.',
                tip)
예제 #9
0
 def getCallTip(self, command="", *args, **kwds):
     """Return call tip text for a command.
     
     Call tip information will be based on the locals namespace."""
     return introspect.getCallTip(command, self.locals, *args, **kwds)
 def getCallTip(self, command='', *args, **kwds):
     """Return call tip text for a command.
     
     Call tip information will be based on the locals namespace."""
     return introspect.getCallTip(command, self.locals, *args, **kwds)