config_load.py 772 B

123456789101112131415161718192021222324252627
  1. import json
  2. from pathlib import Path
  3. class ConfigLoad:
  4. base_dir: Path
  5. def __init__(self, base_dir: str):
  6. self.base_dir = Path(base_dir)
  7. def load_file(self, client, year):
  8. with open(self.base_dir.joinpath(client + '.json'), 'r') as frh:
  9. cfg = json.load(frh)
  10. year_new = {
  11. "plan": year,
  12. "actuals": str(int(year) - 1),
  13. "previous": str(int(year) - 2)
  14. }
  15. cfg['config']['year'] = year_new
  16. cfg['config']['previous'] = [
  17. "Ist " + year_new['previous'],
  18. "Plan " + year_new['actuals'],
  19. "Ist per 10/" + year_new['actuals'],
  20. "FC 12/" + year_new['actuals'],
  21. "Ist " + year_new['actuals']
  22. ]
  23. return cfg