import sys from pathlib import Path import yaml __all__ = [ 'mongo_conf', 'redis_conf', 'oss_conf', 'es_conf', 'constants', 'headers', 'jy_proxy', 'node_module', 'analyze_url', 'node_module_path' ] base_path = Path(__file__).parent yaml_conf = (base_path / 'conf.yaml').resolve() yaml_constants = (base_path / 'constants.yaml').resolve() with open(yaml_conf, encoding="utf-8") as f: conf = yaml.safe_load(f) mongo_conf = conf['mongo'] redis_conf = conf['redis'] es_conf: dict = conf['es'] oss_conf: dict = conf['ali_oss'] with open(yaml_constants, encoding="utf-8") as fp: constants = yaml.safe_load(fp) headers: dict = constants['headers'] jy_proxy: dict = constants['proxy'] node_module: dict = constants['node_module'] analyze_url = f'http://{es_conf["host"]}:{es_conf["port"]}/{es_conf["db"]}/_analyze' if sys.platform == 'linux': node_module_path = node_module['linux'] else: node_module_path = node_module['windows']