mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	BuildApplet will now also update old applets
This commit is contained in:
		
							parent
							
								
									ebe914af7a
								
							
						
					
					
						commit
						8554e302a5
					
				
					 2 changed files with 96 additions and 68 deletions
				
			
		|  | @ -67,7 +67,7 @@ def main(): | ||||||
| 	# Ask for source text if not specified in sys.argv[1:] | 	# Ask for source text if not specified in sys.argv[1:] | ||||||
| 	 | 	 | ||||||
| 	if not sys.argv[1:]: | 	if not sys.argv[1:]: | ||||||
| 		srcfss, ok = macfs.PromptGetFile('Select Python source file:', 'TEXT') | 		srcfss, ok = macfs.PromptGetFile('Select Python source or applet:', 'TEXT', 'APPL') | ||||||
| 		if not ok: | 		if not ok: | ||||||
| 			return | 			return | ||||||
| 		filename = srcfss.as_pathname() | 		filename = srcfss.as_pathname() | ||||||
|  | @ -75,14 +75,23 @@ def main(): | ||||||
| 		if tf[-3:] == '.py': | 		if tf[-3:] == '.py': | ||||||
| 			tf = tf[:-3] | 			tf = tf[:-3] | ||||||
| 		else: | 		else: | ||||||
| 			tf = tf + '.applet' | 			tf = tf + '.out' | ||||||
| 		dstfss, ok = macfs.StandardPutFile('Save application as:', tf) | 		dstfss, ok = macfs.StandardPutFile('Save application as:', tf) | ||||||
| 		if not ok: return | 		if not ok: return | ||||||
| 		process(template, filename, dstfss.as_pathname()) | 		dstfilename = dstfss.as_pathname() | ||||||
|  | 		cr, tp = MacOS.GetCreatorAndType(filename) | ||||||
|  | 		if tp == 'APPL': | ||||||
|  | 			update(template, filename, dstfilename) | ||||||
|  | 		else: | ||||||
|  | 			process(template, filename, dstfilename) | ||||||
| 	else: | 	else: | ||||||
| 		 | 		 | ||||||
| 		# Loop over all files to be processed | 		# Loop over all files to be processed | ||||||
| 		for filename in sys.argv[1:]: | 		for filename in sys.argv[1:]: | ||||||
|  | 			cr, tp = MacOS.GetCreatorAndType(filename) | ||||||
|  | 			if tp == 'APPL': | ||||||
|  | 				update(template, filename, '') | ||||||
|  | 			else: | ||||||
| 				process(template, filename, '') | 				process(template, filename, '') | ||||||
| 
 | 
 | ||||||
| def process(template, filename, output): | def process(template, filename, output): | ||||||
|  | @ -117,9 +126,22 @@ def process(template, filename, output): | ||||||
| 	if output: | 	if output: | ||||||
| 		destname = output | 		destname = output | ||||||
| 	 | 	 | ||||||
|  | 	process_common(template, progress, code, rsrcname, destname, 0) | ||||||
|  | 	 | ||||||
|  | def update(template, filename, output): | ||||||
|  | 	if DEBUG: | ||||||
|  | 		progress = EasyDialogs.ProgressBar("Updating %s..."%os.path.split(filename)[1], 120) | ||||||
|  | 	else: | ||||||
|  | 		progress = None | ||||||
|  | 	if not output: | ||||||
|  | 		output = filename + ' (updated)' | ||||||
|  | 	process_common(template, progress, None, filename, output, 1) | ||||||
|  | 	 | ||||||
|  | 		 | ||||||
|  | def process_common(template, progress, code, rsrcname, destname, is_update): | ||||||
| 	# Try removing the output file | 	# Try removing the output file | ||||||
| 	try: | 	try: | ||||||
| 		os.unlink(output) | 		os.unlink(destname) | ||||||
| 	except os.error: | 	except os.error: | ||||||
| 		pass | 		pass | ||||||
| 		 | 		 | ||||||
|  | @ -163,7 +185,11 @@ def process(template, filename, output): | ||||||
| 		if DEBUG: | 		if DEBUG: | ||||||
| 			progress.inc(50) | 			progress.inc(50) | ||||||
| 	else: | 	else: | ||||||
| 		typesfound, ownertype = copyres(input, output, [], 0, progress) | 		if is_update: | ||||||
|  | 			skip_oldfile = ['cfrg'] | ||||||
|  | 		else: | ||||||
|  | 			skip_oldfile = [] | ||||||
|  | 		typesfound, ownertype = copyres(input, output, skip_oldfile, 0, progress) | ||||||
| 		CloseResFile(input) | 		CloseResFile(input) | ||||||
| 		 | 		 | ||||||
| 	# Check which resource-types we should not copy from the template | 	# Check which resource-types we should not copy from the template | ||||||
|  | @ -195,6 +221,7 @@ def process(template, filename, output): | ||||||
| 	 | 	 | ||||||
| 	UseResFile(output) | 	UseResFile(output) | ||||||
| 	 | 	 | ||||||
|  | 	if code: | ||||||
| 		# Delete any existing 'PYC ' resource named __main__ | 		# Delete any existing 'PYC ' resource named __main__ | ||||||
| 		 | 		 | ||||||
| 		try: | 		try: | ||||||
|  | @ -252,8 +279,8 @@ def copyres(input, output, skiptypes, skipowner, progress=None): | ||||||
| 			res = Get1IndResource(type, ires) | 			res = Get1IndResource(type, ires) | ||||||
| 			id, type, name = res.GetResInfo() | 			id, type, name = res.GetResInfo() | ||||||
| 			lcname = string.lower(name) | 			lcname = string.lower(name) | ||||||
| 			if (type, lcname) == (RESTYPE, RESNAME): | ##			if (type, lcname) == (RESTYPE, RESNAME): | ||||||
| 				continue # Don't copy __main__ from template | ##				continue # Don't copy __main__ from template | ||||||
| 			# XXXX should look for id=0 | 			# XXXX should look for id=0 | ||||||
| 			if lcname == OWNERNAME: | 			if lcname == OWNERNAME: | ||||||
| 				if skipowner: | 				if skipowner: | ||||||
|  |  | ||||||
|  | @ -1,37 +1,38 @@ | ||||||
| (This file must be converted with BinHex 4.0) | (This file must be converted with BinHex 4.0) | ||||||
| 
 | 
 | ||||||
| :%%*eD@aN3A"`E'9d,R*cFQ-!FR0bBe*6483"!*!(#bSMM`#3"!%!!!!++3!!#5N | :%%*eD@aN3A"`E'9d,R*cFQ-!FR0bBe*6483"!*!(#dPr5J#3"!%!!!!+2!!!#6` | ||||||
| !!!%"0K3J9#"S!"3J8(d4X'J4!$S"CbB5,`a1ZJ)-$$S!@RN0E@YKF("XCA3ZFR0 | !!!%00K3J9#"S!"3J8(d4X'J4!$S"CbB5,`a1ZJ)-$$S!@RN33R9TE'4"F("XCA3 | ||||||
| bB`)!!!!rN!J!N!JrN!J!N"L`(eFK!*!'#bVr%F#SD3%G3"(rma0`!"!Zrr1pdK& | ZFR0bBf0PFh&iBbjSFAJZ1'*XE!!!FR0bBe*6483"!!"!!!%!N!m"Al1`(eFK!*! | ||||||
| Q%&%f[P9V!3,fK[P9V!3%`86)"Caj%&3`!!"aP%R!!%#j$&3`!!"pL"R!"B!! | '#bVr%F#SD3%G3"(rma0`!"!Zrr1pdK&Q%&%f[P9V!3,fK[P9V!3%`86)"Caj | ||||||
| "!3)X@P3Y,N5p!3!E2!&Q-#G92KT+J#"6!LJ Jack Jansen
						Jack Jansen