qgis_deployment_toolbelt.utils.ini_interpolation module#

Custom INI files interpolation.

Author: Julien Moura (https://github.com/guts)

class qgis_deployment_toolbelt.utils.ini_interpolation.EnvironmentVariablesInterpolation#

Bases: BasicInterpolation

Custom interpolation to handle environment variables in ini files.

Inspired from https://gist.github.com/malexer/ee2f93b1973120925e8beb3f36b184b8.

Example

[test]
user = $USER
user_home = $HOME
fake_value_from_environment_variable = $QDT_TEST_ENV_VARIABLE
pictures = %(user_home)s/.cache/qgis-deployment-toolbelt
before_get(parser: ConfigParser, section: str, option: str, value: str, defaults: ChainMap) str#

Called for every option=value line in INI file.

Parameters:
  • parser (ConfigParser) – parser whose function is overloaded

  • section (str) – section’s name

  • option (str) – option’s name

  • value (str) – value to try to interpolate

  • defaults (ChainMap) – defaults options/values

Returns:

interpolated value

Return type:

str