Remove basestring mentions remnants of 2.7

This commit is contained in:
Griatch 2018-10-13 19:30:24 +02:00
parent e54b87b6fd
commit 58116ff900
10 changed files with 29 additions and 29 deletions

View file

@ -483,7 +483,7 @@ class DefaultAccount(with_metaclass(TypeclassBase, AccountDB)):
kwargs["options"] = options
if text is not None:
if not (isinstance(text, basestring) or isinstance(text, tuple)):
if not (isinstance(text, str) or isinstance(text, tuple)):
# sanitize text before sending across the wire
try:
text = to_str(text, force_string=True)

View file

@ -211,8 +211,8 @@ def _process_input(caller, prompt, result, cmd, generator):
Args:
caller (Character, Account or Session): the caller.
prompt (basestring): The sent prompt.
result (basestring): The unprocessed answer.
prompt (str): The sent prompt.
result (str): The unprocessed answer.
cmd (Command): The command itself.
generator (GeneratorType): The generator.

View file

@ -2930,7 +2930,7 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
if ';' in self.args:
key, tags = (part.strip().lower() for part in self.args.split(";", 1))
tags = [tag.strip() for tag in tags.split(",")] if tags else None
EvMore(caller, unicode(protlib.list_prototypes(caller, key=key, tags=tags)),
EvMore(caller, str(protlib.list_prototypes(caller, key=key, tags=tags)),
exit_on_lastpage=True)
return
@ -3063,13 +3063,13 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
# A direct creation of an object from a given prototype
prototype = _parse_prototype(
self.args, expect=dict if self.args.strip().startswith("{") else basestring)
self.args, expect=dict if self.args.strip().startswith("{") else str)
if not prototype:
# this will only let through dicts or strings
return
key = '<unnamed>'
if isinstance(prototype, basestring):
if isinstance(prototype, str):
# A prototype key we are looking to apply
key = prototype
prototypes = protlib.search_prototype(prototype)

View file

@ -155,10 +155,10 @@ class TestGeneral(CommandTest):
"Account-nick 'testalias' mapped to 'testaliasedstring2'.")
self.call(general.CmdNick(), "/object testalias = testaliasedstring3",
"Object-nick 'testalias' mapped to 'testaliasedstring3'.")
self.assertEqual(u"testaliasedstring1", self.char1.nicks.get("testalias"))
self.assertEqual(u"testaliasedstring2", self.char1.nicks.get("testalias", category="account"))
self.assertEqual("testaliasedstring1", self.char1.nicks.get("testalias"))
self.assertEqual("testaliasedstring2", self.char1.nicks.get("testalias", category="account"))
self.assertEqual(None, self.char1.account.nicks.get("testalias", category="account"))
self.assertEqual(u"testaliasedstring3", self.char1.nicks.get("testalias", category="object"))
self.assertEqual("testaliasedstring3", self.char1.nicks.get("testalias", category="object"))
def test_get_and_drop(self):
self.call(general.CmdGet(), "Obj", "You pick up Obj.")

View file

@ -595,7 +595,7 @@ class BuildingMenu(object):
if choice_key == self.joker_key:
continue
if not isinstance(menu_key, basestring) or menu_key != choice_key:
if not isinstance(menu_key, str) or menu_key != choice_key:
common = False
break
@ -631,7 +631,7 @@ class BuildingMenu(object):
if choice_key == self.joker_key:
continue
if not isinstance(menu_key, basestring) or menu_key != choice_key:
if not isinstance(menu_key, str) or menu_key != choice_key:
common = False
break

View file

@ -571,7 +571,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
logger.log_trace()
if text is not None:
if not (isinstance(text, basestring) or isinstance(text, tuple)):
if not (isinstance(text, str) or isinstance(text, tuple)):
# sanitize text before sending across the wire
try:
text = to_str(text, force_string=True)

View file

@ -256,7 +256,7 @@ def eval(*args, **kwargs):
string = ",".join(args)
struct = literal_eval(string)
if isinstance(struct, basestring):
if isinstance(struct, str):
# we must shield the string, otherwise it will be merged as a string and future
# literal_evas will pick up e.g. '2' as something that should be converted to a number
struct = '"{}"'.format(struct)

View file

