From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QO8q7-0005Xq-AV for garchives@archives.gentoo.org; Sun, 22 May 2011 13:37:03 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C0AF71C015; Sun, 22 May 2011 13:36:51 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 509661C015 for ; Sun, 22 May 2011 13:36:51 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 8E6F61B4011 for ; Sun, 22 May 2011 13:36:50 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id D9AAF80506 for ; Sun, 22 May 2011 13:36:49 +0000 (UTC) From: "Paweł Hajdan" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Paweł Hajdan" Message-ID: <59f26733ad4684cc923bd4b299b5498f8f015b37.phajdan.jr@gentoo> Subject: [gentoo-commits] proj/arch-tools:master commit in: / X-VCS-Repository: proj/arch-tools X-VCS-Files: bugzilla-viewer.py X-VCS-Directories: / X-VCS-Committer: phajdan.jr X-VCS-Committer-Name: Paweł Hajdan X-VCS-Revision: 59f26733ad4684cc923bd4b299b5498f8f015b37 Date: Sun, 22 May 2011 13:36:49 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 76bf94e016a4e4b74e5c5948def5b249 commit: 59f26733ad4684cc923bd4b299b5498f8f015b37 Author: Pawel Hajdan, Jr gentoo org> AuthorDate: Sun May 22 13:36:34 2011 +0000 Commit: Pawe=C5=82 Hajdan gentoo org> CommitDate: Sun May 22 13:36:34 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/arch-tools.gi= t;a=3Dcommit;h=3D59f26733 Cleanup: convert all indentation to tabs. --- bugzilla-viewer.py | 292 ++++++++++++++++++++++++++--------------------= ------ 1 files changed, 146 insertions(+), 146 deletions(-) diff --git a/bugzilla-viewer.py b/bugzilla-viewer.py index bf034cc..d1de3c0 100755 --- a/bugzilla-viewer.py +++ b/bugzilla-viewer.py @@ -22,163 +22,163 @@ class TermTooSmall(Exception): =20 # Main class (called with curses.wrapper later). class MainWindow: - def __init__(self, screen, bugs, bugs_dict, packages_dict, related_b= ugs, repoman_dict): - self.bugs =3D bugs - self.bugs_dict =3D bugs_dict - self.packages_dict =3D packages_dict - self.related_bugs =3D related_bugs - self.repoman_dict =3D repoman_dict -=09 - curses.curs_set(0) - self.screen =3D screen - - curses.use_default_colors() - self.init_screen() - - c =3D self.screen.getch() - while c not in ( ord("q"), curses.ascii.ESC): - if c =3D=3D ord("j"): - self.scroll_bugs_pad(1) - elif c =3D=3D ord("k"): - self.scroll_bugs_pad(-1) - elif c =3D=3D curses.KEY_DOWN: - self.scroll_contents_pad(1) - elif c =3D=3D curses.KEY_UP: - self.scroll_contents_pad(-1) - elif c =3D=3D curses.KEY_RESIZE: - self.init_screen() - - c =3D self.screen.getch() - - def init_screen(self): - (self.height, self.width) =3D self.screen.getmaxyx() - - if self.height < 12 or self.width < 80: - raise TermTooSmall() - - self.screen.border() - self.screen.vline(1, self.width / 3, curses.ACS_VLINE, self.height - 2) - self.screen.refresh() - - self.fill_bugs_pad() - self.refresh_bugs_pad() - - self.fill_contents_pad() - self.refresh_contents_pad() - - def fill_bugs_pad(self): - self.bugs_pad =3D curses.newpad(len(self.bugs),self.width) - self.bugs_pad.erase() - - self.bugs_pad_pos =3D 0 + def __init__(self, screen, bugs, bugs_dict, packages_dict, related_bugs= , repoman_dict): + self.bugs =3D bugs + self.bugs_dict =3D bugs_dict + self.packages_dict =3D packages_dict + self.related_bugs =3D related_bugs + self.repoman_dict =3D repoman_dict + + curses.curs_set(0) + self.screen =3D screen + + curses.use_default_colors() + self.init_screen() + + c =3D self.screen.getch() + while c not in (ord("q"), curses.ascii.ESC): + if c =3D=3D ord("j"): + self.scroll_bugs_pad(1) + elif c =3D=3D ord("k"): + self.scroll_bugs_pad(-1) + elif c =3D=3D curses.KEY_DOWN: + self.scroll_contents_pad(1) + elif c =3D=3D curses.KEY_UP: + self.scroll_contents_pad(-1) + elif c =3D=3D curses.KEY_RESIZE: + self.init_screen() + + c =3D self.screen.getch() + + def init_screen(self): + (self.height, self.width) =3D self.screen.getmaxyx() + + if self.height < 12 or self.width < 80: + raise TermTooSmall() + + self.screen.border() + self.screen.vline(1, self.width / 3, curses.ACS_VLINE, self.height - 2= ) + self.screen.refresh() + + self.fill_bugs_pad() + self.refresh_bugs_pad() + + self.fill_contents_pad() + self.refresh_contents_pad() + + def fill_bugs_pad(self): + self.bugs_pad =3D curses.newpad(len(self.bugs),self.width) + self.bugs_pad.erase() =20 - for i in range(len(self.bugs)): - self.bugs_pad.addstr(i, 0, - " " + self.bugs[i].find('bug_id').text= + " " + self.bugs[i].find('short_desc').text) - - def scroll_bugs_pad(self, amount): - height =3D len(self.bugs) - - self.bugs_pad_pos +=3D amount - if self.bugs_pad_pos < 0: self.bugs_pad_pos =3D 0 - if self.bugs_pad_pos >=3D height: - self.bugs_pad_pos =3D height - 1 - self.refresh_bugs_pad() - - self.fill_contents_pad() - self.refresh_contents_pad() - - def refresh_bugs_pad(self): - (height, width) =3D self.bugs_pad.getmaxyx() - for i in range(height): - self.bugs_pad.addch(i, 0, " ") - self.bugs_pad.addch(self.bugs_pad_pos, 0, "*") - pos =3D min(height - self.height + 2, max(0, self.bugs_pad_pos - (self.= height / 2))) - self.bugs_pad.refresh( - pos, 0, - 1, 1, - self.height - 2, self.width / 3 - 1) - - def fill_contents_pad(self): - width =3D 2 * self.width / 3 - - bug =3D self.bugs[self.bugs_pad_pos] - - output =3D [] - output +=3D textwrap.wrap(bug.find("short_desc").text, width=3Dwidth-2) - output.append("-" * (width - 2)) - - cpvs =3D self.packages_dict[bug.find("bug_id").text] - if cpvs: - output +=3D textwrap.wrap("Found package cpvs:", width=3Dwidth-2) - for cpv in cpvs: - output +=3D textwrap.wrap(cpv, width=3Dwidth-2) - output.append("-" * (width - 2)) =20 - deps =3D bug.findall("dependson") - if deps: - output +=3D textwrap.wrap("Depends on:", width=3Dwidth-2) - for dep in deps: - dep_bug =3D self.bugs_dict[dep.text] - desc =3D dep.text + " " + dep_bug.find("bug_status").text + " " + dep= _bug.find("short_desc").text - output +=3D textwrap.wrap(desc, width=3Dwidth-2) + for i in range(len(self.bugs)): + self.bugs_pad.addstr(i, 0, + " " + self.bugs[i].find('bug_id').text + " " + self.bugs[i].find('s= hort_desc').text) + + def scroll_bugs_pad(self, amount): + height =3D len(self.bugs) + + self.bugs_pad_pos +=3D amount + if self.bugs_pad_pos < 0: + self.bugs_pad_pos =3D 0 + if self.bugs_pad_pos >=3D height: + self.bugs_pad_pos =3D height - 1 + self.refresh_bugs_pad() + + self.fill_contents_pad() + self.refresh_contents_pad() + + def refresh_bugs_pad(self): + (height, width) =3D self.bugs_pad.getmaxyx() + for i in range(height): + self.bugs_pad.addch(i, 0, " ") + self.bugs_pad.addch(self.bugs_pad_pos, 0, "*") + pos =3D min(height - self.height + 2, max(0, self.bugs_pad_pos - (self= .height / 2))) + self.bugs_pad.refresh( + pos, 0, + 1, 1, + self.height - 2, self.width / 3 - 1) + + def fill_contents_pad(self): + width =3D 2 * self.width / 3 + + bug =3D self.bugs[self.bugs_pad_pos] + + output =3D [] + output +=3D textwrap.wrap(bug.find("short_desc").text, width=3Dwidth-2= ) output.append("-" * (width - 2)) + + cpvs =3D self.packages_dict[bug.find("bug_id").text] + if cpvs: + output +=3D textwrap.wrap("Found package cpvs:", width=3Dwidth-2) + for cpv in cpvs: + output +=3D textwrap.wrap(cpv, width=3Dwidth-2) + output.append("-" * (width - 2)) + + deps =3D bug.findall("dependson") + if deps: + output +=3D textwrap.wrap("Depends on:", width=3Dwidth-2) + for dep in deps: + dep_bug =3D self.bugs_dict[dep.text] + desc =3D dep.text + " " + dep_bug.find("bug_status").text + " " + de= p_bug.find("short_desc").text + output +=3D textwrap.wrap(desc, width=3Dwidth-2) + output.append("-" * (width - 2)) =09 - related =3D self.related_bugs[bug.find("bug_id").text] - if related: - output +=3D textwrap.wrap("Related bugs:", width=3Dwidth-2) - for related_bug in related: - if related_bug['bugid'] =3D=3D bug.find("bug_id").text: - continue - desc =3D related_bug['bugid'] + " " + related_bug['desc'] - output +=3D textwrap.wrap(desc, width=3Dwidth-2) - output.append("-" * (width - 2)) + related =3D self.related_bugs[bug.find("bug_id").text] + if related: + output +=3D textwrap.wrap("Related bugs:", width=3Dwidth-2) + for related_bug in related: + if related_bug['bugid'] =3D=3D bug.find("bug_id").text: + continue + desc =3D related_bug['bugid'] + " " + related_bug['desc'] + output +=3D textwrap.wrap(desc, width=3Dwidth-2) + output.append("-" * (width - 2)) =09 - if bug.find("bug_id").text in repoman_dict and repoman_dict[bug.find("b= ug_id").text]: - output +=3D textwrap.wrap("Repoman output:", width=3Dwidth-2) - lines =3D repoman_dict[bug.find("bug_id").text].split("\n") - for line in lines: - output +=3D textwrap.wrap(line, width=3Dwidth-2) - output.append("-" * (width - 2)) + if bug.find("bug_id").text in repoman_dict and repoman_dict[bug.find("= bug_id").text]: + output +=3D textwrap.wrap("Repoman output:", width=3Dwidth-2) + lines =3D repoman_dict[bug.find("bug_id").text].split("\n") + for line in lines: + output +=3D textwrap.wrap(line, width=3Dwidth-2) + output.append("-" * (width - 2)) =09 - for elem in bug.findall("long_desc"): - output +=3D textwrap.wrap("%s:" % elem.find("who").text, width=3Dwidth= -2) - lines =3D elem.find("thetext").text.split("\n") - for line in lines: - output +=3D textwrap.wrap(line, width=3Dwidth-2) - output.append("-" * (width - 2)) - - self.contents_pad_length =3D len(output) - - self.contents_pad =3D curses.newpad(max(self.contents_pad_length= , self.height), width) - self.contents_pad.erase() + for elem in bug.findall("long_desc"): + output +=3D textwrap.wrap("%s:" % elem.find("who").text, width=3Dwidt= h-2) + lines =3D elem.find("thetext").text.split("\n") + for line in lines: + output +=3D textwrap.wrap(line, width=3Dwidth-2) + output.append("-" * (width - 2)) =20 - self.contents_pad_pos =3D 0 + self.contents_pad_length =3D len(output) =20 - for i in range(len(output)): - if type(output[i]) =3D=3D unicode: - real_output =3D output[i] - else: - real_output =3D unicode(output[i], errors=3D'replace') - self.contents_pad.addstr(i, 0, real_output.encode("utf-8")) + self.contents_pad =3D curses.newpad(max(self.contents_pad_length, self= .height), width) + self.contents_pad.erase() =20 - def scroll_contents_pad(self, amount): - height =3D self.contents_pad_length - self.height + 5 - - self.contents_pad_pos +=3D amount - if self.contents_pad_pos < 0: self.contents_pad_pos =3D 0 - if self.contents_pad_pos >=3D height: - self.contents_pad_pos =3D height - 1 - self.refresh_contents_pad() - - def refresh_contents_pad(self): - self.contents_pad.refresh( - self.contents_pad_pos, 0, - 1, self.width / 3 + 1, - self.height - 2, self.width - 2) - self.screen.refresh() + + for i in range(len(output)): + if type(output[i]) =3D=3D unicode: + real_output =3D output[i] + else: + real_output =3D unicode(output[i], errors=3D'replace') + self.contents_pad.addstr(i, 0, real_output.encode("utf-8")) + + def scroll_contents_pad(self, amount): + height =3D self.contents_pad_length - self.height + 5 + + self.contents_pad_pos +=3D amount + if self.contents_pad_pos < 0: + self.contents_pad_pos =3D 0 + if self.contents_pad_pos >=3D height: + self.contents_pad_pos =3D height - 1 + self.refresh_contents_pad() + + def refresh_contents_pad(self): + self.contents_pad.refresh( + self.contents_pad_pos, 0, + 1, self.width / 3 + 1, + self.height - 2, self.width - 2) + self.screen.refresh() =20 if __name__ =3D=3D "__main__": parser =3D optparse.OptionParser()