Merge lp:~dannf/laika/configurable-bug-patterns into lp:laika

Proposed by dann frazier on 2011-08-08
Status: Merged
Merged at revision: 17
Proposed branch: lp:~dannf/laika/configurable-bug-patterns
Merge into: lp:laika
Diff against target: 90 lines (+18/-4)
2 files modified
laika (+15/-4)
laika.1 (+3/-0)
To merge this branch: bzr merge lp:~dannf/laika/configurable-bug-patterns
Reviewer Review Type Date Requested Status
Alex Chiang 2011-08-08 Approve on 2011-08-18
Review via email: mp+70768@code.launchpad.net

Description of the change

Add --bug-pattern option

To post a comment you must log in.
Alex Chiang (achiang) wrote :

Looks good, thanks Dann!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'laika'
2--- laika 2010-11-24 00:10:09 +0000
3+++ laika 2011-08-08 17:37:25 +0000
4@@ -17,6 +17,7 @@
5 import os
6 import re
7 import sys
8+from string import Template
9
10 from launchpadlib.launchpad import Launchpad
11
12@@ -54,13 +55,14 @@
13
14 bugs = {}
15
16- def __init__(self, user, window, ppas):
17+ def __init__(self, user, window, bugpattern, ppas):
18 cachedir = os.path.expanduser("~/.launchpadlib/cache")
19 self.launchpad = Launchpad.login_with('laika', 'production', cachedir)
20
21 self.user = self.launchpad.people[user]
22 self.window = window
23 self.since = UTCNOW - datetime.timedelta(window)
24+ self.bugpattern = bugpattern
25 self.ppas = ppas
26 self.status = ["New",
27 "Incomplete",
28@@ -105,7 +107,8 @@
29 ago += "%d minute%s" % (minutes, "s" if minutes > 1 else "")
30
31 print task.title
32- print "https://launchpad.net/bugs/" + str(task.bug.id)
33+ t = Template(self.bugpattern)
34+ print t.substitute(bugid=str(task.bug.id))
35 print "last updated", ago, "ago"
36
37 def print_assignments(self):
38@@ -219,6 +222,8 @@
39 return os.getenv("USER")
40 def default_window():
41 return 8
42+ def default_bugpattern():
43+ return 'https://launchpad.net/bugs/$bugid'
44 def default_ppas():
45 return ''
46
47@@ -231,7 +236,7 @@
48 return config
49
50 def main():
51- opts = ['user', 'window', 'ppas']
52+ opts = ['user', 'window', 'bugpattern', 'ppas']
53 config = get_config(opts)
54
55 parser = OptionParser()
56@@ -243,13 +248,19 @@
57 default=config['window'],
58 help='Number of days of past activity to look for. '
59 'Defaults to 8 days')
60+ parser.add_option('-b', '--bug-pattern', dest='bugpattern', type='string',
61+ default=config['bugpattern'],
62+ help='Use this string when displaying a bug reference. '
63+ 'Occurrences of $bugid will be replaced by the actual bug number. '
64+ 'Defaults to \'https://launchpad.net/bugs/$bugid\'')
65 parser.add_option('--ppas', dest='ppas',
66 default=config['ppas'],
67 help='Search for activity in specified PPAs')
68
69 options, arguments = parser.parse_args()
70
71- report = Report(options.user, options.window, options.ppas)
72+ report = Report(options.user, options.window, options.bugpattern,
73+ options.ppas)
74 report.render()
75
76 if __name__ == "__main__":
77
78=== modified file 'laika.1'
79--- laika.1 2010-10-21 12:47:53 +0000
80+++ laika.1 2011-08-08 17:37:25 +0000
81@@ -16,6 +16,9 @@
82 \fB\-w\fR \fIWINDOW\fR, \fB\-\-window\fR=\fIWINDOW\fR
83 number of days of past activity to look for; defaults to 8 days
84 .TP
85+\fB\-b\fR \fIBUGPATTERN\fR, \fB\-\-bugpattern\fR=\fIBUGPATTERN\fR
86+pattern to use when displaying the bug id; occurrences of the substring $bugid will be replaced by the actual bug id number; defaults to 'https://launchpad.net/bugs/$bugid'
87+.TP
88 \fB\-\-ppas\fR=\fIPPA[,PPA[,...]]\fR
89 search for activity in the specified PPAs; use a comma to separate multiple PPAs
90 .TP

Subscribers

People subscribed via source and target branches