|
@@ -1,28 +1,35 @@
|
|
|
-import sys
|
|
|
from pathlib import Path
|
|
|
|
|
|
import yaml
|
|
|
|
|
|
__all__ = [
|
|
|
- 'mongo_conf', 'redis_conf', 'oss_conf', 'es_conf',
|
|
|
+ 'mongo_conf',
|
|
|
+ 'redis_conf',
|
|
|
+ 'oss_conf',
|
|
|
+ 'es_conf',
|
|
|
'constants',
|
|
|
- 'headers', 'jy_proxy', 'node_module', 'crawler_url',
|
|
|
- 'region', 'analyze_url', 'node_module_path'
|
|
|
+ 'headers',
|
|
|
+ 'jy_proxy',
|
|
|
+ 'crawler_url',
|
|
|
+ 'region',
|
|
|
+ 'analyze_url',
|
|
|
+ 'node_module_path'
|
|
|
]
|
|
|
|
|
|
-base_path = Path(__file__).parent
|
|
|
-yaml_conf = (base_path / 'conf.yaml').resolve()
|
|
|
-yaml_constants = (base_path / 'constants.yaml').resolve()
|
|
|
-yaml_areas = (base_path / 'areas.yaml').resolve()
|
|
|
+_base_path = Path(__file__).parent
|
|
|
+_yaml_conf = (_base_path / 'conf.yaml').resolve()
|
|
|
+_yaml_constants = (_base_path / 'constants.yaml').resolve()
|
|
|
+_yaml_areas = (_base_path / 'areas.yaml').resolve()
|
|
|
+_node_modules = (_base_path.parent / 'node_modules').resolve()
|
|
|
|
|
|
-with open(yaml_conf, encoding="utf-8") as f:
|
|
|
+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:
|
|
|
+with open(_yaml_constants, encoding="utf-8") as fp:
|
|
|
constants = yaml.safe_load(fp)
|
|
|
headers: dict = constants['headers']
|
|
|
jy_proxy: dict = constants['proxy']
|
|
@@ -30,12 +37,9 @@ with open(yaml_constants, encoding="utf-8") as fp:
|
|
|
crawler_url: dict = constants['crawler_url']
|
|
|
analyze_url = f'http://{es_conf["host"]}:{es_conf["port"]}/{es_conf["db"]}/_analyze'
|
|
|
|
|
|
-with open(yaml_areas, encoding="utf-8") as fr:
|
|
|
+with open(_yaml_areas, encoding="utf-8") as fr:
|
|
|
areas = yaml.safe_load(fr)
|
|
|
region: dict = areas['area']
|
|
|
|
|
|
|
|
|
-if sys.platform == 'linux':
|
|
|
- node_module_path = node_module['linux']
|
|
|
-else:
|
|
|
- node_module_path = node_module['windows']
|
|
|
+node_module_path = _node_modules
|