diff --git a/iss/tools/config.py b/iss/tools/config.py index 4df03ac..6660239 100644 --- a/iss/tools/config.py +++ b/iss/tools/config.py @@ -3,16 +3,12 @@ import os import sys import yaml -from dotenv import find_dotenv, load_dotenv import re -load_dotenv(find_dotenv()) - - class Config: - def __init__(self, project_dir = os.getenv("PROJECT_DIR"), mode = os.getenv("MODE")): - + def __init__(self, project_dir, mode): + self.project_dir = project_dir self.mode = mode self.path_matcher = re.compile(r'\$\{([^}^{]+)\}') diff --git a/iss/tools/config_template.py b/iss/tools/config_template.py new file mode 100644 index 0000000..5116408 --- /dev/null +++ b/iss/tools/config_template.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- + +import yaml +import os +from dotenv import find_dotenv, load_dotenv +from iss.tools.config import Config + +def main(): + + cfg = Config(project_dir = os.getenv('PROJECT_DIR'), mode = os.getenv('MODE')) + replace_items_recursive(cfg.config) + print(cfg.project_dir + '/config/config.template.yaml') + with open(cfg.project_dir + '/config/config.template.yaml', 'w') as f: + yaml.dump(cfg.config, f, default_flow_style = False) + +def replace_items_recursive(d, v = 'XXX'): + for k in d.keys(): + if type(d.get(k)) is not dict: + d.update({k: v}) + else: + replace_items_recursive(d.get(k)) + +if __name__ == '__main__': + load_dotenv(find_dotenv()) + main() + +