{ "info": { "author": "Klemen Sever", "author_email": "klemen@achedeuzot.me", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content" ], "description": "==============\nDjango EnvConf\n==============\n\n.. image:: https://travis-ci.org/achedeuzot/django-envconf.svg?branch=master\n :target: https://travis-ci.org/achedeuzot/django-envconf.svg?branch=master\n\n.. image:: https://coveralls.io/repos/github/achedeuzot/django-envconf/badge.svg?branch=master\n :target: https://coveralls.io/github/achedeuzot/django-envconf?branch=master\n\n\nDjango EnvConf allows you to configure your application using environment variables\nas recommended by the 12factor methodology.\n\nShamelessly forked & updated from https://github.com/joke2k/django-environ\n\n-----------\nQuick start\n-----------\n\n1. Add \"envconf\" at the top of your ``settings.py`` file like so:\n\n.. code-block:: python\n\n from envconf import Env\n env = Env( # Set default values and casting\n DEBUG=(bool, False)\n )\n env.read_env() # Tries to read the `.env` file which is next to the `manage.py` script.\n # It's probably better to give the path to be sure it'll read the correct file.\n\n\n2. Create a ``.env`` file at the root of your project\n\n.. code-block:: shell\n\n DEBUG=on # or off / false\n # DJANGO_SETTINGS_MODULE=myapp.settings.dev\n SECRET_KEY=Tom-Marvolo-Riddle\n DATABASE_URL=psql://user:un-gitted-password@127.0.0.1:8458/database\n # DATABASE_URL=sqlite:////my-local-sqlite.db # sqlite, notice the 4 slashes. See below for more cases.\n CACHE_URL=memcache://127.0.0.1:11211,127.0.0.1:11212,127.0.0.1:11213\n REDIS_URL=rediscache://127.0.0.1:6379:1?client_class=django_redis.client.DefaultClient&password=un-gitted-password\n\n3. Then fetch the variable you want from the environment in your ``settings.py`` file:\n\n\n.. code-block:: python\n\n DEBUG = env('DEBUG') # Defaults to False\n SECRET_KEY = env('SECRET_KEY') # Raises ImproperlyConfigured exception if SECRET_KEY is not set\n DATABASES = {\n 'default': env.db(), # Raises ImproperlyConfigured exception if DATABASE_URL not in os.environ\n 'extra': env.db('SQLITE_URL', default='sqlite:////tmp/my-tmp-sqlite.db')\n }\n\n------------\nInstallation\n------------\n\nThrough Pypi\n\n.. code-block:: shell\n\n (venv)$ pip install django-envconf\n\nDirectly from git\n\n.. code-block:: shell\n\n (venv)$ pip install git+https://github.com/achedeuzot/django-envconf.git\n # or\n (venv)$ git clone https://github.com/achedeuzot/django-envconf.git && cd django-envconf\n (venv)$ python setup.py install\n\n-----\nUsage\n-----\nIn your settings or configuration module, first either import the standard parser or a Django schema:\n\n.. code-block:: python\n\n # Default\n from envconf import Env\n env = Env()\n\n # Schemas\n from envconf.schemas.django110 import Django110Env as env\n env('DEBUG') # defaults to False\n # Defaults with the following:\n # DEBUG bool\n # SECRET_KEY str\n # DATABASES extracted from DATABASE_URL to dict()\n\n``env`` can be called two ways:\n\n- Type explicit: ``env('VAR_NAME', cast=bool)``\n- Type implicit (see below for supported types): ``env.TYPE('ANOTHER_VAR')``. If type is not specified, it defaults\n to ``str``\n\nCasting explicitly:\n\n.. code-block:: python\n\n # Environment variable: MAIL_ENABLED=1\n\n mail_enabled = env('MAIL_ENABLED', cast=bool)\n # OR mail_enabled = env.bool('MAIL_ENABLED')\n assert mail_enabled is True\n\nCasting nested types (lists and dicts):\n\n.. code-block:: python\n\n # Environment variable: FOO=1,2,3\n foo = env('FOO'), cast=list(int))\n assert foo == [1, 2, 3]\n\nYou can also set defaults:\n\n.. code-block:: python\n\n # Environment variable MAX_ROWS has not been defined\n max_rows = env.int('MAX_ROWS', default=100)\n assert max_rows == 100\n\nThere are some convenience methods:\n- json (a regular JSON string is expected)\n- url (which returns a ``urlparse.ParseResult`` object)\n\n.. code-block:: python\n\n # Environment variable: DATA={\"foo\":\"bar\",\"baz\":true}\n data = env.json('DATA')\n # data = {\n # \"foo\": \"bar\",\n # \"baz\": True,\n # }\n\n # Environment variable: SERVICE=ftp://user:password@example.com/some/path?var=foo\n >>> env.url('SERVICE')\n ParseResult(scheme='ftp', netloc='user:password@example.com',\n path='/some/path', params='', query='var=foo', fragment='')\n\n\nProxied Values\n==============\nAn environment value or default can reference another environ value by referring to it with a $ sign. For example:\n\n.. code-block:: python\n\n PROXIED_VAL = 'hello'\n TEST_VAL ='$PROXIED_VAL'\n environ('TEST_VAL') == 'hello\n environ('UNKNOWN_VAL', default='$PROXIED_VAL') == 'hello'\n\nProxy values are resolved by default. To turn off resolving proxy values\npass ``resolve_proxies=False`` to ``environ``, ``environ.str``, or ``environ.unicode``.\n\nEx: ``environ('DJANGO_SECRET_KEY', '$1233FJSIFWR44', resolve_proxies=False)``\n\nIf you get an infinite recursion when using environ most likely you have an unresolved and perhaps\nunintentional proxy value in an environ string.\nFor example ``environ('DJANGO_SECRET_KEY', '$1233FJSIFWR44')`` will cause an infinite\nrecursion unless you add ``resolve_proxies=False``.\n\nThis is very useful in environment such as Heroku. That way, if you\nchange your mind later on, you just need to change the configuration (see below) and not your code.\n\n.. code-block:: python\n\n # Environment variables: MAILGUN_SMTP_LOGIN=foo,\n # SMTP_LOGIN='$MAILGUN_SMTP_LOGIN'\n\n smtp_login = env('SMTP_LOGIN')\n assert smtp_login == 'foo'\n\n # Change of mind\n # Environment variales: MANDRILL_SMTP_LOGIN=bar\n # SMTP_LOGIN='$MANDRILL_SMTP_LOGIN'\n smtp_login = env('SMTP_LOGIN) # Look ma', no hands !\n assert smtp_login == 'bar'\n\n\nSupported Types\n===============\n- str\n- bool\n- int\n- float\n- json\n- list as CSV (FOO=a,b,c)\n- tuple (FOO=(a,b,c))\n- dict (dict (BAR=key=val,foo=bar) # envconf.Env(BAR=(dict, {}))\n- dict (BAR=key=val;foo=1.1;baz=True) # envconf.Env(BAR=(dict(value=unicode, cast=dict(foo=float,baz=bool)), {}))\n- url\n- path (environ.Path)\n- db_url\n\n - PostgreSQL: postgres://, pgsql://, psql:// or postgresql://\n - PostGIS: postgis://\n - MySQL: mysql:// or mysql2://\n - MySQL for GeoDjango: mysqlgis://\n - SQLITE: sqlite:// (sqlite://:memory: for in-memory database, or sqlite:////file/path [4 slashes !])\n - SQLITE with SPATIALITE for GeoDjango: spatialite://\n - Oracle: oracle://\n - LDAP: ldap://\n- cache_url\n\n - Dummy: dummycache://\n - Database: dbcache://\n - File: filecache://\n - Memory: locmemcache://\n - Memcached: memcache://\n - Python memory: pymemcache://\n - Redis: rediscache://\n- search_url\n\n - ElasticSearch: elasticsearch://\n - Solr: solr://\n - Whoosh: whoosh://\n - Xapian: xapian://\n - Simple cache: simple://\n- email_url\n\n - Dummy mail: dummymail://\n - SMTP: smtp://\n - SMTP+SSL: smtp+ssl://\n - SMTP+TLS: smtp+tls://\n - Console mail: consolemail://\n - File mail: filemail://\n - LocMem mail: memorymail://\n\n\n-----\nTests\n-----\nClone the repo and run the tests ;)\n\n.. code-block:: shell\n\n (venv)$ git clone git@github.com/achedeuzot/django-envconf.git\n (venv)$ cd django-envconf\n (venv)$ python setup.py test\n\n-------\nLicense\n-------\nDjango-envconf is licensed under the BSD License - see the LICENSE file for details\n\n\n-------------\nCompatibility\n-------------\n\nPython 2.6, 2.7, 3.3, 3.4, 3.5\n\nDjango 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 1.10\n\n\n-------\nCredits\n-------\n\n- `django-environ`_ and its contributors & own creditsof course ! Thanks for the awesome package :)\n\n.. _django-environ: https://github.com/joke2k/django-environ\n\n---------\nChangelog\n---------\n\n\n0.1.0, 0.2.0, 0.3.* - 12 Sept 2016\n\n- Fork from ``django_environ`` and update of codebase: removal of six dependencly, better oracle support,\n better URL parsing", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/achedeuzot/django-envconf/tarball/0.3.5", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/achedeuzot/django-envconf", "keywords": null, "license": "BSD License", "maintainer": null, "maintainer_email": null, "name": "django-envconf", "package_url": "https://pypi.org/project/django-envconf/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-envconf/", "project_urls": { "Download": "https://github.com/achedeuzot/django-envconf/tarball/0.3.5", "Homepage": "https://github.com/achedeuzot/django-envconf" }, "release_url": "https://pypi.org/project/django-envconf/0.3.5/", "requires_dist": null, "requires_python": null, "summary": "Django-envconf allows you to configure your application using environment variables as recommended by the 12factor methodology.", "version": "0.3.5" }, "last_serial": 2906538, "releases": { "0.3.3": [ { "comment_text": "", "digests": { "md5": "72c82fede8f1f6fbb16dc9535132a73c", "sha256": "4c99a20434e35b042c112ca5de3da831e1b8b75825c73a51adae355d9613ee5e" }, "downloads": -1, "filename": "django-envconf-0.3.3.tar.gz", "has_sig": false, "md5_digest": "72c82fede8f1f6fbb16dc9535132a73c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20534, "upload_time": "2016-09-12T23:23:06", "url": "https://files.pythonhosted.org/packages/df/8f/9b5cfa5e6371e096b17476447cd787708266b8375755ea2df30715d8e806/django-envconf-0.3.3.tar.gz" } ], "0.3.4": [ { "comment_text": "", "digests": { "md5": "09e0e31fba5612e96c79c54719131fad", "sha256": "c5466d6ed0062f66551b61c1ff4579815dd6391e47c66c741e2d8e8bc6715cc3" }, "downloads": -1, "filename": "django-envconf-0.3.4.tar.gz", "has_sig": false, "md5_digest": "09e0e31fba5612e96c79c54719131fad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20605, "upload_time": "2016-09-12T23:29:41", "url": "https://files.pythonhosted.org/packages/c1/4e/9b14fca2a146b6f080a1fdc38e4e494e056d817055788106f263de7fb186/django-envconf-0.3.4.tar.gz" } ], "0.3.5": [ { "comment_text": "", "digests": { "md5": "dfc238b52ddf1d4db354db5d8563fef2", "sha256": "49bb0823daaf1c457afd6ab533d43fd8b9435c5791bb11526f6860f18e5835ea" }, "downloads": -1, "filename": "django-envconf-0.3.5.tar.gz", "has_sig": false, "md5_digest": "dfc238b52ddf1d4db354db5d8563fef2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20676, "upload_time": "2017-05-29T13:57:28", "url": "https://files.pythonhosted.org/packages/15/57/0d5b2afb128207062814e30bfad8fb668b61ed82659089b65d24c63ee8d1/django-envconf-0.3.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "dfc238b52ddf1d4db354db5d8563fef2", "sha256": "49bb0823daaf1c457afd6ab533d43fd8b9435c5791bb11526f6860f18e5835ea" }, "downloads": -1, "filename": "django-envconf-0.3.5.tar.gz", "has_sig": false, "md5_digest": "dfc238b52ddf1d4db354db5d8563fef2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20676, "upload_time": "2017-05-29T13:57:28", "url": "https://files.pythonhosted.org/packages/15/57/0d5b2afb128207062814e30bfad8fb668b61ed82659089b65d24c63ee8d1/django-envconf-0.3.5.tar.gz" } ] }