PR#332 remove has_key (not working in python3)

Merges #332
Related: #151
This commit is contained in:
Mike McLean 2017-03-07 08:15:42 -05:00
commit a8711956b2
19 changed files with 182 additions and 183 deletions

View file

@ -380,7 +380,7 @@ class BuildRoot(object):
results = []
for fname in results:
if fname.endswith('.log') and not logs.has_key(fname):
if fname.endswith('.log') and fname not in logs:
fpath = os.path.join(resultdir, fname)
logs[fname] = (None, None, 0, fpath)
if workdir and mocklog not in logs:
@ -2215,7 +2215,7 @@ class BuildBaseImageTask(BuildImageTask):
# make sure we only import the user-submitted kickstart file one
# time, otherwise we will have collisions. Remove it from exactly
# 1 results hash from the subtasks
if opts.has_key('kickstart'):
if 'kickstart' in opts:
saw_ks = False
for arch in results.keys():
ks = os.path.basename(opts.get('kickstart'))
@ -5201,7 +5201,7 @@ if __name__ == "__main__":
quit("Error: Unable to log in. Bad credentials?")
except xmlrpclib.ProtocolError:
quit("Error: Unable to connect to server %s" % (options.server))
elif sys.modules.has_key('krbV'):
elif 'krbV' in sys.modules:
krb_principal = options.krb_principal
if krb_principal is None:
krb_principal = options.host_principal_format % socket.getfqdn()

View file

