oemof.tools package

Submodules

oemof.tools.config module

This module provides a highlevel layer for reading and writing config files. There must be a file called “config.ini” in the root-folder of the project. The file has to be of the following structure to be imported correctly.

# this is a comment

# the filestructure is like:



[netCDF]

RootFolder = c://netCDF

FilePrefix = cd2-



[mySQL]

host = localhost

user = guest

password = root

database = znes



[SectionName]

OptionName = value

Option2 = value2
oemof.tools.config.get(section, key)[source]
Parameters:
  • section (str) – Section of the config file
  • key (str) – Key of the config file
Returns:

The value which will be casted to float, int or boolean. If no cast is successful, the raw string will be returned.

Return type:

float, int, str, boolean

oemof.tools.config.init()[source]
oemof.tools.config.main()[source]
oemof.tools.config.set(section, key, value)[source]
Parameters:
  • section (str) – Section of the config file
  • key (str) – Key of the config file
  • value (float, int, str, boolean) – Value for the given key.

oemof.tools.helpers module

This is a collection of helper functions which work on there own and can be used by various classes. If there are too many helper-functions, they will be sorted in different modules.

oemof.tools.helpers.extend_basic_path(subfolder)[source]

Returns a path based on the basic oemof path and creates it if necessary. The subfolder is the name of the path extension.

oemof.tools.helpers.get_basic_path()[source]

Returns the basic oemof path and creates it if necessary.

oemof.tools.helpers.get_fullpath(path, filename)[source]

Combines path and filename to a full path.

oemof.tools.logger module

oemof.tools.logger.check_git_branch()[source]

Passes the used branch and commit to the logger

oemof.tools.logger.check_version()[source]

Returns the actual version number of the used oemof version.

oemof.tools.logger.define_logging(inifile='logging.ini', basicpath=None, subdir='log_files', log_version=True)[source]

Initialise the logger using the logging.conf file in the local path.

Several sentences providing an extended description. Refer to variables using back-ticks, e.g. var.

Parameters:
  • inifile (string, optional (default: logging.ini)) – Name of the configuration file to define the logger. If no ini-file exist a default ini-file will be copied from ‘default_files’ and used.
  • basicpath (string, optional (default: '.oemof' in HOME)) – The basicpath for different oemof related information. By default a ”.oemof’ folder is created in your home directory.
  • subdir (string, optional (default: 'log_files')) – The name of the subfolder of the basicpath where the log-files are stored.
  • log_version (boolean) – If True the actual version or commit is logged while initialising the logger.

Notes

By default the INFO level is printed on the screen and the debug level in a file, but you can easily configure the ini-file. Every module that wants to create logging messages has to import the logging module. The oemof logger module has to be imported once to initialise it.

Examples

To define the default logger you have to import the python logging
library and this function. The first logging message should be the path where the log file is saved to.
>>> import logging
>>> from oemof.tools import logger
>>> logger.define_logging() 
17:56:51-INFO-Path for logging: /HOME/.oemof/log_files
...
>>> logging.debug("Hallo")
oemof.tools.logger.time_logging(start, text, logging_level='debug')[source]

Logs the time between the given start time and the actual time. A text and the debug level is variable.

Parameters:
  • start (float) – start time
  • text (string) – text to describe the log
  • logging_level (string) – logging_level [default=’debug’]

Module contents