python-modernize -f libmodernize.fixes.fix_basestring
This commit is contained in:
parent
c87cab8f54
commit
6a0a5a232b
8 changed files with 32 additions and 24 deletions
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
from __future__ import absolute_import
|
||||
from six.moves import zip
|
||||
import six
|
||||
try:
|
||||
import krbV
|
||||
except ImportError: # pragma: no cover
|
||||
|
|
@ -2706,7 +2707,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:
|
||||
|
|
@ -5382,7 +5383,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)
|
||||
|
|
|
|||
|
|
@ -862,7 +862,7 @@ def _direct_pkglist_add(taginfo, pkginfo, owner, block, extra_arches, force,
|
|||
tag_id = tag['id']
|
||||
pkg = lookup_package(pkginfo, strict=False)
|
||||
if not pkg:
|
||||
if not isinstance(pkginfo, basestring):
|
||||
if not isinstance(pkginfo, six.string_types):
|
||||
raise koji.GenericError("Invalid package: %s" % pkginfo)
|
||||
if owner is not None:
|
||||
owner = get_user(owner, strict=True)['id']
|
||||
|
|
@ -1303,7 +1303,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')
|
||||
|
|
@ -2089,7 +2089,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)
|
||||
|
|
@ -2973,7 +2973,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))
|
||||
|
|
@ -5191,7 +5191,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
|
||||
|
|
@ -5532,11 +5532,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)))
|
||||
|
|
@ -6677,7 +6677,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')
|
||||
|
|
@ -6692,7 +6692,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')
|
||||
|
|
@ -7862,7 +7862,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'])
|
||||
|
|
@ -8782,7 +8782,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
|
||||
|
|
@ -9888,7 +9888,7 @@ class RootExports(object):
|
|||
|
||||
headers = koji.get_header_fields(rpm_path, headers)
|
||||
for key, value in headers.items():
|
||||
if isinstance(value, basestring):
|
||||
if isinstance(value, six.string_types):
|
||||
headers[key] = koji.fixEncoding(value, remove_nonprintable=True)
|
||||
return headers
|
||||
|
||||
|
|
|
|||
|
|
@ -583,7 +583,7 @@ def get_policy(opts, plugins):
|
|||
# tests can be limited to certain policies by setting a class variable
|
||||
for name, test in tests.iteritems():
|
||||
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:
|
||||
|
|
|
|||
|
|
@ -997,7 +997,7 @@ def check_NVR(nvr, strict=False):
|
|||
return False
|
||||
|
||||
def _check_NVR(nvr):
|
||||
if isinstance(nvr, basestring):
|
||||
if isinstance(nvr, six.string_types):
|
||||
nvr = parse_NVR(nvr)
|
||||
if '-' in nvr['version']:
|
||||
raise GenericError('The "-" character not allowed in version field')
|
||||
|
|
@ -1026,7 +1026,7 @@ def check_NVRA(nvra, strict=False):
|
|||
|
||||
|
||||
def _check_NVRA(nvra):
|
||||
if isinstance(nvra, basestring):
|
||||
if isinstance(nvra, six.string_types):
|
||||
nvra = parse_NVRA(nvra)
|
||||
if '-' in nvra['version']:
|
||||
raise GenericError('The "-" character not allowed in version field')
|
||||
|
|
|
|||
|
|
@ -7,11 +7,13 @@ module that is based on the older codepaths in koji. It only provides
|
|||
the bits that koji needs.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
import six.moves.http_client
|
||||
import urlparse
|
||||
import urllib
|
||||
import sys
|
||||
import ssl.SSLCommon
|
||||
import six
|
||||
try:
|
||||
from ssl import ssl as pyssl
|
||||
except ImportError: # pragma: no cover
|
||||
|
|
@ -55,7 +57,7 @@ class Session(object):
|
|||
# Otherwise we make a new one
|
||||
default_port = 80
|
||||
certs = {}
|
||||
if isinstance(verify, basestring):
|
||||
if isinstance(verify, six.string_types):
|
||||
certs['peer_ca_cert'] = verify
|
||||
if cert:
|
||||
certs['key_and_cert'] = cert
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@
|
|||
# Mike McLean <mikem@redhat.com>
|
||||
# Mike Bonnet <mikeb@redhat.com>
|
||||
|
||||
from __future__ import absolute_import
|
||||
import imp
|
||||
import koji
|
||||
import logging
|
||||
import sys
|
||||
import traceback
|
||||
import six
|
||||
|
||||
# the available callback hooks and a list
|
||||
# of functions to be called for each event
|
||||
|
|
@ -85,7 +87,7 @@ class PluginTracker(object):
|
|||
return self.plugins.get(name)
|
||||
|
||||
def pathlist(self, path):
|
||||
if isinstance(path, basestring):
|
||||
if isinstance(path, six.string_types):
|
||||
return [path]
|
||||
else:
|
||||
return path
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import time
|
|||
import six.moves.configparser
|
||||
from zlib import adler32
|
||||
from six.moves import range
|
||||
import six
|
||||
|
||||
# imported from kojiweb and kojihub
|
||||
try:
|
||||
|
|
@ -126,7 +127,7 @@ def multi_fnmatch(s, patterns):
|
|||
|
||||
If patterns is a string, it will be split() first
|
||||
"""
|
||||
if isinstance(patterns, basestring):
|
||||
if isinstance(patterns, six.string_types):
|
||||
patterns = patterns.split()
|
||||
for pat in patterns:
|
||||
if fnmatch(s, pat):
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
# Authors:
|
||||
# Mike McLean <mikem@redhat.com>
|
||||
|
||||
from __future__ import absolute_import
|
||||
import cgi
|
||||
import inspect
|
||||
import koji
|
||||
|
|
@ -32,6 +33,7 @@ import traceback
|
|||
from six.moves.configparser import RawConfigParser
|
||||
from koji.server import WSGIWrapper, ServerError, ServerRedirect
|
||||
from koji.util import dslice
|
||||
import six
|
||||
|
||||
|
||||
class URLNotFound(ServerError):
|
||||
|
|
@ -421,14 +423,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 = 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