当前位置: 首页>>代码示例>>Python>>正文


Python GlobalData.getWidgetForFileName方法代码示例

本文整理汇总了Python中utils.globals.GlobalData.getWidgetForFileName方法的典型用法代码示例。如果您正苦于以下问题:Python GlobalData.getWidgetForFileName方法的具体用法?Python GlobalData.getWidgetForFileName怎么用?Python GlobalData.getWidgetForFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utils.globals.GlobalData的用法示例。


在下文中一共展示了GlobalData.getWidgetForFileName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getImportedNameDefinitionLine

# 需要导入模块: from utils.globals import GlobalData [as 别名]
# 或者: from utils.globals.GlobalData import getWidgetForFileName [as 别名]
def getImportedNameDefinitionLine( path, name, info = None ):
    """ Searches for the given name in the given file and provides its
        line number. -1 if not found.
        Only top level names are searched through. """
    if info is None:
        mainWindow = GlobalData().mainWindow
        widget = mainWindow.getWidgetForFileName( os.path.realpath( path ) )
        if widget is None:
            # The file is not opened now
            info = getBriefModuleInfoFromFile( path )
        else:
            editor = widget.getEditor()
            info = getBriefModuleInfoFromMemory( editor.text() )

    # Check the object names
    for classObj in info.classes:
        if classObj.name == name:
            return classObj.line
    for funcObj in info.functions:
        if funcObj.name == name:
            return funcObj.line
    for globalObj in info.globals:
        if globalObj.name == name:
            return globalObj.line

    return -1
开发者ID:eaglexmw,项目名称:codimension,代码行数:28,代码来源:importutils.py

示例2: __populateFromProject

# 需要导入模块: from utils.globals import GlobalData [as 别名]
# 或者: from utils.globals.GlobalData import getWidgetForFileName [as 别名]
    def __populateFromProject( self ):
        " Populates find name dialog from the project files "

        mainWindow = GlobalData().mainWindow
        for fname in GlobalData().project.filesList:
            if detectFileType( fname ) in [ PythonFileType, Python3FileType ]:
                widget = mainWindow.getWidgetForFileName( fname )
                if widget is None:
                    info = GlobalData().briefModinfoCache.get( fname )
                else:
                    content = widget.getEditor().text()
                    info = getBriefModuleInfoFromMemory( content )
                self.__populateInfo( info, fname )
        return
开发者ID:eaglexmw,项目名称:codimension,代码行数:16,代码来源:findname.py

示例3: __projectFiles

# 需要导入模块: from utils.globals import GlobalData [as 别名]
# 或者: from utils.globals.GlobalData import getWidgetForFileName [as 别名]
 def __projectFiles( self, filterRe ):
     " Project files list respecting the mask "
     mainWindow = GlobalData().mainWindow
     files = []
     for fname in GlobalData().project.filesList:
         if fname.endswith( sep ):
             continue
         if filterRe is None or filterRe.match( fname ):
             widget = mainWindow.getWidgetForFileName( fname )
             if widget is None:
                 # Do not check for broken symlinks
                 if isFileSearchable( fname, False ):
                     files.append( ItemToSearchIn( fname, "" ) )
             else:
                 if widget.getType() in \
                             [ MainWindowTabWidgetBase.PlainTextEditor ]:
                     files.append( ItemToSearchIn( fname,
                                                   widget.getUUID() ) )
         QApplication.processEvents()
         if self.__cancelRequest:
             raise Exception( "Cancel request" )
     return files
开发者ID:eaglexmw,项目名称:codimension,代码行数:24,代码来源:findinfiles.py

示例4: __dirFiles

# 需要导入模块: from utils.globals import GlobalData [as 别名]
# 或者: from utils.globals.GlobalData import getWidgetForFileName [as 别名]
 def __dirFiles( self, path, filterRe, files ):
     " Files recursively for the dir "
     for item in os.listdir( path ):
         QApplication.processEvents()
         if self.__cancelRequest:
             raise Exception( "Cancel request" )
         if os.path.isdir( path + item ):
             if item in [ ".svn", ".cvs" ]:
                 # It does not make sense to search in revision control dirs
                 continue
             anotherDir, isLoop = resolveLink( path + item )
             if not isLoop:
                 self.__dirFiles( anotherDir + sep,
                                  filterRe, files )
             continue
         if not os.path.isfile( path + item ):
             continue
         realItem, isLoop = resolveLink( path + item )
         if isLoop:
             continue
         if filterRe is None or filterRe.match( realItem ):
             found = False
             for itm in files:
                 if itm.fileName == realItem:
                     found = True
                     break
             if not found:
                 mainWindow = GlobalData().mainWindow
                 widget = mainWindow.getWidgetForFileName( realItem )
                 if widget is None:
                     if isFileSearchable( realItem ):
                         files.append( ItemToSearchIn( realItem, "" ) )
                 else:
                     if widget.getType() in \
                                 [ MainWindowTabWidgetBase.PlainTextEditor ]:
                         files.append( ItemToSearchIn( realItem,
                                                       widget.getUUID() ) )
     return
