Improved docstrings + minor changes in config_utils.py

This commit is contained in:
troymc 2016-04-18 11:07:53 +02:00
parent 5482934868
commit 21d234a1eb

View File

@ -22,6 +22,7 @@ from pkg_resources import iter_entry_points, ResolutionError
import bigchaindb import bigchaindb
from bigchaindb.consensus import AbstractConsensusRules from bigchaindb.consensus import AbstractConsensusRules
# logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
CONFIG_DEFAULT_PATH = os.environ.setdefault( CONFIG_DEFAULT_PATH = os.environ.setdefault(
@ -78,19 +79,21 @@ def update(d, u):
def file_config(filename=None): def file_config(filename=None):
"""Returns the values found in a configuration file. """Returns the config values found in a configuration file.
Args: Args:
filename (str): the JSON file with the configuration. Defaults to ``None``. filename (str): the JSON file with the configuration values.
If ``None``, the HOME of the current user and the string ``.bigchaindb`` will be used. If ``None``, CONFIG_DEFAULT_PATH will be used.
Note: Returns:
The function merges the values in ``filename`` with the **default configuration**, dict: The config values in the specified config file (or the
so any update made to ``bigchaindb.config`` will be lost. file at CONFIG_DEFAULT_PATH, if filename == None)
""" """
logger.debug('On entry into file_config(), filename = {}'.format(filename))
if not filename: if not filename:
filename = CONFIG_DEFAULT_PATH filename = CONFIG_DEFAULT_PATH
logger.debug('file_config() will try to open `{}`'.format(filename))
with open(filename) as f: with open(filename) as f:
config = json.load(f) config = json.load(f)
@ -210,7 +213,7 @@ def autoconfigure(filename=None, config=None, force=False):
if config: if config:
newconfig = update(newconfig, config) newconfig = update(newconfig, config)
return set_config(newconfig) set_config(newconfig) # sets bigchaindb.config
def load_consensus_plugin(name=None): def load_consensus_plugin(name=None):