Commit 3e7189b2 authored by Neal Norwitz's avatar Neal Norwitz

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).
parent 36dd4d3e
...@@ -207,7 +207,7 @@ def remove_tree (directory, verbose=0, dry_run=0): ...@@ -207,7 +207,7 @@ def remove_tree (directory, verbose=0, dry_run=0):
cmd[0](cmd[1]) cmd[0](cmd[1])
# remove dir from cache if it's already there # remove dir from cache if it's already there
abspath = os.path.abspath(cmd[1]) abspath = os.path.abspath(cmd[1])
if _path_created.has_key(abspath): if abspath in _path_created:
del _path_created[abspath] del _path_created[abspath]
except (IOError, OSError), exc: except (IOError, OSError), exc:
log.warn(grok_environment_error( log.warn(grok_environment_error(
......
...@@ -239,7 +239,7 @@ class MSVCCompiler (CCompiler) : ...@@ -239,7 +239,7 @@ class MSVCCompiler (CCompiler) :
def initialize(self): def initialize(self):
self.__paths = [] self.__paths = []
if os.environ.has_key("DISTUTILS_USE_SDK") and os.environ.has_key("MSSdk") and self.find_exe("cl.exe"): if "DISTUTILS_USE_SDK" in os.environ and "MSSdk" in os.environ and self.find_exe("cl.exe"):
# Assume that the SDK set up everything alright; don't try to be # Assume that the SDK set up everything alright; don't try to be
# smarter # smarter
self.cc = "cl.exe" self.cc = "cl.exe"
......
...@@ -144,7 +144,7 @@ def search_function(encoding): ...@@ -144,7 +144,7 @@ def search_function(encoding):
pass pass
else: else:
for alias in codecaliases: for alias in codecaliases:
if not _aliases.has_key(alias): if alias not in _aliases:
_aliases[alias] = modname _aliases[alias] = modname
# Return the registry entry # Return the registry entry
......
...@@ -326,7 +326,7 @@ class Directory: ...@@ -326,7 +326,7 @@ class Directory:
file = os.path.basename(file) file = os.path.basename(file)
absolute = os.path.join(self.absolute, src) absolute = os.path.join(self.absolute, src)
assert not re.search(r'[\?|><:/*]"', file) # restrictions on long names assert not re.search(r'[\?|><:/*]"', file) # restrictions on long names
if self.keyfiles.has_key(file): if file in self.keyfiles:
logical = self.keyfiles[file] logical = self.keyfiles[file]
else: else:
logical = None logical = None
......
...@@ -577,9 +577,9 @@ def _process_Nav_args(dftflags, **args): ...@@ -577,9 +577,9 @@ def _process_Nav_args(dftflags, **args):
if args[k] is None: if args[k] is None:
del args[k] del args[k]
# Set some defaults, and modify some arguments # Set some defaults, and modify some arguments
if not args.has_key('dialogOptionFlags'): if 'dialogOptionFlags' not in args:
args['dialogOptionFlags'] = dftflags args['dialogOptionFlags'] = dftflags
if args.has_key('defaultLocation') and \ if 'defaultLocation' in args and \
not isinstance(args['defaultLocation'], Carbon.AE.AEDesc): not isinstance(args['defaultLocation'], Carbon.AE.AEDesc):
defaultLocation = args['defaultLocation'] defaultLocation = args['defaultLocation']
if isinstance(defaultLocation, (Carbon.File.FSSpec, Carbon.File.FSRef)): if isinstance(defaultLocation, (Carbon.File.FSSpec, Carbon.File.FSRef)):
...@@ -587,7 +587,7 @@ def _process_Nav_args(dftflags, **args): ...@@ -587,7 +587,7 @@ def _process_Nav_args(dftflags, **args):
else: else:
defaultLocation = Carbon.File.FSRef(defaultLocation) defaultLocation = Carbon.File.FSRef(defaultLocation)
args['defaultLocation'] = aepack.pack(defaultLocation) args['defaultLocation'] = aepack.pack(defaultLocation)
if args.has_key('typeList') and not isinstance(args['typeList'], Carbon.Res.ResourceType): if 'typeList' in args and not isinstance(args['typeList'], Carbon.Res.ResourceType):
typeList = args['typeList'][:] typeList = args['typeList'][:]
# Workaround for OSX typeless files: # Workaround for OSX typeless files:
if 'TEXT' in typeList and not '\0\0\0\0' in typeList: if 'TEXT' in typeList and not '\0\0\0\0' in typeList:
...@@ -597,7 +597,7 @@ def _process_Nav_args(dftflags, **args): ...@@ -597,7 +597,7 @@ def _process_Nav_args(dftflags, **args):
data = data+type data = data+type
args['typeList'] = Carbon.Res.Handle(data) args['typeList'] = Carbon.Res.Handle(data)
tpwanted = str tpwanted = str
if args.has_key('wanted'): if 'wanted' in args:
tpwanted = args['wanted'] tpwanted = args['wanted']
del args['wanted'] del args['wanted']
return args, tpwanted return args, tpwanted
......
...@@ -216,7 +216,7 @@ class Application: ...@@ -216,7 +216,7 @@ class Application:
if self.do_dialogevent(event): if self.do_dialogevent(event):
return return
(what, message, when, where, modifiers) = event (what, message, when, where, modifiers) = event
if eventname.has_key(what): if what in eventname:
name = "do_" + eventname[what] name = "do_" + eventname[what]
else: else:
name = "do_%d" % what name = "do_%d" % what
...@@ -247,7 +247,7 @@ class Application: ...@@ -247,7 +247,7 @@ class Application:
gotone, dlg, item = DialogSelect(event) gotone, dlg, item = DialogSelect(event)
if gotone: if gotone:
window = dlg.GetDialogWindow() window = dlg.GetDialogWindow()
if self._windows.has_key(window): if window in self._windows:
self._windows[window].do_itemhit(item, event) self._windows[window].do_itemhit(item, event)
else: else:
print 'Dialog event for unknown dialog' print 'Dialog event for unknown dialog'
...@@ -261,7 +261,7 @@ class Application: ...@@ -261,7 +261,7 @@ class Application:
# #
# Find the correct name. # Find the correct name.
# #
if partname.has_key(partcode): if partcode in partname:
name = "do_" + partname[partcode] name = "do_" + partname[partcode]
else: else:
name = "do_%d" % partcode name = "do_%d" % partcode
...@@ -276,7 +276,7 @@ class Application: ...@@ -276,7 +276,7 @@ class Application:
if hasattr(MacOS, 'HandleEvent'): if hasattr(MacOS, 'HandleEvent'):
MacOS.HandleEvent(event) MacOS.HandleEvent(event)
return return
elif self._windows.has_key(wid): elif wid in self._windows:
# It is a window. Hand off to correct window. # It is a window. Hand off to correct window.
window = self._windows[wid] window = self._windows[wid]
try: try:
...@@ -363,7 +363,7 @@ class Application: ...@@ -363,7 +363,7 @@ class Application:
else: else:
# See whether the front window wants it # See whether the front window wants it
w = MyFrontWindow() w = MyFrontWindow()
if w and self._windows.has_key(w): if w and w in self._windows:
window = self._windows[w] window = self._windows[w]
try: try:
do_char = window.do_char do_char = window.do_char
...@@ -378,7 +378,7 @@ class Application: ...@@ -378,7 +378,7 @@ class Application:
def do_updateEvt(self, event): def do_updateEvt(self, event):
(what, message, when, where, modifiers) = event (what, message, when, where, modifiers) = event
wid = WhichWindow(message) wid = WhichWindow(message)
if wid and self._windows.has_key(wid): if wid and wid in self._windows:
window = self._windows[wid] window = self._windows[wid]
window.do_rawupdate(wid, event) window.do_rawupdate(wid, event)
else: else:
...@@ -388,7 +388,7 @@ class Application: ...@@ -388,7 +388,7 @@ class Application:
def do_activateEvt(self, event): def do_activateEvt(self, event):
(what, message, when, where, modifiers) = event (what, message, when, where, modifiers) = event
wid = WhichWindow(message) wid = WhichWindow(message)
if wid and self._windows.has_key(wid): if wid and wid in self._windows:
window = self._windows[wid] window = self._windows[wid]
window.do_activate(modifiers & 1, event) window.do_activate(modifiers & 1, event)
else: else:
...@@ -408,7 +408,7 @@ class Application: ...@@ -408,7 +408,7 @@ class Application:
def do_suspendresume(self, event): def do_suspendresume(self, event):
(what, message, when, where, modifiers) = event (what, message, when, where, modifiers) = event
wid = MyFrontWindow() wid = MyFrontWindow()
if wid and self._windows.has_key(wid): if wid and wid in self._windows:
window = self._windows[wid] window = self._windows[wid]
window.do_activate(message & 1, event) window.do_activate(message & 1, event)
...@@ -432,7 +432,7 @@ class Application: ...@@ -432,7 +432,7 @@ class Application:
def printevent(self, event): def printevent(self, event):
(what, message, when, where, modifiers) = event (what, message, when, where, modifiers) = event
nicewhat = repr(what) nicewhat = repr(what)
if eventname.has_key(what): if what in eventname:
nicewhat = eventname[what] nicewhat = eventname[what]
print nicewhat, print nicewhat,
if what == kHighLevelEvent: if what == kHighLevelEvent:
...@@ -512,7 +512,7 @@ class MenuBar: ...@@ -512,7 +512,7 @@ class MenuBar:
label, shortcut, callback, kind = menu.items[i] label, shortcut, callback, kind = menu.items[i]
if type(callback) == types.StringType: if type(callback) == types.StringType:
wid = MyFrontWindow() wid = MyFrontWindow()
if wid and self.parent._windows.has_key(wid): if wid and wid in self.parent._windows:
window = self.parent._windows[wid] window = self.parent._windows[wid]
if hasattr(window, "domenu_" + callback): if hasattr(window, "domenu_" + callback):
menu.menu.EnableMenuItem(i + 1) menu.menu.EnableMenuItem(i + 1)
...@@ -528,7 +528,7 @@ class MenuBar: ...@@ -528,7 +528,7 @@ class MenuBar:
pass pass
def dispatch(self, id, item, window, event): def dispatch(self, id, item, window, event):
if self.menus.has_key(id): if id in self.menus:
self.menus[id].dispatch(id, item, window, event) self.menus[id].dispatch(id, item, window, event)
else: else:
if DEBUG: print "MenuBar.dispatch(%d, %d, %s, %s)" % \ if DEBUG: print "MenuBar.dispatch(%d, %d, %s, %s)" % \
...@@ -607,7 +607,7 @@ class Menu: ...@@ -607,7 +607,7 @@ class Menu:
else: else:
# callback is string # callback is string
wid = MyFrontWindow() wid = MyFrontWindow()
if wid and self.bar.parent._windows.has_key(wid): if wid and wid in self.bar.parent._windows:
window = self.bar.parent._windows[wid] window = self.bar.parent._windows[wid]
if hasattr(window, "domenu_" + callback): if hasattr(window, "domenu_" + callback):
menuhandler = getattr(window, "domenu_" + callback) menuhandler = getattr(window, "domenu_" + callback)
......
...@@ -134,11 +134,11 @@ class AEServer: ...@@ -134,11 +134,11 @@ class AEServer:
_class = _attributes['evcl'].type _class = _attributes['evcl'].type
_type = _attributes['evid'].type _type = _attributes['evid'].type
if self.ae_handlers.has_key((_class, _type)): if (_class, _type) in self.ae_handlers:
_function = self.ae_handlers[(_class, _type)] _function = self.ae_handlers[(_class, _type)]
elif self.ae_handlers.has_key((_class, '****')): elif (_class, '****') in self.ae_handlers:
_function = self.ae_handlers[(_class, '****')] _function = self.ae_handlers[(_class, '****')]
elif self.ae_handlers.has_key(('****', '****')): elif ('****', '****') in self.ae_handlers:
_function = self.ae_handlers[('****', '****')] _function = self.ae_handlers[('****', '****')]
else: else:
raise 'Cannot happen: AE callback without handler', (_class, _type) raise 'Cannot happen: AE callback without handler', (_class, _type)
...@@ -148,7 +148,7 @@ class AEServer: ...@@ -148,7 +148,7 @@ class AEServer:
_parameters['_attributes'] = _attributes _parameters['_attributes'] = _attributes
_parameters['_class'] = _class _parameters['_class'] = _class
_parameters['_type'] = _type _parameters['_type'] = _type
if _parameters.has_key('----'): if '----' in _parameters:
_object = _parameters['----'] _object = _parameters['----']
del _parameters['----'] del _parameters['----']
# The try/except that used to be here can mask programmer errors. # The try/except that used to be here can mask programmer errors.
......
...@@ -129,7 +129,7 @@ def unpack(desc, formodulename=""): ...@@ -129,7 +129,7 @@ def unpack(desc, formodulename=""):
"""Unpack an AE descriptor to a python object""" """Unpack an AE descriptor to a python object"""
t = desc.type t = desc.type
if unpacker_coercions.has_key(t): if t in unpacker_coercions:
desc = desc.AECoerceDesc(unpacker_coercions[t]) desc = desc.AECoerceDesc(unpacker_coercions[t])
t = desc.type # This is a guess by Jack.... t = desc.type # This is a guess by Jack....
......
...@@ -107,7 +107,7 @@ def keysubst(arguments, keydict): ...@@ -107,7 +107,7 @@ def keysubst(arguments, keydict):
"""Replace long name keys by their 4-char counterparts, and check""" """Replace long name keys by their 4-char counterparts, and check"""
ok = keydict.values() ok = keydict.values()
for k in arguments.keys(): for k in arguments.keys():
if keydict.has_key(k): if k in keydict:
v = arguments[k] v = arguments[k]
del arguments[k] del arguments[k]
arguments[keydict[k]] = v arguments[keydict[k]] = v
...@@ -116,11 +116,11 @@ def keysubst(arguments, keydict): ...@@ -116,11 +116,11 @@ def keysubst(arguments, keydict):
def enumsubst(arguments, key, edict): def enumsubst(arguments, key, edict):
"""Substitute a single enum keyword argument, if it occurs""" """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 return
v = arguments[key] v = arguments[key]
ok = edict.values() ok = edict.values()
if edict.has_key(v): if v in edict:
arguments[key] = Enum(edict[v]) arguments[key] = Enum(edict[v])
elif not v in ok: elif not v in ok:
raise TypeError, 'Unknown enumerator: %s'%v raise TypeError, 'Unknown enumerator: %s'%v
...@@ -129,11 +129,11 @@ def decodeerror(arguments): ...@@ -129,11 +129,11 @@ def decodeerror(arguments):
"""Create the 'best' argument for a raise MacOS.Error""" """Create the 'best' argument for a raise MacOS.Error"""
errn = arguments['errn'] errn = arguments['errn']
err_a1 = errn err_a1 = errn
if arguments.has_key('errs'): if 'errs' in arguments:
err_a2 = arguments['errs'] err_a2 = arguments['errs']
else: else:
err_a2 = MacOS.GetErrorString(errn) err_a2 = MacOS.GetErrorString(errn)
if arguments.has_key('erob'): if 'erob' in arguments:
err_a3 = arguments['erob'] err_a3 = arguments['erob']
else: else:
err_a3 = None err_a3 = None
...@@ -248,10 +248,10 @@ class TalkTo: ...@@ -248,10 +248,10 @@ class TalkTo:
_reply, _arguments, _attributes = self.send(_code, _subcode, _reply, _arguments, _attributes = self.send(_code, _subcode,
_arguments, _attributes) _arguments, _attributes)
if _arguments.has_key('errn'): if 'errn' in _arguments:
raise Error, decodeerror(_arguments) raise Error, decodeerror(_arguments)
if _arguments.has_key('----'): if '----' in _arguments:
return _arguments['----'] return _arguments['----']
if asfile: if asfile:
item.__class__ = asfile item.__class__ = asfile
...@@ -281,7 +281,7 @@ class TalkTo: ...@@ -281,7 +281,7 @@ class TalkTo:
if _arguments.get('errn', 0): if _arguments.get('errn', 0):
raise Error, decodeerror(_arguments) raise Error, decodeerror(_arguments)
# XXXX Optionally decode result # XXXX Optionally decode result
if _arguments.has_key('----'): if '----' in _arguments:
return _arguments['----'] return _arguments['----']
set = _set set = _set
...@@ -290,10 +290,10 @@ class TalkTo: ...@@ -290,10 +290,10 @@ class TalkTo:
# like the "application" class in OSA. # like the "application" class in OSA.
def __getattr__(self, name): def __getattr__(self, name):
if self._elemdict.has_key(name): if name in self._elemdict:
cls = self._elemdict[name] cls = self._elemdict[name]
return DelayedComponentItem(cls, None) return DelayedComponentItem(cls, None)
if self._propdict.has_key(name): if name in self._propdict:
cls = self._propdict[name] cls = self._propdict[name]
return cls() return cls()
raise AttributeError, name raise AttributeError, name
...@@ -315,10 +315,10 @@ class _miniFinder(TalkTo): ...@@ -315,10 +315,10 @@ class _miniFinder(TalkTo):
_reply, _arguments, _attributes = self.send(_code, _subcode, _reply, _arguments, _attributes = self.send(_code, _subcode,
_arguments, _attributes) _arguments, _attributes)
if _arguments.has_key('errn'): if 'errn' in _arguments:
raise Error, decodeerror(_arguments) raise Error, decodeerror(_arguments)
# XXXX Optionally decode result # XXXX Optionally decode result
if _arguments.has_key('----'): if '----' in _arguments:
return _arguments['----'] return _arguments['----']
#pass #pass
......
...@@ -530,10 +530,10 @@ class ComponentItem(SelectableItem): ...@@ -530,10 +530,10 @@ class ComponentItem(SelectableItem):
return s return s
def __getattr__(self, name): def __getattr__(self, name):
if self._elemdict.has_key(name): if name in self._elemdict:
cls = self._elemdict[name] cls = self._elemdict[name]
return DelayedComponentItem(cls, self) return DelayedComponentItem(cls, self)
if self._propdict.has_key(name): if name in self._propdict:
cls = self._propdict[name] cls = self._propdict[name]
return cls(self) return cls(self)
raise AttributeError, name raise AttributeError, name
......
...@@ -481,7 +481,7 @@ class AppBuilder(BundleBuilder): ...@@ -481,7 +481,7 @@ class AppBuilder(BundleBuilder):
if self.standalone or self.semi_standalone: if self.standalone or self.semi_standalone:
self.includeModules.append("argvemulator") self.includeModules.append("argvemulator")
self.includeModules.append("os") self.includeModules.append("os")
if not self.plist.has_key("CFBundleDocumentTypes"): if "CFBundleDocumentTypes" not in self.plist:
self.plist["CFBundleDocumentTypes"] = [ self.plist["CFBundleDocumentTypes"] = [
{ "CFBundleTypeOSTypes" : [ { "CFBundleTypeOSTypes" : [
"****", "****",
......
This diff is collapsed.
...@@ -589,7 +589,7 @@ class SuiteCompiler: ...@@ -589,7 +589,7 @@ class SuiteCompiler:
self.modname = os.path.splitext(os.path.split(self.pathname)[1])[0] self.modname = os.path.splitext(os.path.split(self.pathname)[1])[0]
if self.basepackage and self.basepackage._code_to_module.has_key(code): if self.basepackage and code in self.basepackage._code_to_module:
# We are an extension of a baseclass (usually an application extending # We are an extension of a baseclass (usually an application extending
# Standard_Suite or so). Import everything from our base module # Standard_Suite or so). Import everything from our base module
basemodule = self.basepackage._code_to_module[code] basemodule = self.basepackage._code_to_module[code]
...@@ -656,12 +656,12 @@ class SuiteCompiler: ...@@ -656,12 +656,12 @@ class SuiteCompiler:
fp.write('import aetools\n') fp.write('import aetools\n')
fp.write('import MacOS\n\n') fp.write('import MacOS\n\n')
fp.write("_code = %r\n\n"% (code,)) fp.write("_code = %r\n\n"% (code,))
if self.basepackage and self.basepackage._code_to_module.has_key(code): if self.basepackage and code in self.basepackage._code_to_module:
# We are an extension of a baseclass (usually an application extending # We are an extension of a baseclass (usually an application extending
# Standard_Suite or so). Import everything from our base module # Standard_Suite or so). Import everything from our base module
fp.write('from %s import *\n'%self.basepackage._code_to_fullname[code][0]) fp.write('from %s import *\n'%self.basepackage._code_to_fullname[code][0])
basemodule = self.basepackage._code_to_module[code] basemodule = self.basepackage._code_to_module[code]
elif self.basepackage and self.basepackage._code_to_module.has_key(code.lower()): elif self.basepackage and code.lower() in self.basepackage._code_to_module:
# This is needed by CodeWarrior and some others. # This is needed by CodeWarrior and some others.
fp.write('from %s import *\n'%self.basepackage._code_to_fullname[code.lower()][0]) fp.write('from %s import *\n'%self.basepackage._code_to_fullname[code.lower()][0])
basemodule = self.basepackage._code_to_module[code.lower()] basemodule = self.basepackage._code_to_module[code.lower()]
...@@ -798,7 +798,7 @@ class SuiteCompiler: ...@@ -798,7 +798,7 @@ class SuiteCompiler:
# #
# Decode result # Decode result
# #
fp.write(" if _arguments.has_key('----'):\n") fp.write(" if '----' in _arguments:\n")
if is_enum(returns): if is_enum(returns):
fp.write(" # XXXX Should do enum remapping here...\n") fp.write(" # XXXX Should do enum remapping here...\n")
fp.write(" return _arguments['----']\n") fp.write(" return _arguments['----']\n")
...@@ -842,17 +842,17 @@ class CodeNameMapper: ...@@ -842,17 +842,17 @@ class CodeNameMapper:
def addnamecode(self, type, name, code): def addnamecode(self, type, name, code):
self.name2code[type][name] = code self.name2code[type][name] = code
if not self.code2name[type].has_key(code): if code not in self.code2name[type]:
self.code2name[type][code] = name self.code2name[type][code] = name
def hasname(self, name): def hasname(self, name):
for dict in self.name2code.values(): for dict in self.name2code.values():
if dict.has_key(name): if name in dict:
return True return True
return False return False
def hascode(self, type, code): def hascode(self, type, code):
return self.code2name[type].has_key(code) return code in self.code2name[type]
def findcodename(self, type, code): def findcodename(self, type, code):
if not self.hascode(type, code): if not self.hascode(type, code):
......
...@@ -138,7 +138,7 @@ def _decode(data, key): ...@@ -138,7 +138,7 @@ def _decode(data, key):
key2 = key[:string.index(key, '\245')+1] key2 = key[:string.index(key, '\245')+1]
else: else:
key2 = key key2 = key
if _decoder_table.has_key(key2): if key2 in _decoder_table:
decoder = _decoder_table[key2][0] decoder = _decoder_table[key2][0]
else: else:
decoder = _decode_default decoder = _decode_default
...@@ -151,7 +151,7 @@ def _code(data, key): ...@@ -151,7 +151,7 @@ def _code(data, key):
key2 = key[:string.index(key, '\245')+1] key2 = key[:string.index(key, '\245')+1]
else: else:
key2 = key key2 = key
if _decoder_table.has_key(key2): if key2 in _decoder_table:
coder = _decoder_table[key2][1] coder = _decoder_table[key2][1]
else: else:
coder = _code_default coder = _code_default
...@@ -176,9 +176,6 @@ class IC: ...@@ -176,9 +176,6 @@ class IC:
self.ic.ICEnd() self.ic.ICEnd()
return rv return rv
def has_key(self, key):
return self.__contains__(key)
def __contains__(self, key): def __contains__(self, key):
try: try:
dummy = self.ic.ICFindPrefHandle(key, self.h) dummy = self.ic.ICFindPrefHandle(key, self.h)
......
...@@ -48,7 +48,7 @@ def need(restype, resid, filename=None, modname=None): ...@@ -48,7 +48,7 @@ def need(restype, resid, filename=None, modname=None):
if modname == '__main__': if modname == '__main__':
# If we're main we look in the current directory # If we're main we look in the current directory
searchdirs = [os.curdir] searchdirs = [os.curdir]
if sys.modules.has_key(modname): if modname in sys.modules:
mod = sys.modules[modname] mod = sys.modules[modname]
if hasattr(mod, '__file__'): if hasattr(mod, '__file__'):
searchdirs = [os.path.dirname(mod.__file__)] searchdirs = [os.path.dirname(mod.__file__)]
......
...@@ -147,7 +147,7 @@ class PimpUrllibDownloader(PimpDownloader): ...@@ -147,7 +147,7 @@ class PimpUrllibDownloader(PimpDownloader):
self.update("Downloading %s: opening connection" % url) self.update("Downloading %s: opening connection" % url)
keepgoing = True keepgoing = True
download = urllib2.urlopen(url) download = urllib2.urlopen(url)
if download.headers.has_key("content-length"): if "content-length" in download.headers:
length = long(download.headers['content-length']) length = long(download.headers['content-length'])
else: else:
length = -1 length = -1
...@@ -415,7 +415,7 @@ class PimpDatabase: ...@@ -415,7 +415,7 @@ class PimpDatabase:
for p in packages: for p in packages:
p = dict(p) p = dict(p)
if p.has_key('Download-URL'): if 'Download-URL' in p:
p['Download-URL'] = urllib.basejoin(url, p['Download-URL']) p['Download-URL'] = urllib.basejoin(url, p['Download-URL'])
flavor = p.get('Flavor') flavor = p.get('Flavor')
if flavor == 'source': if flavor == 'source':
...@@ -547,9 +547,9 @@ class PimpPackage: ...@@ -547,9 +547,9 @@ class PimpPackage:
installed through pimp, return the name in (parentheses).""" installed through pimp, return the name in (parentheses)."""
rv = self._dict['Name'] rv = self._dict['Name']
if self._dict.has_key('Version'): if 'Version' in self._dict:
rv = rv + '-%s' % self._dict['Version'] rv = rv + '-%s' % self._dict['Version']
if self._dict.has_key('Flavor'): if 'Flavor' in self._dict:
rv = rv + '-%s' % self._dict['Flavor'] rv = rv + '-%s' % self._dict['Flavor']
if self._dict.get('Flavor') == 'hidden': if self._dict.get('Flavor') == 'hidden':
# Pseudo-package, show in parentheses # Pseudo-package, show in parentheses
...@@ -642,9 +642,9 @@ class PimpPackage: ...@@ -642,9 +642,9 @@ class PimpPackage:
descr = str(item) descr = str(item)
else: else:
name = item['Name'] name = item['Name']
if item.has_key('Version'): if 'Version' in item:
name = name + '-' + item['Version'] name = name + '-' + item['Version']
if item.has_key('Flavor'): if 'Flavor' in item:
name = name + '-' + item['Flavor'] name = name + '-' + item['Flavor']
pkg = self._db.find(name) pkg = self._db.find(name)
if not pkg: if not pkg:
...@@ -795,10 +795,10 @@ class PimpPackage_binary(PimpPackage): ...@@ -795,10 +795,10 @@ class PimpPackage_binary(PimpPackage):
If output is given it should be a file-like object and it If output is given it should be a file-like object and it
will receive a log of what happened.""" will receive a log of what happened."""
if self._dict.has_key('Install-command'): if 'Install-command' in self._dict:
return "%s: Binary package cannot have Install-command" % self.fullname() return "%s: Binary package cannot have Install-command" % self.fullname()
if self._dict.has_key('Pre-install-command'): if 'Pre-install-command' in self._dict:
if _cmd(output, '/tmp', self._dict['Pre-install-command']): if _cmd(output, '/tmp', self._dict['Pre-install-command']):
return "pre-install %s: running \"%s\" failed" % \ return "pre-install %s: running \"%s\" failed" % \
(self.fullname(), self._dict['Pre-install-command']) (self.fullname(), self._dict['Pre-install-command'])
...@@ -831,7 +831,7 @@ class PimpPackage_binary(PimpPackage): ...@@ -831,7 +831,7 @@ class PimpPackage_binary(PimpPackage):
self.afterInstall() self.afterInstall()
if self._dict.has_key('Post-install-command'): if 'Post-install-command' in self._dict:
if _cmd(output, '/tmp', self._dict['Post-install-command']): if _cmd(output, '/tmp', self._dict['Post-install-command']):
return "%s: post-install: running \"%s\" failed" % \ return "%s: post-install: running \"%s\" failed" % \
(self.fullname(), self._dict['Post-install-command']) (self.fullname(), self._dict['Post-install-command'])
...@@ -856,7 +856,7 @@ class PimpPackage_source(PimpPackage): ...@@ -856,7 +856,7 @@ class PimpPackage_source(PimpPackage):
If output is given it should be a file-like object and it If output is given it should be a file-like object and it
will receive a log of what happened.""" will receive a log of what happened."""
if self._dict.has_key('Pre-install-command'): if 'Pre-install-command' in self._dict:
if _cmd(output, self._buildDirname, self._dict['Pre-install-command']): if _cmd(output, self._buildDirname, self._dict['Pre-install-command']):
return "pre-install %s: running \"%s\" failed" % \ return "pre-install %s: running \"%s\" failed" % \
(self.fullname(), self._dict['Pre-install-command']) (self.fullname(), self._dict['Pre-install-command'])
...@@ -893,7 +893,7 @@ class PimpPackage_source(PimpPackage): ...@@ -893,7 +893,7 @@ class PimpPackage_source(PimpPackage):
self.afterInstall() self.afterInstall()
if self._dict.has_key('Post-install-command'): if 'Post-install-command' in self._dict:
if _cmd(output, self._buildDirname, self._dict['Post-install-command']): if _cmd(output, self._buildDirname, self._dict['Post-install-command']):
return "post-install %s: running \"%s\" failed" % \ return "post-install %s: running \"%s\" failed" % \
(self.fullname(), self._dict['Post-install-command']) (self.fullname(), self._dict['Post-install-command'])
...@@ -911,10 +911,10 @@ class PimpPackage_installer(PimpPackage): ...@@ -911,10 +911,10 @@ class PimpPackage_installer(PimpPackage):
If output is given it should be a file-like object and it If output is given it should be a file-like object and it
will receive a log of what happened.""" will receive a log of what happened."""
if self._dict.has_key('Post-install-command'): if 'Post-install-command' in self._dict:
return "%s: Installer package cannot have Post-install-command" % self.fullname() return "%s: Installer package cannot have Post-install-command" % self.fullname()
if self._dict.has_key('Pre-install-command'): if 'Pre-install-command' in self._dict:
if _cmd(output, '/tmp', self._dict['Pre-install-command']): if _cmd(output, '/tmp', self._dict['Pre-install-command']):
return "pre-install %s: running \"%s\" failed" % \ return "pre-install %s: running \"%s\" failed" % \
(self.fullname(), self._dict['Pre-install-command']) (self.fullname(), self._dict['Pre-install-command'])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment