-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbug-export.py
executable file
·70 lines (59 loc) · 1.95 KB
/
bug-export.py
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
#!/usr/bin/python3 -S
#
# Copyright 2009 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
import _pythonpath # noqa: F401
import sys
import transaction
from zope.component import getUtility
from lp.bugs.scripts.bugexport import export_bugtasks
from lp.registry.interfaces.product import IProductSet
from lp.services.scripts.base import LaunchpadScript
class BugExportScript(LaunchpadScript):
description = "Export bugs for a Launchpad product as XML"
def add_my_options(self):
self.parser.add_option(
"-o",
"--output",
metavar="FILE",
action="store",
help="Export bugs to this file",
type="string",
dest="output",
)
self.parser.add_option(
"-p",
"--product",
metavar="PRODUCT",
action="store",
help="Which product to export",
type="string",
dest="product",
)
self.parser.add_option(
"--include-private",
action="store_true",
help="Include private bugs in dump",
dest="include_private",
default=False,
)
def main(self):
if self.options.product is None:
self.parser.error("No product specified")
if self.options.output is not None:
output = open(self.options.output, "wb")
else:
output = getattr(sys.stdout, "buffer", sys.stdout)
product = getUtility(IProductSet).getByName(self.options.product)
if product is None:
self.parser.error(
"Product %s does not exist" % self.options.product
)
export_bugtasks(
transaction,
product,
output,
include_private=self.options.include_private,
)
if __name__ == "__main__":
BugExportScript("bug-export").run()