Skip to main content

Zero dependency lib for python

Project description

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

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.

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

zeroncy-1.0.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

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

zeroncy-1.0-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file zeroncy-1.0.tar.gz.

File metadata

  • Download URL: zeroncy-1.0.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.9.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.1

File hashes

Hashes for zeroncy-1.0.tar.gz
Algorithm Hash digest
SHA256 e5eb53b6831ef7ffee9aded8728376eb49e72b181a26d6e9b1e0284942850e5e
MD5 5498ab106fc7c423d526c1350e89427b
BLAKE2b-256 ab3eb6771780ca4c9375cb31a93dc18292d4d6c7e2b5c40efd6b39b9f1def262

See more details on using hashes here.

File details

Details for the file zeroncy-1.0-py3-none-any.whl.

File metadata

  • Download URL: zeroncy-1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.9.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.1

File hashes

Hashes for zeroncy-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a46f97d0fbce0da2242bfacbc6b30b2867bf65ca553db8fbb4379dab7857475b
MD5 9a0ef83ed37fd71be92a3dcb4a8b75a2
BLAKE2b-256 79e54cf717d554cdb7b6feb2cc2887a719ce5e2a3898be571f5e69ef2bd69ad2

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