diff options
| author | Jack Jansen <jack.jansen@cwi.nl> | 2002-06-09 22:08:52 (GMT) | 
|---|---|---|
| committer | Jack Jansen <jack.jansen@cwi.nl> | 2002-06-09 22:08:52 (GMT) | 
| commit | 388fbf3d4a624becfbdedf6ec1dd57b57a5642ec (patch) | |
| tree | 483a4a8a0fe8876d24049e685a60a9ddd26fcfea /Mac/scripts/BuildApplet.py | |
| parent | 2befa48926ed4804758442033ab2c09c2678bef1 (diff) | |
| download | cpython-388fbf3d4a624becfbdedf6ec1dd57b57a5642ec.zip cpython-388fbf3d4a624becfbdedf6ec1dd57b57a5642ec.tar.gz cpython-388fbf3d4a624becfbdedf6ec1dd57b57a5642ec.tar.bz2  | |
- Better commandline interface to BuildApplet, complete with options,
  verbose output to the console, etc.
- Allow Cocoa applets to be built with BuildApplet.
No full testing has been done yet to ensure OS9 operation hasn't suffered.
Diffstat (limited to 'Mac/scripts/BuildApplet.py')
| -rw-r--r-- | Mac/scripts/BuildApplet.py | 65 | 
1 files changed, 61 insertions, 4 deletions
diff --git a/Mac/scripts/BuildApplet.py b/Mac/scripts/BuildApplet.py index b57c425..0679825 100644 --- a/Mac/scripts/BuildApplet.py +++ b/Mac/scripts/BuildApplet.py @@ -15,7 +15,7 @@ import macfs  import MacOS  import EasyDialogs  import buildtools - +import getopt  def main():  	try: @@ -54,14 +54,71 @@ def buildapplet():  			buildtools.process(template, filename, dstfilename, 1)  	else: +		SHORTOPTS = "o:r:ne:v?" +		LONGOPTS=("output=", "resource=", "noargv", "extra=", "verbose", "help") +		try: +			options, args = getopt.getopt(sys.argv[1:], SHORTOPTS, LONGOPTS) +		except getopt.error: +			usage() +		if options and len(args) > 1: +			sys.stderr.write("Cannot use options when specifying multiple input files") +			sys.exit(1) +		dstfilename = None +		rsrcfilename = None +		raw = 0 +		extras = [] +		verbose = None +		for opt, arg in options: +			if opt in ('-o', '--output'): +				dstfilename = arg +			elif opt in ('-r', '--resource'): +				rsrcfilename = arg +			elif opt in ('-n', '--noargv'): +				raw = 1 +			elif opt in ('-e', '--extra'): +				extras.append(arg) +			elif opt in ('-v', '--verbose'): +				verbose = Verbose() +			elif opt in ('-?', '--help'): +				usage()  		# Loop over all files to be processed -		for filename in sys.argv[1:]: +		for filename in args:  			cr, tp = MacOS.GetCreatorAndType(filename)  			if tp == 'APPL': -				buildtools.update(template, filename, '') +				buildtools.update(template, filename, dstfilename)  			else: -				buildtools.process(template, filename, '', 1) +				buildtools.process(template, filename, dstfilename, 1, +					rsrcname=rsrcfilename, others=extras, raw=raw, progress=verbose) + +def usage(): +	print "BuildApplet creates an application from a Python source file" +	print "Usage:" +	print "  BuildApplet     interactive, single file, no options" +	print "  BuildApplet src1.py src2.py ...   non-interactive multiple file" +	print "  BuildApplet [options] src.py    non-interactive single file" +	print "Options:" +	print "  --output o    Output file; default based on source filename, short -o" +	print "  --resource r  Resource file; default based on source filename, short -r" +	print "  --noargv      Build applet without drag-and-drop sys.argv emulation, short -n, OSX only" +	print "  --extra f     Extra file to put in .app bundle, short -e, OSX only" +	print "  --verbose     Verbose, short -v" +	print "  --help        This message, short -?" +	sys.exit(1) +class Verbose: +	"""This class mimics EasyDialogs.ProgressBar but prints to stderr""" +	def __init__(self, *args): +		if args and args[0]: +			self.label(args[0]) +		 +	def set(self, *args): +		pass +		 +	def inc(self, *args): +		pass +		 +	def label(self, str): +		sys.stderr.write(str+'\n')  if __name__ == '__main__':  	main()  | 
