1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#!/usr/bin/env python
# Written by Henrik Nilsen Omma
# (C) Canonical, Ltd. Licensed under the GPL
import sys
import os
try:
import connector as Connector
from commandLine import commandLine
import utils as utils
except:
from bugHelper.commandLine import commandLine
import launchpadbugs.connector as Connector
import launchpadbugs.utils as utils
import bugHelper.config as config
def main():
conf = config.Config("~/.bughelper/config")
cl = commandLine()
Bug = Connector.ConnectBug(method=cl.options.parsemode)
cookie = cl.options.cookie
if cookie:
cookie = os.path.expanduser(cookie)
else:
try:
cookie = os.path.expanduser(conf.cookie)
except:
if cl.options.debug:
print >> sys.stderr, "No cookie-file found"
if cookie:
Bug.authentication=cookie
if not len(cl.args) == 1:
cl.parser.print_usage()
sys.exit(1)
try:
nr = int(cl.args[0])
except ValueError:
print >> sys.stderr, "Error: given LP-bugnumber has to be an integer"
cl.parser.print_usage()
sys.exit(1)
bug= Bug(nr)
if cl.options.comments:
comments = bug.comments
print "Comments:", len(comments)
print comments
if cl.options.reporter:
print bug.reporter
if cl.options.title:
print bug.title
if cl.options.tags:
print bug.tags
if cl.options.countcomments:
comments = bug.comments
print len(comments)
if cl.options.countcommenters:
commenters = []
comments = bug.comments
for comment in comments:
commenters.append(comment.user)
print len(set(commenters))
if cl.options.isduplicate:
print "Duplicate of %s" % (bug.duplicate_of)
if cl.options.comment or cl.options.lastcomment:
comments = bug.comments
cnr = -1 if cl.options.lastcomment else cl.options.comment
comment = comments[int(cnr)]
if comment:
if cl.options.author:
print comment.user
if cl.options.date:
print comment.date
if not cl.options.author and not cl.options.date:
print comment
elif cl.options.verbose:
text = ''
for c in comments:
text += c.number + ', '
print "available comments: %s" % text
if __name__ == "__main__":
main()
|