Port EvMenu and EvForm for Py3.
This commit is contained in:
parent
8d0d3a942f
commit
aaf13eec16
2 changed files with 5 additions and 6 deletions
|
|
@ -140,7 +140,7 @@ from builtins import object, range
|
||||||
import re
|
import re
|
||||||
import copy
|
import copy
|
||||||
from evennia.utils.evtable import EvCell, EvTable
|
from evennia.utils.evtable import EvCell, EvTable
|
||||||
from evennia.utils.utils import all_from_module, to_str, to_unicode
|
from evennia.utils.utils import all_from_module, to_str, to_unicode, is_iter
|
||||||
from evennia.utils.ansi import ANSIString
|
from evennia.utils.ansi import ANSIString
|
||||||
|
|
||||||
# non-valid form-identifying characters (which can thus be
|
# non-valid form-identifying characters (which can thus be
|
||||||
|
|
@ -161,7 +161,7 @@ def _to_ansi(obj, regexable=False):
|
||||||
obj = _ANSI_ESCAPE.sub(r"||||", obj)
|
obj = _ANSI_ESCAPE.sub(r"||||", obj)
|
||||||
if isinstance(obj, dict):
|
if isinstance(obj, dict):
|
||||||
return dict((key, _to_ansi(value, regexable=regexable)) for key, value in list(obj.items()))
|
return dict((key, _to_ansi(value, regexable=regexable)) for key, value in list(obj.items()))
|
||||||
elif hasattr(obj, "__iter__"):
|
elif is_iter(obj):
|
||||||
return [_to_ansi(o) for o in obj]
|
return [_to_ansi(o) for o in obj]
|
||||||
else:
|
else:
|
||||||
return ANSIString(to_unicode(obj), regexable=regexable)
|
return ANSIString(to_unicode(obj), regexable=regexable)
|
||||||
|
|
@ -260,7 +260,6 @@ class EvForm(object):
|
||||||
|
|
||||||
# get rectangles and assign EvCells
|
# get rectangles and assign EvCells
|
||||||
for key, (iy, leftix, rightix) in list(cell_coords.items()):
|
for key, (iy, leftix, rightix) in list(cell_coords.items()):
|
||||||
|
|
||||||
# scan up to find top of rectangle
|
# scan up to find top of rectangle
|
||||||
dy_up = 0
|
dy_up = 0
|
||||||
if iy > 0:
|
if iy > 0:
|
||||||
|
|
@ -420,7 +419,7 @@ class EvForm(object):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
"Prints the form"
|
"Prints the form"
|
||||||
return ANSIString("\n").join([line for line in self.form])
|
return str(ANSIString("\n").join([line for line in self.form]))
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
"prints the form"
|
"prints the form"
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ from evennia import Command, CmdSet
|
||||||
from evennia.utils import logger
|
from evennia.utils import logger
|
||||||
from evennia.utils.evtable import EvTable
|
from evennia.utils.evtable import EvTable
|
||||||
from evennia.utils.ansi import strip_ansi
|
from evennia.utils.ansi import strip_ansi
|
||||||
from evennia.utils.utils import mod_import, make_iter, pad, m_len
|
from evennia.utils.utils import mod_import, make_iter, pad, m_len, is_iter
|
||||||
from evennia.commands import cmdhandler
|
from evennia.commands import cmdhandler
|
||||||
|
|
||||||
# read from protocol NAWS later?
|
# read from protocol NAWS later?
|
||||||
|
|
@ -726,7 +726,7 @@ class EvMenu(object):
|
||||||
|
|
||||||
# validation of the node return values
|
# validation of the node return values
|
||||||
helptext = ""
|
helptext = ""
|
||||||
if hasattr(nodetext, "__iter__"):
|
if is_iter(nodetext):
|
||||||
if len(nodetext) > 1:
|
if len(nodetext) > 1:
|
||||||
nodetext, helptext = nodetext[:2]
|
nodetext, helptext = nodetext[:2]
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue