Remove basestring mentions remnants of 2.7
This commit is contained in:
parent
e54b87b6fd
commit
58116ff900
10 changed files with 29 additions and 29 deletions
|
|
@ -483,7 +483,7 @@ class DefaultAccount(with_metaclass(TypeclassBase, AccountDB)):
|
||||||
kwargs["options"] = options
|
kwargs["options"] = options
|
||||||
|
|
||||||
if text is not None:
|
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
|
# sanitize text before sending across the wire
|
||||||
try:
|
try:
|
||||||
text = to_str(text, force_string=True)
|
text = to_str(text, force_string=True)
|
||||||
|
|
|
||||||
|
|
@ -211,8 +211,8 @@ def _process_input(caller, prompt, result, cmd, generator):
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
caller (Character, Account or Session): the caller.
|
caller (Character, Account or Session): the caller.
|
||||||
prompt (basestring): The sent prompt.
|
prompt (str): The sent prompt.
|
||||||
result (basestring): The unprocessed answer.
|
result (str): The unprocessed answer.
|
||||||
cmd (Command): The command itself.
|
cmd (Command): The command itself.
|
||||||
generator (GeneratorType): The generator.
|
generator (GeneratorType): The generator.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2930,7 +2930,7 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
||||||
if ';' in self.args:
|
if ';' in self.args:
|
||||||
key, tags = (part.strip().lower() for part in self.args.split(";", 1))
|
key, tags = (part.strip().lower() for part in self.args.split(";", 1))
|
||||||
tags = [tag.strip() for tag in tags.split(",")] if tags else None
|
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)
|
exit_on_lastpage=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
@ -3063,13 +3063,13 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
||||||
# A direct creation of an object from a given prototype
|
# A direct creation of an object from a given prototype
|
||||||
|
|
||||||
prototype = _parse_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:
|
if not prototype:
|
||||||
# this will only let through dicts or strings
|
# this will only let through dicts or strings
|
||||||
return
|
return
|
||||||
|
|
||||||
key = '<unnamed>'
|
key = '<unnamed>'
|
||||||
if isinstance(prototype, basestring):
|
if isinstance(prototype, str):
|
||||||
# A prototype key we are looking to apply
|
# A prototype key we are looking to apply
|
||||||
key = prototype
|
key = prototype
|
||||||
prototypes = protlib.search_prototype(prototype)
|
prototypes = protlib.search_prototype(prototype)
|
||||||
|
|
|
||||||
|
|
@ -155,10 +155,10 @@ class TestGeneral(CommandTest):
|
||||||
"Account-nick 'testalias' mapped to 'testaliasedstring2'.")
|
"Account-nick 'testalias' mapped to 'testaliasedstring2'.")
|
||||||
self.call(general.CmdNick(), "/object testalias = testaliasedstring3",
|
self.call(general.CmdNick(), "/object testalias = testaliasedstring3",
|
||||||
"Object-nick 'testalias' mapped to 'testaliasedstring3'.")
|
"Object-nick 'testalias' mapped to 'testaliasedstring3'.")
|
||||||
self.assertEqual(u"testaliasedstring1", self.char1.nicks.get("testalias"))
|
self.assertEqual("testaliasedstring1", self.char1.nicks.get("testalias"))
|
||||||
self.assertEqual(u"testaliasedstring2", self.char1.nicks.get("testalias", category="account"))
|
self.assertEqual("testaliasedstring2", self.char1.nicks.get("testalias", category="account"))
|
||||||
self.assertEqual(None, self.char1.account.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):
|
def test_get_and_drop(self):
|
||||||
self.call(general.CmdGet(), "Obj", "You pick up Obj.")
|
self.call(general.CmdGet(), "Obj", "You pick up Obj.")
|
||||||
|
|
|
||||||
|
|
@ -595,7 +595,7 @@ class BuildingMenu(object):
|
||||||
if choice_key == self.joker_key:
|
if choice_key == self.joker_key:
|
||||||
continue
|
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
|
common = False
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
@ -631,7 +631,7 @@ class BuildingMenu(object):
|
||||||
if choice_key == self.joker_key:
|
if choice_key == self.joker_key:
|
||||||
continue
|
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
|
common = False
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -571,7 +571,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||||
logger.log_trace()
|
logger.log_trace()
|
||||||
|
|
||||||
if text is not None:
|
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
|
# sanitize text before sending across the wire
|
||||||
try:
|
try:
|
||||||
text = to_str(text, force_string=True)
|
text = to_str(text, force_string=True)
|
||||||
|
|
|
||||||
|
|
@ -256,7 +256,7 @@ def eval(*args, **kwargs):
|
||||||
string = ",".join(args)
|
string = ",".join(args)
|
||||||
struct = literal_eval(string)
|
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
|
# 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
|
# literal_evas will pick up e.g. '2' as something that should be converted to a number
|
||||||
struct = '"{}"'.format(struct)
|
struct = '"{}"'.format(struct)
|
||||||
|
|
|
||||||
|
|
@ -567,7 +567,7 @@ def protfunc_parser(value, available_functions=None, testing=False, stacktrace=F
|
||||||
eventual object #dbrefs in the output from the protfunc.
|
eventual object #dbrefs in the output from the protfunc.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if not isinstance(value, basestring):
|
if not isinstance(value, str):
|
||||||
try:
|
try:
|
||||||
value = value.dbref
|
value = value.dbref
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ prototype, override its name with an empty dict.
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
@ -447,7 +447,7 @@ def batch_update_objects_with_prototype(prototype, diff=None, objects=None):
|
||||||
"""
|
"""
|
||||||
prototype = protlib.homogenize_prototype(prototype)
|
prototype = protlib.homogenize_prototype(prototype)
|
||||||
|
|
||||||
if isinstance(prototype, basestring):
|
if isinstance(prototype, str):
|
||||||
new_prototype = protlib.search_prototype(prototype)
|
new_prototype = protlib.search_prototype(prototype)
|
||||||
else:
|
else:
|
||||||
new_prototype = prototype
|
new_prototype = prototype
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ class TestUtils(EvenniaTest):
|
||||||
'prototype_key': Something,
|
'prototype_key': Something,
|
||||||
'prototype_locks': 'spawn:all();edit:all()',
|
'prototype_locks': 'spawn:all();edit:all()',
|
||||||
'prototype_tags': [],
|
'prototype_tags': [],
|
||||||
'tags': [(u'foo', None, None)],
|
'tags': [('foo', None, None)],
|
||||||
'typeclass': 'evennia.objects.objects.DefaultObject'}, new_prot)
|
'typeclass': 'evennia.objects.objects.DefaultObject'}, new_prot)
|
||||||
|
|
||||||
def test_update_objects_from_prototypes(self):
|
def test_update_objects_from_prototypes(self):
|
||||||
|
|
@ -134,7 +134,7 @@ class TestUtils(EvenniaTest):
|
||||||
'prototype_key': Something,
|
'prototype_key': Something,
|
||||||
'prototype_locks': 'spawn:all();edit:all()',
|
'prototype_locks': 'spawn:all();edit:all()',
|
||||||
'prototype_tags': [],
|
'prototype_tags': [],
|
||||||
'tags': [(u'footag', u'foocategory', None)],
|
'tags': [('footag', 'foocategory', None)],
|
||||||
'typeclass': 'evennia.objects.objects.DefaultObject'})
|
'typeclass': 'evennia.objects.objects.DefaultObject'})
|
||||||
|
|
||||||
self.assertEqual(old_prot,
|
self.assertEqual(old_prot,
|
||||||
|
|
@ -183,7 +183,7 @@ class TestUtils(EvenniaTest):
|
||||||
'typeclass': ('evennia.objects.objects.DefaultObject',
|
'typeclass': ('evennia.objects.objects.DefaultObject',
|
||||||
'evennia.objects.objects.DefaultObject', 'KEEP'),
|
'evennia.objects.objects.DefaultObject', 'KEEP'),
|
||||||
'aliases': {'foo': ('foo', None, 'REMOVE')},
|
'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',
|
'prototype_desc': ('Built from Obj',
|
||||||
'New version of prototype', 'UPDATE'),
|
'New version of prototype', 'UPDATE'),
|
||||||
'permissions': {"Builder": (None, 'Builder', 'ADD')}
|
'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("prot")), [prot1b, prot2, prot3])
|
||||||
self.assertEqual(list(protlib.search_prototype(tags="foo1")), [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):
|
class _MockMenu(object):
|
||||||
|
|
@ -574,17 +574,17 @@ class TestMenuModule(EvenniaTest):
|
||||||
# diff helpers
|
# diff helpers
|
||||||
obj_diff = {
|
obj_diff = {
|
||||||
'attrs': {
|
'attrs': {
|
||||||
u'desc': ((u'desc', u'This is User #1.', None, ''),
|
'desc': (('desc', 'This is User #1.', None, ''),
|
||||||
(u'desc', u'This is User #1.', None, ''),
|
('desc', 'This is User #1.', None, ''),
|
||||||
'KEEP'),
|
'KEEP'),
|
||||||
u'foo': (None,
|
'foo': (None,
|
||||||
(u'foo', u'bar', None, ''),
|
('foo', 'bar', None, ''),
|
||||||
'ADD'),
|
'ADD'),
|
||||||
u'prelogout_location': ((u'prelogout_location', "#2", None, ''),
|
'prelogout_location': (('prelogout_location', "#2", None, ''),
|
||||||
(u'prelogout_location', "#2", None, ''),
|
('prelogout_location', "#2", None, ''),
|
||||||
'KEEP')},
|
'KEEP')},
|
||||||
'home': ('#2', '#2', '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();'
|
'locks': ('boot:false();call:false();control:perm(Developer);delete:false();'
|
||||||
'edit:false();examine:perm(Developer);get:false();msg:all();'
|
'edit:false();examine:perm(Developer);get:false();msg:all();'
|
||||||
'puppet:false();tell:perm(Admin);view: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_locks': ('spawn:all();edit:all()', 'spawn:all();edit:all()', 'KEEP'),
|
||||||
'prototype_tags': {},
|
'prototype_tags': {},
|
||||||
'tags': {'foo': (None, ('foo', None, ''), 'ADD')},
|
'tags': {'foo': (None, ('foo', None, ''), 'ADD')},
|
||||||
'typeclass': (u'typeclasses.characters.Character',
|
'typeclass': ('typeclasses.characters.Character',
|
||||||
u'typeclasses.characters.Character', 'KEEP')}
|
'typeclasses.characters.Character', 'KEEP')}
|
||||||
|
|
||||||
texts, options = olc_menus._format_diff_text_and_options(obj_diff)
|
texts, options = olc_menus._format_diff_text_and_options(obj_diff)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue