[Python-checkins] python/dist/src/Lib/plat-mac EasyDialogs.py,1.11,1.12 FrameWork.py,1.3,1.4 MiniAEFrame.py,1.1,1.2 argvemulator.py,1.2,1.3 icopen.py,1.1,1.2

rhettinger@users.sourceforge.net rhettinger@users.sourceforge.net
Sun, 06 Apr 2003 01:01:36 -0800


Update of /cvsroot/python/python/dist/src/Lib/plat-mac
In directory sc8-pr-cvs1:/tmp/cvs-serv1577/Lib/plat-mac

Modified Files:
	EasyDialogs.py FrameWork.py MiniAEFrame.py argvemulator.py 
	icopen.py 
Log Message:
SF patch #701494:  more apply removals

Index: EasyDialogs.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/EasyDialogs.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** EasyDialogs.py	24 Mar 2003 12:12:24 -0000	1.11
--- EasyDialogs.py	6 Apr 2003 09:00:59 -0000	1.12
***************
*** 6,10 ****
  AskYesNoCancel(question, default) -- display a question and Yes, No and Cancel buttons.
  GetArgv(optionlist, commandlist) -- fill a sys.argv-like list using a dialog
! AskFileForOpen(...) -- Ask the user for an existing file 
  AskFileForSave(...) -- Ask the user for an output file
  AskFolder(...) -- Ask the user to select a folder
--- 6,10 ----
  AskYesNoCancel(question, default) -- display a question and Yes, No and Cancel buttons.
  GetArgv(optionlist, commandlist) -- fill a sys.argv-like list using a dialog
! AskFileForOpen(...) -- Ask the user for an existing file
  AskFileForSave(...) -- Ask the user for an output file
[...1587 lines suppressed...]
!                         time.sleep(0.05)
!                 bar.set(0,100)
!                 for i in xrange(100):
!                         bar.set(i)
!                         time.sleep(0.05)
!                         if i % 10 == 0:
!                                 bar.label(text[(i/10) % 4])
!                 bar.label("Done.")
!                 time.sleep(1.0)         # give'em a chance to see "Done."
!         finally:
!                 del bar
!                 if hasattr(MacOS, 'SchedParams'):
!                         MacOS.SchedParams(*appsw)
  
  if __name__ == '__main__':
!         try:
!                 test()
!         except KeyboardInterrupt:
!                 Message("Operation Canceled.")
  

Index: FrameWork.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/FrameWork.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** FrameWork.py	9 Jan 2003 23:18:39 -0000	1.3
--- FrameWork.py	6 Apr 2003 09:00:59 -0000	1.4
***************
*** 30,39 ****
  
  try:
! 	MyFrontWindow = FrontNonFloatingWindow
  except NameError:
! 	MyFrontWindow = FrontWindow
  
! kHighLevelEvent = 23	# Don't know what header file this should come from
! SCROLLBARWIDTH = 16		# Again, not a clue...
  
  # Trick to forestall a set of SIOUX menus being added to our menubar
[...2106 lines suppressed...]
!         def enablehelp(self, *args):
!                 hm = self.gethelpmenu()
!                 self.nohelpitem = MenuItem(hm, "There isn't any", None, self.nohelp)
! 
!         def nohelp(self, *args):
!                 print "I told you there isn't any!"
! 
!         def debug(self, *args):
!                 import pdb
!                 pdb.set_trace()
  
  
  def test():
!         "Test program"
!         app = TestApp()
!         app.mainloop()
  
  
  if __name__ == '__main__':
!         test()

Index: MiniAEFrame.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/MiniAEFrame.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** MiniAEFrame.py	30 Dec 2002 22:04:20 -0000	1.1
--- MiniAEFrame.py	6 Apr 2003 09:01:00 -0000	1.2
***************
*** 2,8 ****
  
  There are two classes:
! 	AEServer -- a mixin class offering nice AE handling.
! 	MiniApplication -- a very minimal alternative to FrameWork.py,
! 		only suitable for the simplest of AppleEvent servers.
  """
  
--- 2,8 ----
  
  There are two classes:
!         AEServer -- a mixin class offering nice AE handling.
!         MiniApplication -- a very minimal alternative to FrameWork.py,
!                 only suitable for the simplest of AppleEvent servers.
  """
  
***************
*** 22,199 ****
  import EasyDialogs
  
! kHighLevelEvent = 23				# Not defined anywhere for Python yet?
  
  
  class MiniApplication:
! 	
! 	"""A minimal FrameWork.Application-like class"""
! 	
! 	def __init__(self):
! 		self.quitting = 0
! 		# Initialize menu
! 		self.appleid = 1
! 		self.quitid = 2
! 		Menu.ClearMenuBar()
! 		self.applemenu = applemenu = Menu.NewMenu(self.appleid, "\024")
! 		applemenu.AppendMenu("%s;(-" % self.getaboutmenutext())
! 		if MacOS.runtimemodel == 'ppc':
! 			applemenu.AppendResMenu('DRVR')
! 		applemenu.InsertMenu(0)
! 		self.quitmenu = Menu.NewMenu(self.quitid, "File")
! 		self.quitmenu.AppendMenu("Quit")
! 		self.quitmenu.SetItemCmd(1, ord("Q"))
! 		self.quitmenu.InsertMenu(0)
! 		Menu.DrawMenuBar()
! 	
! 	def __del__(self):
! 		self.close()
! 	
! 	def close(self):
! 		pass
! 	
! 	def mainloop(self, mask = everyEvent, timeout = 60*60):
! 		while not self.quitting:
! 			self.dooneevent(mask, timeout)
! 	
! 	def _quit(self):
! 		self.quitting = 1
! 	
! 	def dooneevent(self, mask = everyEvent, timeout = 60*60):
! 			got, event = Evt.WaitNextEvent(mask, timeout)
! 			if got:
! 				self.lowlevelhandler(event)
! 	
! 	def lowlevelhandler(self, event):
! 		what, message, when, where, modifiers = event
! 		h, v = where
! 		if what == kHighLevelEvent:
! 			msg = "High Level Event: %s %s" % \
! 				(`code(message)`, `code(h | (v<<16))`)
! 			try:
! 				AE.AEProcessAppleEvent(event)
! 			except AE.Error, err:
! 				print 'AE error: ', err
! 				print 'in', msg
! 				traceback.print_exc()
! 			return
! 		elif what == keyDown:
! 			c = chr(message & charCodeMask)
! 			if modifiers & cmdKey:
! 				if c == '.':
! 					raise KeyboardInterrupt, "Command-period"
! 				if c == 'q':
! 					if hasattr(MacOS, 'OutputSeen'):
! 						MacOS.OutputSeen()
! 					self.quitting = 1
! 					return
! 		elif what == mouseDown:
! 			partcode, window = Win.FindWindow(where)
! 			if partcode == inMenuBar:
! 				result = Menu.MenuSelect(where)
! 				id = (result>>16) & 0xffff	# Hi word
! 				item = result & 0xffff		# Lo word
! 				if id == self.appleid:
! 					if item == 1:
! 						EasyDialogs.Message(self.getabouttext())
! 					elif item > 1 and hasattr(Menu, 'OpenDeskAcc'):
! 						name = self.applemenu.GetMenuItemText(item)
! 						Menu.OpenDeskAcc(name)
! 				elif id == self.quitid and item == 1:
! 					if hasattr(MacOS, 'OutputSeen'):
! 						MacOS.OutputSeen()
! 					self.quitting = 1
! 				Menu.HiliteMenu(0)
! 				return
! 		# Anything not handled is passed to Python/SIOUX
! 		if hasattr(MacOS, 'HandleEvent'):
! 			MacOS.HandleEvent(event)
! 		else:
! 			print "Unhandled event:", event
! 	
! 	def getabouttext(self):
! 		return self.__class__.__name__
! 	
! 	def getaboutmenutext(self):
! 		return "About %s\311" % self.__class__.__name__
  
  
  class AEServer:
! 	
! 	def __init__(self):
! 		self.ae_handlers = {}
! 	
! 	def installaehandler(self, classe, type, callback):
! 		AE.AEInstallEventHandler(classe, type, self.callback_wrapper)
! 		self.ae_handlers[(classe, type)] = callback
! 	
! 	def close(self):
! 		for classe, type in self.ae_handlers.keys():
! 			AE.AERemoveEventHandler(classe, type)
! 	
! 	def callback_wrapper(self, _request, _reply):
! 		_parameters, _attributes = aetools.unpackevent(_request)
! 		_class = _attributes['evcl'].type
! 		_type = _attributes['evid'].type
! 		
! 		if self.ae_handlers.has_key((_class, _type)):
! 			_function = self.ae_handlers[(_class, _type)]
! 		elif self.ae_handlers.has_key((_class, '****')):
! 			_function = self.ae_handlers[(_class, '****')]
! 		elif self.ae_handlers.has_key(('****', '****')):
! 			_function = self.ae_handlers[('****', '****')]
! 		else:
! 			raise 'Cannot happen: AE callback without handler', (_class, _type)
! 		
! 		# XXXX Do key-to-name mapping here
! 		
! 		_parameters['_attributes'] = _attributes
! 		_parameters['_class'] = _class
! 		_parameters['_type'] = _type
! 		if _parameters.has_key('----'):
! 			_object = _parameters['----']
! 			del _parameters['----']
! 			# The try/except that used to be here can mask programmer errors.
! 			# Let the program crash, the programmer can always add a **args
! 			# to the formal parameter list.
! 			rv = apply(_function, (_object,), _parameters)
! 		else:
! 			#Same try/except comment as above
! 			rv = apply(_function, (), _parameters)
! 		
! 		if rv == None:
! 			aetools.packevent(_reply, {})
! 		else:
! 			aetools.packevent(_reply, {'----':rv})
  
  
  def code(x):
! 	"Convert a long int to the 4-character code it really is"
! 	s = ''
! 	for i in range(4):
! 		x, c = divmod(x, 256)
! 		s = chr(c) + s
! 	return s
  
  class _Test(AEServer, MiniApplication):
! 	"""Mini test application, handles required events"""
! 	
! 	def __init__(self):
! 		MiniApplication.__init__(self)
! 		AEServer.__init__(self)
! 		self.installaehandler('aevt', 'oapp', self.open_app)
! 		self.installaehandler('aevt', 'quit', self.quit)
! 		self.installaehandler('****', '****', self.other)
! 		self.mainloop()
  
- 	def quit(self, **args):
- 		self._quit()
- 		
- 	def open_app(self, **args):
- 		pass
- 		
- 	def other(self, _object=None, _class=None, _type=None, **args):
- 		print 'AppleEvent', (_class, _type), 'for', _object, 'Other args:', args
- 		
  
  if __name__ == '__main__':
! 	_Test()
--- 22,199 ----
  import EasyDialogs
  
! kHighLevelEvent = 23                            # Not defined anywhere for Python yet?
  
  
  class MiniApplication:
