Module hermes
[frames | no frames]

Module hermes

Interface to the Hermes External API.

Overview

This module provides a variety of utility routines used to interface to the Hermes BBS through the Hermes External API.

Importing

This module is safe to import into your namespace using the from ... import * directive:
   from hermes import *
The above import statement is the recommended way of importing the hermes module into your Python files.

Data Attributes

In addition to the functions and constants defined in this module, the Hermes External Runtime will bind a number of additional attributes to this module. These attributes are used to access data contained within the Hermes BBS.

Each of these attributes is an object representing a portion of the Hermes BBS (the BBS itself, a user record, etc.). In addition, each of these objects contains a special data object that the external can use to store data about that object. Properties assigned to the data object must be one of the Python primitive types: numbers, strings, lists, tuples or dictionaries. Trying to store any other type of data will result in an exception being thrown.

More information about these data attributes can be found by reading the documentation for each of the classes listed under the "Property Classes" section of this page.

Resources

The Hermes External Runtime uses the concept of a resource to store string lists, text files and menus for use by an external. A number of functions are provided by the hermes module for accessing these resources. See the "Resources" section of the documentation for descriptions of the various functions.

There are three different types of resources currently understood by the hermes module: menu, strings and text. Each resource is stored as a file in the external's distribution package in a directory with the same name as the resource type. All of the resource directories are stored under the resource directory at the root of the external's package.

The contents of the package for a sample external might look like this: This sample external has two string lists (ErrorList and MessageList) and two text files (Help and Welcome). These resources can be accessed using functions in the hermes module. For example, to print the Welcome text file:
   printTextFile('Welcome')

The printTextFile function will load the Welcome resource, select the appropriate ASCII or ANSI version of the resource based on the user's preferences (the setting of the user.hasAnsi flag) and display the text file.

The format of each type of resource is described in the loadStringList, loadTextFile and runMenu functions.

Example Externals

The Hermes External Development System comes with a brand-new implementation of the Leech game. Leech 2000, as it is called, demonstrates virtually every aspect of the new API and is a great steal-me resource. But because of its completeness, it can be overwhelming as a demonstration of the API itself. So this section instead provides a series of examples designed to walk you through the various parts of the Hermes External API.

Each example is designed to explain a portion of the API and links to the various portions of this module's documentation where you can get more information. Furthermore, the examples are built up interactively in the Python Interpreter external.

Hello World

As far as I know, there was never an implementation of "Hello World" as a classic-model Hermes External. Probably due to the fact that it would have been about fifty lines long and the part about 'hello' buried in a single OutLine statement. The sheer mass of support infrastructure to create the external itself would have surely scared off any budding external developers.

The EDS-based version of "Hello World" is much, much simpler:
   print 'Hello World'
One line. All of the support infrastructure is hidden. Let's try it out interactively and see what happens:
>>> print 'Hello World'
Hello World

You will notice that this external uses Python's built-in print operator to output the text. This is an important point, and one that bears further comment: the Python-based Hermes External API strives to hide the fact that the external is, in fact, running on a Hermes BBS. The same Hello World 'external' that is shown above will work in any Python interpreter. This was done by design. I did not want developers to have to learn hundreds of special APIs and design patterns in order to build externals.

If you know Python, then you already know how to write Hermes externals.

There are a few functions and properties that you will need to use to access data structures stored in Hermes and to get input from the user, but the vast majority of what you will see in these examples is standard Python.

Hello Your Name Here

Let's face it, "Hello World" is a boring external. You are logged in to a BBS and the BBS knows what your name is, so let's have the external customize the greeting:
   from hermes import *
   print 'Hello %s' % (user.name)

And just like that, "Hello Your Name Here" is born.

This example adds two elements that will undoubtably appear in all of your externals: importing the hermes helper module and accessing Hermes properties.

The first line in the example is the one that imports the hermes Python module:
>>> from hermes import *

In this example, we are retrieving the user's name by accessing the name property in the user object. Many other properties are available in the user object, all of which are described in the documentation for that object.

You can interactively query the user object using the Python Interpreter:
>>> user.name
'Michael Alyn Miller'

>>> user.sl
255

>>> user.hasAnsi
1
Each attribute has separate read and write permissions. Furthermore, externals can run at multiple security levels. Not all attributes will be available at some levels. Most externals run at the secAnon level, where only the most basic of information is available. This is done as a security measure and to protect privacy of the BBS and the users of that BBS.

Hello Someone Else's Name

The "Hello Your Name Here" external brought in the hermes module and demonstrated how to access information about the user. The next step is to query the user for information directly. Let's write an external that asks the user for someone else's name:
   from hermes import *
   otherName = textPrompt('Who should I say hello to? ', 32)
   print 'Say hello to %s for me!' % (otherName)

This example introduces one of the standard prompt types that is made available by the hermes module, the textPrompt. As explained in the documentation, textPrompt takes a minimum of two arguments: the prompt text and the maximum length of the response.

Try out this prompt in the interpreter:
>>> otherName = textPrompt('Who should I say hello to? ', 32)
Who should I say hello to? Bob

>>> print 'Say hello to %s for me!' % (otherName)
Say hello to Bob for me!
Since otherName is now a Python variable...
>>> otherName
'Bob'
...you can use it in additional prompts as well:
>>> if yesNoPrompt('%s?  Are you sure? ' % (otherName)):
...     print 'Okay, say hello to %s for me then!' % (otherName)
Bob?  Are you sure? Yes
Okay, say hello to Bob for me then!
Take a look at the list of Prompts in the documentation for the hermes module for information about the other prompts.

Author: Michael Alyn Miller <malyn@strangeGizmo.com>

Copyright: 1999-2006 by Michael Alyn Miller.

License: BSD License (see source code for full license)

Classes
    Property Classes
BBS System data and statistics for the BBS.
External Information about this external.
Instance Temporary data storage for the current run of the external.
Preferences Preferences data for this BBS and external.
User Properties for the user currently accessing this external.
    Style Class
Style ANSI style object.
    Internal Classes
ExternalData Holds external-specific data about one of the other BBS property objects.

Exceptions
ResourceException An exception generated while processing a resource.

Function Summary
    Output
None backspace(count, style, clear)
Write count backspaces to the user's screen.
None clearScreen()
Clear the user's screen.
None printTextFile(fileName, raw)
Print the text file with the given name to the user's screen.
    Prompts
object multipleChoicePrompt(promptText, choiceList, defaultChar, autoAccept, promptStyle, inputStyle)
Prompt the user to select from a specific list of options.
int numericPrompt(promptText, minValue, maxValue, autoAccept, requireResponse, promptStyle, inputStyle)
Prompt the user to enter a number.
None pausePrompt(promptText, promptStyle)
Prompt the user to press a key to continue.
str textPrompt(promptText, maxChars, validChars, autoAccept, replaceChar, forceUppercase, promptStyle, inputStyle)
Prompt the user to enter a string of text.
boolean yesNoPrompt(promptText, defaultValue, autoAccept, trueChar, trueText, falseChar, falseText, promptStyle, inputStyle)
Prompt the user for a Yes/No, True/False, etc answer.
    Resources
dict loadStringList(fileName, nameDecoder, valueDecoder)
Load and return the string list with the given name.
tuple loadTextFile(fileName)
Load and return the text file with the given name.
None runMenu(menuName, printMenuFirst, clearOnFirstPrint, clearOnReprint, lfBeforePrompt)
Load and run the menu with the given name.
    List Formatting
list splitColumns(origList, numColumns, emptyValue)
Split a list into multiple columns.
list splitPages(origList, rowsPerPage, numColumns, emptyValue)
Splits a list into multiple pages, optionally splitting each page into multiple columns.
    Number Formatting
string formatCurrency(value, decimalPlaces, currencySymbol)
Return the given value as a string, prefixed with a currency symbol and with a specific number of decimal places.
string formatNumber(i)
Return the given number as a string with the thousands values separated by commas.
    String Formatting
string plural(number, singularString, pluralString)
Return singularString or pluralString based on whether or not number is greater than 1.
    Utilities
list enumerate(origList)
Return a list containing (index, entry) tuples for each entry in origList.

Variable Summary
    Properties
BBS bbs: BBS properties and statistics.
External external: Information about this external.
Instance instance: Temporary data for the current run of the external.
Preferences prefs: Preferences data for this BBS and external.
User user: Properties for the user currently accessing the external.
    Preconfigured Styles
