|
60 | 60 |
|
61 | 61 | ### Functions ### |
62 | 62 | def load_env_file(filepath): |
63 | | - with open(filepath, encoding="utf-8") as f: |
64 | | - for line in f: |
65 | | - if line.strip() and not line.startswith("#"): |
66 | | - if line.startswith("export "): |
67 | | - line = line[len("export ") :] |
68 | | - key, value = line.strip().split("=", 1) |
69 | | - os.environ[key] = value.strip('"') |
| 63 | + try: |
| 64 | + with open(filepath, encoding="utf-8") as f: |
| 65 | + for line in f: |
| 66 | + if line.strip() and not line.startswith("#"): |
| 67 | + if line.startswith("export "): |
| 68 | + line = line[len("export ") :] |
| 69 | + key, value = line.strip().split("=", 1) |
| 70 | + os.environ[key] = value.strip('"') |
| 71 | + except Exception: |
| 72 | + pass # shhh |
70 | 73 |
|
71 | 74 |
|
72 | 75 | def get_weather_icon(weatherinstance): |
@@ -173,9 +176,10 @@ def format_chances(hour): |
173 | 176 |
|
174 | 177 |
|
175 | 178 | ### Variables ### |
176 | | -# Load environment variables from the specified files |
177 | | -load_env_file(os.path.expanduser("~/.local/state/hyde/staterc")) |
178 | | -load_env_file(os.path.expanduser("~/.local/state/hyde/config")) |
| 179 | +load_env_file( |
| 180 | + os.path.join(os.environ.get("HOME"), ".rlocal", "state", "hyde", "staterc") |
| 181 | +) |
| 182 | +load_env_file(os.path.join(os.environ.get("HOME"), ".local", "state", "hyde", "config")) |
179 | 183 |
|
180 | 184 | temp_unit = os.getenv( |
181 | 185 | "WEATHER_TEMPERATURE_UNIT", "c" |
|
0 commit comments