load.py 853 B

1234567891011121314151617181920212223242526272829303132
  1. from pathlib import Path
  2. import yaml
  3. __all__ = [
  4. 'mongo_conf',
  5. 'redis_conf',
  6. 'es_conf',
  7. 'jy_proxy',
  8. 'node_module_path',
  9. 'headers',
  10. 'analyze_url'
  11. ]
  12. _base_path = Path(__file__).parent
  13. _yaml_conf = (_base_path / 'conf.yaml').resolve()
  14. _yaml_constants = (_base_path / 'constants.yaml').resolve()
  15. _node_modules = (_base_path.parent / 'node_modules').resolve()
  16. with open(_yaml_conf, encoding="utf-8") as f:
  17. _conf = yaml.safe_load(f)
  18. mongo_conf = _conf['mongo']
  19. redis_conf = _conf['redis']
  20. es_conf: dict = _conf['es']
  21. jy_proxy: dict = _conf['proxy']
  22. node_module_path = _node_modules
  23. analyze_url = f'http://{es_conf["host"]}:{es_conf["port"]}/{es_conf["db"]}/_analyze'
  24. with open(_yaml_constants, encoding="utf-8") as fp:
  25. _constants = yaml.safe_load(fp)
  26. headers: dict = _constants['headers']