1. mudpy package

1.1. Submodules

1.2. mudpy.daemon module

mudpy.daemon.main()

1.3. 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.

1.4. 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.

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.

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.

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.

list_avatar_names()

List names of assigned avatars.

new_avatar()

Instantiate a new, unconfigured avatar for this user.

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.

show_menu()

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.check_for_connection(listening_socket)

Check for a waiting connection and return a new user object.

mudpy.misc.command_chat(actor)

Toggle chat mode.

mudpy.misc.command_create(actor, parameters)

Create an element if it does not exist.

mudpy.misc.command_delete(actor, parameters)

Delete a facet from an element.

mudpy.misc.command_destroy(actor, parameters)

Destroy an element if it exists.

mudpy.misc.command_error(actor, input_data)

Generic error for an unrecognized command word.

mudpy.misc.command_halt(actor, parameters)

Halt the world.

mudpy.misc.command_help(actor, parameters)

List available commands and provide help for commands.

mudpy.misc.command_look(actor, parameters)

Look around.

mudpy.misc.command_move(actor, parameters)

Move the avatar in a given direction.

mudpy.misc.command_quit(actor)

Leave the world and go back to the main menu.

mudpy.misc.command_reload(actor)

Reload all code modules, configs and data.

mudpy.misc.command_say(actor, parameters)

Speak to others in the same area.

mudpy.misc.command_set(actor, parameters)

Set a facet of an element.

mudpy.misc.command_show(actor, parameters)

Show program data.

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.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.

mudpy.misc.generic_menu_handler(user)

A generic menu choice handler.

mudpy.misc.get_choice_action(user, choice)

Run any indicated script for the given choice.

mudpy.misc.get_choice_branch(user, choice)

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.

mudpy.misc.get_default_menu_choice(state)

Return the default choice for a menu.

mudpy.misc.get_echo_message(state)

Return a message indicating that echo is off.

mudpy.misc.get_formatted_default_menu_choice(state)

Default menu choice foratted for inclusion in a prompt string.

mudpy.misc.get_formatted_menu_choices(state, choices)

Returns a formatted string of menu choices.

mudpy.misc.get_loglines(level, start, stop)

Return a specific range of loglines filtered by level.

mudpy.misc.get_menu(state, error=None, choices=None)

Show the correct menu text to a user.

mudpy.misc.get_menu_actions(state)

Return a dict of choice:branch.

mudpy.misc.get_menu_branches(state)

Return a dict of choice:branch.

mudpy.misc.get_menu_choices(user)

Return a dict of choice:meaning.

mudpy.misc.get_menu_description(state, error)

Get the description or error text.

mudpy.misc.get_menu_prompt(state)

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.

mudpy.misc.menu_echo_on(state)

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.

1.5. mudpy.password module

Password hashing functions and constants for the mudpy engine.

mudpy.password.create(password)
mudpy.password.verify(password, encoded_hash)

1.6. 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.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.

1.7. 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.

1.8. Module contents

Core modules package for the mudpy engine.

mudpy.load()

Import/reload some modules (be careful, as this can result in loops).