def importPatterns(self, text): imports, num = es_TargetResists.importPatterns(text) lenImports = len(imports) if lenImports == 0: raise ImportError("No patterns found for import") if lenImports != num: raise ImportError( "%d patterns imported from clipboard; %d had errors" % (num, num - lenImports))
def importPatterns(self, text): lookup = {} current = self.getTargetResistsList() for pattern in current: lookup[pattern.name] = pattern imports, num = es_TargetResists.importPatterns(text) for pattern in imports: if pattern.name in lookup: match = lookup[pattern.name] match.__dict__.update(pattern.__dict__) else: db.save(pattern) db.commit() lenImports = len(imports) if lenImports == 0: raise ImportError("No patterns found for import") if lenImports != num: raise ImportError("%d patterns imported from clipboard; %d had errors" % (num, num - lenImports))
def importPatterns(self, text): lookup = {} current = self.getTargetResistsList() for pattern in current: lookup[pattern.name] = pattern imports, num = es_TargetResists.importPatterns(text) for pattern in imports: if pattern.name in lookup: match = lookup[pattern.name] match.__dict__.update(pattern.__dict__) else: db.save(pattern) db.commit() lenImports = len(imports) if lenImports == 0: raise ImportError("No patterns found for import") if lenImports != num: raise ImportError( "%d patterns imported from clipboard; %d had errors" % (num, num - lenImports))
def exportPatterns(self): patterns = self.getTargetResistsList() patterns.sort(key=lambda p: p.name) return es_TargetResists.exportPatterns(*patterns)
def __init__(self, parent, style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE | wx.FRAME_FLOAT_ON_PARENT): wx.Frame.__init__(self, parent, title=u"pyfa: Graph Generator", style=style, size=(520, 390)) try: self.plotPanel = PlotPanelMPL(self) except Exception as e: pyfalog.critical(e) return self.SetIcon( wx.IconFromBitmap(BitmapLoader.getBitmap("graphs_small", "gui"))) self.mainFrame = gui.mainFrame.MainFrame.getInstance() self.CreateStatusBar() sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(sizer) self.graphSelection = wx.Choice(self) for view in Graph.views: view = view() self.graphSelection.Append(view.getName(), view) sizer.Add(self.graphSelection, 0, wx.EXPAND) sizer.Add(self.plotPanel, 1, wx.EXPAND) linePanel = wx.Panel(self) lineSizer = wx.BoxSizer(wx.HORIZONTAL) linePanel.SetSizer(lineSizer) sizer.Add(linePanel, 0, wx.EXPAND) self.buttonLineColor = wx.Button(linePanel, label=" ", style=wx.BU_EXACTFIT | wx.BORDER_NONE) self.buttonLineColor.SetSize(2 * self.buttonLineColor.GetSize()[-1:]) lineSizer.Add(self.buttonLineColor, 0, flag=wx.SHAPED | wx.ALIGN_CENTER_VERTICAL | wx.ALL, border=3) self.labelLine = wx.StaticText(linePanel, label="") lineSizer.Add(self.labelLine, 1, flag=wx.ALIGN_CENTER_VERTICAL | wx.ALL, border=3) sizer.Add(wx.StaticLine(self, style=wx.LI_HORIZONTAL), 0, wx.EXPAND) self.controlPanel = wx.Panel(self) self.controlSizer = wx.BoxSizer(wx.VERTICAL) self.controlPanel.SetSizer(self.controlSizer) sizer.Add(self.controlPanel, 0, wx.EXPAND) sizer.Add(wx.StaticLine(self, style=wx.LI_HORIZONTAL), 0, wx.EXPAND) listPanel = wx.Panel(self) listSizer = wx.BoxSizer(wx.HORIZONTAL) listPanel.SetSizer(listSizer) sizer.Add(listPanel, 0, wx.EXPAND) self.fitList = FitList(listPanel, self) self.fitList.SetMinSize((270, -1)) listSizer.Add(self.fitList, 1, wx.EXPAND) self.tgtList = TargetList(listPanel, self) self.tgtList.SetMinSize((270, -1)) listSizer.Add(self.tgtList, 1, wx.EXPAND) self.graphSelection.Bind(wx.EVT_CHOICE, self.onSelectViewChanged) self.buttonLineColor.Bind(wx.EVT_BUTTON, self.onButtonColorClick) self.Bind(EVT_COLORPOPUP_SELECT, self.onSelectColor) self.fitList.fitList.Bind(wx.EVT_LEFT_DCLICK, self.removeItem) self.fitList.fitList.Bind(wx.EVT_RIGHT_DOWN, self.onAttackerContext) self.tgtList.fitList.Bind(wx.EVT_LEFT_DCLICK, self.removeTarget) self.tgtList.fitList.Bind(wx.EVT_RIGHT_DOWN, self.onTargetContext) self.mainFrame.Bind(GE.FIT_CHANGED, self.onFitChanged) self.mainFrame.Bind(GE.TARGET_RESISTS_CHANGED, self.onTargetResistsChanged) self.Bind(wx.EVT_CLOSE, self.onClose) self.dummyTargetProfile = TargetResists() self.dummyTargetProfile.name = "Dummy" self.fits = collections.OrderedDict() fitID = self.mainFrame.getActiveFit() if fitID: self.fits[fitID] = Fit.getInstance().getFit(fitID) self.fitList.fitList.update(self.fits.values()) self.tgts = collections.OrderedDict() self.fields = {} self.markerX = 0 self.selected = None self.nextColor = 0 self.lineColor = {} self.lineData = {} self.currentViewIndex = None self.currentView = None self.selectView(0) self.Fit() self.SetMinSize(self.GetSize())