flake8: apply E71x rule

This commit is contained in:
Yuming Zhu 2020-02-26 04:28:55 +08:00
parent fa69c4904e
commit 6ed30954b2
13 changed files with 114 additions and 114 deletions

View file

@ -1,5 +1,5 @@
[flake8]
select = I,C,F,E1,E2,E3,E4,E502,E70
select = I,C,F,E1,E2,E3,E4,E502,E70,E71
ignore = E266
exclude =
.git,

View file

@ -3067,7 +3067,7 @@ class ApplianceTask(ImageTask):
def handler(self, name, version, release, arch, target_info, build_tag, repo_info, ksfile, opts=None):
if opts == None:
if opts is None:
opts = {}
self.opts = opts
broot = self.makeImgBuildRoot(build_tag, repo_info, arch,
@ -3088,7 +3088,7 @@ class ApplianceTask(ImageTask):
'--logfile', app_log, '--cache', cachedir, '-o', odir]
for arg_name in ('vmem', 'vcpu', 'format'):
arg = opts.get(arg_name)
if arg != None:
if arg is not None:
cmd.extend(['--%s' % arg_name, arg])
appname = '%s-%s-%s' % (name, version, release)
cmd.extend(['--name', appname])
@ -3223,7 +3223,7 @@ class LiveCDTask(ImageTask):
def handler(self, name, version, release, arch, target_info, build_tag, repo_info, ksfile, opts=None):
if opts == None:
if opts is None:
opts = {}
self.opts = opts
@ -3409,7 +3409,7 @@ class LiveMediaTask(ImageTask):
def handler(self, name, version, release, arch, target_info, build_tag, repo_info, ksfile, opts=None):
if opts == None:
if opts is None:
opts = {}
self.opts = opts
@ -4211,7 +4211,7 @@ class BaseImageTask(OzImageTask):
self.logger.error("ImageFactory features require the following dependencies: pykickstart, imagefactory, oz and possibly python-hashlib")
raise koji.ApplianceError('ImageFactory functions not available')
if opts == None:
if opts is None:
opts = {}
self.arch = arch
self.target_info = target_info
@ -4492,7 +4492,7 @@ class BuildIndirectionImageTask(OzImageTask):
# We can now reference this object directly or via its UUID in persistent storage
return factory_base_image
if opts == None:
if opts is None:
opts = {}
self.opts = opts

View file

@ -100,7 +100,7 @@ def parse_args(args):
opts.arches.extend(EXPAND_ARCHES[multilib_arch])
# always include noarch
if not 'noarch' in opts.arches:
if 'noarch' not in opts.arches:
opts.arches.append('noarch')
if not opts.outputdir:

View file

@ -362,7 +362,7 @@ def handle_add_pkg(goptions, session, args):
to_add = []
for package in args[1:]:
package_id = pkglist.get(package, None)
if not package_id is None:
if package_id is not None:
print("Package %s already exists in tag %s" % (package, tag))
continue
to_add.append(package)
@ -3793,7 +3793,7 @@ def handle_edit_target(goptions, session, args):
parser.error(_("This action requires target or admin privileges"))
targetInfo = session.getBuildTarget(args[0])
if targetInfo == None:
if targetInfo is None:
raise koji.GenericError("No build target with the name or id '%s'" % args[0])
targetInfo['orig_name'] = targetInfo['name']
@ -3890,7 +3890,7 @@ def anon_handle_list_targets(goptions, session, args):
def _printInheritance(tags, sibdepths=None, reverse=False):
if len(tags) == 0:
return
if sibdepths == None:
if sibdepths is None:
sibdepths = []
currtag = tags[0]
tags = tags[1:]
@ -5431,7 +5431,7 @@ def handle_remove_external_repo(goptions, session, args):
session.deleteExternalRepo(args[0])
else:
for tag in tags:
if not tag in current_tags:
if tag not in current_tags:
print(_("External repo %s not associated with tag %s") % (repo, tag))
continue
session.removeExternalRepoFromTag(tag, repo)
@ -6435,7 +6435,7 @@ def handle_move_build(opts, session, args):
if not build:
print(_("Invalid build %s, skipping." % arg))
continue
if not build in builds:
if build not in builds:
builds.append(build)
for build in builds:
@ -7097,11 +7097,11 @@ def handle_dist_repo(options, session, args):
if task_opts.multilib:
if not os.path.exists(task_opts.multilib):
parser.error(_('could not find %s') % task_opts.multilib)
if 'x86_64' in task_opts.arch and not 'i686' in task_opts.arch:
if 'x86_64' in task_opts.arch and 'i686' not in task_opts.arch:
parser.error(_('The multilib arch (i686) must be included'))
if 's390x' in task_opts.arch and not 's390' in task_opts.arch:
if 's390x' in task_opts.arch and 's390' not in task_opts.arch:
parser.error(_('The multilib arch (s390) must be included'))
if 'ppc64' in task_opts.arch and not 'ppc' in task_opts.arch:
if 'ppc64' in task_opts.arch and 'ppc' not in task_opts.arch:
parser.error(_('The multilib arch (ppc) must be included'))
session.uploadWrapper(task_opts.multilib, stuffdir,
callback=_progress_callback)

