evennia.commands.default.batchprocess

Batch processors

These commands implements the ‘batch-command’ and ‘batch-code’ processors, using the functionality in evennia.utils.batchprocessors. They allow for offline world-building.

Batch-command is the simpler system. This reads a file (*.ev) containing a list of in-game commands and executes them in sequence as if they had been entered in the game (including permission checks etc).

Batch-code is a full-fledged python code interpreter that reads blocks of python code (*.py) and executes them in sequence. This allows for much more power than Batch-command, but requires knowing Python and the Evennia API. It is also a severe security risk and should therefore always be limited to superusers only.

class evennia.commands.default.batchprocess.CmdBatchCommands(**kwargs)[source]

Bases: MuxCommand

build from batch-command file

Usage:

batchcommands[/interactive] <python.path.to.file>

Switch:
interactive - this mode will offer more control when

executing the batch file, like stepping, skipping, reloading etc.

Runs batches of commands from a batch-cmd text file (*.ev).

key = 'batchcommands'
aliases = ['batchcmd', 'batchcommand']
switch_options = ('interactive',)
locks = 'cmd:perm(batchcommands) or perm(Developer)'
help_category = 'building'
func()[source]

Starts the processor.

lock_storage = 'cmd:perm(batchcommands) or perm(Developer)'
search_index_entry = {'aliases': 'batchcmd batchcommand', 'category': 'building', 'key': 'batchcommands', 'no_prefix': ' batchcmd batchcommand', 'tags': '', 'text': '\nbuild from batch-command file\n\nUsage:\n batchcommands[/interactive] <python.path.to.file>\n\nSwitch:\n   interactive - this mode will offer more control when\n                 executing the batch file, like stepping,\n                 skipping, reloading etc.\n\nRuns batches of commands from a batch-cmd text file (*.ev).\n\n'}
class evennia.commands.default.batchprocess.CmdBatchCode(**kwargs)[source]

Bases: MuxCommand

build from batch-code file

Usage:

batchcode[/interactive] <python path to file>

Switch:
interactive - this mode will offer more control when

executing the batch file, like stepping, skipping, reloading etc.

debug - auto-delete all objects that has been marked as

deletable in the script file (see example files for syntax). This is useful so as to to not leave multiple object copies behind when testing out the script.

Runs batches of commands from a batch-code text file (*.py).

key = 'batchcode'
aliases = ['batchcodes']
switch_options = ('interactive', 'debug')
locks = 'cmd:superuser()'
help_category = 'building'
func()[source]

Starts the processor.

lock_storage = 'cmd:superuser()'
search_index_entry = {'aliases': 'batchcodes', 'category': 'building', 'key': 'batchcode', 'no_prefix': ' batchcodes', 'tags': '', 'text': '\nbuild from batch-code file\n\nUsage:\n batchcode[/interactive] <python path to file>\n\nSwitch:\n   interactive - this mode will offer more control when\n                 executing the batch file, like stepping,\n                 skipping, reloading etc.\n   debug - auto-delete all objects that has been marked as\n           deletable in the script file (see example files for\n           syntax). This is useful so as to to not leave multiple\n           object copies behind when testing out the script.\n\nRuns batches of commands from a batch-code text file (*.py).\n\n'}
class evennia.commands.default.batchprocess.BatchInteractiveCmdSet(cmdsetobj=None, key=None)[source]

Bases: CmdSet

The cmdset for the interactive batch processor mode.

key = 'Batch_interactive'
priority = 104
at_cmdset_creation()[source]

init the cmdset

path = 'evennia.commands.default.batchprocess.BatchInteractiveCmdSet'
class evennia.commands.default.batchprocess.BatchSafeCmdSet(cmdsetobj=None, key=None)[source]

Bases: CmdSet

The base cmdset for the batch processor. This sets a ‘safe’ abort command that will always be available to get out of everything.

key = 'Batch_default'
priority = 150
at_cmdset_creation()[source]

Init the cmdset

path = 'evennia.commands.default.batchprocess.BatchSafeCmdSet'
class evennia.commands.default.batchprocess.CmdSet(cmdsetobj=None, key=None)[source]

Bases: object

This class describes a unique cmdset that understands priorities. CmdSets can be merged and made to perform various set operations on each other. CmdSets have priorities that affect which of their ingoing commands gets used.

In the examples, cmdset A always have higher priority than cmdset B.

key - the name of the cmdset. This can be used on its own for game operations

mergetype (partly from Set theory):

Union - The two command sets are merged so that as many

commands as possible of each cmdset ends up in the merged cmdset. Same-name commands are merged by priority. This is the most common default. Ex: A1,A3 + B1,B2,B4,B5 = A1,B2,A3,B4,B5

Intersect - Only commands found in both cmdsets

(i.e. which have same names) end up in the merged cmdset, with the higher-priority cmdset replacing the lower one. Ex: A1,A3 + B1,B2,B4,B5 = A1

Replace - The commands of this cmdset completely replaces

the lower-priority cmdset’s commands, regardless of if same-name commands exist. Ex: A1,A3 + B1,B2,B4,B5 = A1,A3

Remove - This removes the relevant commands from the

lower-priority cmdset completely. They are not replaced with anything, so this in effects uses the high-priority cmdset as a filter to affect the low-priority cmdset. Ex: A1,A3 + B1,B2,B4,B5 = B2,B4,B5

Note: Commands longer than 2 characters and starting

with double underscrores, like ‘__noinput_command’ are considered ‘system commands’ and are excempt from all merge operations - they are ALWAYS included across mergers and only affected if same-named system commands replace them.

priority- All cmdsets are always merged in pairs of two so that

the higher set’s mergetype is applied to the lower-priority cmdset. Default commands have priority 0, high-priority ones like Exits and Channels have 10 and 9. Priorities can be negative as well to give default commands preference.

duplicates - determines what happens when two sets of equal

priority merge (only). Defaults to None and has the first of them in the merger (i.e. A above) automatically taking precedence. But if duplicates is true, the result will be a merger with more than one of each name match. This will usually lead to the account receiving a multiple-match error higher up the road, but can be good for things like cmdsets on non-account objects in a room, to allow the system to warn that more than one ‘ball’ in the room has the same ‘kick’ command defined on it, so it may offer a chance to select which ball to kick … Allowing duplicates only makes sense for Union and Intersect, the setting is ignored for the other mergetypes. Note that the duplicates flag is not propagated in a cmdset merger. So A + B = C will result in a cmdset with duplicate commands, but C.duplicates will be None. For duplication to apply to a whole cmdset stack merge, _all_ cmdsets in the stack must have .duplicates=True set.

Finally, if a final cmdset has .duplicates=None (the normal unless created alone with another value), the cmdhandler will assume True for object-based cmdsets and False for all other. This is usually the most intuitive outcome.

key_mergetype (dict) - allows the cmdset to define a unique

mergetype for particular cmdsets. Format is {CmdSetkeystring:mergetype}. Priorities still apply. Example: {‘Myevilcmdset’,’Replace’} which would make sure for this set to always use ‘Replace’ on Myevilcmdset no matter what overall mergetype this set has.

no_objs - don’t include any commands from nearby objects

when searching for suitable commands

no_exits - ignore the names of exits when matching against

commands

no_channels - ignore the name of channels when matching against

commands (WARNING- this is dangerous since the account can then not even ask staff for help if something goes wrong)

__init__(cmdsetobj=None, key=None)[source]

Creates a new CmdSet instance.

Parameters:
  • cmdsetobj (Session, Account, Object, optional) – This is the database object to which this particular instance of cmdset is related. It is often a character but may also be a regular object, Account or Session.

  • key (str, optional) – The idenfier for this cmdset. This helps if wanting to selectively remov cmdsets.

add(cmd, allow_duplicates=False)[source]

Add a new command or commands to this CmdSet, a list of commands or a cmdset to this cmdset. Note that this is not a merge operation (that is handled by the + operator).

Parameters:
  • cmd (Command, list, Cmdset) – This allows for adding one or more commands to this Cmdset in one go. If another Cmdset is given, all its commands will be added.

  • allow_duplicates (bool, optional) – If set, will not try to remove duplicate cmds in the set. This is needed during the merge process to avoid wiping commands coming from cmdsets with duplicate=True.

Notes

If cmd already exists in set, it will replace the old one (no priority checking etc happens here). This is very useful when overloading default commands).

If cmd is another cmdset class or -instance, the commands of that command set is added to this one, as if they were part of the original cmdset definition. No merging or priority checks are made, rather later added commands will simply replace existing ones to make a unique set.

at_cmdset_creation()[source]

Hook method - this should be overloaded in the inheriting class, and should take care of populating the cmdset by use of self.add().

count()[source]

Number of commands in set.

Returns:

N (int) – Number of commands in this Cmdset.

duplicates = None
errmessage = ''
get(cmd)[source]

Get a command from the cmdset. This is mostly useful to check if the command is part of this cmdset or not.

Parameters:

cmd (Command or str) – Either the Command object or its key.

Returns:

cmd (Command) – The first matching Command in the set.

get_all_cmd_keys_and_aliases(caller=None)[source]

Collects keys/aliases from commands

Parameters:

caller (Object, optional) – If set, this is used to check access permissions on each command. Only commands that pass are returned.

Returns:

names (list)

A list of all command keys and aliases in this cmdset. If caller

was given, this list will only contain commands to which caller passed the call locktype check.

get_system_cmds()[source]

Get system commands in cmdset

Returns:

sys_cmds (list) – The system commands in the set.

Notes

As far as the Cmdset is concerned, system commands are any commands with a key starting with double underscore __. These are excempt from merge operations.

key = 'Unnamed CmdSet'
key_mergetypes = {}
make_unique(caller)[source]

Remove duplicate command-keys (unsafe)

Parameters:

caller (object) – Commands on this object will get preference in the duplicate removal.

Notes

This is an unsafe command meant to clean out a cmdset of doublet commands after it has been created. It is useful for commands inheriting cmdsets from the cmdhandler where obj-based cmdsets always are added double. Doublets will be weeded out with preference to commands defined on caller, otherwise just by first-come-first-served.

mergetype = 'Union'
no_channels = None
no_exits = None
no_objs = None
path = 'evennia.commands.cmdset.CmdSet'
persistent = False
priority = 0
remove(cmd)[source]

Remove a command instance from the cmdset.

Parameters:

cmd (Command or str) – Either the Command object to remove or the key of such a command.

to_duplicate = ('key', 'cmdsetobj', 'no_exits', 'no_objs', 'no_channels', 'persistent', 'mergetype', 'priority', 'duplicates', 'errmessage')
class evennia.commands.default.batchprocess.CmdStateAbort(**kwargs)[source]

Bases: MuxCommand

abort

This is a safety feature. It force-ejects us out of the processor and to the default cmdset, regardless of what current cmdset the processor might have put us in (e.g. when testing buggy scripts etc).

key = 'abort'
help_category = 'batchprocess'
locks = 'cmd:perm(batchcommands) or perm(Developer)'
func()[source]

Exit back to default.

aliases = []
lock_storage = 'cmd:perm(batchcommands) or perm(Developer)'
search_index_entry = {'aliases': '', 'category': 'batchprocess', 'key': 'abort', 'no_prefix': ' ', 'tags': '', 'text': '\nabort\n\nThis is a safety feature. It force-ejects us out of the processor and to\nthe default cmdset, regardless of what current cmdset the processor might\nhave put us in (e.g. when testing buggy scripts etc).\n'}
class evennia.commands.default.batchprocess.CmdStateBB(**kwargs)[source]

Bases: MuxCommand

bb

Backwards to previous command. No commands are executed.

key = 'bb'
help_category = 'batchprocess'
locks = 'cmd:perm(batchcommands) or perm(Developer)'
func()[source]
This is the hook function that actually does all the work. It is called

by the cmdhandler right after self.parser() finishes, and so has access to all the variables defined therein.

aliases = []
lock_storage = 'cmd:perm(batchcommands) or perm(Developer)'
search_index_entry = {'aliases': '', 'category': 'batchprocess', 'key': 'bb', 'no_prefix': ' ', 'tags': '', 'text': '\nbb\n\nBackwards to previous command. No commands\nare executed.\n'}
class evennia.commands.default.batchprocess.CmdStateBL(**kwargs)[source]

Bases: MuxCommand

bl

Backwards to previous command, viewing its full source. No commands are executed.

key = 'bl'
help_category = 'batchprocess'
locks = 'cmd:perm(batchcommands) or perm(Developer)'
func()[source]
This is the hook function that actually does all the work. It is called

by the cmdhandler right after self.parser() finishes, and so has access to all the variables defined therein.

aliases = []
lock_storage = 'cmd:perm(batchcommands) or perm(Developer)'
search_index_entry = {'aliases': '', 'category': 'batchprocess', 'key': 'bl', 'no_prefix': ' ', 'tags': '', 'text': '\nbl\n\nBackwards to previous command, viewing its full\nsource. No commands are executed.\n'}
class evennia.commands.default.batchprocess.CmdStateCC(**kwargs)[source]

Bases: MuxCommand

cc

Continue to process all remaining commands.

key = 'cc'
help_category = 'batchprocess'
locks = 'cmd:perm(batchcommands) or perm(Developer)'
func()[source]
This is the hook function that actually does all the work. It is called

by the cmdhandler right after self.parser() finishes, and so has access to all the variables defined therein.

aliases = []
lock_storage = 'cmd:perm(batchcommands) or perm(Developer)'
search_index_entry = {'aliases': '', 'category': 'batchprocess', 'key': 'cc', 'no_prefix': ' ', 'tags': '', 'text': '\ncc\n\nContinue to process all remaining\ncommands.\n'}
class evennia.commands.default.batchprocess.CmdStateHH(**kwargs)[source]

Bases: MuxCommand

Help command

key = 'hh'
help_category = 'batchprocess'
locks = 'cmd:perm(batchcommands) or perm(Developer)'
func()[source]
This is the hook function that actually does all the work. It is called

by the cmdhandler right after self.parser() finishes, and so has access to all the variables defined therein.

aliases = []
lock_storage = 'cmd:perm(batchcommands) or perm(Developer)'
search_index_entry = {'aliases': '', 'category': 'batchprocess', 'key': 'hh', 'no_prefix': ' ', 'tags': '', 'text': 'Help command'}
class evennia.commands.default.batchprocess.CmdStateJJ(**kwargs)[source]

Bases: MuxCommand

jj <command number>

Jump to specific command number

key = 'jj'
help_category = 'batchprocess'
locks = 'cmd:perm(batchcommands) or perm(Developer)'
func()[source]
This is the hook function that actually does all the work. It is called

by the cmdhandler right after self.parser() finishes, and so has access to all the variables defined therein.

aliases = []
lock_storage = 'cmd:perm(batchcommands) or perm(Developer)'
search_index_entry = {'aliases': '', 'category': 'batchprocess', 'key': 'jj', 'no_prefix': ' ', 'tags': '', 'text': '\njj <command number>\n\nJump to specific command number\n'}
class evennia.commands.default.batchprocess.CmdStateJL(**kwargs)[source]

Bases: MuxCommand

jl <command number>

Jump to specific command number and view its full source.

key = 'jl'
help_category = 'batchprocess'
locks = 'cmd:perm(batchcommands) or perm(Developer)'
func()[source]
This is the hook function that actually does all the work. It is called

by the cmdhandler right after self.parser() finishes, and so has access to all the variables defined therein.

aliases = []
lock_storage = 'cmd:perm(batchcommands) or perm(Developer)'
search_index_entry = {'aliases': '', 'category': 'batchprocess', 'key': 'jl', 'no_prefix': ' ', 'tags': '', 'text': '\njl <command number>\n\nJump to specific command number and view its full source.\n'}
class evennia.commands.default.batchprocess.CmdStateLL(**kwargs)[source]

Bases: MuxCommand

ll

Look at the full source for the current command definition.

key = 'll'
help_category = 'batchprocess'
locks = 'cmd:perm(batchcommands) or perm(Developer)'
func()[source]
This is the hook function that actually does all the work. It is called

by the cmdhandler right after self.parser() finishes, and so has access to all the variables defined therein.

aliases = []
lock_storage = 'cmd:perm(batchcommands) or perm(Developer)'
search_index_entry = {'aliases': '', 'category': 'batchprocess', 'key': 'll', 'no_prefix': ' ', 'tags': '', 'text': '\nll\n\nLook at the full source for the current\ncommand definition.\n'}
class evennia.commands.default.batchprocess.CmdStateNL(**kwargs)[source]

Bases: MuxCommand

nl

Go to next command, viewing its full source. No commands are executed.

key = 'nl'
help_category = 'batchprocess'
locks = 'cmd:perm(batchcommands) or perm(Developer)'
func()[source]
This is the hook function that actually does all the work. It is called

by the cmdhandler right after self.parser() finishes, and so has access to all the variables defined therein.

aliases = []
lock_storage = 'cmd:perm(batchcommands) or perm(Developer)'
search_index_entry = {'aliases': '', 'category': 'batchprocess', 'key': 'nl', 'no_prefix': ' ', 'tags': '', 'text': '\nnl\n\nGo to next command, viewing its full source.\nNo commands are executed.\n'}
class evennia.commands.default.batchprocess.CmdStateNN(**kwargs)[source]

Bases: MuxCommand

nn

Go to next command. No commands are executed.

key = 'nn'
help_category = 'batchprocess'
locks = 'cmd:perm(batchcommands) or perm(Developer)'
func()[source]
This is the hook function that actually does all the work. It is called

by the cmdhandler right after self.parser() finishes, and so has access to all the variables defined therein.

aliases = []
lock_storage = 'cmd:perm(batchcommands) or perm(Developer)'
search_index_entry = {'aliases': '', 'category': 'batchprocess', 'key': 'nn', 'no_prefix': ' ', 'tags': '', 'text': '\nnn\n\nGo to next command. No commands are executed.\n'}
class evennia.commands.default.batchprocess.CmdStatePP(**kwargs)[source]

Bases: MuxCommand

pp

Process the currently shown command definition.

key = 'pp'
help_category = 'batchprocess'
locks = 'cmd:perm(batchcommands) or perm(Developer)'
func()[source]

This checks which type of processor we are running.

aliases = []
lock_storage = 'cmd:perm(batchcommands) or perm(Developer)'
search_index_entry = {'aliases': '', 'category': 'batchprocess', 'key': 'pp', 'no_prefix': ' ', 'tags': '', 'text': '\npp\n\nProcess the currently shown command definition.\n'}
class evennia.commands.default.batchprocess.CmdStateQQ(**kwargs)[source]

Bases: MuxCommand

qq

Quit the batchprocessor.

key = 'qq'
help_category = 'batchprocess'
locks = 'cmd:perm(batchcommands) or perm(Developer)'
func()[source]
This is the hook function that actually does all the work. It is called

by the cmdhandler right after self.parser() finishes, and so has access to all the variables defined therein.

aliases = []
lock_storage = 'cmd:perm(batchcommands) or perm(Developer)'
search_index_entry = {'aliases': '', 'category': 'batchprocess', 'key': 'qq', 'no_prefix': ' ', 'tags': '', 'text': '\nqq\n\nQuit the batchprocessor.\n'}
class evennia.commands.default.batchprocess.CmdStateRR(**kwargs)[source]

Bases: MuxCommand

rr

Reload the batch file, keeping the current position in it.

key = 'rr'
help_category = 'batchprocess'
locks = 'cmd:perm(batchcommands) or perm(Developer)'
func()[source]
This is the hook function that actually does all the work. It is called

by the cmdhandler right after self.parser() finishes, and so has access to all the variables defined therein.

aliases = []
lock_storage = 'cmd:perm(batchcommands) or perm(Developer)'
search_index_entry = {'aliases': '', 'category': 'batchprocess', 'key': 'rr', 'no_prefix': ' ', 'tags': '', 'text': '\nrr\n\nReload the batch file, keeping the current\nposition in it.\n'}
class evennia.commands.default.batchprocess.CmdStateRRR(**kwargs)[source]

Bases: MuxCommand

rrr

Reload the batch file, starting over from the beginning.

key = 'rrr'
help_category = 'batchprocess'
locks = 'cmd:perm(batchcommands) or perm(Developer)'
func()[source]
This is the hook function that actually does all the work. It is called

by the cmdhandler right after self.parser() finishes, and so has access to all the variables defined therein.

aliases = []
lock_storage = 'cmd:perm(batchcommands) or perm(Developer)'
search_index_entry = {'aliases': '', 'category': 'batchprocess', 'key': 'rrr', 'no_prefix': ' ', 'tags': '', 'text': '\nrrr\n\nReload the batch file, starting over\nfrom the beginning.\n'}
class evennia.commands.default.batchprocess.CmdStateSL(**kwargs)[source]

Bases: MuxCommand

sl [steps]

Process current command, then step to the next one, viewing its full source. If steps is given, process this many commands.

key = 'sl'
help_category = 'batchprocess'
locks = 'cmd:perm(batchcommands) or perm(Developer)'
func()[source]
This is the hook function that actually does all the work. It is called

by the cmdhandler right after self.parser() finishes, and so has access to all the variables defined therein.

aliases = []
lock_storage = 'cmd:perm(batchcommands) or perm(Developer)'
search_index_entry = {'aliases': '', 'category': 'batchprocess', 'key': 'sl', 'no_prefix': ' ', 'tags': '', 'text': '\nsl [steps]\n\nProcess current command, then step to the next\none, viewing its full source. If steps is given,\nprocess this many commands.\n'}
class evennia.commands.default.batchprocess.CmdStateSS(**kwargs)[source]

Bases: MuxCommand

ss [steps]

Process current command, then step to the next one. If steps is given, process this many commands.

key = 'ss'
help_category = 'batchprocess'
locks = 'cmd:perm(batchcommands) or perm(Developer)'
func()[source]
This is the hook function that actually does all the work. It is called

by the cmdhandler right after self.parser() finishes, and so has access to all the variables defined therein.

aliases = []
lock_storage = 'cmd:perm(batchcommands) or perm(Developer)'
search_index_entry = {'aliases': '', 'category': 'batchprocess', 'key': 'ss', 'no_prefix': ' ', 'tags': '', 'text': '\nss [steps]\n\nProcess current command, then step to the next\none. If steps is given,\nprocess this many commands.\n'}
evennia.commands.default.batchprocess.batch_cmd_exec(caller)[source]

Helper function for executing a single batch-command entry

evennia.commands.default.batchprocess.batch_code_exec(caller)[source]

Helper function for executing a single batch-code entry

evennia.commands.default.batchprocess.format_code(entry)[source]

Formats the viewing of code and errors

evennia.commands.default.batchprocess.format_header(caller, entry)[source]

Formats a header

evennia.commands.default.batchprocess.purge_processor(caller)[source]

This purges all effects running on the caller.

evennia.commands.default.batchprocess.show_curr(caller, showall=False)[source]

Show the current position in stack

evennia.commands.default.batchprocess.step_pointer(caller, step=1)[source]

Step in stack, returning the item located.

stackptr - current position in stack stack - the stack of units step - how many steps to move from stackptr