! 
!         """A minimal FrameWork.Application-like class"""
! 
!         def __init__(self):
!                 self.quitting = 0
!                 # Initialize menu
!                 self.appleid = 1
!                 self.quitid = 2
!                 Menu.ClearMenuBar()
!                 self.applemenu = applemenu = Menu.NewMenu(self.appleid, "\024")
!                 applemenu.AppendMenu("%s;(-" % self.getaboutmenutext())
!                 if MacOS.runtimemodel == 'ppc':
!                         applemenu.AppendResMenu('DRVR')
!                 applemenu.InsertMenu(0)
!                 self.quitmenu = Menu.NewMenu(self.quitid, "File")
!                 self.quitmenu.AppendMenu("Quit")
!                 self.quitmenu.SetItemCmd(1, ord("Q"))
!                 self.quitmenu.InsertMenu(0)
!                 Menu.DrawMenuBar()
! 
!         def __del__(self):
!                 self.close()
! 
!         def close(self):
!                 pass
! 
!         def mainloop(self, mask = everyEvent, timeout = 60*60):
!                 while not self.quitting:
!                         self.dooneevent(mask, timeout)
! 
!         def _quit(self):
!                 self.quitting = 1
! 
!         def dooneevent(self, mask = everyEvent, timeout = 60*60):
!                         got, event = Evt.WaitNextEvent(mask, timeout)
!                         if got:
!                                 self.lowlevelhandler(event)
! 
!         def lowlevelhandler(self, event):
!                 what, message, when, where, modifiers = event
!                 h, v = where
!                 if what == kHighLevelEvent:
!                         msg = "High Level Event: %s %s" % \
!                                 (`code(message)`, `code(h | (v<<16))`)
!                         try:
!                                 AE.AEProcessAppleEvent(event)
!                         except AE.Error, err:
!                                 print 'AE error: ', err
!                                 print 'in', msg
!                                 traceback.print_exc()
!                         return
!                 elif what == keyDown:
!                         c = chr(message & charCodeMask)
!                         if modifiers & cmdKey:
!                                 if c == '.':
!                                         raise KeyboardInterrupt, "Command-period"
!                                 if c == 'q':
!                                         if hasattr(MacOS, 'OutputSeen'):
!                                                 MacOS.OutputSeen()
!                                         self.quitting = 1
!                                         return
!                 elif what == mouseDown:
!                         partcode, window = Win.FindWindow(where)
!                         if partcode == inMenuBar:
!                                 result = Menu.MenuSelect(where)
!                                 id = (result>>16) & 0xffff      # Hi word
!                                 item = result & 0xffff          # Lo word
!                                 if id == self.appleid:
!                                         if item == 1:
!                                                 EasyDialogs.Message(self.getabouttext())
!                                         elif item > 1 and hasattr(Menu, 'OpenDeskAcc'):
!                                                 name = self.applemenu.GetMenuItemText(item)
!                                                 Menu.OpenDeskAcc(name)
!                                 elif id == self.quitid and item == 1:
!                                         if hasattr(MacOS, 'OutputSeen'):
!                                                 MacOS.OutputSeen()
!                                         self.quitting = 1
!                                 Menu.HiliteMenu(0)
!                                 return
!                 # Anything not handled is passed to Python/SIOUX
!                 if hasattr(MacOS, 'HandleEvent'):
!                         MacOS.HandleEvent(event)
!                 else:
!                         print "Unhandled event:", event
! 
!         def getabouttext(self):
!                 return self.__class__.__name__
! 
!         def getaboutmenutext(self):
!                 return "About %s\311" % self.__class__.__name__
  
  
  class AEServer:
! 
!         def __init__(self):
!                 self.ae_handlers = {}
! 
!         def installaehandler(self, classe, type, callback):
!                 AE.AEInstallEventHandler(classe, type, self.callback_wrapper)
!                 self.ae_handlers[(classe, type)] = callback
! 
!         def close(self):
!                 for classe, type in self.ae_handlers.keys():
!                         AE.AERemoveEventHandler(classe, type)
! 
!         def callback_wrapper(self, _request, _reply):
!                 _parameters, _attributes = aetools.unpackevent(_request)
!                 _class = _attributes['evcl'].type
!                 _type = _attributes['evid'].type
! 
!                 if self.ae_handlers.has_key((_class, _type)):
!                         _function = self.ae_handlers[(_class, _type)]
!                 elif self.ae_handlers.has_key((_class, '****')):
!                         _function = self.ae_handlers[(_class, '****')]
!                 elif self.ae_handlers.has_key(('****', '****')):
!                         _function = self.ae_handlers[('****', '****')]
!                 else:
!                         raise 'Cannot happen: AE callback without handler', (_class, _type)
! 
!                 # XXXX Do key-to-name mapping here
! 
!                 _parameters['_attributes'] = _attributes
!                 _parameters['_class'] = _class
!                 _parameters['_type'] = _type
!                 if _parameters.has_key('----'):
!                         _object = _parameters['----']
!                         del _parameters['----']
!                         # The try/except that used to be here can mask programmer errors.
!                         # Let the program crash, the programmer can always add a **args
!                         # to the formal parameter list.
!                         rv = _function(_object, **_parameters)
!                 else:
!                         #Same try/except comment as above
!                         rv = _function(**_parameters)
! 
!                 if rv == None:
!                         aetools.packevent(_reply, {})
!                 else:
!                         aetools.packevent(_reply, {'----':rv})
  
  
  def code(x):