View file

@ -301,7 +301,7 @@ Running Tasks:
rv = 1
for child in session.getTaskChildren(task_id):
child_id = child['id']
if not child_id in tasks.keys():
if child_id not in tasks.keys():
tasks[child_id] = TaskWatcher(child_id, session, task.level + 1, quiet=quiet)
tasks[child_id].update()
# If we found new children, go through the list again,

View file

@ -1156,13 +1156,13 @@ def readPackageList(tagID=None, userID=None, pkgID=None, event=None, inherit=Fal
tag_packages.package_id = tag_package_owners.package_id
JOIN users ON users.id = tag_package_owners.owner
WHERE %(cond1)s AND %(cond2)s"""
if tagID != None:
if tagID is not None:
q += """
AND tag.id = %%(tagID)i"""
if userID != None:
if userID is not None:
q += """
AND users.id = %%(userID)i"""
if pkgID != None:
if pkgID is not None:
if isinstance(pkgID, six.integer_types):
q += """
AND package.id = %%(pkgID)i"""
@ -2236,11 +2236,11 @@ def add_host_to_channel(hostname, channel_name, create=False):
"""
context.session.assertPerm('host')
host = get_host(hostname)
if host == None:
if host is None:
raise koji.GenericError('host does not exist: %s' % hostname)
host_id = host['id']
channel_id = get_channel_id(channel_name, create=create)
if channel_id == None:
if channel_id is None:
raise koji.GenericError('channel does not exist: %s' % channel_name)
channels = list_channels(host_id)
for channel in channels:
@ -2255,11 +2255,11 @@ def add_host_to_channel(hostname, channel_name, create=False):
def remove_host_from_channel(hostname, channel_name):
context.session.assertPerm('host')
host = get_host(hostname)
if host == None:
if host is None:
raise koji.GenericError('host does not exist: %s' % hostname)
host_id = host['id']
channel_id = get_channel_id(channel_name)
if channel_id == None:
if channel_id is None:
raise koji.GenericError('channel does not exist: %s' % channel_name)
found = False
channels = list_channels(host_id)
@ -2385,7 +2385,7 @@ AND channel_id IN %(channels)s)'''
def get_task_descendents(task, childMap=None, request=False):
if childMap == None:
if childMap is None:
childMap = {}
children = task.getChildren(request=request)
children.sort(key=lambda x: x['id'])
@ -2628,7 +2628,7 @@ def repo_init(tag, with_src=False, with_debuginfo=False, event=None, with_separa
created_dirs = set()
for srcdir, destlink in dir_links:
dest_parent = os.path.dirname(destlink)
if not dest_parent in created_dirs:
if dest_parent not in created_dirs:
koji.ensuredir(dest_parent)
created_dirs.add(dest_parent)
relpath = os.path.relpath(srcdir, dest_parent)
@ -3053,9 +3053,9 @@ def get_build_targets(info=None, event=None, buildTagID=None, destTagID=None, qu
clauses.append('build_target.id = %(info)i')
else:
raise koji.GenericError('invalid type for lookup: %s' % type(info))
if buildTagID != None:
if buildTagID is not None:
clauses.append('build_tag = %(buildTagID)i')
if destTagID != None:
if destTagID is not None:
clauses.append('dest_tag = %(destTagID)i')
query = QueryProcessor(columns=[f[0] for f in fields], aliases=[f[1] for f in fields],
@ -4030,7 +4030,7 @@ def get_build(buildInfo, strict=False):
associated task ids, and not all import methods provide source info.
"""
buildID = find_build_id(buildInfo, strict=strict)
if buildID == None:
if buildID is None:
return None
fields = (('build.id', 'id'), ('build.version', 'version'), ('build.release', 'release'),
@ -4294,11 +4294,11 @@ def list_rpms(buildID=None, buildrootID=None, imageID=None, componentBuildrootID
joins = ['LEFT JOIN external_repo ON rpminfo.external_repo_id = external_repo.id']
clauses = []
if buildID != None:
if buildID is not None:
clauses.append('rpminfo.build_id = %(buildID)i')
if buildrootID != None:
if buildrootID is not None:
clauses.append('rpminfo.buildroot_id = %(buildrootID)i')
if componentBuildrootID != None:
if componentBuildrootID is not None:
fields.append(('buildroot_listing.buildroot_id as component_buildroot_id',
'component_buildroot_id'))
fields.append(('buildroot_listing.is_update', 'is_update'))
@ -4306,14 +4306,14 @@ def list_rpms(buildID=None, buildrootID=None, imageID=None, componentBuildrootID
clauses.append('buildroot_listing.buildroot_id = %(componentBuildrootID)i')
# image specific constraints
if imageID != None:
if imageID is not None:
clauses.append('archive_rpm_components.archive_id = %(imageID)i')
joins.append('archive_rpm_components ON rpminfo.id = archive_rpm_components.rpm_id')
if hostID != None:
if hostID is not None:
joins.append('standard_buildroot ON rpminfo.buildroot_id = standard_buildroot.buildroot_id')
clauses.append('standard_buildroot.host_id = %(hostID)i')
if arches != None:
if arches is not None:
if isinstance(arches, (list, tuple)):
clauses.append('rpminfo.arch IN %(arches)s')
elif isinstance(arches, str):
@ -4572,7 +4572,7 @@ def list_archives(buildID=None, buildrootID=None, componentBuildrootID=None, hos
values['component_buildroot_id'] = componentBuildrootID
fields.append(['buildroot_archives.buildroot_id', 'component_buildroot_id'])
fields.append(['buildroot_archives.project_dep', 'project'])
if imageID != None:
if imageID is not None:
# TODO: arg name is now a misnomer, could be any archive
clauses.append('archive_components.archive_id = %(imageID)i')
values['imageID'] = imageID
@ -5217,28 +5217,28 @@ def query_buildroots(hostID=None, tagID=None, state=None, rpmID=None, archiveID=
'LEFT OUTER JOIN events AS repo_create ON repo_create.id = repo.create_event']
clauses = []
if buildrootID != None:
if buildrootID is not None:
if isinstance(buildrootID, (list, tuple)):
clauses.append('buildroot.id IN %(buildrootID)s')
else:
clauses.append('buildroot.id = %(buildrootID)i')
if hostID != None:
if hostID is not None:
clauses.append('host.id = %(hostID)i')
if tagID != None:
if tagID is not None:
clauses.append('tag.id = %(tagID)i')
if state != None:
if state is not None:
if isinstance(state, (list, tuple)):
clauses.append('standard_buildroot.state IN %(state)s')
else:
clauses.append('standard_buildroot.state = %(state)i')
if rpmID != None:
if rpmID is not None:
joins.insert(0, 'buildroot_listing ON buildroot.id = buildroot_listing.buildroot_id')
fields.append(('buildroot_listing.is_update', 'is_update'))
clauses.append('buildroot_listing.rpm_id = %(rpmID)i')
if archiveID != None:
if archiveID is not None:
joins.append('buildroot_archives ON buildroot.id = buildroot_archives.buildroot_id')
clauses.append('buildroot_archives.archive_id = %(archiveID)i')
if taskID != None:
if taskID is not None:
clauses.append('standard_buildroot.task_id = %(taskID)i')
query = QueryProcessor(columns=[f[0] for f in fields], aliases=[f[1] for f in fields],
@ -8052,7 +8052,7 @@ def cancel_build(build_id, cancel_task=True):
if build['state'] != st_canceled:
return False
task_id = build['task_id']
if task_id != None:
if task_id is not None:
build_notification(task_id, build_id)
if cancel_task:
Task(task_id).cancelFull(strict=False)
@ -10220,9 +10220,9 @@ class RootExports(object):
with open(filePath, 'rb') as f:
if isinstance(offset, str):
offset = int(offset)
if offset != None and offset > 0:
if offset is not None and offset > 0:
f.seek(offset, 0)
elif offset != None and offset < 0:
elif offset is not None and offset < 0:
f.seek(offset, 2)
contents = f.read(size)
return base64encode(contents)
@ -10745,7 +10745,7 @@ class RootExports(object):
Return True if the build was successfully canceled, False if not."""
context.session.assertLogin()
build = get_build(buildID)
if build == None:
if build is None:
return False
if build['owner_id'] != context.session.user_id:
if not context.session.hasPerm('admin'):
@ -10919,13 +10919,13 @@ class RootExports(object):
'LEFT JOIN volume ON build.volume_id = volume.id',
'LEFT JOIN users ON build.owner = users.id']
clauses = []
if packageID != None:
if packageID is not None:
clauses.append('package.id = %(packageID)i')
if userID != None:
if userID is not None:
clauses.append('users.id = %(userID)i')
if volumeID != None:
if volumeID is not None:
clauses.append('volume.id = %(volumeID)i')
if taskID != None:
if taskID is not None:
if taskID == -1:
clauses.append('build.task_id IS NOT NULL')
else:
@ -10935,7 +10935,7 @@ class RootExports(object):
clauses.append('build.source ilike %(source)s')
if prefix:
clauses.append("package.name ilike %(prefix)s || '%%'")
if state != None:
if state is not None:
clauses.append('build.state = %(state)i')
if createdBefore:
if not isinstance(createdBefore, str):
@ -11851,7 +11851,7 @@ class RootExports(object):
['completedAfter', 'completion_time', '>'],
]
for key, field, cmp in time_opts:
if opts.get(key) != None:
if opts.get(key) is not None:
value = opts[key]
if not isinstance(value, str):
opts[key] = datetime.datetime.fromtimestamp(value).isoformat(' ')
@ -11946,7 +11946,7 @@ class RootExports(object):
if not (task.isCanceled() or task.isFailed()):
raise koji.GenericError('only canceled or failed tasks may be resubmitted')
taskInfo = task.getInfo()
if taskInfo['parent'] != None:
if taskInfo['parent'] is not None:
raise koji.GenericError('only top-level tasks may be resubmitted')
if not (context.session.user_id == taskInfo['owner'] or self.hasPerm('admin')):
raise koji.GenericError('only the task owner or an admin may resubmit a task')
@ -12191,7 +12191,7 @@ class RootExports(object):
will return len(value), and a return value of any other type will return 1. An invalid
methodName will raise an AttributeError, and invalid arguments will raise a TypeError."""
result = getattr(self, methodName)(*args, **kw)
if result == None:
if result is None:
return 0
elif isinstance(result, (list, tuple, dict)):
return len(result)

View file

@ -619,7 +619,7 @@ def rpm_hdr_size(f, ofs=None):
fo = open(f, 'rb')
else:
fo = f
if ofs != None:
if ofs is not None:
fo.seek(ofs, 0)
magic = fo.read(3)
if magic != RPM_HEADER_MAGIC:
@ -2323,7 +2323,7 @@ class ClientSession(object):
def __init__(self, baseurl, opts=None, sinfo=None):
assert baseurl, "baseurl argument must not be empty"
if opts == None:
if opts is None:
opts = {}
else:
opts = opts.copy()
@ -2422,13 +2422,13 @@ class ClientSession(object):
if not ctx:
ctx = krbV.default_context()
if ccache != None:
if ccache is not None:
ccache = krbV.CCache(name=ccache, context=ctx)
else:
ccache = ctx.default_ccache()
if principal != None:
if keytab != None:
if principal is not None:
if keytab is not None:
cprinc = krbV.Principal(name=principal, context=ctx)
keytab = krbV.Keytab(name=keytab, context=ctx)
ccache.init(cprinc)
@ -3319,7 +3319,7 @@ def formatTimeLong(value):
def buildLabel(buildInfo, showEpoch=False):
"""Format buildInfo (dict) into a descriptive label."""
epoch = buildInfo.get('epoch')
if showEpoch and epoch != None:
if showEpoch and epoch is not None:
epochStr = '%i:' % epoch
else:
epochStr = ''

View file

@ -185,7 +185,7 @@ def getBestArchFromList(archlist, myarch=None):
bestarch = getBestArch(myarch)
if bestarch != myarch:
bestarchchoice = getBestArchFromList(archlist, bestarch)
if bestarchchoice != None and bestarchchoice != "noarch":
if bestarchchoice is not None and bestarchchoice != "noarch":
return bestarchchoice
thisarch = archlist[0]

View file

@ -184,7 +184,7 @@ def convert_datetime(f):
def register_callback(cbtype, func):
if not cbtype in callbacks:
if cbtype not in callbacks:
raise koji.PluginError('"%s" is not a valid callback type' % cbtype)
if not callable(func):
raise koji.PluginError('%s is not callable' % getattr(func, '__name__', 'function'))
@ -192,7 +192,7 @@ def register_callback(cbtype, func):
def run_callbacks(cbtype, *args, **kws):
if not cbtype in callbacks:
if cbtype not in callbacks:
raise koji.PluginError('"%s" is not a valid callback type' % cbtype)
cache = {}
for func in callbacks[cbtype]:

View file

@ -104,9 +104,9 @@ class Rpmdiff:
self.new_data['tags'][tag] = new[tag]
if old_tag != new_tag:
tagname = rpm.tagnames[tag]
if old_tag == None:
if old_tag is None:
self.__add(self.FORMAT, (self.ADDED, tagname))
elif new_tag == None:
elif new_tag is None:
self.__add(self.FORMAT, (self.REMOVED, tagname))
else:
self.__add(self.FORMAT, ('S.5........', tagname))
@ -207,7 +207,7 @@ class Rpmdiff:
self.new_data[name] = sorted(n)
for oldentry in o:
if not oldentry in n:
if oldentry not in n:
if name == 'REQUIRES' and oldentry[1] & self.PREREQ_FLAG:
tagname = 'PREREQ'
else:
@ -216,7 +216,7 @@ class Rpmdiff:
(self.REMOVED, tagname, oldentry[0],
self.sense2str(oldentry[1]), oldentry[2]))
for newentry in n:
if not newentry in o:
if newentry not in o:
if name == 'REQUIRES' and newentry[1] & self.PREREQ_FLAG:
tagname = 'PREREQ'
else:

View file

@ -753,7 +753,7 @@ class BuildTracker(object):
return build
if options.prefer_new and (depth > 0) and (tag is not None) and not (build.state == "common"):
latestBuild = self.newerBuild(build, tag)
if latestBuild != None:
if latestBuild is not None:
build.substitute = latestBuild.nvr
log("%sNewer build replaced: %s->%s" % (head, build.nvr, latestBuild.nvr))
return build
@ -912,7 +912,7 @@ class BuildTracker(object):
fname = os.path.basename(relpath)
self._importURL(url, fname)
build.updateState()
if options.tag_build and not tag == None:
if options.tag_build and tag is not None:
self.tagSuccessful(build.nvr, tag)
return True
@ -1170,7 +1170,7 @@ class BuildTracker(object):
ret = True
elif state == 'CLOSED':
log("Task %i complete (build %s)" % (build.task_id, build.nvr))
if options.tag_build and not tag == None:
if options.tag_build and tag is not None:
self.tagSuccessful(build.nvr, tag)
build.updateState()
ret = True

View file

@ -347,7 +347,7 @@ def notificationedit(environ, notificationID):
notificationID = int(notificationID)
notification = server.getBuildNotification(notificationID)
if notification == None:
if notification is None:
raise koji.GenericError('no notification with ID: %i' % notificationID)
form = environ['koji.form']
@ -635,7 +635,7 @@ def taskinfo(environ, taskID):
values['estCompletion'] = None
if taskBuild and taskBuild['state'] == koji.BUILD_STATES['BUILDING']:
avgDuration = server.getAverageBuildDuration(taskBuild['package_id'])
if avgDuration != None:
if avgDuration is not None:
avgDelta = datetime.timedelta(seconds=avgDuration)
startTime = datetime.datetime.fromtimestamp(taskBuild['creation_ts'])
values['estCompletion'] = startTime + avgDelta
@ -840,7 +840,7 @@ def tags(environ, start=None, order=None, childID=None):
values = _initValues(environ, 'Tags', 'tags')
server = _getServer(environ)
if order == None:
if order is None:
order = 'name'
values['order'] = order
@ -864,14 +864,14 @@ def packages(environ, tagID=None, userID=None, order='package_name', start=None,
values = _initValues(environ, 'Packages', 'packages')
server = _getServer(environ)
tag = None
if tagID != None:
if tagID is not None:
if tagID.isdigit():
tagID = int(tagID)
tag = server.getTag(tagID, strict=True)
values['tagID'] = tagID
values['tag'] = tag
user = None
if userID != None:
if userID is not None:
if userID.isdigit():
userID = int(userID)
user = server.getUser(userID, strict=True)
@ -902,7 +902,7 @@ def packageinfo(environ, packageID, tagOrder='name', tagStart=None, buildOrder='
if packageID.isdigit():
packageID = int(packageID)
package = server.getPackage(packageID)
if package == None:
if package is None:
raise koji.GenericError('invalid package ID: %s' % packageID)
values['title'] = package['name'] + ' | Package Info'
@ -959,7 +959,7 @@ def taginfo(environ, tagID, all='0', packageOrder='package_name', packageStart=N
values['external_repos'] = server.getExternalRepoList(tag['id'])
child = None
if childID != None:
if childID is not None:
child = server.getTag(int(childID), strict=True)
values['child'] = child
@ -1018,7 +1018,7 @@ def tagedit(environ, tagID):
tagID = int(tagID)
tag = server.getTag(tagID)
if tag == None:
if tag is None:
raise koji.GenericError('no tag with ID: %i' % tagID)
form = environ['koji.form']
@ -1059,7 +1059,7 @@ def tagdelete(environ, tagID):
tagID = int(tagID)
tag = server.getTag(tagID)
if tag == None:
if tag is None:
raise koji.GenericError('no tag with ID: %i' % tagID)
server.deleteTag(tag['id'])
@ -1262,7 +1262,7 @@ def buildinfo(environ, buildID):
values['start_time'] = task['start_time']
if build['state'] == koji.BUILD_STATES['BUILDING']:
avgDuration = server.getAverageBuildDuration(build['package_id'])
if avgDuration != None:
if avgDuration is not None:
avgDelta = datetime.timedelta(seconds=avgDuration)
startTime = datetime.datetime.fromtimestamp(build['creation_ts'])
values['estCompletion'] = startTime + avgDelta
@ -1308,7 +1308,7 @@ def builds(environ, userID=None, tagID=None, packageID=None, state=None, order='
if state == 'all':
state = None
elif state != None:
elif state is not None:
state = int(state)
values['state'] = state
@ -1409,15 +1409,15 @@ def rpminfo(environ, rpmID, fileOrder='name', fileStart=None, buildrootOrder='-i
values['title'] = '%(name)s-%%s%(version)s-%(release)s.%(arch)s.rpm' % rpm + ' | RPM Info'
epochStr = ''
if rpm['epoch'] != None:
if rpm['epoch'] is not None:
epochStr = '%s:' % rpm['epoch']
values['title'] = values['title'] % epochStr
build = None
if rpm['build_id'] != None:
if rpm['build_id'] is not None:
build = server.getBuild(rpm['build_id'])
builtInRoot = None
if rpm['buildroot_id'] != None:
if rpm['buildroot_id'] is not None:
builtInRoot = server.getBuildroot(rpm['buildroot_id'])
if rpm['external_repo_id'] == 0:
dep_names = {
@ -1469,7 +1469,7 @@ def archiveinfo(environ, archiveID, fileOrder='name', fileStart=None, buildrootO
if 'relpath' in archive:
wininfo = True
builtInRoot = None
if archive['buildroot_id'] != None:
if archive['buildroot_id'] is not None:
builtInRoot = server.getBuildroot(archive['buildroot_id'])
kojiweb.util.paginateMethod(server, values, 'listArchiveFiles', args=[archive['id']],
start=fileStart, dataName='files', prefix='file', order=fileOrder)
@ -1534,7 +1534,7 @@ def cancelbuild(environ, buildID):
buildID = int(buildID)
build = server.getBuild(buildID)
if build == None:
if build is None:
raise koji.GenericError('unknown build ID: %i' % buildID)
result = server.cancelBuild(build['id'])
@ -1583,7 +1583,7 @@ def hostinfo(environ, hostID=None, userID=None):
if hostID.isdigit():
hostID = int(hostID)
host = server.getHost(hostID)
if host == None:
if host is None:
raise koji.GenericError('invalid host ID: %s' % hostID)
elif userID:
userID = int(userID)
@ -1591,7 +1591,7 @@ def hostinfo(environ, hostID=None, userID=None):
host = None
if hosts:
host = hosts[0]
if host == None:
if host is None:
raise koji.GenericError('invalid host ID: %s' % userID)
else:
raise koji.GenericError('hostID or userID must be provided')
@ -1622,7 +1622,7 @@ def hostedit(environ, hostID):
hostID = int(hostID)
host = server.getHost(hostID)
if host == None:
if host is None:
raise koji.GenericError('no host with ID: %i' % hostID)
form = environ['koji.form']
@ -1694,7 +1694,7 @@ def channelinfo(environ, channelID):
channelID = int(channelID)
channel = server.getChannel(channelID)
if channel == None:
if channel is None:
raise koji.GenericError('invalid channel ID: %i' % channelID)
values['title'] = channel['name'] + ' | Channel Info'
@ -1722,7 +1722,7 @@ def buildrootinfo(environ, buildrootID, builtStart=None, builtOrder=None, compon
buildrootID = int(buildrootID)
buildroot = server.getBuildroot(buildrootID)
if buildroot == None:
if buildroot is None:
raise koji.GenericError('unknown buildroot ID: %i' % buildrootID)
elif buildroot['br_type'] == koji.BR_TYPES['STANDARD']:
@ -1749,11 +1749,11 @@ def rpmlist(environ, type, buildrootID=None, imageID=None, start=None, order='nv
values = _initValues(environ, 'RPM List', 'hosts')
server = _getServer(environ)
if buildrootID != None:
if buildrootID is not None:
buildrootID = int(buildrootID)
buildroot = server.getBuildroot(buildrootID)
values['buildroot'] = buildroot
if buildroot == None:
if buildroot is None:
raise koji.GenericError('unknown buildroot ID: %i' % buildrootID)
if type == 'component':
@ -1769,7 +1769,7 @@ def rpmlist(environ, type, buildrootID=None, imageID=None, start=None, order='nv
else:
raise koji.GenericError('unrecognized type of rpmlist')
elif imageID != None:
elif imageID is not None:
imageID = int(imageID)
values['image'] = server.getArchive(imageID)
# If/When future image types are supported, add elifs here if needed.
@ -1800,7 +1800,7 @@ def archivelist(environ, type, buildrootID=None, imageID=None, start=None, order
buildroot = server.getBuildroot(buildrootID)
values['buildroot'] = buildroot
if buildroot == None:
if buildroot is None:
raise koji.GenericError('unknown buildroot ID: %i' % buildrootID)
if type == 'component':
@ -1851,13 +1851,13 @@ def buildtargetinfo(environ, targetID=None, name=None):
server = _getServer(environ)
target = None
if targetID != None:
if targetID is not None:
targetID = int(targetID)
target = server.getBuildTarget(targetID)
elif name != None:
elif name is not None:
target = server.getBuildTarget(name)
if target == None:
if target is None:
raise koji.GenericError('invalid build target: %s' % (targetID or name))
values['title'] = target['name'] + ' | Build Target Info'
@ -1883,7 +1883,7 @@ def buildtargetedit(environ, targetID):
targetID = int(targetID)
target = server.getBuildTarget(targetID)
if target == None:
if target is None:
raise koji.GenericError('invalid build target: %s' % targetID)
form = environ['koji.form']
@ -1892,12 +1892,12 @@ def buildtargetedit(environ, targetID):
name = form.getfirst('name')
buildTagID = int(form.getfirst('buildTag'))
buildTag = server.getTag(buildTagID)
if buildTag == None:
if buildTag is None:
raise koji.GenericError('invalid tag ID: %i' % buildTagID)
destTagID = int(form.getfirst('destTag'))
destTag = server.getTag(destTagID)
if destTag == None:
if destTag is None:
raise koji.GenericError('invalid tag ID: %i' % destTagID)
server.editBuildTarget(target['id'], name, buildTag['id'], destTag['id'])
@ -1933,7 +1933,7 @@ def buildtargetcreate(environ):
server.createBuildTarget(name, buildTagID, destTagID)
target = server.getBuildTarget(name)
if target == None:
if target is None:
raise koji.GenericError('error creating build target "%s"' % name)
_redirect(environ, 'buildtargetinfo?targetID=%i' % target['id'])
@ -1958,7 +1958,7 @@ def buildtargetdelete(environ, targetID):
targetID = int(targetID)
target = server.getBuildTarget(targetID)
if target == None:
if target is None:
raise koji.GenericError('invalid build target: %i' % targetID)
server.deleteBuildTarget(target['id'])
@ -2029,7 +2029,7 @@ def rpmsbyhost(environ, start=None, order=None, hostArch=None, rpmArch=None):
values['rpmArch'] = rpmArch
values['rpmArchList'] = hostArchList + ['noarch', 'src']
if order == None:
if order is None:
order = '-rpms'
values['order'] = order
@ -2059,7 +2059,7 @@ def packagesbyuser(environ, start=None, order=None):
if numPackages > maxPackages:
maxPackages = numPackages
if order == None:
if order is None:
order = '-packages'
values['order'] = order
@ -2277,13 +2277,13 @@ def recentbuilds(environ, user=None, tag=None, package=None):
server = _getServer(environ)
tagObj = None
if tag != None:
if tag is not None:
if tag.isdigit():
tag = int(tag)
tagObj = server.getTag(tag)
userObj = None
if user != None:
if user is not None:
if user.isdigit():
user = int(user)
userObj = server.getUser(user)
@ -2294,7 +2294,7 @@ def recentbuilds(environ, user=None, tag=None, package=None):
package = int(package)
packageObj = server.getPackage(package)
if tagObj != None:
if tagObj is not None:
builds = server.listTagged(tagObj['id'], inherit=True, package=(packageObj and packageObj['name'] or None),
owner=(userObj and userObj['name'] or None))
builds.sort(key=kojiweb.util.sortByKeyFuncNoneGreatest('completion_time'), reverse=True)

View file

@ -174,7 +174,7 @@ def _genToken(environ, tstamp=None):
user = environ['koji.currentLogin']
else:
return ''
if tstamp == None:
if tstamp is None:
tstamp = _truncTime()
value = user + str(tstamp) + environ['koji.options']['Secret'].value
if six.PY3:
@ -247,7 +247,7 @@ def passthrough(template, *vars):
result = []
for var in vars:
value = template.getVar(var, default=None)
if value != None:
if value is not None:
result.append('%s=%s' % (var, value))
if result:
return '&' + '&'.join(result)
@ -267,7 +267,7 @@ def passthrough_except(template, *exclude):
"""
passvars = []
for var in template._PASSTHROUGH:
if not var in exclude:
if var not in exclude:
passvars.append(var)
return passthrough(template, *passvars)
@ -292,7 +292,7 @@ def paginateList(values, data, start, dataName, prefix=None, order=None, noneGre
under which a number of list-related metadata variables will
be added to the value map.
"""
if order != None:
if order is not None:
if order.startswith('-'):
order = order[1:]
reverse = True
@ -596,7 +596,7 @@ def authToken(template, first=False, form=False):
If first is True, prefix it with ?, otherwise prefix it
with &. If no authToken exists, return an empty string."""
token = template.getVar('authToken', default=None)
if token != None:
if token is not None:
if form:
return '<input type="hidden" name="a" value="%s"/>' % token
if first: