Package parpg :: Module settings :: Class Settings
[hide private]
[frames] | no frames]

Class Settings

source code

object --+
         |
        Settings

An object that represents a settings file, its sectons, and the options defined within those sections.

Instance Methods [hide private]
 
__init__(self, settings_path='', system_path='', user_path='', suffix='.cfg')
initializes a new settings object.
source code
 
__getattr__(self, name)
Returns a Section object to be used for assignment, creating one if it doesn't exist.
source code
 
platform_paths(self, system=None) source code
 
read(self, filenames=None)
Reads a settings file and populates the settings object with its sections and options.
source code
 
write(self, filename=None)
Writes a settings file based on the settings object's sections and options
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]
  sections
Returns a list of existing sections
  system_path
  user_path
  settings_path

Inherited from object: __class__

Method Details [hide private]

__init__(self, settings_path='', system_path='', user_path='', suffix='.cfg')
(Constructor)

source code 
initializes a new settings object. If no paths are given, they are
guessed based on whatever platform the script was run on.

Examples:
    paths = ['/etc/parpg', '/home/user_name/.config/parpg']
    settings = Settings(*paths)
    
    paths = {'system': '/etc/parpg', 
             'user': '/home/user_name/.config/parpg'}
    settings = Settings(**paths)

    settings = Settings('.')

    settigns = Settings()

@param system_path: Path to the system settings file.
@type system_path: string (must be a valid path)

@param user_path: Path to the user settings file. Options that
                  are missing from this file are propogated 
                  from the system settings file and saved on
                  request
@type user_path: string (must be a valid path)

@param suffix: Suffix of the settings file that will be generated.
@type suffix: string

Overrides: object.__init__

__getattr__(self, name)
(Qualification operator)

source code 

Returns a Section object to be used for assignment, creating one if it doesn't exist.

Parameters:
  • name (string) - name of section to be retrieved

read(self, filenames=None)

source code 

Reads a settings file and populates the settings object with its sections and options. Calling this method without any arguments simply re-reads the previously defined filename and paths

Parameters:
  • filenames - name of files to be parsed.
  • path (string or list)

write(self, filename=None)

source code 

Writes a settings file based on the settings object's sections and options

Parameters:
  • filename - Name of file to save to. By default, this is the user settings file.
  • path (string)

Property Details [hide private]

sections

Returns a list of existing sections

Get Method:
unreachable.sections(self) - Returns a list of existing sections

system_path

Get Method:
unreachable.system_path(self)

user_path

Get Method:
unreachable.user_path(self)

settings_path

Get Method:
unreachable.settings_path(self)