Utility for the settings file
Project description
When describing in python of the configuration file, you need to change it in each environment. For example settings.py of Django. This package provides the utility to assist it.
Install
$ pip install custom_settings
How to use it
settings_custom.py
AUTH_CREDENTIAL = 'MY_CREDENTIAL' INTEGER_VALUE = '1'
Do the following to use this configuration file.
>>> import custom_settings
>>> custom = custom_settings.load('settings_custom')
>>> custom.get('AUTH_CREDENTIAL')
'MY_CREDENTIAL'
If you specified type_ argument, convert type to.
>>> custom.get('INTEGER_VALUE', type_=int, default=10)
1
If you specify True in use_environ, if it does not exist in settings_custom, acquired from the os.environ.
>>> custom.get('PS1', use_environ=True)
'$ '
If you specify default, if it does not exist in settings_custom, to used default.
>>> custom.get('NO_SET_VALUE', default=10)
10
If you specify True in raise_exception, if it does not exist in settings_custom, raise exception.
>>> custom.get('NO_SET_VALUE', use_environ=True, raise_exception=True)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/envs/3.5/lib/python3.5/site-packages/custom_settings/adapters.py", line 40, in get
raise exc.NoCustomSettingError('Not been set: {}'.format(name))
custom_settings.exc.NoCustomSettingError: Not been set: NO_SET_VALUE
Other
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file custom_settings-1.0.post1.tar.gz
.
File metadata
- Download URL: custom_settings-1.0.post1.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 602093385c141428676e512d1eab5aca5f942a125ddc44b57b7edc19d87a8789 |
|
MD5 | c3f6a62ea8a38c127f631d973cdbc4b0 |
|
BLAKE2b-256 | f943ddf28ee80c7a3c41e9b7473c31025718146ccf293a172c0fff75ecb68ec1 |
File details
Details for the file custom_settings-1.0.post1-py3-none-any.whl
.
File metadata
- Download URL: custom_settings-1.0.post1-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed2e025dc39e0755eb4cc0aa07fd81fd9a0fd4aed475b5e156232ff78f724fa6 |
|
MD5 | 331137f905ac092d415ef3b7180cc465 |
|
BLAKE2b-256 | 16b10f7ff4ef8ef03a297234528384ed237a2bb8406dbb0b918663017a29c044 |