Changeset 391 for python/trunk/Lib/plat-mac/EasyDialogs.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Lib/plat-mac/EasyDialogs.py
r2 r391 244 244 245 245 246 247 screenbounds = Qd.GetQDGlobalsScreenBits().bounds 246 # The deprecated Carbon QuickDraw APIs are no longer available as of 247 # OS X 10.8. Raise an ImportError here in that case so that callers 248 # of EasyDialogs, like BuildApplet, will do the right thing. 249 250 try: 251 screenbounds = Qd.GetQDGlobalsScreenBits().bounds 252 except AttributeError: 253 raise ImportError("QuickDraw APIs not available") 254 248 255 screenbounds = screenbounds[0]+4, screenbounds[1]+4, \ 249 256 screenbounds[2]-4, screenbounds[3]-4 … … 581 588 del args[k] 582 589 # Set some defaults, and modify some arguments 583 if not args.has_key('dialogOptionFlags'):590 if 'dialogOptionFlags' not in args: 584 591 args['dialogOptionFlags'] = dftflags 585 if args.has_key('defaultLocation')and \592 if 'defaultLocation' in args and \ 586 593 not isinstance(args['defaultLocation'], Carbon.AE.AEDesc): 587 594 defaultLocation = args['defaultLocation'] … … 594 601 args['defaultLocation'] = Carbon.AE.AECreateDesc( 595 602 Carbon.AppleEvents.typeFSRef, defaultLocation.data) 596 if args.has_key('typeList')and not isinstance(args['typeList'], Carbon.Res.ResourceType):603 if 'typeList' in args and not isinstance(args['typeList'], Carbon.Res.ResourceType): 597 604 typeList = args['typeList'][:] 598 605 # Workaround for OSX typeless files: … … 604 611 args['typeList'] = Carbon.Res.Handle(data) 605 612 tpwanted = str 606 if args.has_key('wanted'):613 if 'wanted' in args: 607 614 tpwanted = args['wanted'] 608 615 del args['wanted'] … … 722 729 return tpwanted(rr.selection[0]) 723 730 if issubclass(tpwanted, (str, unicode)): 724 if sys.platform == 'mac': 725 fullpath = rr.selection[0].as_pathname() 726 else: 727 # This is gross, and probably incorrect too 728 vrefnum, dirid, name = rr.selection[0].as_tuple() 729 pardir_fss = Carbon.File.FSSpec((vrefnum, dirid, '')) 730 pardir_fsr = Carbon.File.FSRef(pardir_fss) 731 pardir_path = pardir_fsr.FSRefMakePath() # This is utf-8 732 name_utf8 = unicode(name, 'macroman').encode('utf8') 733 fullpath = os.path.join(pardir_path, name_utf8) 731 # This is gross, and probably incorrect too 732 vrefnum, dirid, name = rr.selection[0].as_tuple() 733 pardir_fss = Carbon.File.FSSpec((vrefnum, dirid, '')) 734 pardir_fsr = Carbon.File.FSRef(pardir_fss) 735 pardir_path = pardir_fsr.FSRefMakePath() # This is utf-8 736 name_utf8 = unicode(name, 'macroman').encode('utf8') 737 fullpath = os.path.join(pardir_path, name_utf8) 734 738 if issubclass(tpwanted, unicode): 735 739 return unicode(fullpath, 'utf8')
Note:
See TracChangeset
for help on using the changeset viewer.