Style DefaultStyle: Style object configured in the BBS preferences for styling all text that is not covered by one of the other styles.
Style NoteStyle: Style object configured in the BBS preferences for styling text of an informational nature (another user logged in, you just received e-mail, etc.).
Style NoticeStyle: Style object configured in the BBS preferences for styling important text that the user should be aware of and take potential action over (they only have five minutes remaining in this call, the BBS is shutting down, they are about to get killed in the game they are playing, etc.).
Style PromptHeaderStyle: Style object configured in the BBS preferences for the text that appears before a standard prompt.
Style PromptStyle: Style object configured in the BBS preferences for styling the promptText of all text and numeric prompts.
Style InputLineStyle: Style object configured in the BBS preferences for styling prompts with input fields.
Style YesNoPromptStyle: Style object configured in the BBS preferences for styling the promptText of all yesNoPrompts.
    Foreground Colors
int fgBlack: Black foreground color Style constant.
int fgBlue: Blue foreground color Style constant.
int fgCyan: Cyan foreground color Style constant.
int fgDkGray: Dark gray foreground color Style constant.
int fgGreen: Green foreground color Style constant.
int fgLtBlue: Light blue foreground color Style constant.
int fgLtCyan: Light cyan foreground color Style constant.
int fgLtGray: Light gray foreground color Style constant.
int fgLtGreen: Light green foreground color Style constant.
int fgLtMagenta: Light magenta foreground color Style constant.
int fgLtRed: Light red foreground color Style constant.
int fgLtYellow: Light yellow foreground color Style constant.
int fgMagenta: Magenta foreground color Style constant.
int fgRed: Red foreground color Style constant.
int fgWhite: White foreground color Style constant.
int fgYellow: Yellow foreground color Style constant.
    Background Colors
int bgBlack: Black background color Style constant.
int bgBlue: Blue background color Style constant.
int bgCyan: Cyan background color Style constant.
int bgDkGray: Dark gray background color Style constant.
int bgGreen: Green background color Style constant.
int bgLtBlue: Light blue background color Style constant.
int bgLtCyan: Light cyan background color Style constant.
int bgLtGray: Light gray background color Style constant.
int bgLtGreen: Light green background color Style constant.
int bgLtMagenta: Light magenta background color Style constant.
int bgLtRed: Light red background color Style constant.
int bgLtYellow: Light yellow background color Style constant.
int bgMagenta: Magenta background color Style constant.
int bgRed: Red background color Style constant.
int bgWhite: White background color Style constant.
int bgYellow: Yellow background color Style constant.
    ANSI Attributes
int attrBlinking: Blinking text Style constant.
int attrIntense: Intense text Style constant.
int attrUnderline: Underline text Style constant.
    Python Constants
int True: The boolean value True (which is missing in Python 2.1).
int False: The boolean value False (which is missing in Python 2.1).

Function Details

backspace(count=1, style=DefaultStyle, clear=1)

Write count backspaces to the user's screen.
Parameters:
count - The number of backspaces to write to the user's screen.
           (type=int)
style - The style to use when writing out the backspace characters. Necessary to ensure that the erased area is filled in correctly if clear is set.
           (type=Style)
clear - True to clear the backspaced area, False to move the cursor without clearing the intervening characters.
           (type=boolean)
Returns:
None

clearScreen()

Clear the user's screen.
Returns:
None

printTextFile(fileName, raw=0)

Print the text file with the given name to the user's screen.

Unless raw is set to True, the text file will be parsed for screen clears and pauses. If the file begins with a Ctrl-L (^L or form-feed), then the screen will be cleared before the text file is output. Additional Ctrl-L characters will insert a pausePrompt at that location in the file. Both of these behaviors are disabled if raw is False.
Parameters:
fileName - The name of the text resource to display.
           (type=string)
raw - True to display the file without any processing, False to convert Ctrl-L characters into screen-clears and pauses.
           (type=boolean)
Returns:
None

multipleChoicePrompt(promptText, choiceList, defaultChar=None, autoAccept=1, promptStyle=PromptStyle, inputStyle=DefaultStyle)

Prompt the user to select from a specific list of options.

The multiple-choice prompt takes a choiceList as its input. This list is a dictionary of (choiceText, choiceValue) tuples, indexed by the character that the user must press to select that choice. The list of allowed characters is built from the keys in the dictionary. The choiceText will be displayed after the user chooses that option.

A sample choiceList might look like this:
   myChoices = {
       'R': ('Run!', doRun),
       'F': ('Fight', doFight),
       'Q': ('Quit', doQuit),
   }
If the user pressed 'F', then the text 'Fight' would appear on their screen after the prompt text and the value doFight (which is presumably a function in the current scope) would be returned from multipleChoicePrompt.
Parameters:
promptText - The text of the multiple choice prompt.
           (type=string)
choiceList - A dictionary of (choiceText, choiceValue) tuples, indexed by the selection character.
           (type=string)
defaultChar - The character to accept as input to the prompt if the user hits return without pressing any of the valid prompt characters. This character must be a key in choiceList.
           (type=char)
autoAccept - True if the prompt should accept a valid character as soon as it is pressed, False if the user must press return before the prompt will accept the user's input.
           (type=boolean)
promptStyle - The style to print the prompt in.
           (type=Style)
inputStyle - The style to print the user's choice in.
           (type=Style)
Returns:
The choiceValue corresponding to the user's selection in choiceList.
           (type=object)

numericPrompt(promptText, minValue, maxValue, autoAccept=0, requireResponse=1, promptStyle=PromptStyle, inputStyle=DefaultStyle)

Prompt the user to enter a number.
Parameters:
promptText - The text of the numeric prompt.
           (type=string)
minValue - The minimum value that the user is allowed to enter.
           (type=int)
maxValue - The maximum value that the user is allowed to enter.
           (type=int)
autoAccept - True if the prompt should accept a valid number as soon as it is enter, False if the user must press return before the prompt will accept the user's input.
           (type=boolean)
requireResponse - True if the user must enter a response to the prompt, False if an empty answer (they just pressed return) is acceptable.
           (type=boolean)
promptStyle - The style to print the prompt in.
           (type=Style)
inputStyle - The style to print the user's choice in.
           (type=Style)
Returns:
The number entered by the user, or None if requireResponse is True and the user pressed return without entering a numeric value.
           (type=int)

pausePrompt(promptText='[PAUSE]', promptStyle=NoteStyle)

Prompt the user to press a key to continue.
Parameters:
promptText - The text of the pause prompt.
           (type=string)
promptStyle - The style to print the prompt in.
           (type=Style)
Returns:
None

textPrompt(promptText, maxChars, validChars=None, autoAccept=0, replaceChar=None, forceUppercase=0, promptStyle=PromptStyle, inputStyle=DefaultStyle)

Prompt the user to enter a string of text.
Parameters:
promptText - The text of the numeric prompt.
           (type=string)
maxChars - The maximum number of characters this prompt will accept.
           (type=number)
validChars - The list of characters this prompt will accept, or None to accept all characters.
           (type=string)
autoAccept - True if the prompt should return as soon as the user has entered maxChars characters, False if the user must press return before the prompt will return.
           (type=boolean)
replaceChar - If this value is given, then the user's input will be echoed back as this character (instead of the characters that they actually pressed).
           (type=character)
promptStyle - The style to print the prompt in.
           (type=Style object)
inputStyle - The style for the input portion of the prompt. Note that the prompt will pre-fill the input area (the space maxChars after the promptText) with this style.
           (type=Style object)
Returns:
The text entered by the user.
           (type=str)

yesNoPrompt(promptText, defaultValue=None, autoAccept=1, trueChar='Y', trueText='Yes', falseChar='N', falseText='No', promptStyle=YesNoPromptStyle, inputStyle=DefaultStyle)

Prompt the user for a Yes/No, True/False, etc answer.
Parameters:
promptText - The text of the yes-no prompt.
           (type=string)
defaultValue - If True or False, then that value is displayed as the default input to the prompt.
           (type=boolean or None)
autoAccept - True if the prompt should accept a valid character as soon as it is pressed, False if the user must press return before the prompt will accept the user's input.
           (type=boolean)
trueChar - The character the user must press to return True from this prompt.
           (type=character)
falseChar - The character the user must press to return False from this prompt.
           (type=character)
promptStyle - The style to print the prompt in.
           (type=Style)
