I have the following project structure:
SmartMirror/
|--config.json
|--main.py
|--widgets/
|--weather/
|--__init__.py
|--weather.py
|--calendar/
|--__init__.py
|--calendar.py
I want to access the config.json file from every widget python file.
What I do right now is use the following line
CONFIG_PATH = os.path.join(os.path.dirname(os.path.abspath("config.json")), "config.json")
which works when I run main.py from the SmartMirror directory but if I directly run the weather.py from a different folder it (understandably) can't locate the config.json file.
I was wondering if there is a better and safer way to access the config file from every widget or any other python module I add in the future.