mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Get rid of a bunch more has_key() uses. We *really* need a tool for this.
test_aepack now passes. IDLE still needs to be converted (among others).
This commit is contained in:
parent
0da7e03e12
commit
f1a69c1666
16 changed files with 109 additions and 112 deletions
|
@ -107,7 +107,7 @@ def keysubst(arguments, keydict):
|
|||
"""Replace long name keys by their 4-char counterparts, and check"""
|
||||
ok = keydict.values()
|
||||
for k in arguments.keys():
|
||||
if keydict.has_key(k):
|
||||
if k in keydict:
|
||||
v = arguments[k]
|
||||
del arguments[k]
|
||||
arguments[keydict[k]] = v
|
||||
|
@ -116,11 +116,11 @@ def keysubst(arguments, keydict):
|
|||
|
||||
def enumsubst(arguments, key, edict):
|
||||
"""Substitute a single enum keyword argument, if it occurs"""
|
||||
if not arguments.has_key(key) or edict is None:
|
||||
if key not in arguments or edict is None:
|
||||
return
|
||||
v = arguments[key]
|
||||
ok = edict.values()
|
||||
if edict.has_key(v):
|
||||
if v in edict:
|
||||
arguments[key] = Enum(edict[v])
|
||||
elif not v in ok:
|
||||
raise TypeError, 'Unknown enumerator: %s'%v
|
||||
|
@ -129,11 +129,11 @@ def decodeerror(arguments):
|
|||
"""Create the 'best' argument for a raise MacOS.Error"""
|
||||
errn = arguments['errn']
|
||||
err_a1 = errn
|
||||
if arguments.has_key('errs'):
|
||||
if 'errs' in arguments:
|
||||
err_a2 = arguments['errs']
|
||||
else:
|
||||
err_a2 = MacOS.GetErrorString(errn)
|
||||
if arguments.has_key('erob'):
|
||||
if 'erob' in arguments:
|
||||
err_a3 = arguments['erob']
|
||||
else:
|
||||
err_a3 = None
|
||||
|
@ -248,10 +248,10 @@ class TalkTo:
|
|||
|
||||
_reply, _arguments, _attributes = self.send(_code, _subcode,
|
||||
_arguments, _attributes)
|
||||
if _arguments.has_key('errn'):
|
||||
if 'errn' in _arguments:
|
||||
raise Error, decodeerror(_arguments)
|
||||
|
||||
if _arguments.has_key('----'):
|
||||
if '----' in _arguments:
|
||||
return _arguments['----']
|
||||
if asfile:
|
||||
item.__class__ = asfile
|
||||
|
@ -281,7 +281,7 @@ class TalkTo:
|
|||
if _arguments.get('errn', 0):
|
||||
raise Error, decodeerror(_arguments)
|
||||
# XXXX Optionally decode result
|
||||
if _arguments.has_key('----'):
|
||||
if '----' in _arguments:
|
||||
return _arguments['----']
|
||||
|
||||
set = _set
|
||||
|
@ -290,10 +290,10 @@ class TalkTo:
|
|||
# like the "application" class in OSA.
|
||||
|
||||
def __getattr__(self, name):
|
||||
if self._elemdict.has_key(name):
|
||||
if name in self._elemdict:
|
||||
cls = self._elemdict[name]
|
||||
return DelayedComponentItem(cls, None)
|
||||
if self._propdict.has_key(name):
|
||||
if name in self._propdict:
|
||||
cls = self._propdict[name]
|
||||
return cls()
|
||||
raise AttributeError, name
|
||||
|
@ -315,10 +315,10 @@ class _miniFinder(TalkTo):
|
|||
|
||||
_reply, _arguments, _attributes = self.send(_code, _subcode,
|
||||
_arguments, _attributes)
|
||||
if _arguments.has_key('errn'):
|
||||
if 'errn' in _arguments:
|
||||
raise Error, decodeerror(_arguments)
|
||||
# XXXX Optionally decode result
|
||||
if _arguments.has_key('----'):
|
||||
if '----' in _arguments:
|
||||
return _arguments['----']
|
||||
#pass
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue