Includes Scheduler, Event, Command, Parser, Verb, and BaseThing (=Noun?)
Also a number of utility functions. I'm a little
disturbed by things like "cap" which simply call
Python library functions -- not sure that we need
such a wrapper, as it likely increases the learning
curve for working with the code. (?) On the other
hand, if used frequently enough, it might clarify
the code. If so, we need to add comments to define
what these things do.
Imported modules
|
|
import adapters
from constants import *
import copy
from interfaces import ISymbol, ILang, IParser
from protocols import adapt, advise
import pub
import random
import re
import string
import types
|
Functions
|
|
|
|
AddVerb
|
AddVerb ( *pVerbs )
AddVerb:
add a verb or list of verbs, singly, as a list, or
separated with commas add a verb or list of verbs, singly, as a list, or separated with commas
|
|
chainLinker
|
chainLinker (
obj,
proto,
default=None,
)
a function that generates a chain
used by, for instance invoke to get at all verb methods in an object.
we can add more functionality here but it's probably best to keep it to
a minimum.
- chainLinker
- Used by the component driven object system
|
|
find
|
find (
obj,
proto,
default=None,
)
minimal interface to chainLinker that simply finds out if an object has a
component that matches the protocol and returns it. If there are more or
less than one an error is raised.
- find
- used by the component driven object system
Exceptions
|
|
pub.errors.ComponentError, "No such component"
pub.errors.ComponentError, "Too many components match"
|
|
|
invoke
|
invoke (
obj,
proto,
meth,
cmd=None,
output=True,
)
invoke is used to run methods in an objects components that can be adapted
to a interface of choice. It can also be used to generate output based on
cmd, or to suppress it. Note: invoke is only use for verb methods. If you want to access other
methods in other ways use chainLinker or other functions that might be
provided.
calling invoke without a cmd gives different responses depending on the
actuall method called. All methods should be able to handle None as value.
Mostly it will result in either an error or immediate execution.
like: invoke(door, IOpen, open ) will try to set the doors state to isOpen
and just let everyone know that the door was opened.
- invoke
- used by the component driven object system
Exceptions
|
|
AttributeError, "Attribute can't be found"
|
|
|
isInstance
|
isInstance ( x )
function to determine whether it's an Instance
|
|
isInt
|
isInt ( x )
function to determine whether it's a number, or interpretable as one
|
|
isString
|
isString ( x )
function to determine whether something is a string
|
|
lingo
|
lingo ( obj, proto )
lingo is used for instances when we want to find the right language.
- lingo
- a language finder
|
|
restoregame
|
restoregame ( filename='pub.dat', quiet=FALSE )
Restore a game.
|
|
savegame
|
savegame ( filename='pub.dat', quiet=FALSE )
Save the game.
|
|
stripPunctuation
|
stripPunctuation ( str )
function to strip commas and periods from a string
|
|
toInt
|
toInt ( x )
function to force it to be a number
|
Classes
|
|
|
|