Package cliutils :: Module persistence
[hide private]
[frames] | no frames]

Module persistence

source code

Classes [hide private]
  _ConfigSection
Wrapper that provides dictionary-like access
  ConfigStorage
Functions [hide private]
 
storage_dir(directory='')
Obtain a directory suitable for storing a persistent file.
source code
 
config(filename, directory='')
Open and parse a config file filename in an optional given directory directory.
source code
 
db(filename, directory='')
Create or load a pickled dictionary from filename in optional directory.
source code
Function Details [hide private]

storage_dir(directory='')

source code 

Obtain a directory suitable for storing a persistent file.

Accepts an optional directory name. If directory is an absolute path, it will be treated as such. Otherwise, it will be treated as a path relative to a writeable directory (on *nix, it's the current user's home directory. On Windows, it's the roaming profile Application Data directory).

If the resulting absolute path refers to a directory that does not exist, it will be created.

config(filename, directory='')

source code 

Open and parse a config file filename in an optional given directory directory.

directory will be passed through storage_dir, so it may be a path relative to the user's home directory. If left blank, therefore, it will be the user's home directory itself.

db(filename, directory='')

source code 

Create or load a pickled dictionary from filename in optional directory.

directory will be passed through storage_dir, so it may be a path relative to the user's home directory.