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


Python GlobalData.getWidgetByUUID方法代码示例

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


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

示例1: __errorActivated

# 需要导入模块: from utils.globals import GlobalData [as 别名]
# 或者: from utils.globals.GlobalData import getWidgetByUUID [as 别名]
    def __errorActivated( self, item, column ):
        " Handles the double click (or Enter) on the item "

        linePos = str( item.text( 1 ) )
        if ":" in linePos:
            parts = linePos.split( ":" )
            lineNumber = int( parts[ 0 ] )
            pos = int( parts[ 1 ] )
        else:
            lineNumber = int( linePos )
            pos = 0

        if self.__reportOption in [ self.SingleFile, self.DirectoryFiles,
                                    self.ProjectFiles ]:
            fileName = str( item.text( 0 ) )
        else:
            # SingleBuffer
            if self.__reportFileName != "":
                if os.path.isabs( self.__reportFileName ):
                    fileName = self.__reportFileName
                else:
                    # Could be unsaved buffer, so try to search by the
                    mainWindow = GlobalData().mainWindow
                    widget = mainWindow.getWidgetByUUID( self.__reportUUID )
                    if widget is None:
                        logging.error( "The unsaved buffer has been closed" )
                        return
                    # The widget was found, so jump to the required
                    editor = widget.getEditor()
                    editor.gotoLine( lineNumber, pos )
                    editor.setFocus()
                    return

        GlobalData().mainWindow.openFile( fileName, lineNumber, pos )
        return
开发者ID:eaglexmw,项目名称:codimension,代码行数:37,代码来源:pylintviewer.py

示例2: search

# 需要导入模块: from utils.globals import GlobalData [as 别名]
# 或者: from utils.globals.GlobalData import getWidgetByUUID [as 别名]
    def search( self, expression ):
        " Perform search within this item "

        self.matches = []
        if self.bufferUUID != "":
            # Search item is the currently loaded buffer
            mainWindow = GlobalData().mainWindow
            widget = mainWindow.getWidgetByUUID( self.bufferUUID )
            if widget is not None:
                # Search in the buffer

                content = widget.getEditor().text().splitlines()
                self.__lookThroughLines( content, expression )
                return

        # Here: there were no buffer or have not found it
        #       try searching in a file
        if not os.path.isabs( self.fileName ) or \
           not os.path.exists( self.fileName ):
            # Unfortunately not all network file systems report the
            # fact that a file has been deleted from the disk so
            # let's simply ignore such files
            return

        # File exists, search in the file
        try:
            f = open( self.fileName )
            content = f.read().split( "\n" )
            f.close()
            self.__lookThroughLines( content, expression )
        except:
            logging.error( "Cannot read " + self.fileName )
        return
开发者ID:eaglexmw,项目名称:codimension,代码行数:35,代码来源:findinfiles.py

示例3: __allItemActivated

# 需要导入模块: from utils.globals import GlobalData [as 别名]
# 或者: from utils.globals.GlobalData import getWidgetByUUID [as 别名]
    def __allItemActivated( self, item, column ):
        " Handles the double click (or Enter) in the total results tree "

        # We process only the error messages and McCabe items
        hiddenColumnText = str( item.text( 2 ) )
        if not hiddenColumnText in [ "M", "E" ]:
            return

        fileName = self.__getTreeItemFileName( item )
        lineNumber = 0
        if hiddenColumnText == "M":
            # This is McCabe item
            objName = str( item.text( 0 ) )
            self.__onMcCabeObject( objName, fileName )
            return
        elif hiddenColumnText == "E":
            # This is an error message
            message = str( item.text( 0 ) )
            pos = message.find( "at line" )
            if pos == -1:
                logging.error( "Unknown format of the message. "
                               "Please inform the developers." )
                return
            parts = message[ pos: ].split()
            try:
                lineNumber = int( parts[ 2 ].replace( ',', '' ) )
            except:
                logging.error( "Unknown format of the message. "
                               "Please inform the developers." )
                return

            if fileName == "":
                # This is an unsaved buffer, try to find the editor by UUID
                mainWindow = GlobalData().mainWindow
                widget = mainWindow.getWidgetByUUID( self.__reportUUID )
                if widget is None:
                    logging.error( "The unsaved buffer has been closed" )
                    return
                # The widget was found, so jump to the required
                editor = widget.getEditor()
                editor.gotoLine( lineNumber )
                editor.setFocus()
                return

        GlobalData().mainWindow.openFile( fileName, lineNumber )
        return