inputStyle - The style to print the user's choice in.
           (type=Style)
Returns:
True if the user pressed trueChar otherwise False.
           (type=boolean)

loadStringList(fileName, nameDecoder=None, valueDecoder=None)

Load and return the string list with the given name.

String list files are composed of name=value tuples, one per line. Here is an example file:
   one=uno
   two=dos
   three=tres
The result of loading this file with loadStringList would be the following dictionary:
   {'one': 'uno', 'two: 'dos', 'three: 'tres'}
Names and values can optionally be processed by a functions. To convert them to classes, for example. The nameDecoder and valueDecoder arguments are used to indicate the functions that should process the values in the file. By default, they return the string contents of the name/value.
Parameters:
fileName - The name of the stringList resource to load
           (type=string)
nameDecoder - This function will be called with each name in the file. The nameDecoder will be passed the string version of the name and should return a value understood by the caller of loadStringList.
           (type=function)
valueDecoder - This function will be called with each value in the file. The valueDecoder will be passed two arguments: the string version of the name and the string version of the value. It should return a value understood by the caller of loadStringList.
           (type=function)
Returns:
A dictionary containing the name/value pairs from the resource.
           (type=dict)

loadTextFile(fileName)

Load and return the text file with the given name.

This function returns a (asciiText, ansiText) tuple containing the ASCII and ANSI versions of the text file. If only ASCII text is included, then both strings will be the same.

The simplest format for a text resource is a raw text file with no markup. A file in that format will return the entire contents of the file for the asciiText and ansiText values.

In addition to raw text files, loadTextFile also supports section files. A section file is a text file that is broken up into separate sections using a special separator string. The separator string must start with --== and must be unique for that section. For example, the following file defines two sections:
   --== Section 1 ==--
   This is text in section 1.
   --== Section 1 ==--

   --== Section 2 ==--
   This is text in section 2.
   --== Section 2 ==--

Notice how each section separator begins with the text --== and is unique in the file. In other words, the string --== Section 1 ==-- that defines the first section is different from the string --== Section 2 ==-- that defines the second section.

Any amount of whitespace can appear before or after each section and is ignored.

A sample text file with ASCII and ANSI sections might look like this:
   --== ASCII TEXT ==--
   Text using only ASCII characters.
   --== ASCII TEXT ==--

   --== ANSI TEXT ==--
   Text with ANSI escape sequences.
   --== ANSI TEXT ==--

In text files, the ASCII section must appear before the ANSI section. But the names of the sections are irrelevant and can be specified by the developer. loadTextFile only considers the order of the selections.

If only a single section exists, then that section is used for both the ASCII and ANSI text.
Parameters:
fileName - The name of the text resource to load
           (type=string)
Returns:
A tuple containing the ASCII text and ANSI text of the given file.
           (type=tuple)

runMenu(menuName, printMenuFirst=1, clearOnFirstPrint=0, clearOnReprint=1, lfBeforePrompt=1)

Load and run the menu with the given name.

This function simplifies the construction, display and prompting associated with a menu. Each menu contains a ASCII and ANSI versions of the menu and a list of commands. The commands are functions in the current scope.

The menu file is in a section file and is in the same format that loadTextFile uses. The difference is that the space outside of the ASCII and ANSI sections is parsed similar to a string list (see loadStringList) and used to populate the menu commands.

The general format of a menu file is:
   menu configuration

   --== ASCII MENU TEXT ==--
   Text for the ASCII menu.
   --== ASCII MENU TEXT ==--

   --== ANSI MENU TEXT ==--
   Text for the ANSI menu.  If this section does not exist, then
   the ASCII menu text will be displayed for all users.
   --== ANSI MENU TEXT ==--
