env_file
env_file
¶
Environment files (.env), for the --envfile command line argument.
This module has no nyx imports so it can run before the rest of the package is imported.
Functions¶
load_env_file(path)
¶
Set the variables of an environment file in this process.
Variables are set in order, so a value can refer to one above it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path | str
|
environment file. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
variables that were set. |
Raises:
| Type | Description |
|---|---|
OSError
|
the file can't be read. |
Source code in src/nyx/static/env_file.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
parse_env_file(text)
¶
Parse the content of an environment file.
Lines are NAME=value, optionally after export. Blank lines and lines starting
with # are skipped, so are lines without a name or an =. A value in single quotes
is taken as it is, one in double quotes or without quotes gets $NAME references
expanded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
content of the file. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
variables in the order of the file. |
Source code in src/nyx/static/env_file.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |