json_config package¶
JSON Config¶
A convenience utility for working with JSON config files.
>>> import json_config, os
>>> config = json_config.connect('config.json')
>>> config['root'] = '/var/www/html'
>>> print(config['root'])
/var/www/html
>>> config
Connect({'root': '/var/www/html'})
>>> os.remove('config.json')
Submodules¶
json_config._compat module¶
Python 2to3 compatibility handling.
-
class
json_config._compat.
NullHandler
(level=0)[source]¶ Bases:
logging.Handler
This handler does nothing. It’s intended to be used to avoid the “No handlers could be found for logger XXX” one-off warning. This is important for library code, which may contain code to log events. If a user of the library does not configure logging, the one-off warning might be produced; to avoid this, the library developer simply needs to instantiate a NullHandler and add it to the top-level logger of the library module or package.
-
json_config._compat.
FileNotFoundError
¶ alias of
IOError
json_config.contracts module¶
json_config.main module¶
-
class
json_config.main.
AutoConfigBase
(config_file=None, **kwargs)[source]¶ Bases:
json_config.main.AutoSyncMixin
,json_config.main.AutoDict
-
class
json_config.main.
AutoDict
(obj=None, _root=None, _parent=None, _key=None)[source]¶ Bases:
json_config.main.TraceRootMixin
,collections.defaultdict
-
class
json_config.main.
AutoSyncMixin
(**kwargs)[source]¶ Bases:
json_config.contracts.AbstractSaveFile
,json_config.contracts.AbstractTraceRoot
,json_config.contracts.AbstractSerializer
-
config_file
= None¶
-
-
class
json_config.main.
PrettyJSONMixin
[source]¶ Bases:
json_config.contracts.AbstractSerializer
-
serializer_ext
= 'json'¶
-
serializer_indent
= 2¶
-
serializer_sort_keys
= True¶
-