[Python-checkins] python/dist/src/Lib/plat-mac EasyDialogs.py,1.6,1.7

jackjansen@users.sourceforge.net jackjansen@users.sourceforge.net
Sun, 26 Jan 2003 12:22:21 -0800


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

Modified Files:
	EasyDialogs.py 
Log Message:
FSRef and EasyDialogs pathname support was pretty much broken in MacPython-OS9. Fixed.

Index: EasyDialogs.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/EasyDialogs.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** EasyDialogs.py	21 Jan 2003 22:57:53 -0000	1.6
--- EasyDialogs.py	26 Jan 2003 20:22:18 -0000	1.7
***************
*** 35,38 ****
--- 35,39 ----
  import macresource
  import os
+ import sys
  
  __all__ = ['Message', 'AskString', 'AskPassword', 'AskYesNoCancel',
***************
*** 636,642 ****
  		return tpwanted(rr.selection[0])
  	if issubclass(tpwanted, str):
! 		return tpwanted(rr.selection_fsr[0].FSRefMakePath())
  	if issubclass(tpwanted, unicode):
! 		return tpwanted(rr.selection_fsr[0].FSRefMakePath(), 'utf8')
  	raise TypeError, "Unknown value for argument 'wanted': %s" % repr(tpwanted)
  
--- 637,643 ----
  		return tpwanted(rr.selection[0])
  	if issubclass(tpwanted, str):
! 		return tpwanted(rr.selection_fsr[0].as_pathname())
  	if issubclass(tpwanted, unicode):
! 		return tpwanted(rr.selection_fsr[0].as_pathname(), 'utf8')
  	raise TypeError, "Unknown value for argument 'wanted': %s" % repr(tpwanted)
  
***************
*** 687,697 ****
  		return tpwanted(rr.selection[0])
  	if issubclass(tpwanted, (str, unicode)):
! 		# This is gross, and probably incorrect too
! 		vrefnum, dirid, name = rr.selection[0].as_tuple()
! 		pardir_fss = Carbon.File.FSSpec((vrefnum, dirid, ''))
! 		pardir_fsr = Carbon.File.FSRef(pardir_fss)
! 		pardir_path = pardir_fsr.FSRefMakePath()  # This is utf-8
! 		name_utf8 = unicode(name, 'macroman').encode('utf8')
! 		fullpath = os.path.join(pardir_path, name_utf8)
  		if issubclass(tpwanted, unicode):
  			return unicode(fullpath, 'utf8')
--- 688,701 ----
  		return tpwanted(rr.selection[0])
  	if issubclass(tpwanted, (str, unicode)):
! 		if sys.platform == 'mac':
! 			fullpath = rr.selection[0].as_pathname()
! 		else:
! 			# This is gross, and probably incorrect too
! 			vrefnum, dirid, name = rr.selection[0].as_tuple()
! 			pardir_fss = Carbon.File.FSSpec((vrefnum, dirid, ''))
! 			pardir_fsr = Carbon.File.FSRef(pardir_fss)
! 			pardir_path = pardir_fsr.FSRefMakePath()  # This is utf-8
! 			name_utf8 = unicode(name, 'macroman').encode('utf8')
! 			fullpath = os.path.join(pardir_path, name_utf8)
  		if issubclass(tpwanted, unicode):
  			return unicode(fullpath, 'utf8')
***************
*** 742,753 ****
  		return tpwanted(rr.selection[0])
  	if issubclass(tpwanted, str):
! 		return tpwanted(rr.selection_fsr[0].FSRefMakePath())
  	if issubclass(tpwanted, unicode):
! 		return tpwanted(rr.selection_fsr[0].FSRefMakePath(), 'utf8')
  	raise TypeError, "Unknown value for argument 'wanted': %s" % repr(tpwanted)
  	
  
  def test():
! 	import time, sys, macfs
  
  	Message("Testing EasyDialogs.")
--- 746,757 ----
  		return tpwanted(rr.selection[0])
  	if issubclass(tpwanted, str):
! 		return tpwanted(rr.selection_fsr[0].as_pathname())
  	if issubclass(tpwanted, unicode):
! 		return tpwanted(rr.selection_fsr[0].as_pathname(), 'utf8')
  	raise TypeError, "Unknown value for argument 'wanted': %s" % repr(tpwanted)
  	
  
  def test():
! 	import time, macfs
  
  	Message("Testing EasyDialogs.")