Skip to content
This repository was archived by the owner on Feb 11, 2023. It is now read-only.

Commit 4be3752

Browse files
committed
Quick start re-added
1 parent 4b76554 commit 4be3752

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

README.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,45 @@ Source Code and Issue Tracking
2727
------------------------------
2828

2929
https://github.com/jbasko/configmanager
30+
31+
Quick Start
32+
-----------
33+
34+
Install from Python Package index with ``pip install configmanager``.
35+
36+
Declare your configuration, the sources, and off you go.
37+
Remember, every configuration item is an object, not just a plain
38+
configuration value.
39+
If you don't need the rich features of configuration items,
40+
use :class:`.configmanager.PlainConfig` instead.
41+
42+
.. code-block:: python
43+
44+
import warnings
45+
from configmanager import Config
46+
47+
config = Config({
48+
'uploads': {
49+
'threads': 1,
50+
'enabled': False,
51+
'db': {
52+
'user': 'root',
53+
'password': {
54+
'@default': 'root',
55+
'@envvar': 'MY_UPLOADER_DB_PASSWORD',
56+
},
57+
}
58+
}
59+
}, load_sources=[
60+
'/etc/my-uploader/config.ini',
61+
'~/.config/my-uploader/config.json',
62+
], auto_load=True)
63+
64+
if config.uploads.db.user.is_default:
65+
warnings.warn('Using default db user!')
66+
67+
if config.uploads.enabled.get():
68+
connect_to_database(
69+
user=config.uploads.db.user.get(),
70+
password=config.uploads.db.password.get(),
71+
)

0 commit comments

Comments
 (0)