mudpy package¶
Submodules¶
mudpy.command module¶
User command functions for the mudpy engine.
- mudpy.command.c_set(actor, parameters)¶
Set a facet of an element.
- mudpy.command.chat(actor, parameters)¶
Toggle chat mode.
- mudpy.command.create(actor, parameters)¶
Create an element if it does not exist.
- mudpy.command.delete(actor, parameters)¶
Delete a facet from an element.
- mudpy.command.destroy(actor, parameters)¶
Destroy an element if it exists.
- mudpy.command.error(actor, input_data)¶
Generic error for an unrecognized command word.
- mudpy.command.evaluate(actor, parameters)¶
Evaluate a Python expression.
- mudpy.command.halt(actor, parameters)¶
Halt the world.
- mudpy.command.help(actor, parameters)¶
List available commands and provide help for commands.
- mudpy.command.look(actor, parameters)¶
Look around.
- mudpy.command.move(actor, parameters)¶
Move the avatar in a given direction.
- mudpy.command.preferences(actor, parameters)¶
List, view and change actor preferences.
- mudpy.command.quit(actor, parameters)¶
Leave the world and go back to the main menu.
- mudpy.command.reload(actor, parameters)¶
Reload all code modules, configs and data.
- mudpy.command.say(actor, parameters)¶
Speak to others in the same area.
- mudpy.command.show(actor, parameters)¶
Show program data.
mudpy.daemon module¶
- mudpy.daemon.main()¶
mudpy.data module¶
Data interface functions for the mudpy engine.
- class mudpy.data.Data(source, universe, flags=None, relative=None)¶
Bases:
object
A file containing universe elements and their facets.
- is_writeable()¶
Returns True if the _lock is False.
- load()¶
Read a file, create elements and poplulate facets accordingly.
- save()¶
Write the data, if necessary.
- mudpy.data.find_file(file_name=None, group=None, prefix=None, relative=None, search=None, stash=None, universe=None)¶
Return an absolute file path based on configuration.
mudpy.misc module¶
Miscellaneous functions for the mudpy engine.
- class mudpy.misc.Element(key, universe, origin=None)¶
Bases:
object
An element of the universe.
- ancestry()¶
Return a list of the element’s inheritance lineage.
- append(facet, value)¶
Append value to a list.
- can_run(command)¶
Check if the user can run this command object.
- clean_contents()¶
Make sure the element’s contents aren’t bogus.
- destroy()¶
Remove an element from the universe and destroy it.
- echo_to_location(message)¶
Show a message to other elements in the current location.
- facets()¶
Return a list of non-inherited facets for this element.
- get(facet, default=None)¶
Retrieve values.
- go_home()¶
Relocate the element to its default location.
- go_to(area)¶
Relocate the element to a specific area.
- has_facet(facet)¶
Return whether the non-inherited facet exists.
- is_admin()¶
Boolean check whether an actor is controlled by an admin owner.
- is_restricted()¶
Boolean check whether command is administrative or debugging.
- link_neighbor(direction)¶
Return the element linked in a given direction.
- look_at(key)¶
Show an element to another element.
- move_direction(direction)¶
Relocate the element in a specified direction.
- portals()¶
Map the portal directions for an area to neighbors.
- reload()¶
Create a new element and replace this one.
- remove_facet(facet)¶
Remove a facet from the element.
- send(message, eol='$(eol)', raw=False, flush=False, add_prompt=True, just_prompt=False, add_terminator=False, prepend_padding=True)¶
Convenience method to pass messages to an owner.
- set(facet, value)¶
Set values.
- update_location()¶
Make sure the location’s contents contain this element.
- class mudpy.misc.Universe(filename='', load=False)¶
Bases:
object
The universe.
- add_group(group, fallback=None)¶
Set up group tracking/metadata.
- debug_mode()¶
Boolean method to indicate whether unsafe debugging is enabled.
- get_time()¶
Convenience method to get the elapsed time counter.
- initialize_server_socket()¶
Create and open the listening socket.
- load()¶
Load universe data from persistent storage.
- new()¶
Create a new, empty Universe (the Big Bang).
- save()¶
Save the universe to persistent storage.
- set_time(elapsed)¶
Convenience method to set the elapsed time counter.
- class mudpy.misc.User¶
Bases:
object
This is a connected user.
- activate_avatar_by_index(index)¶
Enter the world with a particular indexed avatar.
- adjust_echoing()¶
Adjust echoing to match state menu requirements.
- authenticate()¶
Flag the user as authenticated and disconnect duplicates.
- check_idle()¶
Warn or disconnect idle users as appropriate.
- deactivate_avatar()¶
Have the active avatar leave the world.
- delete_avatar(avatar)¶
Remove an avatar from the world and from the user’s list.
- destroy()¶
Destroy the user and associated avatars.
- enqueue_input()¶
Process and enqueue any new input.
- flush()¶
Try to send the last item in the queue and remove it.
- is_admin()¶
Boolean check whether user’s account is an admin.
- list_avatar_names()¶
List names of assigned avatars.
- new_avatar()¶
Instantiate a new, unconfigured avatar for this user.
- prompt()¶
“Generate and return an input prompt.
- pulse()¶
All the things to do to the user per increment.
- quit()¶
Log, close the connection and remove.
- reload()¶
Save, load a new user and relocate the connection.
- remove()¶
Remove a user from the list of connected users.
- replace_old_connections()¶
Disconnect active users with the same name.
- send(output, eol='$(eol)', raw=False, flush=False, add_prompt=True, just_prompt=False, add_terminator=False, prepend_padding=True)¶
Send arbitrary text to a connected user.
Send the user their current menu.
- mudpy.misc.assign_sighook()¶
Assign a customized handler for some signals.
- mudpy.misc.broadcast(message, add_prompt=True)¶
Send a message to all connected users.
- mudpy.misc.call_hook_function(fname, arglist)¶
Safely execute named function with supplied arguments, return result.
- mudpy.misc.check_for_connection(listening_socket)¶
Check for a waiting connection and return a new user object.
- mudpy.misc.create_pidfile(universe)¶
Write a file containing the current process ID.
- mudpy.misc.daemonize(universe)¶
Fork and disassociate from everything.
- mudpy.misc.escape_macros(value)¶
Escapes replacement macros in text.
- mudpy.misc.excepthook(excepttype, value, tracebackdata)¶
Handle uncaught exceptions.
- mudpy.misc.find_command(command_name)¶
Try to find a command by name or abbreviation.
- mudpy.misc.finish()¶
These are functions performed when shutting down the engine.
- mudpy.misc.first_word(text, separator=' ')¶
Returns a tuple of the first word and the rest.
A generic menu choice handler.
- mudpy.misc.get_choice_action(user)¶
Run any indicated script for the given choice.
- mudpy.misc.get_choice_branch(user)¶
Returns the new state matching the given choice.
- mudpy.misc.get_default_action(state)¶
Return the default action.
- mudpy.misc.get_default_branch(state)¶
Return the default branch.
Return the default choice for a menu.
- mudpy.misc.get_echo_message(state)¶
Return a message indicating that echo is off.
Default menu choice foratted for inclusion in a prompt string.
Returns a formatted string of menu choices.
- mudpy.misc.get_loglines(level, start, stop)¶
Return a specific range of loglines filtered by level.
Show the correct menu text to a user.
Return a dict of choice:branch.
Return a dict of choice:branch.
Return a dict of choice:meaning.
Get the description or error text.
Try to get a prompt, if it was defined.
- mudpy.misc.glyph_columns(character)¶
Convenience function to return the column width of a glyph.
- mudpy.misc.handle_user_input(user)¶
The main handler, branches to a state-specific handler.
- mudpy.misc.handler_active(user)¶
Handle input for active users.
- mudpy.misc.handler_checking_password(user)¶
Handle the login account password.
- mudpy.misc.handler_entering_account_name(user)¶
Handle the login account name.
- mudpy.misc.handler_entering_new_password(user)¶
Handle a new password entry.
- mudpy.misc.handler_verifying_new_password(user)¶
Handle the re-entered new password for verification.
- mudpy.misc.log(message, level=0)¶
Log a message.
True if echo is on, false if it is off.
- mudpy.misc.on_pulse()¶
The things which should happen on each pulse, aside from reloads.
- mudpy.misc.override_excepthook()¶
Redefine sys.excepthook with our own.
- mudpy.misc.random_name()¶
Returns a random character name.
- mudpy.misc.reload_data()¶
Reload all relevant objects.
- mudpy.misc.remove_pidfile(universe)¶
Remove the file containing the current process ID.
- mudpy.misc.replace_macros(user, text, is_input=False)¶
Replaces macros in text output.
- mudpy.misc.setup()¶
This contains functions to be performed when starting the engine.
- mudpy.misc.sighook(what, where)¶
Handle external signals.
- mudpy.misc.weighted_choice(data)¶
Takes a dict weighted by value and returns a random key.
- mudpy.misc.wrap_ansi_text(text, width)¶
Wrap text with arbitrary width while ignoring ANSI colors.
mudpy.password module¶
Password hashing functions and constants for the mudpy engine.
- mudpy.password.create(password)¶
- mudpy.password.verify(password, encoded_hash)¶
mudpy.telnet module¶
Telnet functions and constants for the mudpy engine.
- mudpy.telnet.disable(user, telopt, party)¶
Negotiates disabling a Telnet option for the user’s socket.
- mudpy.telnet.enable(user, telopt, party)¶
Negotiates enabling a Telnet option for the indicated user’s socket.
- mudpy.telnet.is_enabled(user, telopt, party, state=1)¶
Indicates whether a specified Telnet option is enabled.
- mudpy.telnet.log(message, user)¶
Log debugging info for Telnet client/server interactions.
- mudpy.telnet.negotiate_telnet_options(user)¶
Reply to and remove telnet negotiation options from partial_input.
- mudpy.telnet.request_ttype(user)¶
Clear and request the terminal type.
- mudpy.telnet.send_command(user, *command)¶
Sends a Telnet command string to the specified user’s socket.
- mudpy.telnet.telnet_proto(*arguments)¶
Return a concatenated series of Telnet protocol commands.
- mudpy.telnet.translate_action(*command)¶
Convert a Telnet command sequence into text suitable for logging.
mudpy.version module¶
Version and diagnostic information for the mudpy engine.
- class mudpy.version.VersionDetail(package)¶
Bases:
object
Version detail for a Python package.
- class mudpy.version.Versions(project_name)¶
Bases:
object
Tracks info on known Python package versions.
Module contents¶
Core modules package for the mudpy engine.
- mudpy.load()¶
Import/reload some modules (be careful, as this can result in loops).