The menu configuration section is where the menu itself is setup. Each line is a name=value pair. There are three types of lines:
  • Menu commands. Each of these lines is in the format function=K;Item text. function is the name of the function in the current scope to call if this menu item is selected. K is the key that the user must press to activate this menu item. Item text is the text that will be displayed when the user activates that item.

    Example menu commands:
       doRun=R;Run!
       doFight=F;Fight
    
    If the user presses 'R', the text 'Run' will be displayed and the doRun function will be called.
  • Special menu commands. Special menu commands are provided by the runMenu function to simplify the building of standard menus. Two special commands are available:
    • <displayMenu>: Displays the text of the menu.
    • <exit>: Exits from the runMenu function.
    These special menu commands might be used as follows:
       <displayMenu>=?;Display Menu
       <exit>=Q;Quit
    
    Pressing '?' would display the text of the menu and press 'Q' would exit the menu and return to the caller of the runMenu function.
  • Configuration parameters. runMenu uses multipleChoicePrompt to request input from the user. The following configuration parameters can be loaded from the menu file and passed to multipleChoicePrompt:
    • _defaultChar: The character of the default menu item. If provided, this item will be selected if the user presses return at the menu prompt.
    • _promptText: The text of the menu prompt. This is a required parameter.
Here is a complete sample menu:
   _promptText=What do you want to do? 
   _defaultChar=Q

   <displayMenu>=?;Display Menu
   <exit>=Q;Quit
   doRun=R;Run!
   doFight=F;Fight

   --== ASCII MENU TEXT ==--
   The What-Next Menu:

     [R] Run!
     [F] Fight
     [Q] Quit
     [?] Show me these choices again
   --== ASCII MENU TEXT ==--

   --== ANSI MENU TEXT ==--
   The What-Next Menu (in ANSI!):

     [R] Run!
     [F] Fight
     [Q] Quit
     [?] Show me these choices again
   --== ANSI MENU TEXT ==--
If this menu was saved in a resource called 'WhatNext', then it could be called with the following code:
   runMenu('WhatNext')
The menu would be loaded, displayed and the user prompted for choices. The runMenu function will exit when the user presses the key identified by the special menu command <exit>. If no <exit> command is provided, then the menu will never exit. This is probably not what you want.
Parameters:
menuName - The name of the menu resource to run.
           (type=string)
printMenuFirst - True to print the menu the first time the user prompt is run, False to prompt the user without printing the menu.
           (type=boolean)
clearOnFirstPrint - True to clear the screen the first time the menu text is displayed, False otherwise. This option has no effect if printMenuFirst is False.
           (type=boolean)
clearOnReprint - True to clear the screen each time the menu text is displayed, False otherwise.
           (type=boolean)
lfBeforePrompt - True if a blank line should be displayed before the prompt is displayed, False to prompt the user immediately after displaying the menu text.
           (type=boolean)
Returns:
None

splitColumns(origList, numColumns, emptyValue=None)

Split a list into multiple columns.

This function splits origList into numColumns, balancing each column to ensure that the minimal number of rows is created. The return value is a list of lists: one list for each row in the table.

Examples:
>>> origList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
>>> splitColumns(origList, 3)
[[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, None]]
>>> origList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
>>> splitColumns(origList, 5)
[[1, 4, 7, 10, None], [2, 5, 8, 11, None], [3, 6, 9, None, None]]
Parameters:
origList - The list to split into columns.
           (type=list or tuple)
numColumns - The number of columns to split origList into.
           (type=int)
emptyValue - The value to insert into empty cells in the table.
           (type=object)
Returns:
A list containing a sub-list for each row in the table. Each entry in the sub-list is a value from origList or the emptyValue if the cell is empty.
           (type=list)

splitPages(origList, rowsPerPage, numColumns=1, emptyValue=None)

Splits a list into multiple pages, optionally splitting each page into multiple columns.

Each page contains at most rowsPerPage rows. If numColumns is set to 1, then each page will contain rowsPerPage items. If numColumns is greater than 1, then each page will contain numColumns * rowsPerPage items, distributed across numColumns columns.

Examples:
>>> origList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
>>> splitPages(origList, 4)
[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11]]
>>> origList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
>>> splitPages(origList, 3, 2)
[[[1, 4], [2, 5], [3, 6]], [[7, 10], [8, 11], [9, None]]]
Parameters:
origList - The list to split into pages.
           (type=list or tuple)
rowsPerPage - The number of rows to put onto each page.
           (type=int)
numColumns - The number of columns to split each page into.
           (type=int)
emptyValue - The value to insert into empty cells in the table if columns are being used. emptyValue will not be inserted into empty rows; the last page will only contain as many rows as necessary to complete origList.
           (type=object)
Returns:
A list containing a sub-list for each page in the table. If numColumns is greater than 1, then a third level of list will be present on each page containing the column data (in the same format as provided by splitColumns.) Each entry in the final sub-list is a value from origList or the emptyValue if the cell is empty.
           (type=list)

formatCurrency(value, decimalPlaces=2, currencySymbol='$')

Return the given value as a string, prefixed with a currency symbol and with a specific number of decimal places.

The number will be formatted with the thousands values separated by commas (see formatNumber for more information).

Examples:
>>> formatCurrency(1234.50)
'$1,234.50'

>>> formatCurrency(1234.50, 0)
'$1,234'
Parameters:
value - The number to convert.
           (type=int or float)
decimalPlaces - The number of decimal places to include, or zero to only return the integer portion of value.
           (type=int)
currencySymbol - The string to prefix the converted value with.
           (type=string)
Returns:
The value with the given currency symbol and to the specified number of decimal places.
           (type=string)

formatNumber(i)

Return the given number as a string with the thousands values separated by commas.

Examples:
>>> formatNumber(1234)
'1,234'

>>> formatNumber(123456)
'123,456'

>>> formatNumber(1234567)
'1,234,567'

>>> formatNumber(-1234)
'-1,234'
Parameters:
i - The number to convert.
           (type=int)
Returns:
The number as a string, with thousands values separated by commas.
           (type=string)

plural(number, singularString, pluralString)

Return singularString or pluralString based on whether or not number is greater than 1.

Examples:
>>> plural(1, 'thing', 'things')
'thing'

>>> plural(2, 'thing', 'things')
'things'
Parameters:
number - The number to test for plurality.
           (type=int)
singularString - The string to return if number is one.
           (type=string)
pluralString - The string to return if number is not one.
           (type=string)
Returns:
singularString if number is 1 otherwise pluralString
           (type=string)

enumerate(origList)

Return a list containing (index, entry) tuples for each entry in origList.

This reproduces the behavior of the enumerate built-in that is missing in Python 2.1

Example:
>>> enumerate(['a', 'b', 'c', 'd', 'e'])
[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'd'), (4, 'e')]
This function is normally used in loops where you need to have the index of each item you are processing:
>>> letterList = ['a', 'b', 'c', 'd', 'e']
>>> for index, letter in enumerate(letterList):
...     print "The letter '%s' is at index %d in the list." % (
...         letter, index)
The letter 'a' is at index 0 in the list.
The letter 'b' is at index 1 in the list.
The letter 'c' is at index 2 in the list.
The letter 'd' is at index 3 in the list.
The letter 'e' is at index 4 in the list.
Parameters:
origList - The list to enumerate.
           (type=list or tuple)
Returns:
A list containing (index, entry) tuples for each entry in origList.
           (type=list)

Variable Details

bbs

BBS properties and statistics.
Type:
BBS

external

Information about this external.
Type:
External

instance

Temporary data for the current run of the external.
Type:
Instance
Value:
<hermes.Instance instance at 0x50210>                                  

prefs

Preferences data for this BBS and external.
Type:
Preferences

user

Properties for the user currently accessing the external.
Type:
User

DefaultStyle

Style object configured in the BBS preferences for styling all text that is not covered by one of the other styles.
Type:
Style
Value:
DefaultStyle                                                           

NoteStyle

Style object configured in the BBS preferences for styling text of an informational nature (another user logged in, you just received e-mail, etc.).
Type:
Style
Value:
NoteStyle                                                              

NoticeStyle

Style object configured in the BBS preferences for styling important text that the user should be aware of and take potential action over (they only have five minutes remaining in this call, the BBS is shutting down, they are about to get killed in the game they are playing, etc.).
Type:
Style
Value:
NoticeStyle                                                            

PromptHeaderStyle

Style object configured in the BBS preferences for the text that appears before a standard prompt. This Style object is used when a prompt has a line of informational text that appears before the prompt itself (which will normally be styled with PromptStyle).
Type:
Style
Value:
PromptHeaderStyle                                                      

PromptStyle

Style object configured in the BBS preferences for styling the promptText of all text and numeric prompts. yesNoPrompts use the YesNoPromptStyle.
Type:
Style
Value:
PromptStyle                                                            

InputLineStyle