!         "Convert a long int to the 4-character code it really is"
!         s = ''
!         for i in range(4):
!                 x, c = divmod(x, 256)
!                 s = chr(c) + s
!         return s
  
  class _Test(AEServer, MiniApplication):
!         """Mini test application, handles required events"""
! 
!         def __init__(self):
!                 MiniApplication.__init__(self)
!                 AEServer.__init__(self)
!                 self.installaehandler('aevt', 'oapp', self.open_app)
!                 self.installaehandler('aevt', 'quit', self.quit)
!                 self.installaehandler('****', '****', self.other)
!                 self.mainloop()
! 
!         def quit(self, **args):
!                 self._quit()
! 
!         def open_app(self, **args):
!                 pass
! 
!         def other(self, _object=None, _class=None, _type=None, **args):
!                 print 'AppleEvent', (_class, _type), 'for', _object, 'Other args:', args
  
  
  if __name__ == '__main__':
!         _Test()

Index: argvemulator.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/argvemulator.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** argvemulator.py	18 Feb 2003 23:28:05 -0000	1.2
--- argvemulator.py	6 Apr 2003 09:01:01 -0000	1.3
***************
*** 12,114 ****
  
  class ArgvCollector:
- 	
- 	"""A minimal FrameWork.Application-like class"""
- 	
- 	def __init__(self):
- 		self.quitting = 0
- 		self.ae_handlers = {}
- 		# Remove the funny -psn_xxx_xxx argument
- 		if len(sys.argv) > 1 and sys.argv[1][:4] == '-psn':
- 			del sys.argv[1]
- 		self.installaehandler('aevt', 'oapp', self.open_app)
- 		self.installaehandler('aevt', 'odoc', self.open_file)
- 	
- 	def installaehandler(self, classe, type, callback):
- 		AE.AEInstallEventHandler(classe, type, self.callback_wrapper)
- 		self.ae_handlers[(classe, type)] = callback
- 	
- 	def close(self):
- 		for classe, type in self.ae_handlers.keys():
- 			AE.AERemoveEventHandler(classe, type)
- 	
- 	def mainloop(self, mask = highLevelEventMask, timeout = 1*60):
- 		stoptime = Evt.TickCount() + timeout
- 		while not self.quitting and Evt.TickCount() < stoptime:
- 			self.dooneevent(mask, timeout)
- 		self.close()
- 	
- 	def _quit(self):
- 		self.quitting = 1
- 	
- 	def dooneevent(self, mask = highLevelEventMask, timeout = 1*60):
- 		got, event = Evt.WaitNextEvent(mask, timeout)
- 		if got:
- 			self.lowlevelhandler(event)
- 	
- 	def lowlevelhandler(self, event):
- 		what, message, when, where, modifiers = event
- 		h, v = where
- 		if what == kHighLevelEvent:
- 			try:
- 				AE.AEProcessAppleEvent(event)
- 			except AE.Error, err:
- 				msg = "High Level Event: %s %s" % \
- 					(`hex(message)`, `hex(h | (v<<16))`)
- 				print 'AE error: ', err
- 				print 'in', msg
- 				traceback.print_exc()
- 			return
- 		else:
- 			print "Unhandled event:", event
  
