Ejemplo n.º 1
0
 def getModInfo(self, path):
     " Provides a module info for the given file "
     from fileutils import (detectFileType, PythonFileType,
                            Python3FileType)
     if detectFileType(path) not in [PythonFileType, Python3FileType]:
         raise Exception("Trying to parse non-python file: " + path)
     return self.briefModinfoCache.get(path)
Ejemplo n.º 2
0
        def getFileLineDocstring( self, fName, line ):
            " Provides a docstring if so for the given file and line "
            from fileutils import ( detectFileType, PythonFileType,
                                    Python3FileType )
            if detectFileType( fName ) not in [ PythonFileType,
                                                Python3FileType ]:
                return ""

            infoCache = self.briefModinfoCache

            def checkFuncObject( obj, line ):
                " Checks docstring for a function or a class "
                if obj.line == line or obj.keywordLine == line:
                    if obj.docstring is None:
                        return True, ""
                    return True, obj.docstring.text
                for item in obj.classes + obj.functions:
                    found, docstring = checkFuncObject( item, line )
                    if found:
                        return True, docstring
                return False, ""

            try:
                info = infoCache.get( fName )
                for item in info.classes + info.functions:
                    found, docstring = checkFuncObject( item, line )
                    if found:
                        return docstring
            except:
                pass
            return ""
Ejemplo n.º 3
0
        def getFileLineDocstring(self, fName, line):
            " Provides a docstring if so for the given file and line "
            from fileutils import (detectFileType, PythonFileType,
                                   Python3FileType)
            if detectFileType(fName) not in [PythonFileType, Python3FileType]:
                return ""

            infoCache = self.briefModinfoCache

            def checkFuncObject(obj, line):
                " Checks docstring for a function or a class "
                if obj.line == line or obj.keywordLine == line:
                    if obj.docstring is None:
                        return True, ""
                    return True, obj.docstring.text
                for item in obj.classes + obj.functions:
                    found, docstring = checkFuncObject(item, line)
                    if found:
                        return True, docstring
                return False, ""

            try:
                info = infoCache.get(fName)
                for item in info.classes + info.functions:
                    found, docstring = checkFuncObject(item, line)
                    if found:
                        return docstring
            except:
                pass
            return ""
Ejemplo n.º 4
0
 def getModInfo( self, path ):
     " Provides a module info for the given file "
     from fileutils import ( detectFileType, PythonFileType,
                             Python3FileType )
     if detectFileType( path ) not in [ PythonFileType,
                                        Python3FileType ]:
         raise Exception( "Trying to parse non-python file: " + path )
     return self.briefModinfoCache.get( path )
Ejemplo n.º 5
0
        def isProjectScriptValid(self):
            " True if the project script valid "
            scriptName = self.project.getProjectScript()
            if not os.path.exists(scriptName):
                return False
            scriptName = os.path.realpath(scriptName)
            if not os.path.isfile(scriptName):
                return False

            from fileutils import (detectFileType, PythonFileType,
                                   Python3FileType)
            if detectFileType(scriptName) in [PythonFileType, Python3FileType]:
                return True
            return False
Ejemplo n.º 6
0
        def isProjectScriptValid( self ):
            " True if the project script valid "
            scriptName = self.project.getProjectScript()
            if not os.path.exists( scriptName ):
                return False
            scriptName = os.path.realpath( scriptName )
            if not os.path.isfile( scriptName ):
                return False

            from fileutils import ( detectFileType, PythonFileType,
                                    Python3FileType )
            if detectFileType( scriptName ) in [ PythonFileType,
                                                 Python3FileType ]:
                return True
            return False
Ejemplo n.º 7
0
        def validateRopeProject( self, fileName = "" ):
            " Validates the existed rope project if so "
            if not self.project.isLoaded():
                return

            # Currently rope supports validating of directories only
            # There is a hope that it will support validating a single file
            # one day. So the fileName argument is ignored by now and the whole
            # project is invalidated.
            if fileName != "":
                from fileutils import ( detectFileType, PythonFileType,
                                        Python3FileType )
                fileType = detectFileType( fileName )
                if fileType not in [ PythonFileType, Python3FileType ]:
                    return
            self.project.validateRopeProject( fileName )
            return
Ejemplo n.º 8
0
        def validateRopeProject(self, fileName=""):
            " Validates the existed rope project if so "
            if not self.project.isLoaded():
                return

            # Currently rope supports validating of directories only
            # There is a hope that it will support validating a single file
            # one day. So the fileName argument is ignored by now and the whole
            # project is invalidated.
            if fileName != "":
                from fileutils import (detectFileType, PythonFileType,
                                       Python3FileType)
                fileType = detectFileType(fileName)
                if fileType not in [PythonFileType, Python3FileType]:
                    return
            self.project.validateRopeProject(fileName)
            return