WLD DeepCoin 단계별 구조 재편 및 설정·문서 통합
로고스/루트 레거시를 제거하고 deepcoin 패키지·scripts 01~05 CLI·docs/reference로 데이터·GT·분석·매칭·운영 단계를 정리했다. config와 .env 기반 설정, trade_anaysis.html 동기화 포함. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
53
deepcoin/env_loader.py
Normal file
53
deepcoin/env_loader.py
Normal file
@@ -0,0 +1,53 @@
|
||||
"""
|
||||
DeepCoin .env 로드 (프로젝트 루트 기준).
|
||||
|
||||
config·HTS·스크립트 진입 전에 한 번 호출하면 cwd와 무관하게 동일한 설정을 사용합니다.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from deepcoin.paths import PROJECT_ROOT
|
||||
|
||||
_ENV_LOADED = False
|
||||
ENV_FILE = PROJECT_ROOT / ".env"
|
||||
|
||||
|
||||
def load_project_env(*, override: bool = False) -> bool:
|
||||
"""
|
||||
PROJECT_ROOT/.env 를 python-dotenv로 로드합니다.
|
||||
|
||||
Args:
|
||||
override: True면 기존 OS 환경 변수를 .env 값으로 덮어씀.
|
||||
|
||||
Returns:
|
||||
.env 파일이 존재해 로드 시도했으면 True, 없으면 False.
|
||||
"""
|
||||
global _ENV_LOADED
|
||||
if _ENV_LOADED and not override:
|
||||
return ENV_FILE.is_file()
|
||||
|
||||
try:
|
||||
from dotenv import load_dotenv
|
||||
except ImportError:
|
||||
_ENV_LOADED = True
|
||||
return False
|
||||
|
||||
if ENV_FILE.is_file():
|
||||
load_dotenv(ENV_FILE, override=override)
|
||||
_ENV_LOADED = True
|
||||
return True
|
||||
|
||||
_ENV_LOADED = True
|
||||
return False
|
||||
|
||||
|
||||
def env_status() -> dict[str, str | bool]:
|
||||
"""디버그용 .env 상태."""
|
||||
return {
|
||||
"project_root": str(PROJECT_ROOT),
|
||||
"env_file": str(ENV_FILE),
|
||||
"env_exists": ENV_FILE.is_file(),
|
||||
"loaded": _ENV_LOADED,
|
||||
}
|
||||
Reference in New Issue
Block a user