Toolbox/Startup.py

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

eric ide

mercurial