Guest User

Untitled

a guest
Apr 25th, 2021
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. """
  2. Module contains application settings
  3. """
  4. import json
  5. from logging import getLogger
  6. from pathlib import Path
  7.  
  8. SETTINGS: dict = {}
  9. logger = getLogger(__name__)
  10.  
  11. """
  12. For reddit -> Location
  13. /root_dir
  14.  /src
  15.  /settings
  16.    /__init_.py
  17. """
  18.  
  19. # Load each settings file
  20. for file in Path("settings").absolute().iterdir():
  21.     if (
  22.         file.name.startswith("dist")
  23.         or file.name.endswith(".py")
  24.         or Path(file).is_dir()
  25.     ):
  26.         continue
  27.     try:
  28.         with open(file, "r") as config:
  29.             SETTINGS[str(file.name).split(".")[0].lower()] = json.load(config)
  30.     except json.decoder.JSONDecodeError:
  31.         logger.warning(f"Could not decode settings:'{file.name}'")
  32.  
Advertisement
Add Comment
Please, Sign In to add comment