config.py 504 B

12345678910111213141516171819202122232425
  1. import os
  2. baseDir = f"{os.path.dirname(__file__)}/.."
  3. def loadConfig(fileName):
  4. cfg = { "card_name": "{_CALL_}_{_Date_}_{_Time_}"
  5. , "verbose": "0"
  6. }
  7. with open(fileName, "rt") as f:
  8. for row in f:
  9. row = row.strip().split("=", 1)
  10. if len(row) != 2:
  11. continue
  12. k = row[0].strip()
  13. v = row[1].strip()
  14. cfg[k] = v
  15. if cfg["verbose"].lower() in ["1", "true", "yes", "on"]:
  16. cfg["verbose"] = True
  17. else:
  18. cfg["verbose"] = False
  19. return cfg