Skip to content

Commit

Permalink
Convert all doxygen documentation to epydoc.
Browse files Browse the repository at this point in the history
  • Loading branch information
stump committed Jun 7, 2010
1 parent 1ba4648 commit a02380c
Show file tree
Hide file tree
Showing 6 changed files with 217 additions and 142 deletions.
10 changes: 3 additions & 7 deletions src/FoFiX.py
Expand Up @@ -23,8 +23,9 @@
# MA 02110-1301, USA. #
#####################################################################

##@package FoFiX
# Main game executable.
'''
Main game executable.
'''

# Register the latin-1 encoding
import codecs
Expand All @@ -44,10 +45,6 @@
import os
import Version

## Display command-line usage and exit.
# Outputs to stdout unless py2exe'd, in which case the usage is presented
# using a MessageBox().
# @param errmsg Optional error message.
def _usage(errmsg=None):
usage = """Usage: %(prog)s [options]
Expand Down Expand Up @@ -117,7 +114,6 @@ def _usage(errmsg=None):
except:
videoAvailable = False

## Main function.
def main():
playing = None
configFile = None
Expand Down
53 changes: 32 additions & 21 deletions src/Log.py
Expand Up @@ -21,8 +21,9 @@
# MA 02110-1301, USA. #
#####################################################################

##@package Log
# Functions for various types of logging that FoFiX needs to do.
'''
Functions for writing to the logfile.
'''

import sys
import os
Expand All @@ -32,10 +33,10 @@
import time
import warnings

## Whether to output log entries to stdout in addition to the logfile.
# Whether to output log entries to stdout in addition to the logfile.
quiet = True

## File object representing the logfile.
# File object representing the logfile.
if os.name == "posix": # evilynux - logfile in ~/.fofix/ for GNU/Linux and MacOS X
# evilynux - Under MacOS X, put the logs in ~/Library/Logs
if os.uname()[0] == "Darwin":
Expand All @@ -47,21 +48,21 @@
else:
logFile = open(Version.PROGRAM_UNIXSTYLE_NAME + ".log", "w") #MFH - local logfile!

## Character encoding to use for logging.
# Character encoding to use for logging.
encoding = "iso-8859-1"

if "-v" in sys.argv or "--verbose" in sys.argv:
quiet = False

## Labels for different priorities, as output to the logfile.
# Labels for different priorities, as output to the logfile.
labels = {
"warn": "(W)",
"debug": "(D)",
"notice": "(N)",
"error": "(E)",
}

## Labels for different priorities, as output to stdout.
# Labels for different priorities, as output to stdout.
if os.name == "posix":
displaylabels = {
"warn": "\033[1;33m(W)\033[0m",
Expand All @@ -72,10 +73,12 @@
else:
displaylabels = labels

## Generic logging function.
# @param cls Priority class for the message
# @param msg Log message text
def _log(cls, msg):
'''
Generic logging function.
@param cls: Priority class for the message
@param msg: Log message text
'''
if not isinstance(msg, unicode):
msg = unicode(msg, encoding).encode(encoding, "ignore")
timeprefix = "[%12.6f] " % (time.time() - _initTime)
Expand All @@ -84,34 +87,42 @@ def _log(cls, msg):
print >>logFile, timeprefix + labels[cls] + " " + msg
logFile.flush() #stump: truncated logfiles be gone!

## Log a major error.
# If this is called while handling an exception, the traceback will
# be automatically included in the log.
# @param msg Error message text
def error(msg):
'''
Log a major error.
If this is called while handling an exception, the traceback will
be automatically included in the log.
@param msg: Error message text
'''
if sys.exc_info() == (None, None, None):
#warnings.warn("Log.error() called without an active exception", UserWarning, 2) #stump: should we enforce this?
_log("error", msg)
else:
_log("error", msg + "\n" + traceback.format_exc())

## Log a warning.
# @param msg Warning message text
def warn(msg):
'''
Log a warning.
@param msg: Warning message text
'''
_log("warn", msg)

## Log a notice.
# @param msg Notice message text
def notice(msg):
'''
Log a notice.
@param msg: Notice message text
'''
_log("notice", msg)

## Log a debug message.
# @param msg Debug message text
def debug(msg):
'''
Log a debug message.
@param msg: Debug message text
'''
_log("debug", msg)

## A hook to catch Python warnings.
def _showwarning(*args, **kw):
'''A hook to catch Python warnings.'''
warn("A Python warning was issued:\n" + warnings.formatwarning(*args, **kw))
_old_showwarning(*args, **kw)
_old_showwarning = warnings.showwarning
Expand Down
5 changes: 3 additions & 2 deletions src/Player.py
Expand Up @@ -225,12 +225,13 @@ def sortOptionsByKey(dict):
controlpath = '/users/controllers'
playerpath = '/users/players'

## Turn a controller name into a virtual path to the appropriate ini.

def _makeControllerIniName(name):
'''Turn a controller name into a virtual path to the appropriate ini.'''
return '%s/%s.ini' % (controlpath, name)

## Turn a player name into a virtual path to the appropriate ini.
def _makePlayerIniName(name):
'''Turn a player name into a virtual path to the appropriate ini.'''
return '%s/%s.ini' % (playerpath, name)

control0 = None
Expand Down
3 changes: 2 additions & 1 deletion src/Song.py
Expand Up @@ -3559,8 +3559,9 @@ def text(self, text):
text = ""


## Stores a list of songs to be played.
class SongQueue:
'''Stores a list of songs to be played.'''

def __init__(self):
self.songName = []
self.library = []
Expand Down

0 comments on commit a02380c

Please sign in to comment.