gummworld2.data (version $Id: data.py 407 2013-08-12 15:11:30Z stabbingfinger@gmail.com $)
index
c:\cygwin64\home\bw\dev\python\dist\gummworld2\gamelib\gummworld2\data.py

data.py - Data resource loader for Gummworld2.
 
Module data may be used directly, but use of the module functions is preferred:
    *   data_py is the absolute path for this module file's directory.
    *   data_dir is the root data directory.
    *   subdirs is a dict(name=subdir) for looking up resource sub-directories
        by name. name is simply an abstract type or description.
    *   paths is a "cooked" dict containing lookups for subdirectories of each
        data type.

 
Modules
       
os

 
Functions
       
filepath(typ, filename)
Return the path to a file in the data directory.
load(typ, filename, mode='rb')
Open a file in the data directory and return its file handle.
 
The mode argument is passed as the second argument to open().
load_font(filename)
Open a font file from the font dir and return its file handle.
load_image(filename)
Open an image file from the image dir and return its file handle.
load_map(filename)
Open a map file from the map dir and return its file handle.
load_sound(filename)
Open a sound file from the sound dir and return its file handle.
load_text(filename)
Open a text file from the text dir and return its file handle.
relpath(filename)
Return the file path relative to data_dir.
 
For example:
    # data.data_dir is "/games/pong/data"
    filename = "/games/pong/data/image/my.png"
    relname = data.relpath(filename)
    # relname is "image/my.png"
set_data_dir(base)
Set the base data directory for game resources.
 
base may be a relative or absolute path. It will be converted to an absolute
path and then normalized.
 
Calling this function changes the base data directory. The full path to a
data resource is constructed by joining data_dir and a subdir.
 
The default data directory is '../../data', relative to the path of this
module file.
 
NOTE: Call this early, before attempting to construct any library objects or
load resources.
 
Any previously loaded resources are unaffected. However, there may be
side-effects, for example memory leaks if a user-defined caching mechanism
uses data paths to fetch resources from cache.
set_subdir(name, subdir)
Set or add a new sub-directory for game resources.
 
name is the unique key used to look up the resource location. subdir is the
path component(s) to append to the data_path base directory.
 
subdir is assumed to be a relative path and is taken at face value. No
sanity or access checks are performed.

 
Data
        __all__ = ['set_data_dir', 'set_subdir', 'filepath', 'relpath', 'load', 'load_font', 'load_image', 'load_map', 'load_sound', 'load_text', 'data_py', 'data_dir', 'subdirs', 'paths']
__author__ = 'Gummbum, (c) 2011-2014'
__version__ = '$Id: data.py 407 2013-08-12 15:11:30Z stabbingfinger@gmail.com $'
data_dir = r'C:\cygwin64\home\bw\dev\python\dist\gummworld2\data'
data_py = r'C:\cygwin64\home\bw\dev\python\dist\gummworld2\gamelib\gummworld2'
paths = {'font': r'C:\cygwin64\home\bw\dev\python\dist\gummworld2\data\font', 'image': r'C:\cygwin64\home\bw\dev\python\dist\gummworld2\data\image', 'map': r'C:\cygwin64\home\bw\dev\python\dist\gummworld2\data\map', 'sound': r'C:\cygwin64\home\bw\dev\python\dist\gummworld2\data\sound', 'text': r'C:\cygwin64\home\bw\dev\python\dist\gummworld2\data\text', 'theme': r'C:\cygwin64\home\bw\dev\python\dist\gummworld2\data\themes'}
subdirs = {'font': 'font', 'image': 'image', 'map': 'map', 'sound': 'sound', 'text': 'text', 'theme': 'themes'}

 
Author
        Gummbum, (c) 2011-2014