-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconfig.py
More file actions
151 lines (126 loc) · 4.06 KB
/
Copy pathconfig.py
File metadata and controls
151 lines (126 loc) · 4.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
"""Configuration for the event tracker."""
from __future__ import annotations
import os
import yaml
REGION_TO_COUNTRIES: dict[str, list[str]] = {
"North America": ["USA", "Canada"],
"Europe": [
"Netherlands",
"Spain",
"France",
"Germany",
"UK",
"Denmark",
"Belgium",
"Ireland",
"Sweden",
"Switzerland",
"Poland",
"Austria",
"Italy",
"Portugal",
"Czech Republic",
"Finland",
"Norway",
"Greece",
],
"Asia Pacific": [
"India",
"China",
"Japan",
"Singapore",
"Australia",
"South Korea",
"Taiwan",
],
"Middle East": ["Israel", "UAE"],
"Latin America": ["Brazil", "Argentina", "Mexico"],
}
COUNTRY_ALIASES: dict[str, str] = {
"u.s.a.": "USA",
"u.s.a": "USA",
"u.s.": "USA",
"usa": "USA",
"united states": "USA",
"united states of america": "USA",
"us": "USA",
"america": "USA",
"uk": "UK",
"united kingdom": "UK",
"great britain": "UK",
"england": "UK",
"uae": "UAE",
"united arab emirates": "UAE",
}
def normalize_country(country: str) -> str:
"""Normalize country name variants to canonical form."""
return COUNTRY_ALIASES.get(country.lower().strip(), country)
DEFAULT_CONFIG_FILE = os.path.join(os.path.dirname(os.path.dirname(__file__)), "config.yaml")
_config_file: str | None = None
def set_config_file(path: str) -> None:
"""Set the config file path for subsequent load calls."""
global _config_file
_config_file = path
def load_regions(config_file: str | None = None) -> list[str]:
"""Load region names from YAML config file."""
path = config_file or _config_file or DEFAULT_CONFIG_FILE
if os.path.exists(path):
with open(path) as f:
data = yaml.safe_load(f)
result: list[str] = data.get("regions", [])
return result
return []
def load_countries(config_file: str | None = None) -> list[str]:
"""Load countries by expanding regions from YAML config file."""
regions = load_regions(config_file)
countries: list[str] = []
for region in regions:
countries.extend(REGION_TO_COUNTRIES.get(region, []))
return countries
def load_global_conferences(config_file: str | None = None) -> list[str]:
"""Load global conferences from YAML config file."""
path = config_file or _config_file or DEFAULT_CONFIG_FILE
if os.path.exists(path):
with open(path) as f:
data = yaml.safe_load(f)
result: list[str] = data.get("global_conferences", [])
return result
return []
def load_topics(config_file: str | None = None) -> list[str]:
"""Load topics from YAML config file."""
path = config_file or _config_file or DEFAULT_CONFIG_FILE
if os.path.exists(path):
with open(path) as f:
data = yaml.safe_load(f)
result: list[str] = data.get("topics", [])
return result
# Fallback defaults if config not found
return [
"ci/cd",
"continuous integration",
"continuous delivery",
"devops",
"platform engineering",
"cloud native",
"kubernetes",
"containers",
"gitops",
"tekton",
]
TARGET_REGIONS = load_regions()
TARGET_COUNTRIES = load_countries()
GLOBAL_CONFERENCES = load_global_conferences()
TOPICS = load_topics()
GOOGLE_CLOUD_PROJECT = os.environ.get(
"GOOGLE_CLOUD_PROJECT",
os.environ.get("ANTHROPIC_VERTEX_PROJECT_ID", ""),
)
GOOGLE_CLOUD_LOCATION = os.environ.get("GOOGLE_CLOUD_LOCATION", "global")
AI_MODEL = os.environ.get("AI_MODEL", "claude-sonnet-4-6")
SLACK_WEBHOOK_URL = os.environ.get("SLACK_WEBHOOK_URL", "")
MEETUP_API_KEY = os.environ.get("MEETUP_API_KEY", "")
def is_ai_configured() -> bool:
"""Return True when Claude on Vertex AI project settings are present."""
return bool(GOOGLE_CLOUD_PROJECT)
DATA_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "data")
EVENTS_FILE = os.path.join(DATA_DIR, "events.json")