def SaveConcepts(self, item): (root, ext) = os.path.splitext(item.name) if ext == ".cxt": cxt = uread_cxt(item.path) elif ext == ".txt": cxt = fca.read_txt(item.path) cl = fca.ConceptLattice(cxt) number_of_concepts = len(cl) default_path = "".join([item.path[:-3], "xml"]) newpath = default_path i = 1 while (os.path.exists(newpath)): newpath = default_path[:-4] + "-{0}".format(i) + newpath[-4:] i += 1 fca.write_xml(newpath, cl) dlg = wx.MessageDialog(None, str(number_of_concepts) +\ " concepts have been stored in " + newpath, "Done", wx.OK | wx.ICON_INFORMATION ) dlg.ShowModal() dlg.Destroy() return [newpath]
def GetFilteredConcepts(item): dialog = FilteringDialog() result = dialog.ShowModal() if result == wx.ID_OK: options = dialog.GetOptions() cs = uread_xml(item.path) precessor = item.precessor while not precessor.type == "Context": precessor = precessor.precessor (root, ext) = os.path.splitext(precessor.name) if ext == ".cxt": cxt = fca.read_cxt(precessor.path) elif ext == ".txt": cxt = fca.read_txt(precessor.path) cs.context = cxt new_cs = fca.filter_concepts(cs, options["function"], options["mode"], options["opt"]) default_path = item.path[:-4] + "-filtered.xml" newpath = default_path i = 1 while (os.path.exists(newpath)): newpath = default_path[:-4] + "-{0}".format(i) + newpath[-4:] i += 1 fca.write_xml(newpath, new_cs) newpath = [newpath] else: newpath = [] dialog.Destroy() return newpath
def ComputeIndex(self, item, workspace): cs = uread_xml(item.path) functions = filtering.get_compute_functions() dlg = wx.SingleChoiceDialog(None, 'Choose index you want to compute', 'Choose index', functions.keys(), wx.CHOICEDLG_STYLE) if dlg.ShowModal() == wx.ID_OK: name = dlg.GetStringSelection() precessor = item.precessor while not precessor.type == "Context": precessor = precessor.precessor cs.context = fca.read_cxt(precessor.path) fca.compute_index(cs, functions[name], name) fca.write_xml(item.path, cs) dlg.Destroy()
def ComputeIndex(self, item, workspace): cs = uread_xml(item.path) functions = filtering.get_compute_functions() dlg = wx.SingleChoiceDialog( None, 'Choose index you want to compute', 'Choose index', functions.keys(), wx.CHOICEDLG_STYLE ) if dlg.ShowModal() == wx.ID_OK: name = dlg.GetStringSelection() precessor = item.precessor while not precessor.type == "Context": precessor = precessor.precessor cs.context = fca.read_cxt(precessor.path) fca.compute_index(cs, functions[name], name) fca.write_xml(item.path, cs) dlg.Destroy()
def OnSaveXML(self, event): self.canvas.SaveCoordinates() write_xml(self.path, self.canvas.cs)