@ -567,7 +567,7 @@ def protfunc_parser(value, available_functions=None, testing=False, stacktrace=F
eventual object #dbrefs in the output from the protfunc.
"""
if not isinstance(value, basestring):
if not isinstance(value, str):
try:
value = value.dbref
except AttributeError:

View file

@ -128,7 +128,7 @@ prototype, override its name with an empty dict.
"""
from __future__ import print_function
import copy
import hashlib
@ -447,7 +447,7 @@ def batch_update_objects_with_prototype(prototype, diff=None, objects=None):
"""
prototype = protlib.homogenize_prototype(prototype)
if isinstance(prototype, basestring):
if isinstance(prototype, str):
new_prototype = protlib.search_prototype(prototype)
else:
new_prototype = prototype

View file

@ -88,7 +88,7 @@ class TestUtils(EvenniaTest):
'prototype_key': Something,
'prototype_locks': 'spawn:all();edit:all()',
'prototype_tags': [],
'tags': [(u'foo', None, None)],
'tags': [('foo', None, None)],
'typeclass': 'evennia.objects.objects.DefaultObject'}, new_prot)
def test_update_objects_from_prototypes(self):
@ -134,7 +134,7 @@ class TestUtils(EvenniaTest):
'prototype_key': Something,
'prototype_locks': 'spawn:all();edit:all()',
'prototype_tags': [],
'tags': [(u'footag', u'foocategory', None)],
'tags': [('footag', 'foocategory', None)],
'typeclass': 'evennia.objects.objects.DefaultObject'})
self.assertEqual(old_prot,
@ -183,7 +183,7 @@ class TestUtils(EvenniaTest):
'typeclass': ('evennia.objects.objects.DefaultObject',
'evennia.objects.objects.DefaultObject', 'KEEP'),
'aliases': {'foo': ('foo', None, 'REMOVE')},
'tags': {u'footag': ((u'footag', u'foocategory', None), None, 'REMOVE')},
'tags': {'footag': (('footag', 'foocategory', None), None, 'REMOVE')},
'prototype_desc': ('Built from Obj',
'New version of prototype', 'UPDATE'),
'permissions': {"Builder": (None, 'Builder', 'ADD')}
@ -391,7 +391,7 @@ class TestPrototypeStorage(EvenniaTest):
self.assertEqual(list(protlib.search_prototype("prot")), [prot1b, prot2, prot3])
self.assertEqual(list(protlib.search_prototype(tags="foo1")), [prot1b, prot2, prot3])
self.assertTrue(str(unicode(protlib.list_prototypes(self.char1))))
self.assertTrue(str(str(protlib.list_prototypes(self.char1))))
class _MockMenu(object):
@ -574,17 +574,17 @@ class TestMenuModule(EvenniaTest):
# diff helpers
obj_diff = {
'attrs': {
u'desc': ((u'desc', u'This is User #1.', None, ''),
(u'desc', u'This is User #1.', None, ''),
'desc': (('desc', 'This is User #1.', None, ''),
('desc', 'This is User #1.', None, ''),
'KEEP'),
u'foo': (None,
(u'foo', u'bar', None, ''),
'foo': (None,
('foo', 'bar', None, ''),
'ADD'),
u'prelogout_location': ((u'prelogout_location', "#2", None, ''),
(u'prelogout_location', "#2", None, ''),
'prelogout_location': (('prelogout_location', "#2", None, ''),
('prelogout_location', "#2", None, ''),
'KEEP')},
'home': ('#2', '#2', 'KEEP'),
'key': (u'TestChar', u'TestChar', 'KEEP'),
'key': ('TestChar', 'TestChar', 'KEEP'),
'locks': ('boot:false();call:false();control:perm(Developer);delete:false();'
'edit:false();examine:perm(Developer);get:false();msg:all();'
'puppet:false();tell:perm(Admin);view:all()',
@ -598,8 +598,8 @@ class TestMenuModule(EvenniaTest):
'prototype_locks': ('spawn:all();edit:all()', 'spawn:all();edit:all()', 'KEEP'),
'prototype_tags': {},
'tags': {'foo': (None, ('foo', None, ''), 'ADD')},
'typeclass': (u'typeclasses.characters.Character',
u'typeclasses.characters.Character', 'KEEP')}
'typeclass': ('typeclasses.characters.Character',
'typeclasses.characters.Character', 'KEEP')}
texts, options = olc_menus._format_diff_text_and_options(obj_diff)
self.assertEqual(