mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-05-18 19:51:57 +02:00
Use optparse to parse gtester-report commandline options
See bug #611778.
This commit is contained in:
parent
ddb9a2f264
commit
8de6d03c44
@ -17,6 +17,7 @@
|
|||||||
# License along with this library; if not, write to the
|
# License along with this library; if not, write to the
|
||||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
# Boston, MA 02111-1307, USA.
|
# Boston, MA 02111-1307, USA.
|
||||||
|
import optparse
|
||||||
import sys, re, xml.dom.minidom
|
import sys, re, xml.dom.minidom
|
||||||
pkginstall_configvars = {
|
pkginstall_configvars = {
|
||||||
#@PKGINSTALL_CONFIGVARS_IN24LINES@ # configvars are substituted upon script installation
|
#@PKGINSTALL_CONFIGVARS_IN24LINES@ # configvars are substituted upon script installation
|
||||||
@ -331,40 +332,31 @@ class ReportWriter (TreeProcess):
|
|||||||
self.oprint ('</html>\n')
|
self.oprint ('</html>\n')
|
||||||
|
|
||||||
# main program handling
|
# main program handling
|
||||||
def parse_files_and_args ():
|
def parse_opts():
|
||||||
from sys import argv, stdin
|
"""Parse program options.
|
||||||
files = []
|
|
||||||
arg_iter = sys.argv[1:].__iter__()
|
:return: An options object and the program arguments.
|
||||||
rest = len (sys.argv) - 1
|
"""
|
||||||
for arg in arg_iter:
|
parser = optparse.OptionParser()
|
||||||
rest -= 1
|
parser.version = pkginstall_configvars.get ('glib-version', '0.0-uninstalled')
|
||||||
if arg == '--help' or arg == '-h':
|
parser.usage = "%prog [OPTIONS] <gtester-log.xml>"
|
||||||
print_help ()
|
parser.description = "Generate HTML reports from the XML log files generated by gtester."
|
||||||
sys.exit (0)
|
parser.epilog = "gtester-report (GLib utils) version %s."% (parser.version,)
|
||||||
elif arg == '--version' or arg == '-v':
|
parser.add_option("-v", "--version", action="store_true", dest="version", default=False,
|
||||||
print_help (False)
|
help="Show program version.")
|
||||||
sys.exit (0)
|
options, files = parser.parse_args()
|
||||||
else:
|
if options.version:
|
||||||
files = files + [ arg ]
|
print parser.epilog
|
||||||
return files
|
return None, None
|
||||||
|
if len(files) != 1:
|
||||||
|
parser.error("Must supply a log file to parse.")
|
||||||
|
return options, files
|
||||||
|
|
||||||
def print_help (with_help = True):
|
|
||||||
import os
|
|
||||||
print "gtester-report (GLib utils) version", pkginstall_configvars.get ('glib-version', '0.0-uninstalled')
|
|
||||||
if not with_help:
|
|
||||||
return
|
|
||||||
print "Usage: %s [OPTIONS] <gtester-log.xml>" % os.path.basename (sys.argv[0])
|
|
||||||
print "Generate HTML reports from the XML log files generated by gtester."
|
|
||||||
print "Options:"
|
|
||||||
print " --help, -h print this help message"
|
|
||||||
print " --version, -v print version info"
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
from sys import argv, stdin
|
options, files = parse_opts()
|
||||||
files = parse_files_and_args()
|
if options is None:
|
||||||
if len (files) != 1:
|
return 0
|
||||||
print_help (True)
|
|
||||||
sys.exit (1)
|
|
||||||
xd = xml.dom.minidom.parse (files[0])
|
xd = xml.dom.minidom.parse (files[0])
|
||||||
rr = ReportReader()
|
rr = ReportReader()
|
||||||
rr.trampoline (xd)
|
rr.trampoline (xd)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user