diff -uNr bughelper.main/bughelper bughelper.main2/bughelper --- bughelper.main/bughelper 2007-01-18 18:44:58.000000000 -0200 +++ bughelper.main2/bughelper 2007-01-18 18:39:22.000000000 -0200 @@ -19,28 +19,22 @@ import bugHelper.utils as utils def main(): - cl = commandLine(sys.argv[1:]) - if not cl.valid: - print """%s [-a] [-A] -l -%s [-a] [-A] -%s -V""" % (sys.argv[0], sys.argv[0], sys.argv[0]) - sys.exit(1) - if cl.version: - print "bughelper %s" % (cl.version) - sys.exit(0) - + cl = commandLine() files = infoFiles() - - if not utils.package_exists(cl.sourcepackage): + + if cl.options.package != '' and cl.options.url == '': + cl.options.url = "https://bugs.launchpad.net/distros/ubuntu/+source/%s/+bugs" % cl.options.package + + if cl.options.url == '' and not utils.package_exists(cl.options.package): print "Package not found" sys.exit(1) - if not bugList(cl).bugs: + if not bugList(cl.options).bugs: print "No bugs found" sys.exit(1) - for bugNum in bugList(cl).bugs: - b = bug(bugNum, cl) + for bugNum in bugList(cl.options).bugs: + b = bug(bugNum, cl.options) info_file = files.get_info_file(b.sourcepackage) if len(info_file.clues): diff -uNr bughelper.main/bugHelper/commandLine.py bughelper.main2/bugHelper/commandLine.py --- bughelper.main/bugHelper/commandLine.py 2007-01-18 18:44:58.000000000 -0200 +++ bughelper.main2/bugHelper/commandLine.py 2007-01-18 18:41:53.000000000 -0200 @@ -1,54 +1,45 @@ # Written by Henrik Nilsen Omma # (C) Canonical, Ltd. Licensed under the GPL +# +# +# Qui Jan 18 16:22:53 UTC 2007 +# Fernando Ribeiro +# Changed to use OptParser python module import utils +from optparse import OptionParser + class commandLine: - def __init__(self, args): - self.args = args - self.sourcepackage = "" - # indicate if the passed argument at all make sense - self.valid = False - self.url = "" - self.all = False - self.attachments = False - self.version = "" - - # options - # -a all bugs - try: - ind = self.args.index("-a") - self.all = True - except: - pass - - # -A search Attachments too - try: - ind = self.args.index("-A") - self.attachments = True - except: - pass - - - # below this point actions are determined - # -l specific bug list - try: - ind = self.args.index("-l") - self.listing = True - self.url = self.args[ind+1] - self.valid = True - except: - self.listing = False - - try: - ind = self.args.index("-V") - self.version = utils.find_version_number() - self.valid = True - except: - pass - - if not self.valid and len(self.args): - self.sourcepackage = self.args[-1] - self.url = "https://bugs.launchpad.net/distros/ubuntu/+source/%s/+bugs" % (self.sourcepackage) - self.valid = True + def __init__(self): + #self.options = {} + #self.args = {} + + parser = OptionParser(version="%prog " + "%s"%(utils.find_version_number())) + + # usage message + if parser.get_prog_name() == "bughelper": + parser.set_defaults(all=False, attachments=False, package='', url='') + parser.set_usage(usage="%prog [--version] [-a] [-A] [-p ] [-l ]") + parser.add_option("-p", "--package", type="string", dest="package", metavar="package name", help="Package") + parser.add_option("-a", "--all", action="store_true", dest="all", metavar="all", help="all Bugs") + parser.add_option("-l", "--url", type="string", dest="url", metavar="URL", help="bug list URL") + parser.add_option("-A", "--attachments", action="store_true", dest="attachments", metavar="Attachments", help="search attachements") + + + if parser.get_prog_name() == "bugnumbers": + parser.set_defaults(all=False, package='', url='') + parser.set_usage(usage="%prog [--version] [-a] [-p ] [-l ]") + parser.add_option("-p", "--package", type="string", dest="package", metavar="package name", help="Package") + parser.add_option("-a", "--all", action="store_true", dest="all", metavar="all", help="all Bugs") + parser.add_option("-l", "--url", type="string", dest="url", metavar="URL", help="bug list URL") + + if parser.get_prog_name() == "bugxml": + parser.set_defaults(text='', clue='', package='') + parser.set_usage(usage="%prog [--version] [-e ] [-v ] [-p ]") + parser.add_option("-e", type="string", dest="text", metavar="text", help="text") + parser.add_option("-v", type="string", dest="clue", metavar="clue", help="clue file") + parser.add_option("-p", "--package", type="string", nargs=3, dest="package", metavar="package name", help="Package") + # options with arguments + (self.options, self.args) = parser.parse_args() diff -uNr bughelper.main/bugHelper/commandLine.py.bkp bughelper.main2/bugHelper/commandLine.py.bkp --- bughelper.main/bugHelper/commandLine.py.bkp 1969-12-31 21:00:00.000000000 -0300 +++ bughelper.main2/bugHelper/commandLine.py.bkp 2007-01-18 13:55:14.000000000 -0200 @@ -0,0 +1,54 @@ +# Written by Henrik Nilsen Omma +# (C) Canonical, Ltd. Licensed under the GPL + +import utils + +class commandLine: + def __init__(self, args): + self.args = args + self.sourcepackage = "" + # indicate if the passed argument at all make sense + self.valid = False + self.url = "" + self.all = False + self.attachments = False + self.version = "" + + # options + # -a all bugs + try: + ind = self.args.index("-a") + self.all = True + except: + pass + + # -A search Attachments too + try: + ind = self.args.index("-A") + self.attachments = True + except: + pass + + + # below this point actions are determined + # -l specific bug list + try: + ind = self.args.index("-l") + self.listing = True + self.url = self.args[ind+1] + self.valid = True + except: + self.listing = False + + try: + ind = self.args.index("-V") + self.version = utils.find_version_number() + self.valid = True + except: + pass + + if not self.valid and len(self.args): + self.sourcepackage = self.args[-1] + self.url = "https://bugs.launchpad.net/distros/ubuntu/+source/%s/+bugs" % (self.sourcepackage) + self.valid = True + Arquivos binários bughelper.main/bugHelper/commandLine.pyc e bughelper.main2/bugHelper/commandLine.pyc diferem diff -uNr bughelper.main/bugHelper/HTMLOperations.py bughelper.main2/bugHelper/HTMLOperations.py --- bughelper.main/bugHelper/HTMLOperations.py 2007-01-18 18:44:58.000000000 -0200 +++ bughelper.main2/bugHelper/HTMLOperations.py 2007-01-18 17:30:13.000000000 -0200 @@ -58,7 +58,7 @@ class bug: def __init__(self, bugnumber, cl): self.url = bugUrl = baseUrl + bugnumber - self.sourcepackage = cl.sourcepackage + self.sourcepackage = cl.package attachmentslist = Set() self.attachments = Set() Arquivos binários bughelper.main/bugHelper/HTMLOperations.pyc e bughelper.main2/bugHelper/HTMLOperations.pyc diferem Arquivos binários bughelper.main/bugHelper/infoFilesDefinitions.pyc e bughelper.main2/bugHelper/infoFilesDefinitions.pyc diferem Arquivos binários bughelper.main/bugHelper/infoFiles.pyc e bughelper.main2/bugHelper/infoFiles.pyc diferem Arquivos binários bughelper.main/bugHelper/__init__.pyc e bughelper.main2/bugHelper/__init__.pyc diferem diff -uNr bughelper.main/bugHelper/utils.py bughelper.main2/bugHelper/utils.py --- bughelper.main/bugHelper/utils.py 2007-01-18 18:44:58.000000000 -0200 +++ bughelper.main2/bugHelper/utils.py 2007-01-18 14:50:23.000000000 -0200 @@ -24,7 +24,7 @@ apt_pkg.init() sources = apt_pkg.GetPkgSrcRecords() sources.Restart() - if sources.Lookup(package_name) == None: + if not sources.Lookup(str(package_name)): return False else: return True Arquivos binários bughelper.main/bugHelper/utils.pyc e bughelper.main2/bugHelper/utils.pyc diferem Arquivos binários bughelper.main/bugHelper/XMLOperations.pyc e bughelper.main2/bugHelper/XMLOperations.pyc diferem diff -uNr bughelper.main/bugnumbers bughelper.main2/bugnumbers --- bughelper.main/bugnumbers 2007-01-18 18:44:58.000000000 -0200 +++ bughelper.main2/bugnumbers 2007-01-18 18:37:30.000000000 -0200 @@ -16,27 +16,21 @@ def main(): - cl = commandLine(sys.argv[1:]) + cl = commandLine() - if not cl.valid: - print """%s [-a] [-A] -l -%s [-a] [-A] -%s -V""" % (sys.argv[0], sys.argv[0], sys.argv[0]) - sys.exit(1) - if cl.version: - print "bughelper %s" % (cl.version) - sys.exit(0) + if cl.options.package != '' and cl.options.url == '': + cl.options.url = "https://bugs.launchpad.net/distros/ubuntu/+source/%s/+bugs" % cl.options.package - if not utils.package_exists(cl.sourcepackage): + if cl.options.url == '' and not utils.package_exists(cl.options.package): print "Package not found" sys.exit(1) - if not bugList(cl).bugs: + if not bugList(cl.options).bugs: print "No bugs found" sys.exit(1) - if bugList(cl).bugs != []: - print bugList(cl).bugs + if bugList(cl.options).bugs != []: + print bugList(cl.options).bugs if __name__ == "__main__": diff -uNr bughelper.main/bugxml bughelper.main2/bugxml --- bughelper.main/bugxml 2007-01-18 18:44:58.000000000 -0200 +++ bughelper.main2/bugxml 2007-01-18 18:33:20.000000000 -0200 @@ -3,6 +3,8 @@ # Written by Henrik Nilsen Omma # (C) Canonical, Ltd. Licensed under the GPL +from bugHelper.commandLine import commandLine + try: import XMLOperations import utils @@ -11,48 +13,39 @@ import bugHelper.utils as utils import urllib -import string import sys import os def main(): - if len(sys.argv) < 3: - print """Usage: %s -e - %s -v - %s -sa '' ''""" % (sys.argv[0], - sys.argv[0], - sys.argv[0]) - sys.exit(1) - - if sys.argv[1] == '-e': - print "COPY: %s " % (urllib.quote(string.join(sys.argv[2:]), safe=' ')) - print "Will be unquoted: %s" % (urllib.unquote(string.join(sys.argv[2:]))) - sys.exit(1) + cl = commandLine() + if cl.options.package != '' and cl.options.url == '': + cl.options.url = "https://bugs.launchpad.net/distros/ubuntu/+source/%s/+bugs" % cl.options.package[0] - if sys.argv[1] == '-sa': - try: - package = sys.argv[2] - condition = sys.argv[3] - clue = sys.argv[4] - except: - print "Usage: %s -sa '' ''" % sys.argv[0] - sys.exit(1) + if cl.options.text != '': + print "COPY: %s " % (urllib.quote(''.join(cl.options.text), safe=' ')) + print "Will be unquoted: %s" % (urllib.unquote(''.join(cl.options.text))) + sys.exit(1) + + if cl.options.package != '': + package = cl.options.package[0] + condition = cl.options.package[1] + clue = cl.options.package[2] - if not utils.package_exists(sys.argv[2]): - print "Package %s does not exist." % sys.argv[2] - sys.exit(1) + if not utils.package_exists(package): + print "Package %s does not exist." % package + sys.exit(1) - XMLOperations.add_simple_clue(package, condition, clue) - sys.exit(0) + XMLOperations.add_simple_clue(package, condition, clue) + sys.exit(0) - if sys.argv[1] == '-v': + if cl.options.clue != '': schema = XMLOperations.find_schema() if schema == '': print "Schema file not found." sys.exit(1) - xml_file = string.join(sys.argv[2:]) + xml_file = ''.join(cl.options.clue) if not os.path.exists(xml_file): if not os.path.exists(os.path.join(os.getcwd(), xml_file)): print "Neither %s nor %s exist." % (xml_file,