init python part (#7)

This commit is contained in:
KevinHuSh
2023-12-14 19:19:03 +08:00
committed by GitHub
parent 95c6cbbf45
commit f4456af464
21 changed files with 582328 additions and 0 deletions

24
python/util/config.py Executable file
View File

@ -0,0 +1,24 @@
from configparser import ConfigParser
import os,inspect
CF = ConfigParser()
__fnm = os.path.join(os.path.dirname(__file__), '../conf/sys.cnf')
if not os.path.exists(__fnm):__fnm = os.path.join(os.path.dirname(__file__), '../../conf/sys.cnf')
assert os.path.exists(__fnm), f"【EXCEPTION】can't find {__fnm}." + os.path.dirname(__file__)
if not os.path.exists(__fnm): __fnm = "./sys.cnf"
CF.read(__fnm)
class Config:
def __init__(self, env):
self.env = env
if env == "spark":CF.read("./cv.cnf")
def get(self, key):
global CF
return CF.get(self.env, key)
def init(env):
return Config(env)