def split_config(config):
"""Split the 'config' object into a set of fields.
:param config: Configuration
:type param: dict or str
:raises: yaml.error.YAMLError if config is a str that doesn't parse
"""
if not isinstance(config, dict):
config = yaml.load(config)
db = config.get("db", None)
host = config.get("host", "0.0.0.0")
user_name = config.get("user_name", None)
password = config.get("password", None)
port = int(config.get("port", 27017))
coll = config.get("collection", None)
return db, host, user_name, password, port, coll
评论列表
文章目录