Skip to main content

Environment variable helpers

Project description

Roskarl

Is a tiny module for environment variables.

Requires

Python 3.9.5

How to install

pip install roskarl

Example usage

from roskarl.env import (
    env_var_bool,
    env_var_cron,
    env_var_float,
    env_var_int,
    env_var_list,
    env_var,
    env_var_tz,
    env_var_dsn,
    DSN
)

str

value = env_var(name="STR_VAR")

returns str

bool

value = env_var_bool(name="BOOL_VAR")

tz

value = env_var_tz(name="TZ_VAR")

list

value = env_var_list(name="LIST_VAR", separator="|")

returns list if value is splittable by separator

int

value = env_var_int(name="INT_VAR")

returns int if value is numeric

float

value = env_var_float(name="INT_VAR")

returns float if value is float

cron

value = env_var_cron(name="CRON_EXPRESSION_VAR")

DSN

Note: if you use special characters in the password, these must be URL-encoded

from urllib.parse import quote
password = 'My$ecret!Pass@2024'
encoded = quote(password, safe='')
print(encoded)  # My%24ecret%21Pass%402024 <--- use this
value = env_var_dsn(name="DSN_VAR", type)

returns DSN object if value is like a dsn

needs to be formatted like this:

postgresql://username:password@hostname:5432/database_name

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

roskarl-2.3.4.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

roskarl-2.3.4-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file roskarl-2.3.4.tar.gz.

File metadata

  • Download URL: roskarl-2.3.4.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for roskarl-2.3.4.tar.gz
Algorithm Hash digest
SHA256 a7191c70fbd82b4a4915c10334e28cd6da9d40ed5c20b53094ada84684b149e1
MD5 3220b818230b378866c0ca7ef07f09fc
BLAKE2b-256 18431387d8b7c0598beb44a07f0dd2be1be228760a130da02dfce1747f54c212

See more details on using hashes here.

File details

Details for the file roskarl-2.3.4-py3-none-any.whl.

File metadata

  • Download URL: roskarl-2.3.4-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for roskarl-2.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 39882f0b60f67b7e77e40b5aaa3caf31039db6c495364bed5063337a685ce653
MD5 8ffba7e15591372d6c189e1a717441dc
BLAKE2b-256 87b9ac74073601b77f193f19b92dfc2966d9c736fe290832ba4e9f774f4233ed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page