1
0
Fork 0
mirror of https://github.com/prise6/smart-iss-posts synced 2024-04-25 02:30:27 +02:00

fonction pour generer le template yaml

This commit is contained in:
Francois 2019-03-10 00:18:44 +01:00
parent 1aa1d8051a
commit f62ee67730
2 changed files with 29 additions and 6 deletions

View file

@ -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'\$\{([^}^{]+)\}')

View file

@ -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()