Gave a more informative error message when reading non-UTF-8 batchfiles containing international symbols (issue97) as well as refactored the processors a bit further. Fixed some minor typographic details in some other commands.
This commit is contained in:
parent
76edd254b0
commit
933e29afee
6 changed files with 115 additions and 73 deletions
|
|
@ -29,8 +29,24 @@ from src.commands.cmdset import CmdSet
|
|||
|
||||
|
||||
HEADER_WIDTH = 70
|
||||
UTF8_ERROR = \
|
||||
"""
|
||||
{rDecode error in '%s'.{n
|
||||
|
||||
This file contains non-ascii character(s). This is common if you
|
||||
wrote some input in a language that has more letters and special
|
||||
symbols than English; such as accents or umlauts. This is usually
|
||||
fine and fully supported! But for Evennia to know how to decode such
|
||||
characters in a universal way, the batchfile must be saved with the
|
||||
international 'UTF-8' encoding. This file is not.
|
||||
|
||||
Please re-save the batchfile with the UTF-8 encoding (refer to the
|
||||
documentation of your text editor on how to do this, or switch to a
|
||||
better featured one) and try again.
|
||||
|
||||
The (first) error was found with a character on line %s in the file.
|
||||
"""
|
||||
|
||||
#global defines for storage
|
||||
|
||||
#------------------------------------------------------------
|
||||
# Helper functions
|
||||
|
|
@ -192,9 +208,15 @@ class CmdBatchCommands(MuxCommand):
|
|||
return
|
||||
python_path = self.args
|
||||
|
||||
#parse indata file
|
||||
|
||||
commands = BATCHCMD.parse_file(python_path)
|
||||
#parse indata file
|
||||
|
||||
try:
|
||||
commands = BATCHCMD.parse_file(python_path)
|
||||
except UnicodeDecodeError, err:
|
||||
lnum = err.linenum
|
||||
caller.msg(UTF8_ERROR % (python_path, lnum))
|
||||
return
|
||||
|
||||
if not commands:
|
||||
string = "'%s' not found.\nYou have to supply the python path "
|
||||
string += "of the file relative to \nyour batch-file directory (%s)."
|
||||
|
|
@ -271,7 +293,13 @@ class CmdBatchCode(MuxCommand):
|
|||
python_path = self.args
|
||||
|
||||
#parse indata file
|
||||
codes = BATCHCODE.parse_file(python_path)
|
||||
try:
|
||||
codes = BATCHCODE.parse_file(python_path)
|
||||
except UnicodeDecodeError, err:
|
||||
lnum = err.linenum
|
||||
caller.msg(UTF8_ERROR % (python_path, lnum))
|
||||
return
|
||||
|
||||
if not codes:
|
||||
string = "'%s' not found.\nYou have to supply the python path "
|
||||
string += "of the file relative to \nyour batch-file directory (%s)."
|
||||
|
|
|
|||
|
|
@ -491,11 +491,11 @@ class CmdSay(MuxCommand):
|
|||
speech = caller.location.at_say(caller, speech)
|
||||
|
||||
# Feedback for the object doing the talking.
|
||||
caller.msg("You say, '%s'" % speech)
|
||||
caller.msg('You say, "%s{n"' % speech)
|
||||
|
||||
# Build the string to emit to neighbors.
|
||||
emit_string = "{c%s{n says, '%s'" % (caller.name,
|
||||
speech)
|
||||
emit_string = '{c%s{n says, "%s{n"' % (caller.name,
|
||||
speech)
|
||||
caller.location.msg_contents(emit_string,
|
||||
exclude=caller)
|
||||
|
||||
|
|
|
|||
|
|
@ -205,7 +205,6 @@ class CmdSetObjAlias(MuxCommand):
|
|||
obj.aliases = aliases
|
||||
caller.msg("Aliases for '%s' are now set to %s." % (obj.name, aliases))
|
||||
|
||||
|
||||
class CmdName(ObjManipCommand):
|
||||
"""
|
||||
cname - change the name and/or aliases of an object
|
||||
|
|
|
|||
|
|
@ -48,9 +48,9 @@ know you want to!
|
|||
# Now let's place the button where it belongs (let's say limbo #2 is
|
||||
# the evil lair in our example)
|
||||
|
||||
@teleport #2
|
||||
teleport #2
|
||||
|
||||
#... and drop it (remember, this comment ends input to @teleport, so don't
|
||||
#forget it!) The very last command in the file need not be ended with #.
|
||||
|
||||
drop button
|
||||
drop button
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue