[Python-checkins] CVS: python/dist/src/Mac/scripts gensuitemodule.py,1.21,1.22

Jack Jansen jackjansen@users.sourceforge.net
Sat, 30 Mar 2002 15:43:07 -0800


Update of /cvsroot/python/python/dist/src/Mac/scripts
In directory usw-pr-cvs1:/tmp/cvs-serv8393/scripts

Modified Files:
	gensuitemodule.py 
Log Message:
Modified to allow it to run in MachoPython in a reasonable way. It still
needs a decent commandline interface, though.


Index: gensuitemodule.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/scripts/gensuitemodule.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** gensuitemodule.py	24 Jan 2002 22:44:07 -0000	1.21
--- gensuitemodule.py	30 Mar 2002 23:43:04 -0000	1.22
***************
*** 15,32 ****
  import macfs
  import keyword
  
  from Carbon.Res import *
  
  def main():
! 	fss, ok = macfs.PromptGetFile('Select file with aeut/aete resource:')
! 	if not ok:
! 		sys.exit(0)
! 	processfile(fss.as_pathname())
  
  def processfile(fullname):
  	"""Process all resources in a single file"""
  	cur = CurResFile()
! 	print fullname
! 	rf = OpenRFPerm(fullname, 0, 1)
  	try:
  		UseResFile(rf)
--- 15,39 ----
  import macfs
  import keyword
+ import macresource
  
  from Carbon.Res import *
  
+ DEFAULT_PACKAGEFOLDER=os.path.join(sys.prefix, 'Mac', 'Lib', 'lib-scriptpackages')
+ 
  def main():
! 	if len(sys.argv) > 1:
! 		for filename in sys.argv[1:]:
! 			processfile(filename)
! 	else:
! 		fss, ok = macfs.PromptGetFile('Select file with aeut/aete resource:')
! 		if not ok:
! 			sys.exit(0)
! 		processfile(fss.as_pathname())
  
  def processfile(fullname):
  	"""Process all resources in a single file"""
  	cur = CurResFile()
! 	print "Processing", fullname
! 	rf = macresource.open_pathname(fullname)
  	try:
  		UseResFile(rf)
***************
*** 226,230 ****
  	fss = macfs.FSSpec(fname)
  	creatorsignature, dummy = fss.GetCreatorType()
! 	packagename = identify(os.path.basename(fname))
  	if language:
  		packagename = packagename+'_lang%d'%language
--- 233,237 ----
  	fss = macfs.FSSpec(fname)
  	creatorsignature, dummy = fss.GetCreatorType()
! 	packagename = identify(os.path.splitext(os.path.basename(fname))[0])
  	if language:
  		packagename = packagename+'_lang%d'%language
***************
*** 233,238 ****
  	if len(packagename) > 27:
  		packagename = packagename[:27]
! 	macfs.SetFolder(os.path.join(sys.prefix, ':Mac:Lib:lib-scriptpackages'))
! 	fss, ok = macfs.GetDirectory('Package folder for %s'%packagename)
  	if not ok:
  		return
--- 240,245 ----
  	if len(packagename) > 27:
  		packagename = packagename[:27]
! 	macfs.SetFolder(DEFAULT_PACKAGEFOLDER)
! 	fss, ok = macfs.GetDirectory('Create and select package folder for %s'%packagename)
  	if not ok:
  		return
***************
*** 289,293 ****
  			fp.write(",\n\t\t%s_Events"%modname)
  		fp.write(",\n\t\taetools.TalkTo):\n")
! 		fp.write("\t_signature = '%s'\n\n"%creatorsignature)
  	fp.close()
  	
--- 296,300 ----
  			fp.write(",\n\t\t%s_Events"%modname)
  		fp.write(",\n\t\taetools.TalkTo):\n")
! 		fp.write("\t_signature = %s\n\n"%`creatorsignature`)
  	fp.close()