-
Notifications
You must be signed in to change notification settings - Fork 213
Open
Description
This is another try on #35.
An interesting idea would be to add a helper for mapping-like env values like:
DATABASE_URLS="SQLite3=sqlite://:memory:,PostgreSQL=postgres://postgres:postgres@localhost:5432/postgres"to return the respective Python dict objects. Implementation can be as simple as:
def parse_dict(value, *, item_sep=",", key_value_sep="="):
def split_and_strip(value, sep):
return list(map(str.strip, value.split(sep)))
items = split_and_strip(value, item_sep)
return dict(split_and_strip(item, key_value_sep) for item in items)or a similar callable class.
Something similar is implemented in environs.
but personally I prefer python-decouple as it natively supports .env file auto-reading.
Metadata
Metadata
Assignees
Labels
No labels