开发者ID:eaglexmw,项目名称:codimension,代码行数:40,代码来源:findinfiles.py

示例5: __populateFromProject

# 需要导入模块: from utils.globals import GlobalData [as 别名]
# 或者: from utils.globals.GlobalData import getWidgetForFileName [as 别名]
    def __populateFromProject( self ):
        " Populates find name dialog from the project files "

        mainWindow = GlobalData().mainWindow
        showTooltips = Settings().findFileTooltips
        for fname in GlobalData().project.filesList:
            if fname.endswith( os.path.sep ):
                continue
            fileType = detectFileType( fname )
            tooltip = ""
            if showTooltips and fileType in [ PythonFileType, Python3FileType ]:
                widget = mainWindow.getWidgetForFileName( fname )
                if widget is None:
                    info = GlobalData().briefModinfoCache.get( fname )
                else:
                    content = widget.getEditor().text()
                    info = getBriefModuleInfoFromMemory( content )
                if info.docstring is not None:
                    tooltip = info.docstring.text
            newItem = FileItem( self.rootItem, getFileIcon( fileType ),
                                fname, tooltip )
            self.rootItem.appendChild( newItem )
            self.count += 1
        return
开发者ID:eaglexmw,项目名称:codimension,代码行数:26,代码来源:findfile.py

示例6: __process

# 需要导入模块: from utils.globals import GlobalData [as 别名]
# 或者: from utils.globals.GlobalData import getWidgetForFileName [as 别名]
    def __process( self ):
        " Analysis process "

        self.__inProgress = True

        mainWindow = GlobalData().mainWindow
        editorsManager = mainWindow.editorsManagerWidget.editorsManager
        modified = editorsManager.getModifiedList( True ) # True - only project files
        if modified:
            modNames = [ modItem[ 0 ] for modItem in modified ]
            label = "File"
            if len( modified ) >= 2:
                label += "s"
            label += ": "
            logging.warning( "The analisys is performed for the content of saved files. " \
                             "The unsaved modifications will not be taken into account. " \
                             + label + ", ".join( modNames ) )

        self.__updateFoundLabel()
        self.__progressBar.setRange( 0,
                                   len( self.__srcModel.rootItem.childItems ) )
        QApplication.processEvents()
        QApplication.setOverrideCursor( QCursor( Qt.WaitCursor ) )

        count = 0
        candidates = []
        for treeItem in self.__srcModel.rootItem.childItems:
            if self.__cancelRequest:
                break

            name = str( treeItem.data( 0 ) ).split( '(' )[ 0 ]
            path = os.path.realpath( treeItem.getPath() )
            lineNumber = int( treeItem.data( 2 ) )
            absPosition = treeItem.sourceObj.absPosition

            count += 1
            self.__progressBar.setValue( count )
            self.__infoLabel.setText( self.__formInfoLabel( name ) )
            QApplication.processEvents()

            # Analyze the name
            found = False
            try:
                # True is for throwing exceptions
                locations = getOccurrences( path, absPosition, True )

                if len( locations ) == 1 and \
                   locations[ 0 ][ 1 ] == lineNumber:
                    found = True
                    index = getSearchItemIndex( candidates, path )
                    if index < 0:
                        widget = mainWindow.getWidgetForFileName( path )
                        if widget is None:
                            uuid = ""
                        else:
                            uuid = widget.getUUID()
                        newItem = ItemToSearchIn( path, uuid )
                        candidates.append( newItem )
                        index = len( candidates ) - 1
                    candidates[ index ].addMatch( name, lineNumber )

            except Exception, exc:
                # There is nothing interesting with exceptions here.
                # It seems to me that rope throws them in case if the same item
                # is declared multiple times in a file. I also suspect that
                # exceptions may come up in case of syntactic errors.
                # So I just suppress them.
                pass

                #logging.warning( "Error detected while analysing " + \
                #                 self.__whatAsString() + " '" + name + \
                #                 "'. Message: " + str( exc ) )

            if found:
                self.__found += 1
                self.__updateFoundLabel()
            QApplication.processEvents()
开发者ID:eaglexmw,项目名称:codimension,代码行数:79,代码来源:notused.py


注:本文中的utils.globals.GlobalData.getWidgetForFileName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。