Resolve merge conflicts with master.

This commit is contained in:
Griatch 2017-08-19 21:30:42 +02:00
commit 7ff783fea1
21 changed files with 900 additions and 122 deletions

View file

@ -80,6 +80,8 @@ __all__ = ("import_cmdset", "CmdSetHandler")
_CACHED_CMDSETS = {}
_CMDSET_PATHS = utils.make_iter(settings.CMDSET_PATHS)
_IN_GAME_ERRORS = settings.IN_GAME_ERRORS
_CMDSET_FALLBACKS = settings.CMDSET_FALLBACKS
# Output strings
@ -102,6 +104,16 @@ _ERROR_CMDSET_EXCEPTION = _(
Compile/Run error when loading cmdset '{path}'.",
(Traceback was logged {timestamp})""")
_ERROR_CMDSET_FALLBACK = _(
"""
Error encountered for cmdset at path '{path}'.
Replacing with fallback '{fallback_path}'.
""")
_ERROR_CMDSET_NO_FALLBACK = _(
"""Fallback path '{fallback_path}' failed to generate a cmdset."""
)
class _ErrorCmdSet(CmdSet):
"""
@ -351,6 +363,22 @@ class CmdSetHandler(object):
elif path:
cmdset = self._import_cmdset(path)
if cmdset:
if cmdset.key == '_CMDSET_ERROR':
# If a cmdset fails to load, check if we have a fallback path to use
fallback_path = _CMDSET_FALLBACKS.get(path, None)
if fallback_path:
err = _ERROR_CMDSET_FALLBACK.format(path=path, fallback_path=fallback_path)
logger.log_err(err)
if _IN_GAME_ERRORS:
self.obj.msg(err)
cmdset = self._import_cmdset(fallback_path)
# If no cmdset is returned from the fallback, we can't go further
if not cmdset:
err = _ERROR_CMDSET_NO_FALLBACK.format(fallback_path=fallback_path)
logger.log_err(err)
if _IN_GAME_ERRORS:
self.obj.msg(err)
continue
cmdset.permanent = cmdset.key != '_CMDSET_ERROR'
self.cmdset_stack.append(cmdset)

View file

@ -184,7 +184,8 @@ class CmdCopy(ObjManipCommand):
copy an object and its properties
Usage:
@copy[/reset] <original obj> [= new_name][;alias;alias..][:new_location] [,new_name2 ...]
@copy[/reset] <original obj> [= <new_name>][;alias;alias..]
[:<new_location>] [,<new_name2> ...]
switch:
reset - make a 'clean' copy off the object, thus
@ -205,7 +206,8 @@ class CmdCopy(ObjManipCommand):
caller = self.caller
args = self.args
if not args:
caller.msg("Usage: @copy <obj> [=new_name[;alias;alias..]][:new_location] [, new_name2...]")
caller.msg("Usage: @copy <obj> [=<new_name>[;alias;alias..]]"
"[:<new_location>] [, <new_name2>...]")
return
if not self.rhs:
@ -446,7 +448,7 @@ class CmdCreate(ObjManipCommand):
create new objects
Usage:
@create[/drop] objname[;alias;alias...][:typeclass], objname...
@create[/drop] <objname>[;alias;alias...][:typeclass], <objname>...
switch:
drop - automatically drop the new object into your current
@ -481,7 +483,7 @@ class CmdCreate(ObjManipCommand):
caller = self.caller
if not self.args:
string = "Usage: @create[/drop] <newname>[;alias;alias...] [:typeclass_path]"
string = "Usage: @create[/drop] <newname>[;alias;alias...] [:typeclass.path]"
caller.msg(string)
return
@ -684,9 +686,9 @@ class CmdDig(ObjManipCommand):
build new rooms and connect them to the current location
Usage:
@dig[/switches] roomname[;alias;alias...][:typeclass]
[= exit_to_there[;alias][:typeclass]]
[, exit_to_here[;alias][:typeclass]]
@dig[/switches] <roomname>[;alias;alias...][:typeclass]
[= <exit_to_there>[;alias][:typeclass]]
[, <exit_to_here>[;alias][:typeclass]]
Switches:
tel or teleport - move yourself to the new room
@ -718,9 +720,10 @@ class CmdDig(ObjManipCommand):
caller = self.caller
if not self.lhs:
string = "Usage: @dig[/teleport] roomname[;alias;alias...][:parent] [= exit_there"
string = "Usage: @dig[/teleport] <roomname>[;alias;alias...]" \
"[:parent] [= <exit_there>"
string += "[;alias;alias..][:parent]] "
string += "[, exit_back_here[;alias;alias..][:parent]]"
string += "[, <exit_back_here>[;alias;alias..][:parent]]"
caller.msg(string)
return
@ -823,7 +826,7 @@ class CmdTunnel(COMMAND_DEFAULT_CLASS):
create new rooms in cardinal directions only
Usage:
@tunnel[/switch] <direction> [= roomname[;alias;alias;...][:typeclass]]
@tunnel[/switch] <direction> [= <roomname>[;alias;alias;...][:typeclass]]
Switches:
oneway - do not create an exit back to the current location
@ -868,7 +871,8 @@ class CmdTunnel(COMMAND_DEFAULT_CLASS):
"Implements the tunnel command"
if not self.args or not self.lhs:
string = "Usage: @tunnel[/switch] <direction> [= roomname[;alias;alias;...][:typeclass]]"
string = "Usage: @tunnel[/switch] <direction> [= <roomname>" \
"[;alias;alias;...][:typeclass]]"
self.caller.msg(string)
return
if self.lhs not in self.directions:
@ -1025,7 +1029,7 @@ class CmdSetHome(CmdLink):
set an object's home location
Usage:
@home <obj> [= home_location]
@home <obj> [= <home_location>]
The "home" location is a "safety" location for objects; they
will be moved there if their current location ceases to exist. All
@ -1042,7 +1046,7 @@ class CmdSetHome(CmdLink):
def func(self):
"implement the command"
if not self.args:
string = "Usage: @home <obj> [= home_location]"
string = "Usage: @home <obj> [= <home_location>]"
self.caller.msg(string)
return
@ -1076,7 +1080,7 @@ class CmdListCmdSets(COMMAND_DEFAULT_CLASS):
list command sets defined on an object
Usage:
@cmdsets [obj]
@cmdsets <obj>
This displays all cmdsets assigned
to a user. Defaults to yourself.
@ -1105,7 +1109,7 @@ class CmdName(ObjManipCommand):
change the name and/or aliases of an object
Usage:
@name obj = name;alias1;alias2
@name <obj> = <newname>;alias1;alias2
Rename an object to something new. Use *obj to
rename an account.
@ -1322,7 +1326,7 @@ def _convert_from_string(cmd, strobj):
Python 2.6 and later:
Supports all Python structures through literal_eval as long as they
are valid Python syntax. If they are not (such as [test, test2], ie
withtout the quotes around the strings), the entire structure will
without the quotes around the strings), the entire structure will
be converted to a string and a warning will be given.
We need to convert like this since all data being sent over the
@ -1379,6 +1383,7 @@ def _convert_from_string(cmd, strobj):
# nested lists/dicts)
return rec_convert(strobj.strip())
class CmdSetAttribute(ObjManipCommand):
"""
set attribute on an object or account
@ -1398,7 +1403,7 @@ class CmdSetAttribute(ObjManipCommand):
(if any).
The most common data to save with this command are strings and
numbers. You can however also set Python primities such as lists,
numbers. You can however also set Python primitives such as lists,
dictionaries and tuples on objects (this might be important for
the functionality of certain custom objects). This is indicated
by you starting your value with one of |c'|n, |c"|n, |c(|n, |c[|n
@ -1557,7 +1562,7 @@ class CmdTypeclass(COMMAND_DEFAULT_CLASS):
set or change an object's typeclass
Usage:
@typclass[/switch] <object> [= <typeclass.path>]
@typeclass[/switch] <object> [= typeclass.path]
@type ''
@parent ''
@swap - this is a shorthand for using /force/reset flags.
@ -1574,7 +1579,7 @@ class CmdTypeclass(COMMAND_DEFAULT_CLASS):
Example:
@type button = examples.red_button.RedButton
If the typeclass.path is not given, the current object's
If the typeclass_path is not given, the current object's
typeclass is assumed.
View or set an object's typeclass. If setting, the creation hooks
@ -1603,7 +1608,7 @@ class CmdTypeclass(COMMAND_DEFAULT_CLASS):
caller = self.caller
if not self.args:
caller.msg("Usage: %s <object> [=<typeclass]" % self.cmdstring)
caller.msg("Usage: %s <object> [= typeclass]" % self.cmdstring)
return
# get object to swap on
@ -1674,7 +1679,7 @@ class CmdWipe(ObjManipCommand):
clear all attributes from an object
Usage:
@wipe <object>[/attribute[/attribute...]]
@wipe <object>[/<attr>[/<attr>...]]
Example:
@wipe box
@ -1695,7 +1700,7 @@ class CmdWipe(ObjManipCommand):
caller = self.caller
if not self.args:
caller.msg("Usage: @wipe <object>[/attribute/attribute...]")
caller.msg("Usage: @wipe <object>[/<attr>/<attr>...]")
return
# get the attributes set by our custom parser
@ -1727,7 +1732,7 @@ class CmdLock(ObjManipCommand):
Usage:
@lock <object>[ = <lockstring>]
or
@lock[/switch] object/<access_type>
@lock[/switch] <object>/<access_type>
Switch:
del - delete given access type
@ -1747,7 +1752,7 @@ class CmdLock(ObjManipCommand):
an object locked with this string will only be possible to
pick up by Admins or by object with id=25.
You can add several access_types after oneanother by separating
You can add several access_types after one another by separating
them by ';', i.e:
'get:id(25);delete:perm(Builder)'
"""
@ -1761,7 +1766,8 @@ class CmdLock(ObjManipCommand):
caller = self.caller
if not self.args:
string = "@lock <object>[ = <lockstring>] or @lock[/switch] object/<access_type>"
string = "@lock <object>[ = <lockstring>] or @lock[/switch] " \
"<object>/<access_type>"
caller.msg(string)
return
@ -2334,7 +2340,7 @@ class CmdScript(COMMAND_DEFAULT_CLASS):
attach a script to an object
Usage:
@script[/switch] <obj> [= <script.path or scriptkey>]
@script[/switch] <obj> [= script_path or <scriptkey>]
Switches:
start - start all non-running scripts on object, or a given script only
@ -2360,7 +2366,7 @@ class CmdScript(COMMAND_DEFAULT_CLASS):
caller = self.caller
if not self.args:
string = "Usage: @script[/switch] <obj> [= <script.path or script key>]"
string = "Usage: @script[/switch] <obj> [= script_path or <script key>]"
caller.msg(string)
return
@ -2561,7 +2567,7 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
Usage:
@spawn
@spawn[/switch] prototype_name
@spawn[/switch] <prototype_name>
@spawn[/switch] {prototype dictionary}
Switch:

View file

@ -16,6 +16,7 @@ from evennia.utils.eveditor import EvEditor
from evennia.utils.utils import string_suggestions, class_from_module
COMMAND_DEFAULT_CLASS = class_from_module(settings.COMMAND_DEFAULT_CLASS)
HELP_MORE = settings.HELP_MORE
# limit symbol import for API
__all__ = ("CmdHelp", "CmdSetHelp")
@ -45,9 +46,9 @@ class CmdHelp(Command):
return_cmdset = True
# Help messages are wrapped in an EvMore call (unless using the webclient
# with separate help popups) If you want to avoid this, simply set the
# 'help_more' flag to False.
help_more = True
# with separate help popups) If you want to avoid this, simply add
# 'HELP_MORE = False' in your settings/conf/settings.py
help_more = HELP_MORE
# suggestion cutoff, between 0 and 1 (1 => perfect match)
suggestion_cutoff = 0.6
@ -197,7 +198,8 @@ class CmdHelp(Command):
# retrieve all available commands and database topics
all_cmds = [cmd for cmd in cmdset if self.check_show_help(cmd, caller)]
all_topics = [topic for topic in HelpEntry.objects.all() if topic.access(caller, 'view', default=True)]
all_categories = list(set([cmd.help_category.lower() for cmd in all_cmds] + [topic.help_category.lower() for topic in all_topics]))
all_categories = list(set([cmd.help_category.lower() for cmd in all_cmds] + [topic.help_category.lower()
for topic in all_topics]))
if query in ("list", "all"):
# we want to list all available help entries, grouped by category
@ -221,7 +223,8 @@ class CmdHelp(Command):
if suggestion_maxnum > 0:
vocabulary = [cmd.key for cmd in all_cmds if cmd] + [topic.key for topic in all_topics] + all_categories
[vocabulary.extend(cmd.aliases) for cmd in all_cmds]
suggestions = [sugg for sugg in string_suggestions(query, set(vocabulary), cutoff=suggestion_cutoff, maxnum=suggestion_maxnum)
suggestions = [sugg for sugg in string_suggestions(query, set(vocabulary), cutoff=suggestion_cutoff,
maxnum=suggestion_maxnum)
if sugg != query]
if not suggestions:
suggestions = [sugg for sugg in vocabulary if sugg != query and sugg.startswith(query)]
@ -230,9 +233,9 @@ class CmdHelp(Command):
match = [cmd for cmd in all_cmds if cmd == query]
if len(match) == 1:
formatted = self.format_help_entry(match[0].key,
match[0].get_help(caller, cmdset),
aliases=match[0].aliases,
suggested=suggestions)
match[0].get_help(caller, cmdset),
aliases=match[0].aliases,
suggested=suggestions)
self.msg_help(formatted)
return
@ -240,16 +243,17 @@ class CmdHelp(Command):
match = list(HelpEntry.objects.find_topicmatch(query, exact=True))
if len(match) == 1:
formatted = self.format_help_entry(match[0].key,
match[0].entrytext,
aliases=match[0].aliases.all(),
suggested=suggestions)
match[0].entrytext,
aliases=match[0].aliases.all(),
suggested=suggestions)
self.msg_help(formatted)
return
# try to see if a category name was entered
if query in all_categories:
self.msg_help(self.format_help_list({query:[cmd.key for cmd in all_cmds if cmd.help_category==query]},
{query:[topic.key for topic in all_topics if topic.help_category==query]}))
self.msg_help(self.format_help_list({query: [cmd.key for cmd in all_cmds if cmd.help_category == query]},
{query: [topic.key for topic in all_topics
if topic.help_category == query]}))
return
# no exact matches found. Just give suggestions.
@ -263,6 +267,7 @@ def _loadhelp(caller):
else:
return ""
def _savehelp(caller, buffer):
entry = caller.db._editing_help
caller.msg("Saved help entry.")
@ -274,6 +279,7 @@ def _quithelp(caller):
caller.msg("Closing the editor.")
del caller.db._editing_help
class CmdSetHelp(COMMAND_DEFAULT_CLASS):
"""
Edit the help database.
@ -305,7 +311,7 @@ class CmdSetHelp(COMMAND_DEFAULT_CLASS):
help_category = "Building"
def func(self):
"Implement the function"
"""Implement the function"""
switches = self.switches
lhslist = self.lhslist
@ -327,7 +333,7 @@ class CmdSetHelp(COMMAND_DEFAULT_CLASS):
# check if we have an old entry with the same name
try:
for querystr in topicstrlist:
old_entry = HelpEntry.objects.find_topicmatch(querystr) # also search by alias
old_entry = HelpEntry.objects.find_topicmatch(querystr) # also search by alias
if old_entry:
old_entry = list(old_entry)[0]
break
@ -350,12 +356,12 @@ class CmdSetHelp(COMMAND_DEFAULT_CLASS):
else:
helpentry = create.create_help_entry(topicstr,
self.rhs, category=category,
locks=lockstring,aliases=aliases)
locks=lockstring, aliases=aliases)
self.caller.db._editing_help = helpentry
EvEditor(self.caller, loadfunc=_loadhelp, savefunc=_savehelp,
quitfunc=_quithelp, key="topic {}".format(topicstr),
persistent=True)
quitfunc=_quithelp, key="topic {}".format(topicstr),
persistent=True)
return
if 'append' in switches or "merge" in switches or "extend" in switches:
@ -399,21 +405,21 @@ class CmdSetHelp(COMMAND_DEFAULT_CLASS):
self.msg("Overwrote the old topic '%s'%s." % (topicstr, aliastxt))
else:
self.msg("Topic '%s'%s already exists. Use /replace to overwrite "
"or /append or /merge to add text to it." % (topicstr, aliastxt))
"or /append or /merge to add text to it." % (topicstr, aliastxt))
else:
# no old entry. Create a new one.
new_entry = create.create_help_entry(topicstr,
self.rhs, category=category,
locks=lockstring,aliases=aliases)
locks=lockstring, aliases=aliases)
if new_entry:
self.msg("Topic '%s'%s was successfully created." % (topicstr, aliastxt))
if 'edit' in switches:
# open the line editor to edit the helptext
self.caller.db._editing_help = new_entry
EvEditor(self.caller, loadfunc=_loadhelp,
savefunc=_savehelp, quitfunc=_quithelp,
key="topic {}".format(new_entry.key),
persistent=True)
savefunc=_savehelp, quitfunc=_quithelp,
key="topic {}".format(new_entry.key),
persistent=True)
return
else:
self.msg("Error when creating topic '%s'%s! Contact an admin." % (topicstr, aliastxt))