Observed since 20 Oct, 19:30 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
adi-env-parser
Adinsure Environment parser
EnvironmentParser class parses all environment variables with certain prefix and creates a Python dictionary based on the structure of these variables. The values are converted to booleans and integers when detected as such by default.
General variable structure rules:
Value conversion rules:
true or false when lower
casedExample of instantiating of EnvironmentParser object using MYPREFIX as a prefix
for environment variables. Upon instantiation, the object will automatically parse
the current environment variables and store them in its configuration property.
import json
from adi_env_parser import EnvironmentParser
parser = EnvironmentParser(prefix="MYPREFIX")
print(json.dump(json.dumps(parser.configuration, indent=4)))
It is possible to provide existing JSON/JSONC formatted file as a configuration base.
import json
from adi_env_parser import EnvironmentParser
parser = EnvironmentParser(prefix="MYPREFIX", config_file="configuration.json")
print(json.dump(json.dumps(parser.configuration, indent=4)))
It is possible to disable value conversion by setting convert_values parameter
when instantiating EnvironmentParser object.
from adi_env_parser import EnvironmentParser
parser = EnvironmentParser(prefix="MYPREFIX", convert_values=False)
Examples use PYENV as environment variable prefix. This is default prefix used when not specifying one explicitly when instatiating EnvironmentParser.
Environment variables:
PYENV_hotel_name="Blue Falcon"
PYENV_rooms__room_1="James Holden"
PYENV_rooms__room_2="Amos Burton"
PYENV_rooms__room_3="Naomi Nagata"
PYENV_rooms__room_4="Alex Kamal"
Resulting object:
{
"hotel_name": "Blue Falcon",
"rooms": {
"room_1": "James Holden",
"room_2": "Amos Burton",
"room_3": "Naomi Nagata",
"room_4": "Alex Kamal"
}
}
Environment variables:
PYENV_hotel_name="Blue Falcon"
PYENV_room_1__inventory__0="Wardrobe"
PYENV_room_1__inventory__1="Table"
PYENV_room_1__inventory__2="Lamp"
Resulting object:
{
"hotel_name": "Blue Falcon",
"room_1": {
"inventory": [
"Wardrobe",
"Table",
"Lamp"
]
}
}
Environment variables:
PYENV_hotel_name="Blue Falcon"
PYENV_rooms__0__name="Room 1"
PYENV_rooms__0__capacity="2"
PYENV_rooms__2__name="Room 2"
PYENV_rooms__2__capacity="2"
Resulting object:
{
"hotel_name": "Blue Falcon",
"rooms": [
{
"name": "Room 1",
"capacity": "2"
},
{
"name": "Room 2",
"capacity": "2"
}
]
}
Module provides console utility which can be used for parsing of environment variables. It also supports reading of existing JSON/JSONC formatted file and setting indentation for output of created configuration JSON object.
➜ adi-env-parser --help
usage: adi-env-parser -p <prefix> -j <base_json_file>
Parses environment variables with defined prefix and creates JSON output from the parsed structure.
optional arguments:
-h, --help show this help message and exit
--prefix [PREFIX], -p [PREFIX]
Environment variable prefix. Default: PYENV
--json [JSON], -j [JSON]
JSON/JSONC formatted file to read as base configuration
--indent [INDENT], -i [INDENT]
Number of spaces to use for indentation of output JSON string
--ignore-prefix IGNORE_PREFIX, -n IGNORE_PREFIX
Environment variable prefix to ignore. Can be used multiple times.
pip install -e ".[dev]"
pip install -e ".[test]"
# Install build-local package group if you want to build packages locally
pip install -e ".[build-local]"
pre-commit install
New version is built and published on tag in GitHub repository. The package version is infered from commit name.
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
pyjson5Environment{
"extras": "",
"marker": null,
"requires_python": "<4,>=3.8",
"evaluation": "NOT_EVALUATED"
} | pyjson5>=2.0.1 | runtime |
pre-commitEnvironment{
"extras": "",
"marker": "extra == \"dev\"",
"requires_python": "<4,>=3.8",
"evaluation": "NOT_EVALUATED"
} | pre-commit; extra == "dev" | runtime |
autopep8Environment{
"extras": "",
"marker": "extra == \"dev\"",
"requires_python": "<4,>=3.8",
"evaluation": "NOT_EVALUATED"
} | autopep8; extra == "dev" | runtime |
pytestEnvironment{
"extras": "",
"marker": "extra == \"dev\"",
"requires_python": "<4,>=3.8",
"evaluation": "NOT_EVALUATED"
} | pytest; extra == "dev" | runtime |
pytestEnvironment{
"extras": "",
"marker": "extra == \"test\"",
"requires_python": "<4,>=3.8",
"evaluation": "NOT_EVALUATED"
} | pytest; extra == "test" | runtime |
setuptoolsEnvironment{
"extras": "",
"marker": "extra == \"build-local\"",
"requires_python": "<4,>=3.8",
"evaluation": "NOT_EVALUATED"
} | setuptools>=45; extra == "build-local" | runtime |
setuptools-scmEnvironment{
"extras": "toml",
"marker": "extra == \"build-local\"",
"requires_python": "<4,>=3.8",
"evaluation": "NOT_EVALUATED"
} | setuptools-scm[toml]>=6.2; extra == "build-local" | runtime |
buildEnvironment{
"extras": "",
"marker": "extra == \"build-local\"",
"requires_python": "<4,>=3.8",
"evaluation": "NOT_EVALUATED"
} | build; extra == "build-local" | runtime |
bdist_wheel · 10.22 KB · Python py3
Shared repository data · GitHub
Observed since 20 Oct, 19:30 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:9ba75cf26eb76453471591a3180e1d034b306e397fc7fb38fd00f64affb6ec7b