core.env

core.env.getdir(envvar: str, default: Path | None = None, create: bool | None = None) Path[source]

Returns the value of environment variable envvar, assumed to represent a directory path. If this variable is not defined, returns default.

The environment variable can be defined in the users .bashrc, or in a file .env in the current working directory.

Parameters:
  • envvar – the input environment variable

  • default

    the default path, if the environment variable is not defined default values are predefined for the following variables:

    • DIR_DATA : “data” (in current working directory)

    • DIR_STATIC : DIR_DATA/”static”

    • DIR_SAMPLES : DIR_DATA/”sample_products”

    • DIR_ANCILLARY : DIR_DATA/”ancillary”

  • create – whether to silently create the directory if it does not exist. If not provided this parameter defaults to False except for DIR_STATIC, DIR_SAMPLES and DIR_ANCILLARY.

Returns:

the path to the directory.

core.env.getvar(envvar: str, default: str | None = None) str[source]

Returns the value of environment variable envvar. If this variable is not defined, returns default.

The environment variable can be defined in the users .bashrc, or in a file .env in the current working directory.

Parameters:
  • envvar – the input environment variable

  • default – the default return, if the environment variable is not defined

Returns:

the requested environment variable or the default if the var is not defined and a default has been provided.