def diff_selection(self, *args): lrow = self.view.lbox.get_selected_data()[0] rrow = self.view.rbox.get_selected_data()[0] lscript = TraitScript(self.conn, self.lsuite) rscript = TraitScript(self.conn, self.rsuite) lscript.set_trait(lrow.trait) rscript.set_trait(rrow.trait) ldata = lscript.scriptdata(lrow.script) rdata = rscript.scriptdata(rrow.script) differ = Differ(ldata, rdata) differ.diff() if differ.isdifferent('left', ldata): newdata = differ.get_data('left') lscript.update_scriptdata(lrow.script, newdata) if differ.isdifferent('right', rdata): newdata = differ.get_data('right') rscript.update_scriptdata(rrow.script, newdata)
class TraitList(KListView): def __init__(self, app, parent, ftype='template', name='TraitList'): KListView.__init__(self, parent, name) dbwidget(self, app) self.ftype = ftype self.scripts = None self.templates = None self.traits = None self.setRootIsDecorated(True) self.addColumn('trait/file') self.addColumn('name') self.addColumn('package') def set_suite(self, suite): self.scripts = TraitScript(self.conn, suite) self.templates = TraitTemplate(self.conn, suite) self.traits = Traits(self.conn, suite) def refreshlistView(self): self.clear() if self.ftype == 'template': self.setColumnText(1, 'template') elif self.ftype == 'script': self.setColumnText(1, 'script') for trait in self.traits.list(): item = KListViewItem(self, trait) item.trait = trait if self.ftype == 'template': for row in self.templates.templates(trait): titem = KListViewItem(item, str(row.templatefile), row.template, row.package) titem.trait = trait titem.row = row elif self.ftype == 'script': for row in self.scripts.cmd.select(clause=Eq('trait', trait), order='script'): sitem = KListViewItem(item, str(row.scriptfile), row.script) sitem.trait = trait sitem.row = row def getData(self): item = self.currentItem() if self.ftype == 'template': self.templates.set_trait(item.trait) return self.templates.templatedata(item.row.package, item.row.template) elif self.ftype == 'script': self.scripts.set_trait(item.trait) return self.scripts.scriptdata(item.row.script) def updateData(self, data): item = self.currentItem() row = item.row if self.ftype == 'template': self.templates.set_trait(item.trait) self.templates.update_templatedata(row.package, row.template, data) elif self.ftype == 'script': self.scripts.set_trait(item.trait) self.scripts.update_scriptdata(row.script, data)
class TraitList(KListView): def __init__(self, app, parent, ftype='template', name='TraitList'): KListView.__init__(self, parent, name) dbwidget(self, app) self.ftype = ftype self.scripts = None self.templates = None self.traits = None self.trait = None self.setRootIsDecorated(True) self.addColumn('trait/file') self.addColumn('name') self.addColumn('package') def set_suite(self, suite): self.scripts = TraitScript(self.conn, suite) self.templates = TraitTemplate(self.conn, suite) self.traits = Traits(self.conn, suite) def set_trait(self, trait): self.trait = trait def refreshlistView(self): self.clear() if self.ftype == 'template': self.setColumnText(1, 'template') elif self.ftype == 'script': self.setColumnText(1, 'script') if self.trait is None: traits = self.traits.list() else: traits = [self.trait] for trait in traits: item = KListViewItem(self, trait) item.trait = trait if self.ftype == 'template': for row in self.templates.templates(trait): titem = KListViewItem(item, str(row.templatefile), row.template, row.package) titem.trait = trait titem.row = row elif self.ftype == 'script': for row in self.scripts.cmd.select(clause=Eq('trait', trait), order='script'): sitem = KListViewItem(item, str(row.scriptfile), row.script) sitem.trait = trait sitem.row = row def getData(self): item = self.currentItem() if self.ftype == 'template': self.templates.set_trait(item.trait) return self.templates.templatedata(item.row.package, item.row.template) elif self.ftype == 'script': self.scripts.set_trait(item.trait) return self.scripts.scriptdata(item.row.script) def updateData(self, data): item = self.currentItem() row = item.row if self.ftype == 'template': self.templates.set_trait(item.trait) self.templates.update_templatedata(row.package, row.template, data) elif self.ftype == 'script': self.scripts.set_trait(item.trait) self.scripts.update_scriptdata(row.script, data)