def printTable(self): #print(",".join(self.filter)) from oscpluginoverview.texttable import Texttable table = Texttable() table.set_color(self.colorize) table.set_attr('G', 0) # green headline table.set_attr('B', None, 0) # blue 1st col rows = [] header = [] #header.append(" ") header.append("package") for r in self.repos: header.append(r) rows.append(header) for p in self.packages: # Don't print if the package is filtered if p in self.filter: continue row = [] row.append(p) cmp = None for r in self.repos: v = self.versions[r][p] if v == None: v = '-' if cmp == None: cmp = v else: # version has become multiline! # pkg version, rev in prj and req number # for obssr repos. 1st. col is usually # the devel prj, so test whether the # others have the same ver/rev. #+=========+========+==========+ #| pkg | obs:// | obssr:// | #+=========+========+==========+ #| apache2 | 3.3 | 3.3 | #| | rev 1 | rev 1 | #| | | #15022 | #+---------+--------+----------+ if not v.startswith(cmp): table.set_attr('R', len(rows), len(row)) row.append(v) rows.append(row) #versions[repo] = version #row.append(version) #packages = oscpluginoverview.sources.evalPackages(repos, data, pkgopt) table.add_rows(rows) if self.config.has_option(self.name, 'nopackages'): print(table.colorize_text('M', "(blacklisted: %s)" % self.config.get(self.name, 'nopackages'))) print(table.colorize_text('M',"** %s ** " % self.name)) print(table.draw()) print
def printTable(self): # print(",".join(self.filter)) from oscpluginoverview.texttable import Texttable table = Texttable() table.set_color(self.colorize) table.set_attr("G", 0) # green headline table.set_attr("B", None, 0) # blue 1st col rows = [] header = [] # header.append(" ") header.append("package") for r in self.repos: header.append(r) rows.append(header) for p in self.packages: # Don't print if the package is filtered if p in self.filter: continue row = [] row.append(p) cmp = None for r in self.repos: v = self.versions[r][p] if v == None: v = "-" if cmp == None: cmp = v else: # version has become multiline! # pkg version, rev in prj and req number # for obssr repos. 1st. col is usually # the devel prj, so test whether the # others have the same ver/rev. # +=========+========+==========+ # | pkg | obs:// | obssr:// | # +=========+========+==========+ # | apache2 | 3.3 | 3.3 | # | | rev 1 | rev 1 | # | | | #15022 | # +---------+--------+----------+ if not v.startswith(cmp): table.set_attr("R", len(rows), len(row)) row.append(v) rows.append(row) # versions[repo] = version # row.append(version) # packages = oscpluginoverview.sources.evalPackages(repos, data, pkgopt) table.add_rows(rows) if self.config.has_option(self.name, "nopackages"): print(table.colorize_text("M", "(blacklisted: %s)" % self.config.get(self.name, "nopackages"))) print(table.colorize_text("M", "** %s ** " % self.name)) print(table.draw()) print
def changelogDiff(self): """ Returns a diff with package changes (obtained from the .changes file) of the whole group. The 2 newer versions are used to compare """ config = self.config view = self.name diffidx = None if config.has_option(view, 'repodiff'): raw = config.get(view, 'repodiff') idx = raw.split(',') if len(idx) == 2: i0 = atoi(idx[0]) - 1 i1 = atoi(idx[1]) - 1 if i0 == i1 or i0 < 0 or i1 < 0 or i0 >= len(self.repos) or i1 >= len(self.repos): raise Exception("repodiff index out of range got '%s'" % raw) diffidx = (i0, i1) else: raise Exception("malformed repodiff expecting '<NUMBER>,<NUMBER>' got '%s'" % raw) if not self.changelog: file_str = StringIO() file_str.write("Looking for changes..\n") # find higher version per package and where does it come from # map package to bigger version for package, repovers in self.versions_rev.items(): res = [] if diffidx: for e in repovers.items(): if e[0] == self.repos[diffidx[0]]: res.insert(0, e) elif e[0] == self.repos[diffidx[1]]: res.append(e) else: res = sorted(repovers.items(), lambda x, y: self.packageCompare(package, x, y)) # now we have a list of tuples (repo, version) for this package # we find the last two and ask for the changes file. Take care # the package version is not None, and also the changelog isn't. # Changelog None indicates the repo does not provide changes (obssr://). if len(res) >= 2: idx = len(res) - 1 changesnew = None reponew = None while idx >= 0: if res[idx][1]: reponew = res[idx][0] changesnew = self.data[reponew].changelog(package) idx -= 1 if changesnew != None: break if changesnew == None: continue changesold = None repoold = None while idx >= 0: if res[idx][1]: repoold = res[idx][0] changesold = self.data[repoold].changelog(package) idx -= 1 if changesold != None: break if changesold == None: continue self.changelog_packages.append(package) changesdiff = oscpluginoverview.diff.diff_strings(changesold, changesnew) if not changesdiff: # suppress empty diffs continue from oscpluginoverview.texttable import Texttable table = Texttable() table.set_color(self.colorize) file_str.write(table.colorize_text('B', "+--------------------------------------------------------------------------+\n")) file_str.write(table.colorize_text('B', "------- %s ( %s vs %s )\n" % (package, reponew, repoold))) file_str.write(table.colorize_text('B', "+--------------------------------------------------------------------------+\n")) file_str.write(changesdiff) file_str.write("\n") self.changelog = file_str.getvalue() # if the changelog was cached # just return it return self.changelog
def changelogDiff(self): """ Returns a diff with package changes (obtained from the .changes file) of the whole group. The 2 newer versions are used to compare """ config = self.config view = self.name diffidx = None if config.has_option(view, "repodiff"): raw = config.get(view, "repodiff") idx = raw.split(",") if len(idx) == 2: i0 = atoi(idx[0]) - 1 i1 = atoi(idx[1]) - 1 if i0 == i1 or i0 < 0 or i1 < 0 or i0 >= len(self.repos) or i1 >= len(self.repos): raise Exception("repodiff index out of range got '%s'" % raw) diffidx = (i0, i1) else: raise Exception("malformed repodiff expecting '<NUMBER>,<NUMBER>' got '%s'" % raw) if not self.changelog: file_str = StringIO() file_str.write("Looking for changes..\n") # find higher version per package and where does it come from # map package to bigger version for package, repovers in self.versions_rev.items(): res = [] if diffidx: for e in repovers.items(): if e[0] == self.repos[diffidx[0]]: res.insert(0, e) elif e[0] == self.repos[diffidx[1]]: res.append(e) else: res = sorted(repovers.items(), lambda x, y: self.packageCompare(package, x, y)) # now we have a list of tuples (repo, version) for this package # we find the last two and ask for the changes file. Take care # the package version is not None, and also the changelog isn't. # Changelog None indicates the repo does not provide changes (obssr://). if len(res) >= 2: idx = len(res) - 1 changesnew = None reponew = None while idx >= 0: if res[idx][1]: reponew = res[idx][0] changesnew = self.data[reponew].changelog(package) idx -= 1 if changesnew != None: break if changesnew == None: continue changesold = None repoold = None while idx >= 0: if res[idx][1]: repoold = res[idx][0] changesold = self.data[repoold].changelog(package) idx -= 1 if changesold != None: break if changesold == None: continue self.changelog_packages.append(package) changesdiff = oscpluginoverview.diff.diff_strings(changesold, changesnew) if not changesdiff: # suppress empty diffs continue from oscpluginoverview.texttable import Texttable table = Texttable() table.set_color(self.colorize) file_str.write( table.colorize_text( "B", "+--------------------------------------------------------------------------+\n" ) ) file_str.write(table.colorize_text("B", "------- %s ( %s vs %s )\n" % (package, reponew, repoold))) file_str.write( table.colorize_text( "B", "+--------------------------------------------------------------------------+\n" ) ) file_str.write(changesdiff) file_str.write("\n") self.changelog = file_str.getvalue() # if the changelog was cached # just return it return self.changelog