@ -83,7 +83,7 @@ def parse_args(args):
# expand arches
for arch in opts.arches[:]:
if EXPAND_ARCHES.has_key(arch):
if arch in EXPAND_ARCHES:
opts.arches.extend(EXPAND_ARCHES[arch])
# support multilib repos
@ -205,7 +205,7 @@ class RepoMerge(object):
continue
seen_srpms[pkg.sourcerpm] = 1
srpm_name, ver, rel, epoch, arch = rpmUtils.miscutils.splitFilename(pkg.sourcerpm)
if include_srpms.has_key(srpm_name):
if srpm_name in include_srpms:
other_srpm, other_repoid = include_srpms[srpm_name]
if pkg.repoid != other_repoid:
# We found a rpm built from an srpm with the same name in a previous repo.
@ -230,7 +230,7 @@ class RepoMerge(object):
sys.stderr.write('Ignoring older source nvr: '
'%s < %s\n' % (pkg.sourcerpm, other_srpm))
# otherwise same, so we already have it
elif self.blocked.has_key(srpm_name):
elif srpm_name in self.blocked:
sys.stderr.write('Ignoring blocked package: %s\n\n' % \
pkg.sourcerpm)
continue
@ -246,7 +246,7 @@ class RepoMerge(object):
srpm_name, ver, rel, epoch, arch = rpmUtils.miscutils.splitFilename(pkg.sourcerpm)
incl_srpm, incl_repoid = include_srpms.get(srpm_name, (None, None))
pkg_nvra = str(pkg)
if seen_rpms.has_key(pkg_nvra):
if pkg_nvra in seen_rpms:
sys.stderr.write('Duplicate rpm: %s\n' % pkg_nvra)
elif incl_srpm is None:
sys.stderr.write('Excluding %s (%s is blocked)\n'

View file

@ -223,11 +223,11 @@ def get_options():
if cmd.lower() in greetings:
cmd = "moshimoshi"
cmd = cmd.replace('-', '_')
if globals().has_key('anon_handle_' + cmd):
if ('anon_handle_' + cmd) in globals():
if not options.force_auth and '--mine' not in args:
options.noauth = True
cmd = 'anon_handle_' + cmd
elif globals().has_key('handle_' + cmd):
elif ('handle_' + cmd) in globals():
cmd = 'handle_' + cmd
else:
list_commands()
@ -520,7 +520,7 @@ def watch_logs(session, tasklist, opts):
for log in logs:
contents = 'placeholder'
while contents:
if not taskoffsets.has_key(log):
if log not in taskoffsets:
taskoffsets[log] = 0
contents = session.downloadTaskOutput(task_id, log, taskoffsets[log], 16384)
@ -2026,9 +2026,9 @@ def handle_prune_signed_copies(options, session, args):
return "%s: %s" % (time_str, fmt % x)
for nvr, binfo in builds:
#listBuilds returns slightly different data than normal
if not binfo.has_key('id'):
if 'id' not in binfo:
binfo['id'] = binfo['build_id']
if not binfo.has_key('name'):
if 'name' not in binfo:
binfo['name'] = binfo['package_name']
if options.debug:
print("DEBUG: %s" % nvr)
@ -2149,7 +2149,7 @@ def handle_prune_signed_copies(options, session, args):
else:
#other build revoked
#see if our build has resurfaced
if others.has_key(entry['build_id']):
if entry['build_id'] in others:
del others[entry['build_id']]
if replaced_ts is not None and not others:
#we've become latest again
@ -2873,7 +2873,7 @@ def anon_handle_list_tagged(options, session, args):
else:
rinfo['path'] = os.path.join(builddir, pathinfo.rpm(rinfo))
fmt = "%(path)s"
data = [x for x in data if x.has_key('path')]
data = [x for x in data if 'path' in x]
else:
fmt = "%(name)s-%(version)s-%(release)s.%(arch)s"
if options.sigs:
@ -2972,7 +2972,7 @@ def anon_handle_list_untagged(options, session, args):
x['refs'] = "%s" % builds
else:
x['refs'] = ''
#data = [x for x in data if not refs.has_key(x['id'])]
#data = [x for x in data if x['id'] not in refs)]
if options.paths:
for x in data:
x['path'] = pathinfo.build(x)
@ -3243,7 +3243,7 @@ def anon_handle_list_pkgs(options, session, args):
else:
if not options.show_blocked and pkg.get('blocked',False):
continue
if pkg.has_key('tag_id'):
if 'tag_id' in pkg:
if pkg['extra_arches'] is None:
pkg['extra_arches'] = ""
fmt = "%(package_name)-23s %(tag_name)-23s %(extra_arches)-16s %(owner_name)-15s"
@ -3571,35 +3571,35 @@ def handle_clone_tag(options, session, args):
#construct to-do lists.
paddlist = [] # list containing new packages to be added from src tag
for (package_name, pkg) in srcpkgs.iteritems():
if not dstpkgs.has_key(package_name):
if package_name not in dstpkgs:
paddlist.append(pkg)
paddlist.sort(key = lambda x: x['package_name'])
pdellist = [] # list containing packages no more present in dst tag
for (package_name, pkg) in dstpkgs.iteritems():
if not srcpkgs.has_key(package_name):
if package_name not in srcpkgs:
pdellist.append(pkg)
pdellist.sort(key = lambda x: x['package_name'])
baddlist = [] # list containing new builds to be added from src tag
for (nvr, lbld) in srclblds.iteritems():
if not dstlblds.has_key(nvr):
if nvr not in dstlblds:
baddlist.append(lbld)
baddlist.sort(key = lambda x: x['package_name'])
bdellist = [] # list containing new builds to be removed from src tag
for (nvr, lbld) in dstlblds.iteritems():
if not srclblds.has_key(nvr):
if nvr not in srclblds:
bdellist.append(lbld)
bdellist.sort(key = lambda x: x['package_name'])
gaddlist = [] # list containing new groups to be added from src tag
for (grpname, group) in srcgroups.iteritems():
if not dstgroups.has_key(grpname):
if grpname not in dstgroups:
gaddlist.append(group)
gdellist = [] # list containing groups to be removed from src tag
for (grpname, group) in dstgroups.iteritems():
if not srcgroups.has_key(grpname):
if grpname not in srcgroups:
gdellist.append(group)
grpchanges = {} # dict of changes to make in shared groups
for (grpname, group) in srcgroups.iteritems():
if dstgroups.has_key(grpname):
if grpname in dstgroups:
grpchanges[grpname] = {'adds':[], 'dels':[]}
# Store whether group is inherited or not
grpchanges[grpname]['inherited'] = False
@ -4117,12 +4117,12 @@ def anon_handle_list_tag_history(options, session, args):
if event_id == x['revoke_event']:
ts = x['revoke_ts']
fmt = "%(name)s-%(version)s-%(release)s untagged from %(tag_name)s"
if x.has_key('revoker_name'):
if 'revoker_name' in x:
fmt += " by %(revoker_name)s"
elif event_id == x['create_event']:
ts = x['create_ts']
fmt = "%(name)s-%(version)s-%(release)s tagged into %(tag_name)s"
if x.has_key('creator_name'):
if 'creator_name' in x:
fmt += " by %(creator_name)s"
if x['active']:
fmt += " [still active]"
@ -4162,11 +4162,11 @@ def _print_histline(entry, **kwargs):
return
if create:
ts = x['create_ts']
if x.has_key('creator_name'):
if 'creator_name' in x:
who = "by %(creator_name)s"
else:
ts = x['revoke_ts']
if x.has_key('revoker_name'):
if 'revoker_name' in x:
who = "by %(revoker_name)s"
if table == 'tag_listing':
if edit:
@ -4784,7 +4784,7 @@ def anon_handle_taginfo(options, session, args):
repos = {}
if not event:
for target in dest_targets + build_targets:
if not repos.has_key(target['build_tag']):
if target['build_tag'] not in repos:
repo = session.getRepo(target['build_tag'])
if repo is None:
repos[target['build_tag']] = "no active repo"
@ -6527,7 +6527,7 @@ def handle_untag_build(options, session, args):
seen_pkg = {}
builds = []
for binfo in tagged:
if not seen_pkg.has_key(binfo['name']):
if binfo['name'] not in seen_pkg:
#latest for this package
if options.verbose:
print(_("Leaving latest build for package %(name)s: %(nvr)s") % binfo)

View file

@ -369,7 +369,7 @@ class Task(object):
#otherwise, find the top-level task and go from there
seen = {task_id:1}
while parent is not None:
if seen.has_key(parent):
if parent in seen:
raise koji.GenericError("Task LOOP at task %i" % task_id)
task_id = parent
seen[task_id] = 1
@ -382,7 +382,7 @@ class Task(object):
#query for use in loop
q_children = """SELECT id FROM task WHERE parent = %(task_id)i"""
for task_id in tasklist:
if seen.has_key(task_id):
if task_id in seen:
#shouldn't happen
raise koji.GenericError("Task LOOP at task %i" % task_id)
seen[task_id] = 1
@ -483,7 +483,7 @@ def make_task(method, arglist, **opts):
priority: the priority of the task
assign: a host_id to assign the task to
"""
if opts.has_key('parent'):
if 'parent' in opts:
# for subtasks, we use some of the parent's options as defaults
fields = ('state', 'owner', 'channel_id', 'priority', 'arch')
q = """SELECT %s FROM task WHERE id = %%(parent)i""" % ','.join(fields)
@ -647,7 +647,7 @@ def _writeInheritanceData(tag_id, changes, clear=False):
if link.get('delete link'):
check_fields = ('parent_id')
for f in fields:
if not link.has_key(f):
if f not in link:
raise koji.GenericError("No value for %s" % f)
# read current data and index
data = dict([[link['parent_id'], link] for link in readInheritanceData(tag_id)])
@ -741,16 +741,16 @@ def readFullInheritanceRecurse(tag_id, event, order, prunes, top, hist, currdept
id = link['tag_id']
else:
id = link['parent_id']
if jumps.has_key(id):
if id in jumps:
id = jumps[id]
if top.has_key(id):
if id in top:
#LOOP!
if event is None:
# only log if the issue is current
log_error("Warning: INHERITANCE LOOP detected at %s -> %s, pruning" % (tag_id, id))
#auto prune
continue
if prunes.has_key(id):
if id in prunes:
# ignore pruned tags
continue
if link['intransitive'] and len(top) > 1 and not reverse:
@ -784,7 +784,7 @@ def readFullInheritanceRecurse(tag_id, event, order, prunes, top, hist, currdept
filter.append(pattern)
link['filter'] = filter
# check history to avoid redundant entries
if hist.has_key(id):
if id in hist:
#already been there
#BUT, options may have been different
rescan = True
@ -984,7 +984,7 @@ def pkglist_unblock(taginfo, pkginfo, force=False):
#it's possible this was the only entry in the inheritance or that the next entry
#back is also a blocked entry. if so, we need to add it back as unblocked
pkglist = readPackageList(tag_id, pkgID=pkg_id, inherit=True)
if not pkglist.has_key(pkg_id) or pkglist[pkg_id]['blocked']:
if pkg_id not in pkglist or pkglist[pkg_id]['blocked']:
_pkglist_add(tag_id, pkg_id, previous['owner_id'], False, previous['extra_arches'])
koji.plugin.run_callbacks('postPackageListChange', action='unblock', tag=tag, package=pkg)
@ -1064,7 +1064,7 @@ def readPackageList(tagID=None, userID=None, pkgID=None, event=None, inherit=Fal
# same query as before, with different params
for p in _multiRow(q, locals(), [pair[1] for pair in fields]):
pkgid = p['package_id']
if not with_dups and packages.has_key(pkgid):
if not with_dups and pkgid in packages:
#previous data supercedes
continue
# apply package filters
@ -1240,7 +1240,7 @@ def readTaggedBuilds(tag, event=None, inherit=False, latest=False, package=None,
# list should take priority
continue
if latest:
if (latest is True and seen.has_key(pkgid)) or seen.get(pkgid, 0) >= latest:
if (latest is True and pkgid in seen) or seen.get(pkgid, 0) >= latest:
# only take the first N entries
# (note ordering in query above)
continue
@ -1316,7 +1316,7 @@ def readTaggedRPMS(tag, package=None, arch=None, event=None, inherit=False, late
tags_seen = {}
def _iter_rpms():
for tagid in taglist:
if tags_seen.has_key(tagid):
if tagid in tags_seen:
#certain inheritance trees can (legitimately) have the same tag
#appear more than once (perhaps once with a package filter and once
#without). The hard part of that was already done by readTaggedBuilds.
@ -1411,7 +1411,7 @@ def readTaggedArchives(tag, package=None, event=None, inherit=False, latest=True
archives = []
tags_seen = {}
for tagid in taglist:
if tags_seen.has_key(tagid):
if tagid in tags_seen:
#certain inheritance trees can (legitimately) have the same tag
#appear more than once (perhaps once with a package filter and once
#without). The hard part of that was already done by readTaggedBuilds.
@ -1598,7 +1598,7 @@ def _grplist_add(taginfo, grpinfo, block, force, **opts):
changed = False
for field in cfg_fields:
old = previous[field]
if opts.has_key(field):
if field in opts:
if opts[field] != old:
changed = True
else:
@ -1724,7 +1724,7 @@ def _grp_pkg_add(taginfo, grpinfo, pkg_name, block, force, **opts):
changed = False
for field in cfg_fields:
old = previous[field]
if opts.has_key(field):
if field in opts:
if opts[field] != old:
changed = True
else:
@ -1848,7 +1848,7 @@ def _grp_req_add(taginfo, grpinfo, reqinfo, block, force, **opts):
changed = False
for field in cfg_fields:
old = previous[field]
if opts.has_key(field):
if field in opts:
if opts[field] != old:
changed = True
else:
@ -1978,7 +1978,7 @@ def get_tag_groups(tag, event=None, inherit=True, incl_pkgs=True, incl_reqs=True
for tagid in taglist:
for grp_pkg in _multiRow(q, locals(), fields):
grp_id = grp_pkg['group_id']
if not groups.has_key(grp_id):
if grp_id not in groups:
#tag does not have this group
continue
group = groups[grp_id]
@ -1999,7 +1999,7 @@ def get_tag_groups(tag, event=None, inherit=True, incl_pkgs=True, incl_reqs=True
for tagid in taglist:
for grp_req in _multiRow(q, locals(), fields):
grp_id = grp_req['group_id']
if not groups.has_key(grp_id):
if grp_id not in groups:
#tag does not have this group
continue
group = groups[grp_id]
@ -2007,7 +2007,7 @@ def get_tag_groups(tag, event=None, inherit=True, incl_pkgs=True, incl_reqs=True
#ignore blocked groups
continue
req_id = grp_req['req_id']
if not groups.has_key(req_id):
if req_id not in groups:
#tag does not have this group
continue
elif groups[req_id]['blocked']:
@ -2990,7 +2990,7 @@ def _edit_tag(tagInfo, **kwargs):
raise koji.GenericError("Maven support not enabled")
tag = get_tag(tagInfo, strict=True)
if kwargs.has_key('perm'):
if 'perm' in kwargs:
if kwargs['perm'] is None:
kwargs['perm_id'] = None
else:
@ -3022,7 +3022,7 @@ def _edit_tag(tagInfo, **kwargs):
data = tag.copy()
changed = False
for key in ('perm_id', 'arches', 'locked', 'maven_support', 'maven_include_all'):
if kwargs.has_key(key) and data[key] != kwargs[key]:
if key in kwargs and data[key] != kwargs[key]:
changed = True
data[key] = kwargs[key]
if changed:
@ -3336,7 +3336,7 @@ def get_external_repo_list(tag_info, event=None):
repos = []
for tag_id in tag_list:
for tag_repo in get_tag_external_repos(tag_info=tag_id, event=event):
if not seen_repos.has_key(tag_repo['external_repo_id']):
if tag_repo['external_repo_id'] not in seen_repos:
repos.append(tag_repo)
seen_repos[tag_repo['external_repo_id']] = 1
return repos
@ -3386,8 +3386,7 @@ def find_build_id(X, strict=False):
else:
raise koji.GenericError("Invalid argument: %r" % X)
if not (data.has_key('name') and data.has_key('version') and
data.has_key('release')):
if not ('name' in data and 'version' in data and 'release' in data):
raise koji.GenericError('did not provide name, version, and release')
c = context.cnx.cursor()
@ -3586,13 +3585,13 @@ def get_rpm(rpminfo, strict=False, multi=False):
else:
raise koji.GenericError("Invalid argument: %r" % rpminfo)
clauses = []
if data.has_key('id'):
if 'id' in data:
clauses.append("rpminfo.id=%(id)s")
else:
clauses.append("""rpminfo.name=%(name)s AND version=%(version)s
AND release=%(release)s AND arch=%(arch)s""")
retry = False
if data.has_key('location'):
if 'location' in data:
data['external_repo_id'] = get_external_repo_id(data['location'], strict=True)
clauses.append("""external_repo_id = %(external_repo_id)i""")
elif not multi:
@ -3982,7 +3981,7 @@ def list_archives(buildID=None, buildrootID=None, componentBuildrootID=None, hos
if typeInfo:
for key in ('group_id', 'artifact_id', 'version'):
if typeInfo.has_key(key):
if key in typeInfo:
clauses.append('maven_archives.%s = %%(%s)s' % (key, key))
values[key] = typeInfo[key]
elif type == 'win':
@ -4674,7 +4673,7 @@ def new_build(data):
raise koji.GenericError("No name or package id provided for build")
data['pkg_id'] = new_package(name, strict=False)
for f in ('version', 'release', 'epoch'):
if not data.has_key(f):
if f not in data:
raise koji.GenericError("No %s value for build" % f)
if 'extra' in data:
try:
@ -4788,7 +4787,7 @@ def check_noarch_rpms(basepath, rpms):
for relpath in rpms:
if relpath.endswith('.noarch.rpm'):
filename = os.path.basename(relpath)
if noarch_rpms.has_key(filename):
if filename in noarch_rpms:
# duplicate found, add it to the duplicate list
# but not the result list
noarch_rpms[filename].append(relpath)
@ -4830,7 +4829,7 @@ def import_build(srpm, rpms, brmap=None, task_id=None, build_id=None, logs=None)
#verify buildroot ids from brmap
found = {}
for br_id in brmap.values():
if found.has_key(br_id):
if br_id in found:
continue
found[br_id] = 1
#this will raise an exception if the buildroot id is invalid
@ -5447,7 +5446,7 @@ def add_external_rpm(rpminfo, external_repo, strict=True):
('size', int),
('buildtime', (int, long)))
for field, allowed in dtypes:
if not rpminfo.has_key(field):
if field not in rpminfo:
raise koji.GenericError("%s field missing: %r" % (field, rpminfo))
if not isinstance(rpminfo[field], allowed):
#this will catch unwanted NULLs
@ -7345,7 +7344,7 @@ class InsertProcessor(object):
parts.append("(%s) " % ', '.join(columns))
values = []
for key in columns:
if self.data.has_key(key):
if key in self.data:
values.append("%%(%s)s" % key)
else:
values.append("(%s)" % self.rawdata[key])
@ -7746,7 +7745,7 @@ class OperationTest(koji.policy.MatchTest):
def policy_get_user(data):
"""Determine user from policy data (default to logged-in user)"""
if data.has_key('user_id'):
if 'user_id' in data:
return get_user(data['user_id'])
elif context.session.logged_in:
return get_user(context.session.user_id)
@ -7758,7 +7757,7 @@ def policy_get_pkg(data):
returns dict as lookup_package
if package does not exist yet, the id field will be None
"""
if data.has_key('package'):
if 'package' in data:
pkginfo = lookup_package(data['package'], strict=False)
if not pkginfo:
#for some operations (e.g. adding a new package), the package
@ -7768,7 +7767,7 @@ def policy_get_pkg(data):
else:
raise koji.GenericError("Invalid package: %s" % data['package'])
return pkginfo
if data.has_key('build'):
if 'build' in data:
binfo = get_build(data['build'], strict=True)
return {'id' : binfo['package_id'], 'name' : binfo['name']}
#else
@ -7778,7 +7777,7 @@ def policy_get_pkg(data):
def policy_get_cgs(data):
"""Determine content generators from policy data"""
if not data.has_key('build'):
if 'build' not in data:
raise koji.GenericError("policy requires build data")
binfo = get_build(data['build'], strict=True)
@ -7940,14 +7939,14 @@ class BuildTagTest(koji.policy.BaseSimpleTest):
name = 'buildtag'
def run(self, data):
args = self.str.split()[1:]
if data.has_key('build_tag'):
if 'build_tag' in data:
tagname = get_tag(data['build_tag'], strict=True)['name']
for pattern in args:
if fnmatch.fnmatch(tagname, pattern):
return True
#else
return False
elif data.has_key('build'):
elif 'build' in data:
#determine build tag from buildroots
#in theory, we should find only one unique build tag
#it is possible that some rpms could have been imported later and hence
@ -8081,9 +8080,9 @@ class SourceTest(koji.policy.MatchTest):
name = "source"
field = '_source'
def run(self, data):
if data.has_key('source'):
if 'source' in data:
data[self.field] = data['source']
elif data.has_key('build'):
elif 'build' in data:
build = get_build(data['build'])
if build['source'] is not None:
data[self.field] = build['source']
@ -8538,7 +8537,7 @@ class RootExports(object):
'only admins may create high-priority tasks')
taskOpts['priority'] = koji.PRIO_DEFAULT + priority
if not opts.has_key('scratch') and not opts.has_key('indirection_template_url'):
if 'scratch' not in opts and 'indirection_template_url' not in opts:
raise koji.ActionNotAllowed('Non-scratch builds must provide url for the indirection template')
return make_task('indirectionimage', [opts], **taskOpts)
@ -8558,7 +8557,7 @@ class RootExports(object):
'only admins may create high-priority tasks')
taskOpts['priority'] = koji.PRIO_DEFAULT + priority
if not opts.has_key('scratch') and not opts.has_key('ksurl'):
if 'scratch' not in opts and 'ksurl' not in opts:
raise koji.ActionNotAllowed('Non-scratch builds must provide ksurl')
return make_task('image', [name, version, arches, target, inst_tree, opts], **taskOpts)
@ -9059,7 +9058,7 @@ class RootExports(object):
# package list check
pkgs = readPackageList(tagID=tag_id, pkgID=pkg_id, inherit=True)
pkg_error = None
if not pkgs.has_key(pkg_id):
if pkg_id not in pkgs:
pkg_error = "Package %s not in list for %s" % (build['name'], tag['name'])
elif pkgs[pkg_id]['blocked']:
pkg_error = "Package %s blocked in %s" % (build['name'], tag['name'])
@ -9134,7 +9133,7 @@ class RootExports(object):
# Make sure package is on the list for the tag we're adding it to
pkgs = readPackageList(tagID=tag2_id, pkgID=pkg_id, inherit=True)
pkg_error = None
if not pkgs.has_key(pkg_id):
if pkg_id not in pkgs:
pkg_error = "Package %s not in list for tag %s" % (package, tag2)
elif pkgs[pkg_id]['blocked']:
pkg_error = "Package %s blocked in tag %s" % (package, tag2)
@ -9482,13 +9481,13 @@ class RootExports(object):
('maven_builds.artifact_id', 'maven_artifact_id'),
('maven_builds.version', 'maven_version')])
if typeInfo:
if typeInfo.has_key('group_id'):
if 'group_id' in typeInfo:
clauses.append('maven_builds.group_id = %(group_id)s')
group_id = typeInfo['group_id']
if typeInfo.has_key('artifact_id'):
if 'artifact_id' in typeInfo:
clauses.append('maven_builds.artifact_id = %(artifact_id)s')
artifact_id = typeInfo['artifact_id']
if typeInfo.has_key('version'):
if 'version' in typeInfo:
clauses.append('maven_builds.version = %(version)s')
version = typeInfo['version']
elif type == 'win':
@ -9905,7 +9904,7 @@ class RootExports(object):
if pkg_id is None or tag_id is None:
return False
pkgs = readPackageList(tagID=tag_id, pkgID=pkg_id, inherit=True)
if not pkgs.has_key(pkg_id):
if pkg_id not in pkgs:
return False
else:
#still might be blocked
@ -10200,15 +10199,15 @@ class RootExports(object):
for f in ['arch', 'state']:
# Include list types
if opts.has_key(f):
if f in opts:
conditions.append('%s IN %%(%s)s' % (f, f))
# Exclude list types
if opts.has_key('not_' + f):
if ('not_' + f) in opts:
conditions.append('%s NOT IN %%(not_%s)s' % (f, f))
for f in ['owner', 'host_id', 'channel_id', 'parent']:
# Include int types
if opts.has_key(f):
if f in opts:
if opts[f] is None:
conditions.append('%s IS NULL' % f)
elif isinstance(opts[f], types.ListType):
@ -10216,7 +10215,7 @@ class RootExports(object):
else:
conditions.append('%s = %%(%s)i' % (f, f))
# Exclude int types
if opts.has_key('not_' + f):
if ('not_' + f) in opts:
if opts['not_' + f] is None:
conditions.append('%s IS NOT NULL' % f)
elif isinstance(opts['not_' + f], types.ListType):
@ -10224,7 +10223,7 @@ class RootExports(object):
else:
conditions.append('%s != %%(not_%s)i' % (f, f))
if opts.has_key('method'):
if 'method' in opts:
conditions.append('method = %(method)s')
time_opts = [
@ -11387,7 +11386,7 @@ class HostExports(object):
ptask = Task(parent)
ptask.assertHost(host.id)
opts['parent'] = parent
if opts.has_key('label'):
if 'label' in opts:
# first check for existing task with this parent/label
q = """SELECT id FROM task
WHERE parent=%(parent)s AND label=%(label)s"""
@ -11395,7 +11394,7 @@ class HostExports(object):
if row:
#return task id
return row[0]
if opts.has_key('kwargs'):
if 'kwargs' in opts:
arglist = koji.encode_args(*arglist, **opts['kwargs'])
del opts['kwargs']
return make_task(method, arglist, **opts)
@ -11535,7 +11534,7 @@ class HostExports(object):
logger.debug('renaming %s to %s' % (src, dest))
safer_move(src, dest)
os.symlink(dest, src)
if sub_results.has_key('rpmresults'):
if 'rpmresults' in sub_results:
rpm_results = sub_results['rpmresults']
for relpath in [rpm_results['srpm']] + rpm_results['rpms'] + \
rpm_results['logs']:
@ -11907,7 +11906,7 @@ class HostExports(object):
logger.warning('Task %s failed, no image available' % task_id)
continue
importImageInternal(task_id, build_id, sub_results)
if sub_results.has_key('rpmresults'):
if 'rpmresults' in sub_results:
rpm_results = sub_results['rpmresults']
_import_wrapper(rpm_results['task_id'],
get_build(build_id, strict=True), rpm_results)
@ -12066,7 +12065,7 @@ class HostExports(object):
for entry in ignore:
ignore_info = entry['maven_info']
ignore_label = koji.mavenLabel(ignore_info)
if not ignore_by_label.has_key(ignore_label):
if ignore_label not in ignore_by_label:
ignore_by_label[ignore_label] = {}
for fileinfo in entry['files']:
filename = fileinfo['filename']

View file

@ -1058,7 +1058,7 @@ class POMHandler(xml.sax.handler.ContentHandler):
if self.tag_stack[-2] == 'parent':
# Only set a value from the "parent" tag if we don't already have
# that value set
if not self.values.has_key(self.tag_stack[-1]):
if self.tag_stack[-1] not in self.values:
self.values[self.tag_stack[-1]] = self.tag_content.strip()
elif self.tag_stack[-2] == 'project':
self.values[self.tag_stack[-1]] = self.tag_content.strip()
@ -1179,7 +1179,7 @@ BuildArch: noarch
#index groups
groups = dict([(g['name'], g) for g in grplist])
for group_name in need:
if seen_grp.has_key(group_name):
if group_name in seen_grp:
continue
seen_grp[group_name] = 1
group = groups.get(group_name)
@ -1191,12 +1191,12 @@ BuildArch: noarch
pkglist.sort(lambda a, b: cmp(a['package'], b['package']))
for pkg in pkglist:
pkg_name = pkg['package']
if seen_pkg.has_key(pkg_name):
if pkg_name in seen_pkg:
continue
data.append("Requires: %s\n" % pkg_name)
for req in group['grouplist']:
req_name = req['name']
if seen_grp.has_key(req_name):
if req_name in seen_grp:
continue
need.append(req_name)
data.append("""
@ -1307,7 +1307,7 @@ def generate_comps(groups, expand_groups=False):
for p in g['packagelist']:
seen_pkg[p['package']] = 1
for group_name in need:
if seen_grp.has_key(group_name):
if group_name in seen_grp:
continue
seen_grp[group_name] = 1
group = group_idx.get(group_name)
@ -1323,14 +1323,14 @@ def generate_comps(groups, expand_groups=False):
pkglist.sort(lambda a, b: cmp(a['package'], b['package']))
for pkg in pkglist:
pkg_name = pkg['package']
if seen_pkg.has_key(pkg_name):
if pkg_name in seen_pkg:
continue
data.append(
""" %s
""" % package_entry(pkg))
for req in group['grouplist']:
req_name = req['name']
if seen_grp.has_key(req_name):
if req_name in seen_grp:
continue
need.append(req_name)
data.append(
@ -1640,7 +1640,7 @@ def read_config(profile_name, user_config=None):
#note the config_defaults dictionary also serves to indicate which
#options *can* be set via the config file. Such options should
#not have a default value set in the option parser.
if result.has_key(name):
if name in result:
if name in ('anon_retry', 'offline_retry', 'keepalive',
'use_fast_upload', 'krb_rdns', 'use_old_ssl'):
result[name] = config.getboolean(profile_name, name)
@ -2747,7 +2747,7 @@ def _taskLabel(taskInfo):
arch = taskInfo['arch']
extra = ''
if method in ('build', 'maven'):
if taskInfo.has_key('request'):
if 'request' in taskInfo:
source, target = taskInfo['request'][:2]
if '://' in source:
module_info = _module_info(source)
@ -2755,20 +2755,20 @@ def _taskLabel(taskInfo):
module_info = os.path.basename(source)
extra = '%s, %s' % (target, module_info)
elif method in ('buildSRPMFromSCM', 'buildSRPMFromCVS'):
if taskInfo.has_key('request'):
if 'request' in taskInfo:
url = taskInfo['request'][0]
extra = _module_info(url)
elif method == 'buildArch':
if taskInfo.has_key('request'):
if 'request' in taskInfo:
srpm, tagID, arch = taskInfo['request'][:3]
srpm = os.path.basename(srpm)
extra = '%s, %s' % (srpm, arch)
elif method == 'buildMaven':
if taskInfo.has_key('request'):
if 'request' in taskInfo:
build_tag = taskInfo['request'][1]
extra = build_tag['name']
elif method == 'wrapperRPM':
if taskInfo.has_key('request'):
if 'request' in taskInfo:
build_target = taskInfo['request'][1]
build = taskInfo['request'][2]
if build:
@ -2776,49 +2776,49 @@ def _taskLabel(taskInfo):
else:
extra = build_target['name']
elif method == 'winbuild':
if taskInfo.has_key('request'):
if 'request' in taskInfo:
#vm = taskInfo['request'][0]
url = taskInfo['request'][1]
target = taskInfo['request'][2]
module_info = _module_info(url)
extra = '%s, %s' % (target, module_info)
elif method == 'vmExec':
if taskInfo.has_key('request'):
if 'request' in taskInfo:
extra = taskInfo['request'][0]
elif method == 'buildNotification':
if taskInfo.has_key('request'):
if 'request' in taskInfo:
build = taskInfo['request'][1]
extra = buildLabel(build)
elif method == 'newRepo':
if taskInfo.has_key('request'):
if 'request' in taskInfo:
extra = str(taskInfo['request'][0])
elif method in ('tagBuild', 'tagNotification'):
# There is no displayable information included in the request
# for these methods
pass
elif method == 'prepRepo':
if taskInfo.has_key('request'):
if 'request' in taskInfo:
tagInfo = taskInfo['request'][0]
extra = tagInfo['name']
elif method == 'createrepo':
if taskInfo.has_key('request'):
if 'request' in taskInfo:
arch = taskInfo['request'][1]
extra = arch
elif method == 'dependantTask':
if taskInfo.has_key('request'):
if 'request' in taskInfo:
extra = ', '.join([subtask[0] for subtask in taskInfo['request'][1]])
elif method in ('chainbuild', 'chainmaven'):
if taskInfo.has_key('request'):
if 'request' in taskInfo:
extra = taskInfo['request'][1]
elif method == 'waitrepo':
if taskInfo.has_key('request'):
if 'request' in taskInfo:
extra = str(taskInfo['request'][0])
if len(taskInfo['request']) >= 3:
nvrs = taskInfo['request'][2]
if isinstance(nvrs, list):
extra += ', ' + ', '.join(nvrs)
elif method in ('livecd', 'appliance', 'image', 'livemedia'):
if taskInfo.has_key('request'):
if 'request' in taskInfo:
stuff = taskInfo['request']
if method == 'image':
kickstart = os.path.basename(stuff[-1]['kickstart'])
@ -2826,7 +2826,7 @@ def _taskLabel(taskInfo):
kickstart = os.path.basename(stuff[4])
extra = '%s, %s-%s, %s' % (stuff[3], stuff[0], stuff[1], kickstart)
elif method in ('createLiveCD', 'createAppliance', 'createImage', 'createLiveMedia'):
if taskInfo.has_key('request'):
if 'request' in taskInfo:
stuff = taskInfo['request']
if method == 'createImage':
kickstart = os.path.basename(stuff[-1]['kickstart'])
@ -2835,11 +2835,11 @@ def _taskLabel(taskInfo):
extra = '%s, %s-%s-%s, %s, %s' % (stuff[4]['name'], stuff[0],
stuff[1], stuff[2], kickstart, stuff[3])
elif method == 'restart':
if taskInfo.has_key('request'):
if 'request' in taskInfo:
host = taskInfo['request'][0]
extra = host['name']
elif method == 'restartVerify':
if taskInfo.has_key('request'):
if 'request' in taskInfo:
task_id, host = taskInfo['request'][:2]
extra = host['name']

View file

@ -532,7 +532,7 @@ class Session(object):
def hasPerm(self, name):
if not self.logged_in:
return False
return self.perms.has_key(name)
return name in self.perms
def assertPerm(self, name):
if not self.hasPerm(name) and not self.hasPerm('admin'):
@ -546,7 +546,7 @@ class Session(object):
if not self.logged_in:
return False
#groups indexed by id
return self.groups.has_key(group_id)
return group_id in self.groups
def isUser(self, user_id):
if not self.logged_in:

View file

@ -37,7 +37,7 @@ class ThreadLocal(object):
def __getattr__(self, key):
id = thread.get_ident()
tdict = object.__getattribute__(self, '_tdict')
if not tdict.has_key(id):
if id not in tdict:
raise AttributeError(key)
data = tdict[id]
return object.__getattribute__(data, key)
@ -45,7 +45,7 @@ class ThreadLocal(object):
def __setattr__(self, key, value):
id = thread.get_ident()
tdict = object.__getattribute__(self, '_tdict')
if not tdict.has_key(id):
if id not in tdict:
tdict[id] = _data()
data = tdict[id]
return object.__setattr__(data, key, value)
@ -53,7 +53,7 @@ class ThreadLocal(object):
def __delattr__(self, key):
id = thread.get_ident()
tdict = object.__getattribute__(self, '_tdict')
if not tdict.has_key(id):
if id not in tdict:
raise AttributeError(key)
data = tdict[id]
ret = object.__delattr__(data, key)
@ -71,7 +71,7 @@ class ThreadLocal(object):
def _threadclear(self):
id = thread.get_ident()
tdict = object.__getattribute__(self, '_tdict')
if not tdict.has_key(id):
if id not in tdict:
return
del tdict[id]

View file

@ -523,7 +523,7 @@ class TaskManager(object):
# this makes no sense now, but may in the future
self.logger.warn("Expiring taskless buildroot: %(id)i/%(tag_name)s/%(arch)s" % br)
self.session.host.setBuildRootState(id, st_expired)
elif not self.tasks.has_key(task_id):
elif task_id not in self.tasks:
#task not running - expire the buildroot
#TODO - consider recycling hooks here (with strong sanity checks)
self.logger.info("Expiring buildroot: %(id)i/%(tag_name)s/%(arch)s" % br)
@ -534,7 +534,7 @@ class TaskManager(object):
return
local_br = self._scanLocalBuildroots()
# get info on local_only buildroots (most likely expired)
local_only = [id for id in local_br.iterkeys() if not db_br.has_key(id)]
local_only = [id for id in local_br.iterkeys() if id not in db_br]
if local_only:
missed_br = self.session.listBuildroots(buildrootID=tuple(local_only))
#get all the task info in one call
@ -681,7 +681,7 @@ class TaskManager(object):
# the tasks returned are those that are open and locked
# by this host.
id = task['id']
if not self.pids.has_key(id):
if id not in self.pids:
#We don't have a process for this
#Expected to happen after a restart, otherwise this is an error
stale.append(id)
@ -707,10 +707,10 @@ class TaskManager(object):
# the subprocess handles most everything, we just need to clear things out
if self.cleanupTask(id, wait=False):
del self.pids[id]
if self.tasks.has_key(id):
if id in self.tasks:
del self.tasks[id]
for id, pid in self.pids.items():
if not tasks.has_key(id):
if id not in tasks:
# expected to happen when:
# - we are in the narrow gap between the time the task
# records its result and the time the process actually
@ -776,7 +776,7 @@ class TaskManager(object):
if task['method'] not in self.handlers:
self.logger.warn("Skipping task %(id)i, no handler for method %(method)s", task)
continue
if self.tasks.has_key(task['id']):
if task['id'] in self.tasks:
# we were running this task, but it apparently has been
# freed or reassigned. We can't do anything with it until
# updateTasks notices this and cleans up.
@ -791,7 +791,7 @@ class TaskManager(object):
elif task['state'] == koji.TASK_STATES['FREE']:
bin = "%(channel_id)s:%(arch)s" % task
self.logger.debug("task is free, bin=%r" % bin)
if not bins.has_key(bin):
if bin not in bins:
continue
#see where our available capacity is compared to other hosts for this bin
#(note: the hosts in this bin are exactly those that could
@ -1076,7 +1076,7 @@ class TaskManager(object):
"""
self.logger.info("Attempting to take task %s" % task['id'])
method = task['method']
if self.handlers.has_key(method):
if method in self.handlers:
handlerClass = self.handlers[method]
else:
raise koji.GenericError("No handler found for method '%s'" % method)

View file

@ -59,7 +59,7 @@ class PluginTracker(object):
self.plugins = {}
def load(self, name, path=None, reload=False):
if self.plugins.has_key(name) and not reload:
if name in self.plugins and not reload:
return self.plugins[name]
mod_name = name
if self.prefix:
@ -67,7 +67,7 @@ class PluginTracker(object):
#Using a prefix helps prevent overlap with other modules
#(no '.' -- it causes problems)
mod_name = self.prefix + name
if sys.modules.has_key(mod_name) and not reload:
if mod_name in sys.modules and not reload:
raise koji.PluginError('module name conflict: %s' % mod_name)
if path is None:
path = self.searchpath

View file

@ -135,7 +135,7 @@ def dslice(dict, keys, strict=True):
"""Returns a new dictionary containing only the specified keys"""
ret = {}
for key in keys:
if strict or dict.has_key(key):
if strict or key in dict:
#for strict we skip the has_key check and let the dict generate the KeyError
ret[key] = dict[key]
return ret
@ -144,7 +144,7 @@ def dslice_ex(dict, keys, strict=True):
"""Returns a new dictionary with only the specified keys removed"""
ret = dict.copy()
for key in keys:
if strict or ret.has_key(key):
if strict or key in ret:
del ret[key]
return ret

View file

@ -129,7 +129,7 @@ class RunRootTask(tasks.BaseTaskHandler):
#pick the first suitable match from tag's archlist
for br_arch in tag_arches.split():
br_arch = koji.canonArch(br_arch)
if host_arches.has_key(br_arch):
if br_arch in host_arches:
#we're done
break
else:

View file

@ -343,7 +343,7 @@ def ensure_connection(session):
warn(_("WARNING: The server is at API version %d and the client is at %d" % (ret, koji.API_VERSION)))
def has_krb_creds():
if not sys.modules.has_key('krbV'):
if 'krbV' not in sys.modules:
return False
try:
ctx = krbV.default_context()

View file

@ -320,7 +320,7 @@ def activate_session(session):
elif options.user:
#authenticate using user/password
session.login()
elif sys.modules.has_key('krbV'):
elif 'krbV' in sys.modules:
try:
if options.keytab and options.principal:
session.krb_login(principal=options.principal, keytab=options.keytab, proxyuser=options.runas)
@ -511,7 +511,7 @@ class TrackedBuild(object):
remote.multicall = True
unpack = []
for br_id in buildroots:
if seen.has_key(br_id):
if br_id in seen:
continue
seen[br_id] = 1
#br_info = remote.getBuildroot(br_id, strict=True)
@ -997,7 +997,7 @@ class BuildTracker(object):
missing_pkgs = []
for dep in deps:
name = dep.info['name']
if not pkgs.has_key(name):
if name not in pkgs:
#guess owner
owners = {}
for pkg in session.listPackages(pkgID=name):
@ -1051,8 +1051,8 @@ class BuildTracker(object):
#fix build group package list based on base of build to shadow
needed = dict([(n, 1) for n in build.base])
current = dict([(p['package'], 1) for p in build_group['packagelist']])
add_pkgs = [n for n in needed if not current.has_key(n)]
drop_pkgs = [n for n in current if not needed.has_key(n)]
add_pkgs = [n for n in needed if n not in current]
drop_pkgs = [n for n in current if n not in needed]
#no group deps needed/allowed
drop_deps = [(g['name'], 1) for g in build_group['grouplist']]
if drop_deps:

View file

@ -354,7 +354,7 @@ class RepoManager(object):
repodir = "%s/%s" % (tagdir, repo_id)
if not os.path.isdir(repodir):
continue
if self.repos.has_key(repo_id):
if repo_id in self.repos:
#we're already managing it, no need to deal with it here
continue
try:
@ -538,7 +538,7 @@ class RepoManager(object):
break
if covered:
continue
if self.tasks.has_key(tag_id):
if tag_id in self.tasks:
#repo creation in progress
#TODO - implement a timeout
continue
@ -596,7 +596,7 @@ class RepoManager(object):
#some cleanup
n_deletes = 0
for tag_id, repolist in tag_repos.items():
if not tags.has_key(tag_id):
if tag_id not in tags:
#repos for these tags are no longer required
for repo in repolist:
if repo.ready():
@ -813,7 +813,7 @@ if __name__ == "__main__":
elif options.user:
# authenticate using user/password
session.login()
elif sys.modules.has_key('krbV') and options.principal and options.keytab:
elif 'krbV' in sys.modules and options.principal and options.keytab:
session.krb_login(options.principal, options.keytab, options.ccache)
#get an exclusive session
try:

View file

@ -1078,7 +1078,7 @@ if __name__ == "__main__":
quit("Error: Unable to log in. Bad credentials?")
except xmlrpclib.ProtocolError:
quit("Error: Unable to connect to server %s" % (options.server))
elif sys.modules.has_key('krbV'):
elif 'krbV' in sys.modules:
krb_principal = options.krb_principal
if krb_principal is None:
krb_principal = options.host_principal_format % socket.getfqdn()

View file

@ -109,7 +109,7 @@
<td class="container">
#if $len($rpmsByArch) > 0
<table class="nested">
#if $rpmsByArch.has_key('src')
#if 'src' in $rpmsByArch
<tr><th>src</th><th></th></tr>
#for $rpm in $rpmsByArch['src']
#set $rpmfile = '%(name)s-%(version)s-%(release)s.%(arch)s.rpm' % $rpm

View file

@ -21,22 +21,22 @@
<tr>
<th>Size</th><td>$file.size</td>
</tr>
#if $file.has_key('mtime') and $file.mtime
#if 'mtime' in $file and $file.mtime
<tr>
<th>Modification time</th><td>$util.formatTimeLong($datetime.datetime.fromtimestamp($file.mtime))</td>
</tr>
#end if
#if $file.has_key('user') and $file.user
#if 'user' in $file and $file.user
<tr>
<th>User</th><td>$file.user</td>
</tr>
#end if
#if $file.has_key('group') and $file.group
#if 'group' in $file and $file.group
<tr>
<th>Group</th><td>$file.group</td>
</tr>
#end if
#if $file.has_key('mode') and $file.mode
#if 'mode' in $file and $file.mode
<tr>
<th>Mode</th><td class="rpmheader">$util.formatMode($file.mode)</td>
</tr>

View file

@ -325,7 +325,7 @@ def notificationedit(environ, notificationID):
form = environ['koji.form']
if form.has_key('save'):
if 'save' in form:
package_id = form.getfirst('package')
if package_id == 'all':
package_id = None
@ -338,7 +338,7 @@ def notificationedit(environ, notificationID):
else:
tag_id = int(tag_id)
if form.has_key('success_only'):
if 'success_only' in form:
success_only = True
else:
success_only = False
@ -346,7 +346,7 @@ def notificationedit(environ, notificationID):
server.updateNotification(notification['id'], package_id, tag_id, success_only)
_redirect(environ, 'index')
elif form.has_key('cancel'):
elif 'cancel' in form:
_redirect(environ, 'index')
else:
values = _initValues(environ, 'Edit Notification')
@ -365,7 +365,7 @@ def notificationcreate(environ):
form = environ['koji.form']
if form.has_key('add'):
if 'add' in form:
user = environ['koji.currentUser']
if not user:
raise koji.GenericError('not logged-in')
@ -382,7 +382,7 @@ def notificationcreate(environ):
else:
tag_id = int(tag_id)
if form.has_key('success_only'):
if 'success_only' in form:
success_only = True
else:
success_only = False
@ -390,7 +390,7 @@ def notificationcreate(environ):
server.createNotification(user['id'], package_id, tag_id, success_only)
_redirect(environ, 'index')
elif form.has_key('cancel'):
elif 'cancel' in form:
_redirect(environ, 'index')
else:
values = _initValues(environ, 'Edit Notification')
@ -883,7 +883,7 @@ def taginfo(environ, tagID, all='0', packageOrder='package_name', packageStart=N
tagsByChild = {}
for parent in inheritance:
child_id = parent['child_id']
if not tagsByChild.has_key(child_id):
if child_id not in tagsByChild:
tagsByChild[child_id] = []
tagsByChild[child_id].append(child_id)
@ -925,22 +925,22 @@ def tagcreate(environ):
form = environ['koji.form']
if form.has_key('add'):
if 'add' in form:
params = {}
name = form['name'].value
params['arches'] = form['arches'].value
params['locked'] = bool(form.has_key('locked'))
params['locked'] = 'locked' in form
permission = form['permission'].value
if permission != 'none':
params['perm'] = int(permission)
if mavenEnabled:
params['maven_support'] = bool(form.has_key('maven_support'))
params['maven_include_all'] = bool(form.has_key('maven_include_all'))
params['maven_support'] = bool('maven_support' in form)
params['maven_include_all'] = bool('maven_include_all' in form)
tagID = server.createTag(name, **params)
_redirect(environ, 'taginfo?tagID=%i' % tagID)
elif form.has_key('cancel'):
elif 'cancel' in form:
_redirect(environ, 'tags')
else:
values = _initValues(environ, 'Add Tag', 'tags')
@ -965,24 +965,24 @@ def tagedit(environ, tagID):
form = environ['koji.form']
if form.has_key('save'):
if 'save' in form:
params = {}
params['name'] = form['name'].value
params['arches'] = form['arches'].value
params['locked'] = bool(form.has_key('locked'))
params['locked'] = bool('locked' in form)
permission = form['permission'].value
if permission == 'none':
params['perm'] = None
else:
params['perm'] = int(permission)
if mavenEnabled:
params['maven_support'] = bool(form.has_key('maven_support'))
params['maven_include_all'] = bool(form.has_key('maven_include_all'))
params['maven_support'] = bool('maven_support' in form)
params['maven_include_all'] = bool('maven_include_all' in form)
server.editTag2(tag['id'], **params)
_redirect(environ, 'taginfo?tagID=%i' % tag['id'])
elif form.has_key('cancel'):
elif 'cancel' in form:
_redirect(environ, 'taginfo?tagID=%i' % tag['id'])
else:
values = _initValues(environ, 'Edit Tag', 'tags')
@ -1017,22 +1017,22 @@ def tagparent(environ, tagID, parentID, action):
if action in ('add', 'edit'):
form = environ['koji.form']
if form.has_key('add') or form.has_key('save'):
if 'add' in form or 'save' in form:
newDatum = {}
newDatum['parent_id'] = parent['id']
newDatum['priority'] = int(form.getfirst('priority'))
maxdepth = form.getfirst('maxdepth')
maxdepth = len(maxdepth) > 0 and int(maxdepth) or None
newDatum['maxdepth'] = maxdepth
newDatum['intransitive'] = bool(form.has_key('intransitive'))
newDatum['noconfig'] = bool(form.has_key('noconfig'))
newDatum['intransitive'] = bool('intransitive' in form)
newDatum['noconfig'] = bool('noconfig' in form)
newDatum['pkg_filter'] = form.getfirst('pkg_filter')
data = server.getInheritanceData(tag['id'])
data.append(newDatum)
server.setInheritanceData(tag['id'], data)
elif form.has_key('cancel'):
elif 'cancel' in form:
pass
else:
values = _initValues(environ, action.capitalize() + ' Parent Tag', 'tags')
@ -1133,7 +1133,7 @@ def buildinfo(environ, buildID):
for rpm in debuginfos:
rpmsByArch.setdefault(rpm['arch'], []).append(rpm)
if rpmsByArch.has_key('src'):
if 'src' in rpmsByArch:
srpm = rpmsByArch['src'][0]
headers = server.getRPMHeaders(srpm['id'], headers=['summary', 'description'])
values['summary'] = koji.fixEncoding(headers.get('summary'))
@ -1143,7 +1143,7 @@ def buildinfo(environ, buildID):
noarch_log_dest = 'noarch'
if build['task_id']:
task = server.getTaskInfo(build['task_id'], request=True)
if rpmsByArch.has_key('noarch') and \
if 'noarch' in rpmsByArch and \
[a for a in rpmsByArch.keys() if a not in ('noarch', 'src')]:
# This build has noarch and other-arch packages, indicating either
# noarch in extra-arches (kernel) or noarch subpackages.
@ -1197,7 +1197,7 @@ def buildinfo(environ, buildID):
else:
values['perms'] = []
for field in ['summary', 'description', 'changelog']:
if not values.has_key(field):
if field not in values:
values[field] = None
values['start_time'] = build.get('start_time') or build['creation_time']
@ -1567,12 +1567,12 @@ def hostedit(environ, hostID):
form = environ['koji.form']
if form.has_key('save'):
if 'save' in form:
arches = form['arches'].value
capacity = float(form['capacity'].value)
description = form['description'].value
comment = form['comment'].value
enabled = bool(form.has_key('enabled'))
enabled = bool('enabled' in form)
channels = form.getlist('channels')
server.editHost(host['id'], arches=arches, capacity=capacity,
@ -1592,7 +1592,7 @@ def hostedit(environ, hostID):
server.addHostToChannel(host['name'], channel)
_redirect(environ, 'hostinfo?hostID=%i' % host['id'])
elif form.has_key('cancel'):
elif 'cancel' in form:
_redirect(environ, 'hostinfo?hostID=%i' % host['id'])
else:
values = _initValues(environ, 'Edit Host', 'hosts')
@ -1804,7 +1804,7 @@ def buildtargetedit(environ, targetID):
form = environ['koji.form']
if form.has_key('save'):
if 'save' in form:
name = form.getfirst('name')
buildTagID = int(form.getfirst('buildTag'))
buildTag = server.getTag(buildTagID)
@ -1819,7 +1819,7 @@ def buildtargetedit(environ, targetID):
server.editBuildTarget(target['id'], name, buildTag['id'], destTag['id'])
_redirect(environ, 'buildtargetinfo?targetID=%i' % target['id'])
elif form.has_key('cancel'):
elif 'cancel' in form:
_redirect(environ, 'buildtargetinfo?targetID=%i' % target['id'])
else:
values = _initValues(environ, 'Edit Build Target', 'buildtargets')
@ -1837,7 +1837,7 @@ def buildtargetcreate(environ):
form = environ['koji.form']
if form.has_key('add'):
if 'add' in form:
# Use the str .value field of the StringField object,
# since xmlrpclib doesn't know how to marshal the StringFields
# returned by mod_python
@ -1852,7 +1852,7 @@ def buildtargetcreate(environ):
raise koji.GenericError('error creating build target "%s"' % name)
_redirect(environ, 'buildtargetinfo?targetID=%i' % target['id'])
elif form.has_key('cancel'):
elif 'cancel' in form:
_redirect(environ, 'buildtargets')
else:
values = _initValues(environ, 'Add Build Target', 'builtargets')
@ -2222,7 +2222,7 @@ def search(environ, start=None, order=None):
values['error'] = None
form = environ['koji.form']
if form.has_key('terms') and form['terms']:
if 'terms' in form and form['terms']:
terms = form['terms'].value
terms = terms.strip()
type = form['type'].value

View file

@ -123,17 +123,17 @@ def _genHTML(environ, fileName):
else:
environ['koji.values']['currentUser'] = None
environ['koji.values']['authToken'] = _genToken(environ)
if not environ['koji.values'].has_key('mavenEnabled'):
if 'mavenEnabled' not in environ['koji.values']:
if 'koji.session' in environ:
environ['koji.values']['mavenEnabled'] = environ['koji.session'].mavenEnabled()
else:
environ['koji.values']['mavenEnabled'] = False
if not environ['koji.values'].has_key('winEnabled'):
if 'winEnabled' not in environ['koji.values']:
if 'koji.session' in environ:
environ['koji.values']['winEnabled'] = environ['koji.session'].winEnabled()
else:
environ['koji.values']['winEnabled'] = False
if not environ['koji.values'].has_key('LoginDisabled'):
if 'LoginDisabled' not in environ['koji.values']:
if 'koji.options' in environ:
environ['koji.values']['LoginDisabled'] = environ['koji.options']['LoginDisabled']
else: