* hugdaylist: Improved argument and error handling.

This commit is contained in:
Jonathan Patrick Davies 2008-08-11 10:57:19 +01:00
parent 59a6f32e8e
commit 684715ff89
2 changed files with 14 additions and 4 deletions

1
debian/changelog vendored
View File

@ -3,6 +3,7 @@ ubuntu-dev-tools (0.37ubuntu1) intrepid; urgency=low
[ Jonathan Patrick Davies ] [ Jonathan Patrick Davies ]
* get-branches: Open the teams code page before making a new directory. * get-branches: Open the teams code page before making a new directory.
* doc/get-branches.1: Created. * doc/get-branches.1: Created.
* hugdaylist: Improved argument and error handling.
-- Jonathan Patrick Davies <jpds@ubuntu.com> Sun, 10 August 2008 22:07:58 +0100 -- Jonathan Patrick Davies <jpds@ubuntu.com> Sun, 10 August 2008 22:07:58 +0100

View File

@ -50,6 +50,7 @@ def check_args():
# Our usage options. # Our usage options.
usage = "usage: %prog [-n <number>] launchpad-buglist-url" usage = "usage: %prog [-n <number>] launchpad-buglist-url"
optParser = OptionParser(usage) optParser = OptionParser(usage)
argsParsed = 0
# Options - namely just the number of bugs to output. # Options - namely just the number of bugs to output.
optParser.add_option("-n", "--number", action = "store_true", optParser.add_option("-n", "--number", action = "store_true",
@ -57,11 +58,14 @@ def check_args():
# Parse arguments. # Parse arguments.
(options, args) = optParser.parse_args() (options, args) = optParser.parse_args()
print options
print args
# Check if we want a number other than the default. # Check if we want a number other than the default.
if options.number: if options.number:
try: try:
howmany = int(args[0]) howmany = int(args[argsParsed])
argsParsed += 1
except: except:
print >> sys.stderr, "Option '-n' requires an integer for an " \ print >> sys.stderr, "Option '-n' requires an integer for an " \
"argument." "argument."
@ -75,7 +79,7 @@ def check_args():
optParser.print_help() optParser.print_help()
sys.exit(1) sys.exit(1)
else: else:
url = args[0] url = args[argsParsed]
return (howmany, url) return (howmany, url)
@ -92,8 +96,13 @@ def filter_unsolved(b):
def main(): def main():
(howmany, url) = check_args() (howmany, url) = check_args()
bl = BugList(url) try:
bl = BugList(url)
except:
print >> sys.stderr, "The page '%s' does not appear to exist." % url
sys.exit(1)
l = filter(filter_unsolved, bl) l = filter(filter_unsolved, bl)
if not l: if not l: