Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

configr: A practical configuration library for your Python apps.

Project Description
Configr 2017.1824.3119-8f16a2d
=======


.. image:: https://travis-ci.org/ArneBachmann/configr.svg?branch=master
:target: https://travis-ci.org/ArneBachmann/configr

.. image:: https://badge.fury.io/py/configr.svg
:target: https://badge.fury.io/py/configr

.. image:: https://coveralls.io/repos/github/ArneBachmann/configr/badge.svg?branch=master
:target: https://coveralls.io/github/ArneBachmann/configr?branch=master

.. image:: https://img.shields.io/pypi/pyversions/Django.svg
:target: https://github.com/ArneBachmann/configr

.. image:: https://img.shields.io/github/license/mashape/apistatus.svg
:target: https://github.com/ArneBachmann/configr


Synopsis
--------

This small utility library helps managing global or per-user configuration for your Python apps.
Installation through ``pip`` will install the ``appdirs`` package as a dependency, but the code may be used without any external dependencies as well.


Code Example
------------

Simple use::

>>> import configr
>>> cfg = configr.Configr("myapp")
>>> cfg.a = "Value of A"
>>> print cfg["a"]
Value of A


Motivation
----------

This library helps solving a common problem found in many apps: simplified configuration/settings/preset handling.


Installation
------------

Using pip::

pip install configr

Using setup.py (usually elevated rights are needed, e.g. via ``sudo`` (Linux) or ``runas`` (Windows))::

python setup.py install


API reference
-------------

The Configr object has the following functions::

__init__(_, name, data = {}, defaults = {}) # Constructor. "data" initializes the configuration, while "defaults" contains fallback values not explicity set on the configuration data.
saveSettings(_, keys = None, location = None) # Persist the configuration. "keys" limits the entries written. "location" is a file system path
loadSettings(_, data = {}, location = None, ignores = []) # load configuration. "data" is used if its key is not found in the file. "ignores" are keys to not load. location" is a file system path
keys(_) # returns list of keys in the configuration object (Python 2) or an dict_keys object (Python 3)

Configr objects support dictionary and attribute style access to get or set entries, as well as the usual means to remove entries via ``del`` and ``remove()``.
Both "loadSettings" and "saveSettings" support an additional "clientCodeLocation" parameter to allow passing a path to further separated several installation locations of the same app on a single file system. This allows to separate settings for each installation, if they are placed in different directories.

Both functions also return a named 2-tuple containing last loaded/saved file location in the first (.path), or an exception in the second (.error) position.


Building, packaging and distribution
------------------------------------

Run ``python setup.py build sdist`` to package the module.
Run ``twine upload dist/*.tar.gz`` to upload the module to PyPI.


Todo
----

This library is supposed to be lightweight and gets the job done so far.
If you have ideas, please put them into the projec's issue tracker on Github.


Tests
-----

The tool provides unit tests through the doctest module and integration tests through the unittest module.


Contributors
------------

This library is currently developed and maintained by Arne Bachmann.


License
-------

Licensed under the terms of MIT license.

MIT License

Copyright (c) 2016-2017 Arne Bachmann

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Release History

Release History

This version
History Node

2017.1824.3119

History Node

2017.1824.3043

History Node

2017.1707.2247

History Node

2017.1706.2413

History Node

2017.1701.3213

History Node

2017.1701.3212

History Node

2017.1701.3208

History Node

2017.1701.3146

History Node

2017.1701.3046

History Node

2017.1625.3048

History Node

2017.1623.3102

History Node

2017.1623.3024

History Node

2017.1623.2543

History Node

2017.1623.2542

History Node

2017.1623.2537

History Node

2017.1515.2733

History Node

2017.206.1733

History Node

2016.1230.2312

History Node

2016.1201.2318

History Node

2016.1201.2142

History Node

1.0.2

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
configr-2017.1824.3119.tar.gz (8.6 kB) Copy SHA256 Checksum SHA256 Source Aug 24, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting