Ejemplo n.º 1
0
    def process( self ):
        """ Parses the content and displays the results """

        if not self.__connected:
            self.__connectEditorSignals()

        content = self.__editor.text()
        cf = getControlFlowFromMemory( content )
        if cf.errors:
            self.__navBar.updateInfoIcon( self.__navBar.STATE_BROKEN_UTD )
            errors = []
            for err in cf.errors:
                if err[ 0 ] == -1 and err[ 1 ] == -1:
                    errors.append( err[ 2 ] )
                elif err[ 1 ] == -1:
                    errors.append( "[" + str( err[0] ) + ":] " + err[ 2 ] )
                elif err[ 0 ] == -1:
                    errors.append( "[:" + str( err[1] ) + "] " + err[ 2 ] )
                else:
                    errors.append( "[" + str( err[0] ) + ":" + str( err[1] ) + "] " + err[ 2 ] )
            self.__navBar.setErrors( errors )
            return
        self.__cf = cf

        # Validate CML comments
        cmlWarnings = CMLVersion.validateCMLComments( self.__cf )
        if cmlWarnings:
            self.__cf.warnings += cmlWarnings

        # That will clear the error tooltip as well
        self.__navBar.updateInfoIcon( self.__navBar.STATE_OK_UTD )

        if self.__cf.warnings:
            warnings = []
            for warn in self.__cf.warnings:
                if warn[ 0 ] == -1 and warn[ 1 ] == -1:
                    warnings.append( warn[ 2 ] )
                elif warn[ 1 ] == -1:
                    warnings.append( "[" + str( warn[0] ) + ":] " + warn[ 2 ] )
                elif warn[ 0 ] == -1:
                    warnings.append( "[:" + str( warn[1] ) + "] " + warn[ 2 ] )
                else:
                    warnings.append( "[" + str( warn[0] ) + ":" + str( warn[1] ) + "] " + warn[ 2 ] )
            self.__navBar.setWarnings( warnings )
        else:
            self.__navBar.clearWarnings()

        self.scene.clear()
        try:
            # Top level canvas has no adress and no parent canvas
            canvas = VirtualCanvas( self.cflowSettings, None, None, None )
            canvas.layoutModule( self.__cf )
            canvas.setEditor( self.__editor )
            width, height = canvas.render()
            self.scene.setSceneRect( 0, 0, width, height )
            canvas.draw( self.scene, 0, 0 )
        except Exception, exc:
            logging.error( str( exc ) )
            raise
Ejemplo n.º 2
0
    def process(self):
        """Parses the content and displays the results"""
        if not self.__connected:
            self.__connectEditorSignals()

        start = timer()
        cf = getControlFlowFromMemory(self.__editor.text)
        end = timer()
        if cf.errors:
            self.__navBar.updateInfoIcon(self.__navBar.STATE_BROKEN_UTD)
            errors = []
            for err in cf.errors:
                if err[0] == -1 and err[1] == -1:
                    errors.append(err[2])
                elif err[1] == -1:
                    errors.append('[' + str(err[0]) + ':] ' + err[2])
                elif err[0] == -1:
                    errors.append('[:' + str(err[1]) + '] ' + err[2])
                else:
                    errors.append('[' + str(err[0]) + ':' +
                                  str(err[1]) + '] ' + err[2])
            self.__navBar.setErrors(errors)
            return

        self.__cf = cf
        if self.isDebugMode():
            logging.info('Parsed file: %s', formatFlow(str(self.__cf)))
            logging.info('Parse timing: %f', end - start)

        # Collect warnings (parser + CML warnings) and valid groups
        self.__validGroups = []
        self.__allGroupId = set()
        allWarnings = self.__cf.warnings + \
                      CMLVersion.validateCMLComments(self.__cf,
                                                     self.__validGroups,
                                                     self.__allGroupId)

        # That will clear the error tooltip as well
        self.__navBar.updateInfoIcon(self.__navBar.STATE_OK_UTD)

        if allWarnings:
            warnings = []
            for warn in allWarnings:
                if warn[0] == -1 and warn[1] == -1:
                    warnings.append(warn[2])
                elif warn[1] == -1:
                    warnings.append('[' + str(warn[0]) + ':] ' + warn[2])
                elif warn[0] == -1:
                    warnings.append('[:' + str(warn[1]) + '] ' + warn[2])
                else:
                    warnings.append('[' + str(warn[0]) + ':' +
                                    str(warn[1]) + '] ' + warn[2])
            self.__navBar.setWarnings(warnings)
        else:
            self.__navBar.clearWarnings()

        self.redrawScene()
Ejemplo n.º 3
0
    def process(self):
        """ Parses the content and displays the results """

        if not self.__connected:
            self.__connectEditorSignals()

        content = self.__editor.text()
        cf = getControlFlowFromMemory(content)
        if cf.errors:
            self.__navBar.updateInfoIcon(self.__navBar.STATE_BROKEN_UTD)
            errors = []
            for err in cf.errors:
                if err[0] == -1 and err[1] == -1:
                    errors.append(err[2])
                elif err[1] == -1:
                    errors.append("[" + str(err[0]) + ":] " + err[2])
                elif err[0] == -1:
                    errors.append("[:" + str(err[1]) + "] " + err[2])
                else:
                    errors.append("[" + str(err[0]) + ":" + str(err[1]) +
                                  "] " + err[2])
            self.__navBar.setErrors(errors)
            return
        self.__cf = cf

        # Validate CML comments
        cmlWarnings = CMLVersion.validateCMLComments(self.__cf)
        if cmlWarnings:
            self.__cf.warnings += cmlWarnings

        # That will clear the error tooltip as well
        self.__navBar.updateInfoIcon(self.__navBar.STATE_OK_UTD)

        if self.__cf.warnings:
            warnings = []
            for warn in self.__cf.warnings:
                if warn[0] == -1 and warn[1] == -1:
                    warnings.append(warn[2])
                elif warn[1] == -1:
                    warnings.append("[" + str(warn[0]) + ":] " + warn[2])
                elif warn[0] == -1:
                    warnings.append("[:" + str(warn[1]) + "] " + warn[2])
                else:
                    warnings.append("[" + str(warn[0]) + ":" + str(warn[1]) +
                                    "] " + warn[2])
            self.__navBar.setWarnings(warnings)
        else:
            self.__navBar.clearWarnings()

        self.scene.clear()
        try:
            # Top level canvas has no adress and no parent canvas
            canvas = VirtualCanvas(self.cflowSettings, None, None, None)
            canvas.layoutModule(self.__cf)
            canvas.setEditor(self.__editor)
            width, height = canvas.render()
            self.scene.setSceneRect(0, 0, width, height)
            canvas.draw(self.scene, 0, 0)
        except Exception, exc:
            logging.error(str(exc))
            raise