! 	def callback_wrapper(self, _request, _reply):
! 		_parameters, _attributes = aetools.unpackevent(_request)
! 		_class = _attributes['evcl'].type
! 		_type = _attributes['evid'].type
! 		
! 		if self.ae_handlers.has_key((_class, _type)):
! 			_function = self.ae_handlers[(_class, _type)]
! 		elif self.ae_handlers.has_key((_class, '****')):
! 			_function = self.ae_handlers[(_class, '****')]
! 		elif self.ae_handlers.has_key(('****', '****')):
! 			_function = self.ae_handlers[('****', '****')]
! 		else:
! 			raise 'Cannot happen: AE callback without handler', (_class, _type)
! 		
! 		# XXXX Do key-to-name mapping here
! 		
! 		_parameters['_attributes'] = _attributes
! 		_parameters['_class'] = _class
! 		_parameters['_type'] = _type
! 		if _parameters.has_key('----'):
! 			_object = _parameters['----']
! 			del _parameters['----']
! 			# The try/except that used to be here can mask programmer errors.
! 			# Let the program crash, the programmer can always add a **args
! 			# to the formal parameter list.
! 			rv = apply(_function, (_object,), _parameters)
! 		else:
! 			#Same try/except comment as above
! 			rv = apply(_function, (), _parameters)
! 		
! 		if rv == None:
! 			aetools.packevent(_reply, {})
! 		else:
! 			aetools.packevent(_reply, {'----':rv})
  
! 	def open_app(self, **args):
! 		self._quit()
! 		
! 	def open_file(self, _object=None, **args):
! 		for alias in _object:
! 			fsr = alias.FSResolveAlias(None)[0]
! 			pathname = fsr.as_pathname()
! 			sys.argv.append(pathname)
! 		self._quit()
! 		
! 	def other(self, _object=None, _class=None, _type=None, **args):
! 		print 'Ignore AppleEvent', (_class, _type), 'for', _object, 'Other args:', args
  
  if __name__ == '__main__':
! 	ArgvCollector().mainloop()
! 	print "sys.argv=", sys.argv
--- 12,114 ----
  
  class ArgvCollector:
  
!         """A minimal FrameWork.Application-like class"""
  
