Skip to main content

Zeroncy

A simple python tool to make your projet more decoupled.

Just put your project variables on a config file instead store in encironment variable. You can use a .env for json file...

PyPI version Coverage Tests Code style: black License: GPL v2

Installing

pip install zeroncy

How to Use

  1. Using .env file
  • create a .env file in project root and set variables...

    DATABASE_URL=postgres://user:pwd@localhost:5432/psql
    ALLOWED_HOSTS=localhost, 127.0.0.0.1
    PORT=5000
    
  • Then you could use your variables on your settings module...

    >>> import zeroncy
    
    >>> zeroncy.config()
    
    >>> zeroncy.get("DATABASE_URL")
    'postgres://user:pwd@localhost:5432/psql'
    
    # If you want a diferent type you can pass the cast parameter
    
    >>> zeroncy.get("PORT", cast=int)
    5000
    
    # If your var has more than one value, you must set the many parameter to true...
    
    >>> zeroncy.get("ALLOWED_HOSTS", many=True)
    ['localhost', '127.0.0.0.1']
    
  1. Using .env.json file
  • Create a .env.json file on project root:

    {
        "DATABASE_URL": "postgres://user:pwd@localhost:5432/psql",
        "ALLOWED_HOSTS": "localhost, 127.0.0.0.1",
        "PORT": 5000
    }
    
  • Then you could use on a similar way as the previous

    >>> import zeroncy
    
    >>> zeroncy.config(dict) # passes dict as parameter
    
    >>> zeroncy.get("DATABASE_URL")
    'postgres://user:pwd@localhost:5432/psql'
    
    >>> zeroncy.get("PORT")
    5000
    
    >>> zeroncy.get("ALLOWED_HOSTS", many=True)
    ['localhost', '127.0.0.0.1']
    
    # Note that on Json config you don't need to passes cast parameter for other types (Integer in this example)
    

References


LICENSE

                GNU GENERAL PUBLIC LICENSE
                   Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. https://fsf.org/ Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

Metadata

Release files for zeroncy 1.0.2

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

Source distribution (sdist)

Source distribution for zeroncy 1.0.2
File Size Uploaded
zeroncy-1.0.2.tar.gz 19.5 kB Details

Release files / zeroncy-1.0.2.tar.gz

Download URL zeroncy-1.0.2.tar.gz
Size 19.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0ff110ee3de2d9cb683f17b5d019b5cf921651482935c8a3ed30e904f132f683
BLAKE2b-256 checksum
How to use checksums
610ae98844dd1659064a44c3df9d5e3d8f91fe8e4004e29a90691d1b35812bf6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.3.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.6

Release history Release notifications | RSS feed

This release

1.0.2 This release

1 release file

1.0.1

1 release file

1.0

2 release files

0.5

1 release file

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