python3: fix use of basetring
This commit is contained in:
parent
b5255c2532
commit
44486852d1
6 changed files with 8 additions and 8 deletions
|
|
@ -178,7 +178,7 @@ def aslist(obj, sep=None, strip=True):
|
|||
:param sep:
|
||||
:param strip:
|
||||
"""
|
||||
if isinstance(obj, (basestring,)):
|
||||
if isinstance(obj, (str,)):
|
||||
lst = obj.split(sep)
|
||||
if strip:
|
||||
lst = [v.strip() for v in lst]
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ def aslist(obj, sep=None, strip=True):
|
|||
:param sep:
|
||||
:param strip:
|
||||
"""
|
||||
if isinstance(obj, (basestring,)):
|
||||
if isinstance(obj, (str,)):
|
||||
if obj in ['', ""]:
|
||||
return []
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ if PY3:
|
|||
|
||||
MAXSIZE = sys.maxsize
|
||||
else:
|
||||
string_types = basestring,
|
||||
string_types = str,
|
||||
integer_types = (int, long)
|
||||
class_types = (type, types.ClassType)
|
||||
text_type = unicode
|
||||
|
|
@ -701,7 +701,7 @@ if print_ is None:
|
|||
if fp is None:
|
||||
return
|
||||
def write(data):
|
||||
if not isinstance(data, basestring):
|
||||
if not isinstance(data, str):
|
||||
data = str(data)
|
||||
# If the file has an encoding, encode unicode with it.
|
||||
if (isinstance(fp, file) and
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ def post_message(channel, message, username, registry=None):
|
|||
return
|
||||
|
||||
message_obj = message
|
||||
if isinstance(message, basestring):
|
||||
if isinstance(message, str):
|
||||
message_obj = {
|
||||
'message': message,
|
||||
'level': 'success',
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ def select(name, selected_values, options, id=NotGiven, **attrs):
|
|||
for opt in options_iter:
|
||||
if isinstance(opt, tuple) and len(opt) == 2:
|
||||
value, label = opt
|
||||
elif isinstance(opt, basestring):
|
||||
elif isinstance(opt, str):
|
||||
value = label = opt
|
||||
else:
|
||||
raise ValueError('invalid select option type %r' % type(opt))
|
||||
|
|
@ -195,7 +195,7 @@ def select(name, selected_values, options, id=NotGiven, **attrs):
|
|||
for opt2 in value:
|
||||
if isinstance(opt2, tuple) and len(opt2) == 2:
|
||||
group_value, group_label = opt2
|
||||
elif isinstance(opt2, basestring):
|
||||
elif isinstance(opt2, str):
|
||||
group_value = group_label = opt2
|
||||
else:
|
||||
raise ValueError('invalid select option type %r' % type(opt2))
|
||||
|
|
|
|||
|
|
@ -767,7 +767,7 @@ class ScmModel(BaseModel):
|
|||
f_path = safe_str(f_path)
|
||||
# decoding here will force that we have proper encoded values
|
||||
# in any other case this will throw exceptions and deny commit
|
||||
if isinstance(content, (basestring,)):
|
||||
if isinstance(content, (str,)):
|
||||
content = safe_str(content)
|
||||
elif isinstance(content, (file, cStringIO.OutputType,)):
|
||||
content = content.read()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue