Gentoo Archives: gentoo-catalyst

From: Brian Dolbec <dolsen@g.o>
To: gentoo-catalyst@l.g.o
Subject: [gentoo-catalyst] [patch] cleanup long lines, improve useage() output formatting slightly
Date: Wed, 27 Feb 2013 09:17:51
Message-Id: 1361956647.20292.6.camel@big_daddy.dol-sen.ca
1 another commit that will apply cleanly to master.
2
3 =======================================================
4
5 diff --git a/catalyst b/catalyst
6 index 0878ce4..2a9b75c 100755
7 @@ -24,31 +24,33 @@ __version__="2.0.12.2"
8 conf_values={}
9
10 def usage():
11 - print "Usage catalyst [options] [-C variable=value...] [ -s identifier]"
12 - print " -a --clear-autoresume clear autoresume flags"
13 - print " -c --config use specified configuration file"
14 - print " -C --cli catalyst commandline (MUST BE LAST OPTION)"
15 - print " -d --debug enable debugging"
16 - print " -f --file read specfile"
17 - print " -F --fetchonly fetch files only"
18 - print " -h --help print this help message"
19 - print " -p --purge clear tmp dirs,package cache and autoresume flags"
20 - print " -P --purgeonly clear tmp dirs,package cache and autoresume flags and exit"
21 - print " -T --purgetmponly clear tmp dirs and autoresume flags and exit"
22 - print " -s --snapshot generate a release snapshot"
23 - print " -V --version display version information"
24 - print " -v --verbose verbose output"
25 - print
26 - print "Usage examples:"
27 - print
28 - print "Using the commandline option (-C, --cli) to build a Portage snapshot:"
29 - print "catalyst -C target=snapshot version_stamp=my_date"
30 - print
31 - print "Using the snapshot option (-s, --snapshot) to build a release snapshot:"
32 - print "catalyst -s 20071121"
33 - print
34 - print "Using the specfile option (-f, --file) to build a stage target:"
35 - print "catalyst -f stage1-specfile.spec"
36 + print """Usage catalyst [options] [-C variable=value...] [ -s identifier]
37 + -a --clear-autoresume clear autoresume flags
38 + -c --config use specified configuration file
39 + -C --cli catalyst commandline (MUST BE LAST OPTION)
40 + -d --debug enable debugging
41 + -f --file read specfile
42 + -F --fetchonly fetch files only
43 + -h --help print this help message
44 + -p --purge clear tmp dirs,package cache, autoresume flags
45 + -P --purgeonly clear tmp dirs,package cache, autoresume flags and exit
46 + -T --purgetmponly clear tmp dirs and autoresume flags and exit
47 + -s --snapshot generate a release snapshot
48 + -V --version display version information
49 + -v --verbose verbose output
50 +
51 +Usage examples:
52 +
53 +Using the commandline option (-C, --cli) to build a Portage snapshot:
54 +catalyst -C target=snapshot version_stamp=my_date
55 +
56 +Using the snapshot option (-s, --snapshot) to build a release snapshot:
57 +catalyst -s 20071121"
58 +
59 +Using the specfile option (-f, --file) to build a stage target:
60 +catalyst -f stage1-specfile.spec
61 +"""
62 +
63
64 def version():
65 print "Catalyst, version "+__version__
66 @@ -78,7 +80,8 @@ def parse_config(myconfig):
67 # first, try the one passed (presumably from the cmdline)
68 if myconfig:
69 if os.path.exists(myconfig):
70 - print "Using command line specified Catalyst configuration file, "+myconfig
71 + print "Using command line specified Catalyst configuration file, "+\
72 + myconfig
73 config_file=myconfig
74
75 else:
76 @@ -88,7 +91,8 @@ def parse_config(myconfig):
77
78 # next, try the default location
79 elif os.path.exists("/etc/catalyst/catalyst.conf"):
80 - print "Using default Catalyst configuration file, /etc/catalyst/catalyst.conf"
81 + print "Using default Catalyst configuration file," + \
82 + " /etc/catalyst/catalyst.conf"
83 config_file="/etc/catalyst/catalyst.conf"
84
85 # can't find a config file (we are screwed), so bail out
86 @@ -188,14 +192,16 @@ def parse_config(myconfig):
87 conf_values["port_logdir"]=myconf["port_logdir"];
88
89 def import_modules():
90 - # import catalyst's own modules (i.e. catalyst_support and the arch modules)
91 + # import catalyst's own modules
92 + # (i.e. catalyst_support and the arch modules)
93 targetmap={}
94
95 try:
96 for x in required_build_targets:
97 try:
98 fh=open(conf_values["sharedir"]+"/modules/"+x+".py")
99 - module=imp.load_module(x,fh,"modules/"+x+".py",(".py","r",imp.PY_SOURCE))
100 + module=imp.load_module(x,fh,"modules/"+x+".py",
101 + (".py","r",imp.PY_SOURCE))
102 fh.close()
103
104 except IOError:
105 @@ -205,7 +211,8 @@ def import_modules():
106 for x in valid_build_targets:
107 try:
108 fh=open(conf_values["sharedir"]+"/modules/"+x+".py")
109 - module=imp.load_module(x,fh,"modules/"+x+".py",(".py","r",imp.PY_SOURCE))
110 + module=imp.load_module(x,fh,"modules/"+x+".py",
111 + (".py","r",imp.PY_SOURCE))
112 module.register(targetmap)
113 fh.close()
114
115 @@ -223,7 +230,8 @@ def import_modules():
116 def build_target(addlargs, targetmap):
117 try:
118 if addlargs["target"] not in targetmap:
119 - raise CatalystError,"Target \""+addlargs["target"]+"\" not available."
120 + raise CatalystError, \
121 + "Target \"%s\" not available." % addlargs["target"]
122
123 mytarget=targetmap[addlargs["target"]](conf_values, addlargs)
124
125 @@ -231,7 +239,8 @@ def build_target(addlargs, targetmap):
126
127 except:
128 catalyst.util.print_traceback()
129 - print "!!! catalyst: Error encountered during run of target " + addlargs["target"]
130 + print "!!! catalyst: Error encountered during run of target " + \
131 + addlargs["target"]
132 sys.exit(1)
133
134 if __name__ == "__main__":
135 @@ -250,8 +259,12 @@ if __name__ == "__main__":
136
137 # parse out the command line arguments
138 try:
139 - opts,args = getopt.getopt(sys.argv[1:], "apPThvdc:C:f:FVs:", ["purge", "purgeonly", "purgetmponly", "help", "version", "debug",\
140 - "clear-autoresume", "config=", "cli=", "file=", "fetch", "verbose","snapshot="])
141 + opts,args = getopt.getopt(sys.argv[1:], "apPThvdc:C:f:FVs:",
142 + ["purge", "purgeonly", "purgetmponly", "help", "version", "debug",
143 + "clear-autoresume", "config=", "cli=", "file=", "fetch",
144 + "verbose","snapshot="
145 + ]
146 + )
147
148 except getopt.GetoptError:
149 usage()
150
151 --
152 Brian Dolbec <dolsen@g.o>