-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
125 lines (104 loc) · 3.61 KB
/
config.py
File metadata and controls
125 lines (104 loc) · 3.61 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
"""
Configuration file for Virtual Football Prediction System - COMPLETE VERSION
"""
# League name standardization mapping
LEAGUE_NAME_MAPPING = {
# Raw names from Selenium -> Standardized names
'england': 'england virtual',
'spain': 'spain virtual',
'italy': 'italy virtual',
'germany': 'germany virtual',
'france': 'france virtual',
# Handle variations you might encounter
'england virtual': 'england virtual',
'spain virtual': 'spain virtual',
'italy virtual': 'italy virtual',
'germany virtual': 'germany virtual',
'france virtual': 'france virtual',
# Handle title case variations
'England': 'england virtual',
'Spain': 'spain virtual',
'Italy': 'italy virtual',
'Germany': 'germany virtual',
'France': 'france virtual',
'England Virtual': 'england virtual',
'Spain Virtual': 'spain virtual',
'Italy Virtual': 'italy virtual',
'Germany Virtual': 'germany virtual',
'France Virtual': 'france virtual',
}
# Virtual league IDs (from your API)
VIRTUAL_LEAGUES = {
'england virtual': 'sv:category:202120001',
'spain virtual': 'sv:category:202120002',
'italy virtual': 'sv:category:202120003',
'germany virtual': 'sv:category:202120004',
'france virtual': 'sv:category:202120005'
}
# Display names for frontend
DISPLAY_NAMES = {
'england virtual': 'England Virtual League',
'spain virtual': 'Spain Virtual League',
'italy virtual': 'Italy Virtual League',
'germany virtual': 'Germany Virtual League',
'france virtual': 'France Virtual League'
}
def standardize_league_name(league_name):
"""
Standardize league names to consistent format.
Args:
league_name (str): Raw league name from any source
Returns:
str: Standardized league name
"""
if not league_name:
return 'unknown virtual'
# Clean the input
league_name = str(league_name).strip()
# Try exact match first
if league_name.lower() in LEAGUE_NAME_MAPPING:
return LEAGUE_NAME_MAPPING[league_name.lower()]
# Try with original case
if league_name in LEAGUE_NAME_MAPPING:
return LEAGUE_NAME_MAPPING[league_name]
# If contains any known league name, extract it
league_lower = league_name.lower()
for raw_name, standard_name in LEAGUE_NAME_MAPPING.items():
if raw_name.lower() in league_lower:
return standard_name
# Default: make it virtual
league_base = league_name.lower().replace('virtual', '').strip()
return f"{league_base} virtual"
def get_display_name(league_name):
"""
Get display-friendly league name.
Args:
league_name (str): Standardized league name
Returns:
str: Display name
"""
if not league_name:
return "Unknown Virtual League"
standardized = standardize_league_name(league_name)
return DISPLAY_NAMES.get(standardized, standardized.title())
def debug_league_mapping(input_name):
"""
Debug function to see how a league name gets processed.
"""
print(f"Input: '{input_name}'")
print(f"Standardized: '{standardize_league_name(input_name)}'")
print(f"Display: '{get_display_name(input_name)}'")
# Test the mapping
if __name__ == '__main__':
test_names = [
'england', 'England', 'ENGLAND',
'spain virtual', 'Spain Virtual',
'italy', 'Germany', 'france',
'England Virtual League',
'unknown league'
]
print("Testing league name standardization:")
print("=" * 50)
for name in test_names:
debug_league_mapping(name)
print("-" * 30)