Skip to main content

Utility for the settings file

Project description

CircleCI Status CodeCov Status

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


Download files

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

Source Distribution

custom_settings-1.0.post1.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

custom_settings-1.0.post1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file custom_settings-1.0.post1.tar.gz.

File metadata

File hashes

Hashes for custom_settings-1.0.post1.tar.gz
Algorithm Hash digest
SHA256 602093385c141428676e512d1eab5aca5f942a125ddc44b57b7edc19d87a8789
MD5 c3f6a62ea8a38c127f631d973cdbc4b0
BLAKE2b-256 f943ddf28ee80c7a3c41e9b7473c31025718146ccf293a172c0fff75ecb68ec1

See more details on using hashes here.

File details

Details for the file custom_settings-1.0.post1-py3-none-any.whl.

File metadata

File hashes

Hashes for custom_settings-1.0.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 ed2e025dc39e0755eb4cc0aa07fd81fd9a0fd4aed475b5e156232ff78f724fa6
MD5 331137f905ac092d415ef3b7180cc465
BLAKE2b-256 16b10f7ff4ef8ef03a297234528384ed237a2bb8406dbb0b918663017a29c044

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page