Toolbox/Startup.py

branch
Py2 comp.
changeset 3060
5883ce99ee12
parent 3058
0a02c433f52d
parent 3039
8dd0165d805d
child 3145
a9de05d4a22f
equal deleted inserted replaced
3058:0a02c433f52d 3060:5883ce99ee12
29 Module function to show the usage information. 29 Module function to show the usage information.
30 30
31 @param appinfo dictionary describing the application 31 @param appinfo dictionary describing the application
32 @param optlen length of the field for the commandline option (integer) 32 @param optlen length of the field for the commandline option (integer)
33 """ 33 """
34 options = [\ 34 options = [
35 ("--version", "show the program's version number and exit"), 35 ("--version", "show the program's version number and exit"),
36 ("-h, --help", "show this help message and exit") 36 ("-h, --help", "show this help message and exit")
37 ] 37 ]
38 options.extend(appinfo["options"]) 38 options.extend(appinfo["options"])
39 39
40 print(""" 40 print("""\n"""
41 Usage: {bin} [OPTIONS] {arg} 41 """Usage: {bin} [OPTIONS] {arg}\n"""
42 42 """\n"""
43 {name} - {description} 43 """{name} - {description}\n"""
44 44 """\n"""
45 Options:""".format(**appinfo)) 45 """Options:""".format(**appinfo))
46 for opt in options: 46 for opt in options:
47 print(" {0} {1}".format(opt[0].ljust(optlen), opt[1])) 47 print(" {0} {1}".format(opt[0].ljust(optlen), opt[1]))
48 sys.exit(0) 48 sys.exit(0)
49 49
50 50
52 """ 52 """
53 Module function to show the version information. 53 Module function to show the version information.
54 54
55 @param appinfo dictionary describing the application 55 @param appinfo dictionary describing the application
56 """ 56 """
57 print(""" 57 print("""\n"""
58 {name} {version} 58 """{name} {version}\n"""
59 59 """\n"""
60 {description} 60 """{description}\n"""
61 61 """\n"""
62 Copyright (c) 2002 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> 62 """Copyright (c) 2002 - 2013 Detlev Offenbach"""
63 This is free software; see LICENSE.GPL3 for copying conditions. 63 """ <detlev@die-offenbachs.de>\n"""
64 There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A 64 """This is free software; see LICENSE.GPL3 for copying"""
65 PARTICULAR PURPOSE.""".format(**appinfo)) 65 """ conditions.\n"""
66 """There is NO warranty; not even for MERCHANTABILITY or FITNESS"""
67 """ FOR A\n"""
68 """PARTICULAR PURPOSE.""".format(**appinfo))
66 sys.exit(0) 69 sys.exit(0)
67 70
68 71
69 def handleArgs(argv, appinfo): 72 def handleArgs(argv, appinfo):
70 """ 73 """
79 ddindex = 30000 # arbitrarily large number 82 ddindex = 30000 # arbitrarily large number
80 args = { 83 args = {
81 "--version": version, 84 "--version": version,
82 "--help": usage, 85 "--help": usage,
83 "-h": usage 86 "-h": usage
84 } 87 }
85 if '--' in argv: 88 if '--' in argv:
86 ddindex = argv.index("--") 89 ddindex = argv.index("--")
87 for a in args: 90 for a in args:
88 if a in argv and argv.index(a) < ddindex: 91 if a in argv and argv.index(a) < ddindex:
89 args[a](appinfo) 92 args[a](appinfo)

eric ide

mercurial