6.6. foundations.environment

environment.py

Platform:
Windows, Linux, Mac Os X.
Description:
This module provides environment variables manipulation objects.

Others:

6.6.1. Module Attributes

foundations.environment.LOGGER

6.6.2. Functions

foundations.environment.getSystemApplicationDataDirectory()[source]

This definition returns the system Application data directory.

Examples directories:

- 'C:\Users\$USER\AppData\Roaming' on Windows 7.
- 'C:\Documents and Settings\$USER\Application Data' on Windows XP.
- '/Users/$USER/Library/Preferences' on Mac Os X.
- '/home/$USER' on Linux.
Returns:User Application data directory. ( String )
foundations.environment.getUserApplicationDataDirectory()[source]
This definition returns the user Application directory.

Examples directories:

- 'C:\Users\$USER\AppData\Roaming\Provider\Application' on Windows 7.
- 'C:\Documents and Settings\$USER\Application Data\Provider\Application' on Windows XP.
- '/Users/$USER/Library/Preferences/Provider/Application' on Mac Os X.
- '/home/$USER/.Provider/Application' on Linux.
Returns:User Application directory. ( String )

6.6.3. Classes

class foundations.environment.Environment(*args, **kwargs)[source]

Bases: object

This class provides methods to manipulate environment variables.

Usage:

>>> environment = Environment(JOHN="DOE", DOE="JOHN")
>>> environment.setValues()
True
>>> import os
>>> os.environ["JOHN"]
u'DOE'
>>> os.environ["DOE"]
u'JOHN'
Parameters:
  • *args – Variables. ( * )
  • **kwargs – Variables : Values. ( * )
variables[source]

This method is the property for self.__variables attribute.

Returns:self.__variables. ( Dictionary )
getValues(*args)[source]

This method gets environment variables values.

Usage:

>>> environment = Environment("HOME")
>>> environment.getValues()
{'HOME': u'/Users/JohnDoe'}
>>> environment.getValues("USER")
{'HOME': u'/Users/JohnDoe', 'USER': u'JohnDoe'}
Parameters:*args – Additional variables names to retrieve values from. ( * )
Returns:Variables : Values. ( Dictionary )
setValues(**kwargs)[source]

This method sets environment variables values.

Usage:

>>> environment = Environment()
>>> environment.setValues(JOHN="DOE", DOE="JOHN")
True
>>> import os
>>> os.environ["JOHN"]
'DOE'
>>> os.environ["DOE"]
'JOHN'
Parameters:**kwargs – Variables : Values. ( * )
Returns:Method success. ( String )
Note :Any variable with a None value will be skipped.
getValue(variable=None)[source]

This method gets given environment variable value.

Parameters:variable – Variable to retrieve value. ( String )
Returns:Variable value. ( String )
Note :If the variable argument is not given the first self.__variables attribute value will be returned.
setValue(variable, value)[source]

This method sets given environment variable with given value.

Parameters:
  • variable – Variable to set value. ( String )
  • value – Variable value. ( String )
Returns:

Method success. ( Boolean )

Table Of Contents

Previous topic

6.5. foundations.decorators

Next topic

6.7. foundations.exceptions

This Page