mpylab.tools.configuration module

This is mpylab.tools.configuration.

Provides the Configuration class; used for ini files

author:

Hans Georg Krauthäuser (main author)

license:

GPLv3 or higher

class mpylab.tools.configuration.Configuration(ini: str | TextIO, cnftmpl: dict, casesensitive: bool = False)

Bases: object

Class for all configuration files.

mpylab.tools.configuration.parse_ini_value(value, inline_files=None)

Parse a value from an ini file without using eval().

Supported: - plain strings - ints, floats, bools, None - tuples, lists, dicts via ast.literal_eval - embedded inline data files via placeholders

mpylab.tools.configuration.preprocess_ini_text(text)

Replace embedded inline-file Python expressions with placeholders so that configparser can parse the ini text.

Returns:

processed_text, inline_files

mpylab.tools.configuration.strbool(s) bool

Returns True if int(s) is True or False otherwise. ‘0’ -> False; ‘1’ -> True