开发者ID:eaglexmw,项目名称:codimension,代码行数:48,代码来源:pymetricsviewer.py

示例4: addMatch

# 需要导入模块: from utils.globals import GlobalData [as 别名]
# 或者: from utils.globals.GlobalData import getWidgetByUUID [as 别名]
    def addMatch( self, name, lineNumber ):
        " Used to add a match which was found outside of find in files "
        match = Match( lineNumber, 0, 0 )

        # Load the file and identify matched line and tooltip
        try:
            if self.bufferUUID != "":
                mainWindow = GlobalData().mainWindow
                widget = mainWindow.getWidgetByUUID( self.bufferUUID )
                if widget is not None:
                    content = widget.getEditor().text().splitlines()
                else:
                    raise Exception( "Inconsistency. Buffer disappeared." )
            else:
                f = open( self.fileName )
                content = f.read().split( "\n" )
                f.close()

            self.__fillInMatch( match, content, name, lineNumber )
        except:
            pass

        self.matches.append( match )
        return
开发者ID:eaglexmw,项目名称:codimension,代码行数:26,代码来源:findinfiles.py

示例5: __onMcCabeObject

# 需要导入模块: from utils.globals import GlobalData [as 别名]
# 或者: from utils.globals.GlobalData import getWidgetByUUID [as 别名]
    def __onMcCabeObject( self, objName, fileName ):
        " Called when the user activated McCabe item "

        info = None

        mainWindow = GlobalData().mainWindow
        widget = mainWindow.getWidgetByUUID( self.__reportUUID )
        if widget is None:
            if fileName == "":
                logging.error( "The unsaved buffer has been closed" )
                return
            # No widget, but we know the file name
            info = getBriefModuleInfoFromFile( fileName )
        else:
            # The widget was found
            editor = widget.getEditor()
            # The editor content has been modified, so re-parse the buffer
            info = getBriefModuleInfoFromMemory( editor.text() )

        parts = objName.split( '.' )
        currentIndex = 0
        functionsContainer = info.functions
        classesContainer = info.classes
        line = -1

        if objName == "__main__" and len( parts ) == 1:
            # Special case - global file scope
            line = 1
            currentIndex = 1

        while currentIndex < len( parts ):
            found = False
            for func in functionsContainer:
                if func.name == parts[ currentIndex ]:
                    if currentIndex == len( parts ) - 1:
                        # Found, jump to the line
                        line = func.line
                        break
                    functionsContainer = func.functions
                    classesContainer = func.classes
                    found = True
                    break
            if line != -1:
                break
            if found:
                currentIndex += 1
                continue
            for klass in classesContainer:
                if klass.name == parts[ currentIndex ]:
                    if currentIndex == len( parts ) - 1:
                        # Found, jump to the line
                        line = klass.line
                        break
                    functionsContainer = klass.functions
                    classesContainer = klass.classes
                    found = True
            if line != -1:
                break
            if found:
                currentIndex += 1
                continue

            # Not found
            logging.error( "Cannot find the " + objName )
            return

        # Here we have the line number
        if widget is None:
            GlobalData().mainWindow.openFile( fileName, line )
        else:
            editor = widget.getEditor()
            editor.gotoLine( line )
            editor.setFocus()
        return
开发者ID:eaglexmw,项目名称:codimension,代码行数:76,代码来源:pymetricsviewer.py


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