4.6.2 pde.tools.config module

Handles configuration variables of the package.

Config

Class handling the package configuration.

get_package_versions

Tries to load certain python packages and returns their version.

parse_version_str

Helper function converting a version string into a list of integers.

check_package_version

Checks whether a package has a sufficient version.

packages_from_requirements

Read package names from a requirements file.

environment

Obtain information about the compute environment.

class Config(items=None, mode='update')[source]

Bases: UserDict

Class handling the package configuration.

Parameters:
  • items (dict, optional) – Configuration values that should be added or overwritten to initialize the configuration.

  • mode (str) –

    Defines the mode in which the configuration is used. Possible values are

    • insert: any new configuration key can be inserted

    • update: only the values of pre-existing items can be updated

    • locked: no values can be changed

    Note that the items specified by items will always be inserted, independent of the mode.

to_dict()[source]

Convert the configuration to a simple dictionary.

Returns:

A representation of the configuration in a normal dict.

Return type:

dict

check_package_version(package_name, min_version)[source]

Checks whether a package has a sufficient version.

Parameters:
  • package_name (str)

  • min_version (str)

environment()[source]

Obtain information about the compute environment.

Returns:

information about the python installation and packages

Return type:

dict

get_ffmpeg_version()[source]

Read version number of ffmpeg program.

Return type:

str | None

get_package_versions(packages, *, na_str='not available')[source]

Tries to load certain python packages and returns their version.

Parameters:
  • packages (list) – The names of all packages

  • na_str (str) – Text to return if package is not available

Returns:

Dictionary with version for each package name

Return type:

dict

packages_from_requirements(requirements_file)[source]

Read package names from a requirements file.

Parameters:

requirements_file (str or Path) – The file from which everything is read

Returns:

list of package names

Return type:

list[str]

parse_version_str(ver_str)[source]

Helper function converting a version string into a list of integers.

Parameters:

ver_str (str)

Return type:

list[int]