Module: config.py — badsnakes - v0.2.0 Documentation

# Module: config.py

Purpose:

  This module provides the functionality for reading and importing the `config.toml` file to the project.

Platform:

  Linux/Windows | Python 3.10+

Developer:

  J Berendt

Email:

  development@s3dev.uk

Comments:

  If the version of Python is 3.11+, the `tomllib` builtin is used to load the config file. Otherwise, the third-party `toml` library is used. If `toml` is not installed, the user is notified the library must be installed, and the program is exited.

Example:

  Example code use:

      >>> from badsnakes.libs.config import (analysercfg,
                                             config,
                                             systemcfg)

class badsnakes.libs.config.Config

  Bases: `object`

  General project configuration wrapper class.

  Note

  This class is used to simply read and provide access to the settings defined in the `config.toml` file.

  All configuration keys are to be set in the `config.toml` file, not in this module.

  property analyserconfig

    Public accessor to the analyser’s configuration items.

  property config

    Public accessor to all configuration items.

  property dir_root

    Public accessor to the project’s root directory.

  property projectconfig

    Public accessor to project configuration items.

  property systemconfig

    Public accessor to system configuration items.

  _load_config()

    Load the config TOML file into memory.

    This method is called on class instantiation.

    If using Python 3.11+, the builtin `tomllib` library is used to read the config file. Otherwise, the third-party `toml` library is used.