Skip to content

Commit 733e834

Browse files
author
Adriano Sanges
committed
Refactor scan_properties.py to improve environment variable loading
- Introduce a new function to load environment variables from multiple potential .env file locations - Enhance error handling by providing a warning if no .env file is found - Streamline the loading process for better configuration management
1 parent c3d1b4b commit 733e834

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.env
2+
*.env
3+
.env.*

real-estate-etl/scan_properties.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@
77
import os
88
from telegram_api import send_message, format_property_message
99

10+
def load_env_file():
11+
if os.path.exists("../.env"):
12+
load_dotenv("../.env")
13+
elif os.path.exists("../files/.env"):
14+
load_dotenv("../files/.env")
15+
else:
16+
print("Warning: No .env file found in ../.env or ../files/.env")
1017

18+
load_env_file()
1119

1220
if __name__ == "__main__":
1321

1422

15-
load_dotenv("../.env")
16-
1723
url: str = os.getenv("scrape_url")
1824
warehouse_name: str = os.getenv("warehouse_name")
1925
motherduck_token: str = os.getenv("motherduck_token")

0 commit comments

Comments
 (0)