python-modernize -f libmodernize.fixes.fix_basestring
This commit is contained in:
parent
7f6b717eb6
commit
5ad9027320
4 changed files with 18 additions and 17 deletions
|
|
@ -2837,7 +2837,7 @@ class ImageTask(BaseTaskHandler):
|
|||
self.ks.handler.repo.repoList = [] # delete whatever the ks file told us
|
||||
if opts.get('repo'):
|
||||
user_repos = opts['repo']
|
||||
if isinstance(user_repos, basestring):
|
||||
if isinstance(user_repos, six.string_types):
|
||||
user_repos = user_repos.split(',')
|
||||
index = 0
|
||||
for user_repo in user_repos:
|
||||
|
|
@ -5658,7 +5658,7 @@ class WaitrepoTask(BaseTaskHandler):
|
|||
if not targets:
|
||||
raise koji.GenericError("No build target for tag: %s" % taginfo['name'])
|
||||
|
||||
if isinstance(newer_than, basestring) and newer_than.lower() == "now":
|
||||
if isinstance(newer_than, six.string_types) and newer_than.lower() == "now":
|
||||
newer_than = start
|
||||
if not isinstance(newer_than, (type(None), int, long, float)):
|
||||
raise koji.GenericError("Invalid value for newer_than: %s" % newer_than)
|
||||
|
|
|
|||
|
|
@ -1324,7 +1324,7 @@ def readTaggedRPMS(tag, package=None, arch=None, event=None, inherit=False, late
|
|||
joins.append('LEFT OUTER JOIN rpmsigs on rpminfo.id = rpmsigs.rpm_id')
|
||||
if arch:
|
||||
data['arch'] = arch
|
||||
if isinstance(arch, basestring):
|
||||
if isinstance(arch, six.string_types):
|
||||
clauses.append('rpminfo.arch = %(arch)s')
|
||||
elif isinstance(arch, (list, tuple)):
|
||||
clauses.append('rpminfo.arch IN %(arch)s')
|
||||
|
|
@ -2135,7 +2135,7 @@ def remove_host_from_channel(hostname, channel_name):
|
|||
def rename_channel(old, new):
|
||||
"""Rename a channel"""
|
||||
context.session.assertPerm('admin')
|
||||
if not isinstance(new, basestring):
|
||||
if not isinstance(new, six.string_types):
|
||||
raise koji.GenericError("new channel name must be a string")
|
||||
cinfo = get_channel(old, strict=True)
|
||||
dup_check = get_channel(new, strict=False)
|
||||
|
|
@ -3055,7 +3055,7 @@ def get_tag(tagInfo, strict=False, event=None):
|
|||
clauses = [eventCondition(event, table='tag_config')]
|
||||
if isinstance(tagInfo, (int, long)):
|
||||
clauses.append("tag.id = %(tagInfo)i")
|
||||
elif isinstance(tagInfo, basestring):
|
||||
elif isinstance(tagInfo, six.string_types):
|
||||
clauses.append("tag.name = %(tagInfo)s")
|
||||
else:
|
||||
raise koji.GenericError('invalid type for tagInfo: %s' % type(tagInfo))
|
||||
|
|
@ -5498,7 +5498,7 @@ class CG_Importer(object):
|
|||
datetime.datetime.fromtimestamp(float(metadata['build']['end_time'])).isoformat(' ')
|
||||
owner = metadata['build'].get('owner', None)
|
||||
if owner:
|
||||
if not isinstance(owner, basestring):
|
||||
if not isinstance(owner, six.string_types):
|
||||
raise koji.GenericError("Invalid owner format (expected username): %s" % owner)
|
||||
buildinfo['owner'] = get_user(owner, strict=True)['id']
|
||||
self.buildinfo = buildinfo
|
||||
|
|
@ -5889,11 +5889,11 @@ def add_external_rpm(rpminfo, external_repo, strict=True):
|
|||
|
||||
# sanity check rpminfo
|
||||
dtypes = (
|
||||
('name', basestring),
|
||||
('version', basestring),
|
||||
('release', basestring),
|
||||
('name', six.string_types),
|
||||
('version', six.string_types),
|
||||
('release', six.string_types),
|
||||
('epoch', (int, type(None))),
|
||||
('arch', basestring),
|
||||
('arch', six.string_types),
|
||||
('payloadhash', str),
|
||||
('size', int),
|
||||
('buildtime', (int, long)))
|
||||
|
|
@ -6851,7 +6851,7 @@ def query_history(tables=None, **kwargs):
|
|||
fields['creator.id = %(editor)i'] = '_created_by'
|
||||
fields['revoker.id = %(editor)i'] = '_revoked_by'
|
||||
elif arg == 'after':
|
||||
if not isinstance(value, basestring):
|
||||
if not isinstance(value, six.string_types):
|
||||
value = datetime.datetime.fromtimestamp(value).isoformat(' ')
|
||||
data['after'] = value
|
||||
clauses.append('ev1.time > %(after)s OR ev2.time > %(after)s')
|
||||
|
|
@ -6866,7 +6866,7 @@ def query_history(tables=None, **kwargs):
|
|||
fields[c_test] = '_created_after_event'
|
||||
fields[r_test] = '_revoked_after_event'
|
||||
elif arg == 'before':
|
||||
if not isinstance(value, basestring):
|
||||
if not isinstance(value, six.string_types):
|
||||
value = datetime.datetime.fromtimestamp(value).isoformat(' ')
|
||||
data['before'] = value
|
||||
clauses.append('ev1.time < %(before)s OR ev2.time < %(before)s')
|
||||
|
|
@ -8045,7 +8045,7 @@ def policy_get_pkg(data):
|
|||
if not pkginfo:
|
||||
#for some operations (e.g. adding a new package), the package
|
||||
#entry may not exist yet
|
||||
if isinstance(data['package'], basestring):
|
||||
if isinstance(data['package'], six.string_types):
|
||||
return {'id' : None, 'name' : data['package']}
|
||||
else:
|
||||
raise koji.GenericError("Invalid package: %s" % data['package'])
|
||||
|
|
@ -8965,7 +8965,7 @@ class RootExports(object):
|
|||
# we will accept offset and size as strings to work around xmlrpc limits
|
||||
offset = koji.decode_int(offset)
|
||||
size = koji.decode_int(size)
|
||||
if isinstance(md5sum, basestring):
|
||||
if isinstance(md5sum, six.string_types):
|
||||
# this case is for backwards compatibility
|
||||
verify = "md5"
|
||||
digest = md5sum
|
||||
|
|
|
|||
|
|
@ -553,7 +553,7 @@ def get_policy(opts, plugins):
|
|||
# tests can be limited to certain policies by setting a class variable
|
||||
for name, test in six.iteritems(tests):
|
||||
if hasattr(test, 'policy'):
|
||||
if isinstance(test.policy, basestring):
|
||||
if isinstance(test.policy, six.string_types):
|
||||
if pname != test.policy:
|
||||
continue
|
||||
elif pname not in test.policy:
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import traceback
|
|||
from ConfigParser import RawConfigParser
|
||||
from koji.server import ServerError, ServerRedirect
|
||||
from koji.util import dslice
|
||||
import six
|
||||
|
||||
|
||||
class URLNotFound(ServerError):
|
||||
|
|
@ -397,14 +398,14 @@ class Dispatcher(object):
|
|||
else:
|
||||
# last one wins
|
||||
headers[key] = (name, value)
|
||||
if isinstance(result, basestring):
|
||||
if isinstance(result, six.string_types):
|
||||
headers.setdefault('content-length', ('Content-Length', str(len(result))))
|
||||
headers.setdefault('content-type', ('Content-Type', 'text/html'))
|
||||
headers = list(headers.values()) + extra
|
||||
self.logger.debug("Headers:")
|
||||
self.logger.debug(koji.util.LazyString(pprint.pformat, [headers]))
|
||||
start_response(status, headers)
|
||||
if isinstance(result, basestring):
|
||||
if isinstance(result, six.string_types):
|
||||
result = [result]
|
||||
return result
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue