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

Utility functions for menu operation.

mudpy.menu.activate_avatar_action(user)

Activate the selected avatar in the activate_avatar state.

mudpy.menu.activate_avatar_action_a(user)

Abort selection by doing nothing.

mudpy.menu.activate_avatar_create(user)

List available avatars as choices for the activate_avatar state.

mudpy.menu.checking_new_account_name_action_d(user)

Destroy the new account because the user asked to disconnect.

mudpy.menu.checking_new_account_name_action_g(user)

Destroy the new account, the user asked to go back to name entry.

mudpy.menu.choose_gender_action(user)

Set the avatar’s gender to the selected value.

mudpy.menu.choose_name_action(user)

Set the avatar’s name to the selected value.

mudpy.menu.choose_name_create_1(user)

Provide a randomly-generated name as choice 1.

mudpy.menu.choose_name_create_2(user)

Provide a randomly-generated name as choice 2.

mudpy.menu.choose_name_create_3(user)

Provide a randomly-generated name as choice 3.

mudpy.menu.choose_name_create_4(user)

Provide a randomly-generated name as choice 4.

mudpy.menu.choose_name_create_5(user)

Provide a randomly-generated name as choice 5.

mudpy.menu.choose_name_create_6(user)

Provide a randomly-generated name as choice 6.

mudpy.menu.choose_name_create_7(user)

Provide a randomly-generated name as choice 7.

mudpy.menu.delete_account_action_y(user)

Permanently delete the account and all avatars, as requested.

mudpy.menu.delete_avatar_action(user)

Delete the selected avatar.

mudpy.menu.delete_avatar_action_a(user)

Abort avatar deletion.

mudpy.menu.delete_avatar_create(user)

List available avatars for possible deletion.

mudpy.menu.main_utility_action_c(user)

Create a new avatar.

mudpy.menu.main_utility_demand_a(user)

Only include avatar activation if the account has avatars.

mudpy.menu.main_utility_demand_c(user)

Only include avatar creation if avatar count is below the limit.

mudpy.menu.main_utility_demand_d(user)

Only include avatar deletion if the account has avatars.

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.

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.

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

mudpy.misc.generic_menu_handler(user)

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.

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.

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