Skip to content

Commit b5c6310

Browse files
committed
Performed Black Formatting
1 parent 7669d10 commit b5c6310

22 files changed

+4571
-2949
lines changed

app.py

Lines changed: 1421 additions & 697 deletions
Large diffs are not rendered by default.

config.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import streamlit as st
88

9+
910
# Supabase Configuration
1011
def get_supabase_config():
1112
"""Get Supabase configuration from Streamlit secrets"""
@@ -16,6 +17,7 @@ def get_supabase_config():
1617
}
1718
return {"url": None, "key": None}
1819

20+
1921
# Gemini API Configuration
2022
def get_gemini_api_key():
2123
"""
@@ -25,11 +27,13 @@ def get_gemini_api_key():
2527
return st.secrets["gemini"]["api_key"]
2628
return None
2729

30+
2831
def check_gemini_config():
2932
"""Check if Gemini API is properly configured"""
3033
api_key = get_gemini_api_key()
3134
return api_key is not None and api_key.strip() != ""
3235

36+
3337
def get_gemini_instructions():
3438
"""Return instructions for setting up Gemini API"""
3539
return """
@@ -63,17 +67,18 @@ def get_gemini_instructions():
6367
Once configured, you can upload screenshots and the AI will automatically extract match data.
6468
"""
6569

70+
6671
def show_gemini_status():
6772
"""Show Gemini API connection status"""
6873
if check_gemini_config():
6974
st.success("✅ Gemini API is configured and ready to use!")
7075
return True
7176
else:
7277
st.error("❌ Gemini API is not configured")
73-
78+
7479
# Provide more specific debugging information
7580
st.info("**Debugging Information:**")
76-
81+
7782
# Check if secrets are available
7883
if st.secrets:
7984
st.write("✅ Streamlit secrets are available")
@@ -91,19 +96,23 @@ def show_gemini_status():
9196
st.write(f"❌ Error reading secrets: {e}")
9297
else:
9398
st.write("❌ No Streamlit secrets available")
94-
95-
st.info("Please set up your Gemini API key to enable AI-powered image extraction.")
99+
100+
st.info(
101+
"Please set up your Gemini API key to enable AI-powered image extraction."
102+
)
96103
with st.expander("📋 Gemini API Setup Instructions"):
97104
st.markdown(get_gemini_instructions())
98105
return False
99106

107+
100108
def check_supabase_config():
101109
"""Check if Supabase is properly configured"""
102110
config = get_supabase_config()
103111
if not config["url"] or not config["key"]:
104112
return False
105113
return True
106114

115+
107116
def get_supabase_instructions():
108117
"""Return instructions for setting up Supabase"""
109118
return """
@@ -176,6 +185,7 @@ def get_supabase_instructions():
176185
```
177186
"""
178187

188+
179189
def show_supabase_status():
180190
"""Show Supabase connection status"""
181191
if check_supabase_config():
@@ -186,4 +196,4 @@ def show_supabase_status():
186196
st.info("Please set up your Supabase credentials to enable cloud storage.")
187197
with st.expander("📋 Supabase Setup Instructions"):
188198
st.markdown(get_supabase_instructions())
189-
return False
199+
return False

test-utils/add_players.py

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,92 +12,96 @@
1212
# Add utils to path
1313
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
1414

15-
from utils.data_processing import load_match_data, save_match_data, get_next_match_id, add_match_to_dataframe
15+
from utils.data_processing import (
16+
load_match_data,
17+
save_match_data,
18+
get_next_match_id,
19+
add_match_to_dataframe,
20+
)
21+
1622

1723
def add_sample_matches_for_players(new_players):
1824
"""
1925
Add sample matches for new players to populate the system.
20-
26+
2127
Args:
2228
new_players: List of new player names to add
2329
"""
2430
print(f"🎮 Adding sample matches for {len(new_players)} new players...")
25-
31+
2632
# Load existing data
2733
df = load_match_data()
28-
34+
2935
# Get the next match ID
3036
next_match_id = get_next_match_id(df)
31-
37+
3238
# Create sample matches for each new player
3339
new_matches = []
34-
40+
3541
for i, player_name in enumerate(new_players):
3642
# Create a sample match for each player
3743
match_data = {
38-
'match_id': next_match_id + i,
39-
'datetime': datetime.now() - timedelta(days=len(new_players) - i),
40-
'game_mode': 'FFA',
41-
'map_name': 'City',
42-
'team': None,
43-
'player_name': player_name,
44-
'kills': 15 + (i * 2), # Vary kills slightly
45-
'deaths': 8 + (i % 3), # Vary deaths slightly
46-
'assists': None, # FFA mode
47-
'score': 1500 + (i * 100),
48-
'weapon': 'AK47',
49-
'ping': 45 + (i * 5),
50-
'coins': 120 + (i * 20),
51-
'match_length': 10
44+
"match_id": next_match_id + i,
45+
"datetime": datetime.now() - timedelta(days=len(new_players) - i),
46+
"game_mode": "FFA",
47+
"map_name": "City",
48+
"team": None,
49+
"player_name": player_name,
50+
"kills": 15 + (i * 2), # Vary kills slightly
51+
"deaths": 8 + (i % 3), # Vary deaths slightly
52+
"assists": None, # FFA mode
53+
"score": 1500 + (i * 100),
54+
"weapon": "AK47",
55+
"ping": 45 + (i * 5),
56+
"coins": 120 + (i * 20),
57+
"match_length": 10,
5258
}
5359
new_matches.append(match_data)
54-
60+
5561
# Add matches to dataframe
5662
for match in new_matches:
5763
df = add_match_to_dataframe(df, [match])
58-
64+
5965
# Save the updated data
6066
save_match_data(df)
61-
67+
6268
print(f"✅ Added {len(new_matches)} sample matches for new players!")
6369
print("📊 New players added:")
6470
for player in new_players:
6571
print(f" • {player}")
66-
72+
6773
return df
6874

75+
6976
def main():
7077
"""Main function to add new players."""
7178
print("🎯 Deadshot Stats - Add New Players")
7279
print("=" * 40)
73-
80+
7481
# List of new players to add
75-
new_players = [
76-
"DevilOHeaven",
77-
"MaXiMus22",
78-
"Heet63"
79-
]
80-
82+
new_players = ["DevilOHeaven", "MaXiMus22", "Heet63"]
83+
8184
# You can add more players here
8285
# new_players.extend([
8386
# "Player4",
8487
# "Player5",
8588
# "Player6"
8689
# ])
87-
90+
8891
print(f"📋 Adding {len(new_players)} players to the system...")
89-
92+
9093
# Add sample matches for new players
9194
df = add_sample_matches_for_players(new_players)
92-
95+
9396
print(f"\n✅ Successfully added {len(new_players)} players!")
9497
print(f"📊 Total players in system: {len(df['player_name'].unique())}")
9598
print(f"📈 Total matches in system: {len(df['match_id'].unique())}")
96-
99+
97100
print("\n🚀 You can now run the app:")
98101
print("streamlit run app.py")
99-
102+
100103
print("\n💡 The new players will appear in the dropdown menus!")
101104

105+
102106
if __name__ == "__main__":
103-
main()
107+
main()

test-utils/debug_supabase.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

test-utils/migrate_to_supabase.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

test-utils/test_app.py

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,30 @@
88
import time
99
import os
1010

11+
1112
def test_dependencies():
1213
"""Test if all required dependencies are installed."""
1314
print("🔍 Testing dependencies...")
14-
15+
1516
required_packages = [
1617
"streamlit",
17-
"pandas",
18+
"pandas",
1819
"plotly",
1920
"scikit-learn",
2021
"google-generativeai",
21-
"Pillow"
22+
"Pillow",
2223
]
23-
24+
2425
missing_packages = []
25-
26+
2627
for package in required_packages:
2728
try:
2829
__import__(package.replace("-", "_"))
2930
print(f"✅ {package}")
3031
except ImportError:
3132
print(f"❌ {package} - Missing")
3233
missing_packages.append(package)
33-
34+
3435
if missing_packages:
3536
print(f"\n⚠️ Missing packages: {', '.join(missing_packages)}")
3637
print("Please run: pip install -r requirements.txt")
@@ -39,99 +40,104 @@ def test_dependencies():
3940
print("\n✅ All dependencies are installed!")
4041
return True
4142

43+
4244
def test_data_files():
4345
"""Test if required data files exist."""
4446
print("\n📁 Testing data files...")
45-
47+
4648
required_files = [
4749
"data/matches.csv",
4850
"app.py",
4951
"utils/data_processing.py",
5052
"utils/calculations.py",
5153
"utils/visualizations.py",
52-
"utils/image_processing.py"
54+
"utils/image_processing.py",
5355
]
54-
56+
5557
missing_files = []
56-
58+
5759
for file_path in required_files:
5860
if os.path.exists(file_path):
5961
print(f"✅ {file_path}")
6062
else:
6163
print(f"❌ {file_path} - Missing")
6264
missing_files.append(file_path)
63-
65+
6466
if missing_files:
6567
print(f"\n⚠️ Missing files: {', '.join(missing_files)}")
6668
return False
6769
else:
6870
print("\n✅ All required files exist!")
6971
return True
7072

73+
7174
def test_app_startup():
7275
"""Test if the app can start without errors."""
7376
print("\n🚀 Testing app startup...")
74-
77+
7578
try:
7679
# Try to import the main app
7780
import sys
78-
sys.path.append('.')
79-
81+
82+
sys.path.append(".")
83+
8084
# Test imports
8185
from utils.data_processing import load_match_data
8286
from utils.calculations import get_player_stats
8387
from utils.visualizations import create_overview_cards
8488
from utils.image_processing import extract_data_from_image
85-
89+
8690
print("✅ All imports successful!")
87-
91+
8892
# Test data loading
8993
try:
9094
df = load_match_data()
9195
print(f"✅ Data loaded successfully! {len(df)} rows found.")
9296
except Exception as e:
9397
print(f"⚠️ Data loading warning: {e}")
94-
98+
9599
return True
96-
100+
97101
except Exception as e:
98102
print(f"❌ App startup failed: {e}")
99103
return False
100104

105+
101106
def main():
102107
"""Run all tests."""
103108
print("🧪 Deadshot Stats App Test Suite")
104109
print("=" * 50)
105-
110+
106111
tests = [
107112
("Dependencies", test_dependencies),
108113
("Data Files", test_data_files),
109-
("App Startup", test_app_startup)
114+
("App Startup", test_app_startup),
110115
]
111-
116+
112117
passed = 0
113118
total = len(tests)
114-
119+
115120
for test_name, test_func in tests:
116121
print(f"\n📋 Running {test_name} test...")
117122
if test_func():
118123
passed += 1
119124
print(f"✅ {test_name} test passed!")
120125
else:
121126
print(f"❌ {test_name} test failed!")
122-
127+
123128
print("\n" + "=" * 50)
124129
print(f"📊 Test Results: {passed}/{total} tests passed")
125-
130+
126131
if passed == total:
127132
print("🎉 All tests passed! The app should work correctly.")
128133
print("\n🚀 To run the app:")
129134
print("streamlit run app.py")
130135
else:
131136
print("⚠️ Some tests failed. Please fix the issues above.")
132-
137+
133138
return passed == total
134139

140+
135141
if __name__ == "__main__":
136142
success = main()
137-
sys.exit(0 if success else 1)
143+
sys.exit(0 if success else 1)

0 commit comments

Comments
 (0)