Table of Contents

Module: utils mudlib/utils.py

Holds utility functions that should get called from mudlib things, but never by regular coders.

Imported modules   
import re
import string
import time
import types
Functions   
date_string
evaluateVBFC
format_human_time
parse_filename
parse_first_semicolon
parse_out_flags
parse_path
  date_string 
date_string ()

Returns a the localtime string in the form of MM-DD-YYYY.

returns:

(string) the localtime string in MM-DD-YYYY format

  evaluateVBFC 
evaluateVBFC ( tokens )

Evalutes a tuple of tokens. Each token is either a string, or a callable object that returns a string (such as a VBFC). If it's a string, it's appended to the message being generated. If it's callable, the object is called and its return value is appended to the message being generated. After all tokens are evaluated, the message is returned.

arguments:

tokens
(list of VBFCs and strings)

returns:

(string)

  format_human_time 
format_human_time ( secs )

Takes in a bunch of seconds and formats it into a string of days/hours/minutes/seconds.

This is horribly written and I don't even know if it should go here either.... but it works!

arguments:

secs
(int) the interval in seconds

returns:

(string) a human-readable form of that interval

  parse_filename 
parse_filename ( path )

Parses a filename from a given filepath.

Parses a filename (actually, it just removes from the last / to the beginning).

ex: /world/data/blah -> blah

arguments:

path
(string) the path that includes a filename

returns:

(string)

  parse_first_semicolon 
parse_first_semicolon ( text )

This method takens in text and parses it into two pieces. The first piece is everything up to the first ; and that is not \; The second piece is everything else.

arguments:

text
(string) the text to parse the first semicolon from

returns:

if a semicolon is found that's unescaped, it returns the text up to the first semicolon and then the rest in a list.

otherwise it returns the text.

  parse_out_flags 
parse_out_flags ( list )

Takes a command line thingy and separates flags from non-flags. This could probably be done better.... :)

FIXME - get rid of this function and use the getopts methods instead.

arguments:

list
(list of strings) -- the arguments

returns:

two lists--the first is a lsit of flags and the second is a list of non-flags

  parse_path 
parse_path (
        home_dir,
        cur_dir,
        path,
        )

Parses relative path and returns an explicit path.

Takes in a home_dir, a current_dir and a path and parses the path string into an actual path relative to the root of the mud directory tree.

Handles ., .., ~, /, and some funky instances like if they have too many .. or they have // next to each other or misplaced ~.

arguments:

home_dir
(string) the home directory for the coder
cur_dir
(string) the current directory the coder is in
path
(string) the path to parse relative to either the current dir (cur_dir) or the home dir (home_dir)

returns:

(string) the explicit dir based on the mud root directory

Classes   
PatternMatcher

A finite state machine with no cycles.


Table of Contents

This document was automatically generated on Thu Jan 24 08:57:43 2002 by HappyDoc version 2.0