Style object configured in the BBS preferences for styling prompts with input fields. Very few prompts use input fields. They are generally only necessary in form-based applications where the user has a specific number of characters in which to type their response.
Type:
Style
Value:
InputLineStyle                                                         

YesNoPromptStyle

Style object configured in the BBS preferences for styling the promptText of all yesNoPrompts.
Type:
Style
Value:
YesNoPromptStyle                                                       

fgBlack

Black foreground color Style constant.
Type:
int
Value:
0                                                                     

fgBlue

Blue foreground color Style constant.
Type:
int
Value:
4                                                                     

fgCyan

Cyan foreground color Style constant.
Type:
int
Value:
6                                                                     

fgDkGray

Dark gray foreground color Style constant. Also sets attrIntense.
Type:
int
Value:
8                                                                     

fgGreen

Green foreground color Style constant.
Type:
int
Value:
2                                                                     

fgLtBlue

Light blue foreground color Style constant. Also sets attrIntense.
Type:
int
Value:
12                                                                    

fgLtCyan

Light cyan foreground color Style constant. Also sets attrIntense.
Type:
int
Value:
14                                                                    

fgLtGray

Light gray foreground color Style constant.
Type:
int
Value:
7                                                                     

fgLtGreen

Light green foreground color Style constant. Also sets attrIntense.
Type:
int
Value:
10                                                                    

fgLtMagenta

Light magenta foreground color Style constant. Also sets attrIntense.
Type:
int
Value:
13                                                                    

fgLtRed

Light red foreground color Style constant. Also sets attrIntense.
Type:
int
Value:
9                                                                     

fgLtYellow

Light yellow foreground color Style constant. Also sets attrIntense.
Type:
int
Value:
11                                                                    

fgMagenta

Magenta foreground color Style constant.
Type:
int
Value:
5                                                                     

fgRed

Red foreground color Style constant.
Type:
int
Value:
1                                                                     

fgWhite

White foreground color Style constant. Also sets attrIntense.
Type:
int
Value:
15                                                                    

fgYellow

Yellow foreground color Style constant.
Type:
int
Value:
3                                                                     

bgBlack

Black background color Style constant.
Type:
int
Value:
16                                                                    

bgBlue

Blue background color Style constant.
Type:
int
Value:
20                                                                    

bgCyan

Cyan background color Style constant.
Type:
int
Value:
22                                                                    

bgDkGray

Dark gray background color Style constant. Also sets attrIntense.
Type:
int
Value:
24                                                                    

bgGreen

Green background color Style constant.
Type:
int
Value:
18                                                                    

bgLtBlue

Light blue background color Style constant. Also sets attrIntense.
Type:
int
Value:
28                                                                    

bgLtCyan

Light cyan background color Style constant. Also sets attrIntense.
Type:
int
Value:
30                                                                    

bgLtGray

Light gray background color Style constant.
Type:
int
Value:
23                                                                    

bgLtGreen

Light green background color Style constant. Also sets attrIntense.
Type:
int
Value:
26                                                                    

bgLtMagenta

Light magenta background color Style constant. Also sets attrIntense.
Type:
int
Value:
29                                                                    

bgLtRed

Light red background color Style constant. Also sets attrIntense.
Type:
int
Value:
25                                                                    

bgLtYellow

Light yellow background color Style constant. Also sets attrIntense.
Type:
int
Value:
27                                                                    

bgMagenta

Magenta background color Style constant.
Type:
int
Value:
21                                                                    

bgRed

Red background color Style constant.
Type:
int
Value:
17                                                                    

bgWhite

White background color Style constant. Also sets attrIntense.
Type:
int
Value:
31                                                                    

bgYellow

Yellow background color Style constant.
Type:
int
Value:
19                                                                    

attrBlinking

Blinking text Style constant.
Type:
int
Value:
34                                                                    

attrIntense

Intense text Style constant.
Type:
int
Value:
32                                                                    

attrUnderline

Underline text Style constant.
Type:
int
Value:
33                                                                    

True

The boolean value True (which is missing in Python 2.1).
Type:
int
Value:
1                                                                     

False

The boolean value False (which is missing in Python 2.1).
Type:
int
Value:
0                                                                     

Generated by Epydoc 2.1 on Mon Mar 27 20:48:39 2006 http://epydoc.sf.net