mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
Port grab-attachments to optparse
This commit is contained in:
parent
3f776be478
commit
eedb60b296
@ -18,30 +18,28 @@
|
|||||||
#
|
#
|
||||||
# ##################################################################
|
# ##################################################################
|
||||||
|
|
||||||
|
from optparse import OptionParser
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from ubuntutools.lp.libsupport import get_launchpad
|
from ubuntutools.lp.libsupport import get_launchpad
|
||||||
|
|
||||||
USAGE = "grab-attachments <bug numbers>"
|
USAGE = "grab-attachments <bug numbers>"
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) == 1:
|
p = OptionParser('Usage: %prog [options] <bug numbers>')
|
||||||
print >> sys.stderr, USAGE
|
opts, args = p.parse_args()
|
||||||
sys.exit(1)
|
if len(args) < 1:
|
||||||
|
p.error('No bug numbers provided')
|
||||||
if sys.argv[1] in ["--help", "-h"]:
|
|
||||||
print USAGE
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
launchpad = get_launchpad("ubuntu-dev-tools")
|
launchpad = get_launchpad("ubuntu-dev-tools")
|
||||||
|
|
||||||
for arg in sys.argv[1:]:
|
for arg in args:
|
||||||
try:
|
try:
|
||||||
number = int(arg)
|
number = int(arg)
|
||||||
except:
|
except:
|
||||||
print >> sys.stderr, "'%s' is not a valid bug number." % arg
|
p.error("'%s' is not a valid bug number." % arg)
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
b = launchpad.bugs[number]
|
b = launchpad.bugs[number]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user