Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Lib/plat-mac/EasyDialogs.py

    r2 r391  
    244244
    245245
    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
     250try:
     251    screenbounds = Qd.GetQDGlobalsScreenBits().bounds
     252except AttributeError:
     253    raise ImportError("QuickDraw APIs not available")
     254
    248255screenbounds = screenbounds[0]+4, screenbounds[1]+4, \
    249256    screenbounds[2]-4, screenbounds[3]-4
     
    581588            del args[k]
    582589    # Set some defaults, and modify some arguments
    583     if not args.has_key('dialogOptionFlags'):
     590    if 'dialogOptionFlags' not in args:
    584591        args['dialogOptionFlags'] = dftflags
    585     if args.has_key('defaultLocation') and \
     592    if 'defaultLocation' in args and \
    586593            not isinstance(args['defaultLocation'], Carbon.AE.AEDesc):
    587594        defaultLocation = args['defaultLocation']
     
    594601            args['defaultLocation'] = Carbon.AE.AECreateDesc(
    595602                    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):
    597604        typeList = args['typeList'][:]
    598605        # Workaround for OSX typeless files:
     
    604611        args['typeList'] = Carbon.Res.Handle(data)
    605612    tpwanted = str
    606     if args.has_key('wanted'):
     613    if 'wanted' in args:
    607614        tpwanted = args['wanted']
    608615        del args['wanted']
     
    722729        return tpwanted(rr.selection[0])
    723730    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)
    734738        if issubclass(tpwanted, unicode):
    735739            return unicode(fullpath, 'utf8')
Note: See TracChangeset for help on using the changeset viewer.