scistag.common.env.Env

class Env[source]

Bases: object

Environment helper class

Methods

insert_environment_data

Searches for double curly brackets inside string followed by env.

load_env_file

Loads an environment file located at str and applies it

Attributes

__dict__

__doc__

__module__

__weakref__

list of weak references to the object (if defined)

static insert_environment_data(text)[source]

Searches for double curly brackets inside string followed by env. All occurrences for which an environment exists will be replaced with the environment variables content.

Example: https://{{env.username}}:{{env.password}}@myserver.com

will insert the environment variables username and password inside the string.

Parameters

text (str) – The text to search within

Returns

The string into which the environment variables were inserted

static load_env_file(path, fail_silent=False)[source]

Loads an environment file located at str and applies it

The file is usually named .env and has the format key=value where a key value pair is defined per line.

Parameters
  • path (str) – The file’s path.

  • fail_silent (bool) – If set no error will be risen if the file is missing.

Return type

dict

Returns

A dictionary containing all key value pairs