Skip to main content

EnvServ

Before starting, install dotenv

pip install python-dotenv

EnvServ - Model view for easy Python development

Example №1

# file: .env
FirstVar = Hello, world!
SecondVar = 42
ThirdVar = 23
from envserv import EnvBase

class MyEnv(EnvBase):
    __envfile__ = '.env'

    FirstVar: str
    SecondVar: int
    ThirdVar: float

env = MyEnv()

print(env) # EnvServ(FirstVar:<class 'str'> = Hello, world!, SecondVar:<class 'int'> = 42, ThirdVar:<class 'float'> = 23.0)
print(env.FirstVar, env.SecondVar,env.ThirdVar) # Hello, world! 42 23.0
print(type(env.FirstVar), type(env.SecondVar), type(env.ThirdVar)) # <class 'str'> <class 'int'> <class 'float'>

Example №2

from envserv import EnvBase

class MyEnv(EnvBase):
    __envfile__ = '.env'

    FirstVar: str

env = MyEnv()

env.FirstVar = "New variable value" # Also changes a variable in the .env file

print(env) # EnvServ(FirstVar:<class 'str'> = New variable value)
print(env.FirstVar) # New variable value
print(type(env.FirstVar)) # <class 'str'>

Example №3

# file: .env
pass = 100
from envserv import EnvBase, variable

class MyEnv(EnvBase):
    __envfile__ = '.env'
    
    pass_: int = variable(alias='pass',overwrite=False)

env = MyEnv()

print(env) # EnvServ(pass_:<class 'int'> = 100)
print(env.pass_) # 100
print(type(env.pass_)) # <class 'int'>

env.pass_ = 1 # envserv.errors.EnvVariableError: Error overwriting variable pass_: It cannot be overwritten

Example №4

# file: .env
A = Text
ERR = this is error
C = [1, 2, 3, 4, 5]
D = {1: 2, 3: 4}
E = null
F = {1,2,3,4,5}
from envserv import EnvBase, Variable

class MyEnv(EnvBase):
    __envfile__ = '.env'
    
    A: str
    B: int = Variable(alias="ERR", error=False)
    C: list
    D: dict
    E: None
    F: set
    not_in: str = "test"


env = MyEnv()
print(env.all())
print(env.json())

# Output:
# {'A': 'Text', 'B': 'this is error', 'C': [1, 2, 3, 4, 5], 'D': {1: 2, 3: 4}, 'E': None, 'F': {1, 2, 3, 4, 5}, 'not_in': 'test'}
# {"A": "Text", "B": "this is error", "C": [1, 2, 3, 4, 5], "D": {"1": 2, "3": 4}, "E": null, "F": [1, 2, 3, 4, 5], "not_in": "test"}

Example 5

# file: .env
json_string = {"checked": null}
from envserv import EnvBase
from envserv.typing import JSON

class MyEnv(EnvBase):
    __envfile__ = '.env'
    
    json_string: JSON


env = MyEnv()
print(env.all())
print(env.json())

# Output:
# {'json_string': {'checked': None}}
# {"json_string": {"checked": null}}

Version logger

1.0.8

  • Added JSON support
  • Added CI/CD
  • Version filtering changed from latest to first
  • Code refactoring

1.0.7

  • Fixed variable function

1.0.6

  • Added the ability to have a default value for .env variable
  • Fixed reading of .env file

1.0.5

  • Code refactoring has been completed
  • Added class Variable
  • Added toString parameter to all() function and added json() function

1.0.4

  • Added support for the list, dict and None variable
  • Added parameter encoding to the class instance
  • Added function all() to display the dictionary

1.0.3

  • Fix alias param
  • Fix error message

1.0.2

  • Added setting for docker-compose (Variable __envfile__ does not need to be written)

1.0.1

  • Added rules for variable (beta)

1.0.0

  • Model added
  • Added variable change
  • Added class instance information output

Metadata

Release files for envserv 1.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for envserv 1.0.8
File Size Uploaded Provenance Actions
envserv-1.0.8.tar.gz 5.4 kB Without provenance Details for envserv-1.0.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for envserv 1.0.8
File Interpreter ABI Platform Actions
envserv-1.0.8-py3-none-any.whl Python 3 none any Details for envserv-1.0.8-py3-none-any.whl

Total release size: 11.8 kB

Release files / envserv-1.0.8.tar.gz

Download URL envserv-1.0.8.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
82307adccc154922dfd35a1aab85922d8a1c0c631b08929a67011bd155dcea9e
BLAKE2b-256 checksum
How to use checksums
0f860b1ddac2f94c2fc96fd386500a8b752c550c4cd4165d21cef4daf509fdb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / envserv-1.0.8-py3-none-any.whl

Download URL envserv-1.0.8-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
73f998f034c4f7c979be80c1e1d9833bc25fe13e8bf609fa9e1e557c07b1c1b4
BLAKE2b-256 checksum
How to use checksums
72023fe41c6be60bacf8f9d296613b96b26b71513a15ee1c4b076e68e7a0216a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for envserv 1.0.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page