plesty.server.model.envfile

A device’s .env file: the values plesty-lib’s EnvSettings reads.

Every hub device reads its instrument address, credentials and report archive from .env in its working directory — the same file for the server and the field test. On a bench that file is <home>/run/<name>/.env (the server’s working directory); the presenter also folds it into the environment of a field-test run, whose working directory is the checkout.

The format is the usual dotenv subset: KEY=VALUE per line, # comments, optional single or double quotes around the value, export prefix ignored.

Attributes

ENV_FILENAME

Functions

parse_env(→ dict[str, str])

Parse dotenv text into a mapping (later keys win).

render_env(→ str)

Render a mapping as dotenv text (one KEY=VALUE per line, quoted when needed).

read_env(→ dict[str, str])

Parse the file at path; empty when it does not exist.

_quote(→ str)

Module Contents

plesty.server.model.envfile.ENV_FILENAME = '.env'
plesty.server.model.envfile.parse_env(text: str) dict[str, str]

Parse dotenv text into a mapping (later keys win).

Parameters:

text (str)

Return type:

dict[str, str]

plesty.server.model.envfile.render_env(values: collections.abc.Mapping[str, str]) str

Render a mapping as dotenv text (one KEY=VALUE per line, quoted when needed).

Parameters:

values (collections.abc.Mapping[str, str])

Return type:

str

plesty.server.model.envfile.read_env(path: str | os.PathLike[str]) dict[str, str]

Parse the file at path; empty when it does not exist.

Parameters:

path (str | os.PathLike[str])

Return type:

dict[str, str]

plesty.server.model.envfile._quote(value: str) str
Parameters:

value (str)

Return type:

str