AppEnv

Application environment class. This holds information about the application environment loaded from an application preference file of the name .application-name which is searched for in the following locations:

This class implements the dictionary interface for variable access.

Methods

__getitem__(self, item)

   def __getitem__(self, item):

__init__(self, appName)

   def __init__(self, appName):

Constructs an AppEnv instance. appName should be a string application name, mainModule should be the location of the main module.

__setitem__(self, item, val)

   def __setitem__(self, item, val):

_findEnvFile(self)

   def _findEnvFile(self):

get(self, key, default)

   def get(self, key, default):

Gets the application environment variable identified by key. If this value is not currently among the application variables, returns default.

getStrict(self, key)

   def getStrict(self, key):

Gets the application environment variable identified by key. If this variable is not defined, or is defined as an empty or all whitespace string, raises a KeyError.

If the value is defined, all whitespace will be stripped from the end end beginning of it.

has_key(self, key)

   def has_key(self, key):

loaded(self)

   def loaded(self):

Returns true (1) if the variable file was loaded, false (0) if not.

save(self)

   def save(self):

Saves the environment file. If the file was not already loaded or specified through the setPath() method, the file will be written to the home directory or (if it does not exist) the first non-empty directory in sys.path.

setPath(self, path)

   def setPath(self, path):

Sets the variable file path. The variable file will be constructed from path and the application name.

writeTo(self, file)

   def writeTo(self, file):

Writes the file representation of the environment to the given file.