!         def __init__(self):
!                 self.quitting = 0
!                 self.ae_handlers = {}
!                 # Remove the funny -psn_xxx_xxx argument
!                 if len(sys.argv) > 1 and sys.argv[1][:4] == '-psn':
!                         del sys.argv[1]
!                 self.installaehandler('aevt', 'oapp', self.open_app)
!                 self.installaehandler('aevt', 'odoc', self.open_file)
! 
!         def installaehandler(self, classe, type, callback):
!                 AE.AEInstallEventHandler(classe, type, self.callback_wrapper)
!                 self.ae_handlers[(classe, type)] = callback
! 
!         def close(self):
!                 for classe, type in self.ae_handlers.keys():
!                         AE.AERemoveEventHandler(classe, type)
! 
!         def mainloop(self, mask = highLevelEventMask, timeout = 1*60):
!                 stoptime = Evt.TickCount() + timeout
!                 while not self.quitting and Evt.TickCount() < stoptime:
!                         self.dooneevent(mask, timeout)
!                 self.close()
! 
!         def _quit(self):
!                 self.quitting = 1
! 
!         def dooneevent(self, mask = highLevelEventMask, timeout = 1*60):
!                 got, event = Evt.WaitNextEvent(mask, timeout)
!                 if got:
!                         self.lowlevelhandler(event)
! 
!         def lowlevelhandler(self, event):
!                 what, message, when, where, modifiers = event
!                 h, v = where
!                 if what == kHighLevelEvent:
!                         try:
!                                 AE.AEProcessAppleEvent(event)
!                         except AE.Error, err:
!                                 msg = "High Level Event: %s %s" % \
!                                         (`hex(message)`, `hex(h | (v<<16))`)
!                                 print 'AE error: ', err
!                                 print 'in', msg
!                                 traceback.print_exc()
!                         return
!                 else:
!                         print "Unhandled event:", event
! 
!         def callback_wrapper(self, _request, _reply):
!                 _parameters, _attributes = aetools.unpackevent(_request)
!                 _class = _attributes['evcl'].type
!                 _type = _attributes['evid'].type
! 
!                 if self.ae_handlers.has_key((_class, _type)):
!                         _function = self.ae_handlers[(_class, _type)]
!                 elif self.ae_handlers.has_key((_class, '****')):
!                         _function = self.ae_handlers[(_class, '****')]
!                 elif self.ae_handlers.has_key(('****', '****')):
!                         _function = self.ae_handlers[('****', '****')]
!                 else:
!                         raise 'Cannot happen: AE callback without handler', (_class, _type)
! 
!                 # XXXX Do key-to-name mapping here
! 
!                 _parameters['_attributes'] = _attributes
!                 _parameters['_class'] = _class
!                 _parameters['_type'] = _type
!                 if _parameters.has_key('----'):
!                         _object = _parameters['----']
!                         del _parameters['----']
!                         # The try/except that used to be here can mask programmer errors.
!                         # Let the program crash, the programmer can always add a **args
!                         # to the formal parameter list.
!                         rv = _function(_object, **_parameters)
!                 else:
!                         #Same try/except comment as above
!                         rv = _function(**_parameters)
! 
!                 if rv == None:
!                         aetools.packevent(_reply, {})
!                 else:
!                         aetools.packevent(_reply, {'----':rv})
! 
!         def open_app(self, **args):
!                 self._quit()
! 
!         def open_file(self, _object=None, **args):
!                 for alias in _object:
!                         fsr = alias.FSResolveAlias(None)[0]
!                         pathname = fsr.as_pathname()
!                         sys.argv.append(pathname)
!                 self._quit()
! 
!         def other(self, _object=None, _class=None, _type=None, **args):
!                 print 'Ignore AppleEvent', (_class, _type), 'for', _object, 'Other args:', args
  
  if __name__ == '__main__':
!         ArgvCollector().mainloop()
!         print "sys.argv=", sys.argv

Index: icopen.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/icopen.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** icopen.py	30 Dec 2002 22:04:20 -0000	1.1
--- icopen.py	6 Apr 2003 09:01:02 -0000	1.2
***************
*** 30,34 ****
  Put this file in your Python path, and create a file named {Python}:sitecustomize.py
  that contains:
! 	import icopen
  
  (If {Python}:sitecustomizer.py already exists, just add the 'import' line to it.)
--- 30,34 ----
  Put this file in your Python path, and create a file named {Python}:sitecustomize.py
  that contains:
!         import icopen
  
  (If {Python}:sitecustomizer.py already exists, just add the 'import' line to it.)
***************
*** 43,58 ****
  
  def _open_with_typer(*args):
! 	file = apply(_builtin_open, args)
! 	filename = args[0]
! 	mode = 'r'
! 	if args[1:]:
! 		mode = args[1]
! 	if mode[0] == 'w':
! 		from ic import error, settypecreator
! 		try:
! 			settypecreator(filename)
! 		except error:
! 			pass
! 	return file
  
  __builtin__.open = _open_with_typer
--- 43,58 ----
  
  def _open_with_typer(*args):
!         file = _builtin_open(*args)
!         filename = args[0]
!         mode = 'r'
!         if args[1:]:
!                 mode = args[1]
!         if mode[0] == 'w':
!                 from ic import error, settypecreator
!                 try:
!                         settypecreator(filename)
!                 except error:
!                         pass
!         return file
  
  __builtin__.open = _open_with_typer
***************
*** 64,66 ****
  _open_with_typer('test.html', 'w')
  _open_with_typer('test.foo', 'w')
! """
\ No newline at end of file
--- 64,66 ----
  _open_with_typer('test.html', 'w')
  _open_with_typer('test.foo', 'w')
! """