def GetMacCabeMetric(path): """ """ complexity = 0.0 try: p = os.path.dirname(path) if p not in sys.path: sys.path.append(p) import maccabe as codepaths except ImportError as info: msg = 'ERROR: maccabe module not imported: %s\n' % info sys.stderr.write(msg) return complexity else: cls = Components.GetClass(path) if inspect.isclass(cls): args = Components.GetArgs(cls) devs = getInstance(cls, args) ### Get class of model if not path.endswith('.pyc'): ### mcCabe complexity ### beware to use tab for devs code of models L = [ getattr(cls, fct) for fct in ('extTransition', 'intTransition', 'outputFnc') if hasattr(cls, fct) ] source_list = list(map(inspect.getsource, L)) L_args = [] for text in source_list: ### textwrap for deleting the indentation ast = codepaths.ast.parse(textwrap.dedent(text).strip()) visitor = codepaths.PathGraphingAstVisitor() visitor.preorder(ast, visitor) for graph in visitor.graphs.values(): complexity += graph.complexity() return complexity ### for .pyc file else: return 0.0 else: return 0.0
def OnItemDeselected(self, event): """ Item has been deselected """ line_number = self.getColumnText(self.currentItem, 2) python_path = self.getColumnText(self.currentItem, 4) if line_number != "": ### DEVS model retrieve devs = getInstance(Components.GetClass(python_path)) ### check error and change image if not isinstance(devs, tuple): self.SetItemImage(self.currentItem, self.idx2)
def OnUpdate(self, evt): """ Update list has been invocked """ ### deep copy of data list D = copy.deepcopy(self.list.itemDataMap) ### update in error line self.list.itemDataMap for k,v in D.items(): line_number = v[2] if line_number != "": python_path = v[-1] devs = getInstance(Components.GetClass(python_path)) ### check error and change image if not isinstance(devs, tuple): self.list.itemDataMap[k] = (v[0], "", "", v[3], v[4]) ### refresh items self.list.RefreshItems(-1,-1)
def OnUpdate(self, evt): """ Update list has been invocked """ ### deep copy of data list D = copy.deepcopy(self.list.itemDataMap) ### update in error line self.list.itemDataMap for k, v in D.items(): line_number = v[2] if line_number != "": python_path = v[-1] devs = getInstance(Components.GetClass(python_path)) ### check error and change image if not isinstance(devs, tuple): self.list.itemDataMap[k] = (v[0], "", "", v[3], v[4]) ### refresh items self.list.RefreshItems(-1, -1)