James McCool commited on
Commit
53d6dd0
·
1 Parent(s): a7f801a

Refine comments and logic in load_contest_file function for lineup processing

Browse files

- Updated comments to clarify the distinction between filling required positions and outfield positions, enhancing code readability.
- Adjusted the logic for assigning players to outfield positions to ensure it checks for 'OF' in the position dictionary, improving accuracy in player assignments.
- These changes contribute to ongoing efforts to enhance code clarity and data handling within the application.

Files changed (1) hide show
  1. global_func/load_contest_file.py +3 -3
global_func/load_contest_file.py CHANGED
@@ -90,7 +90,7 @@ def load_contest_file(upload, sport):
90
  print(f"\nProcessing lineup {idx}:")
91
  print(f"Players found: {players}")
92
 
93
- # First pass: fill required positions
94
  required_positions = ['SP1', 'SP2', 'C', '1B', '2B', '3B', 'SS']
95
  for pos in required_positions:
96
  for player in players:
@@ -102,11 +102,11 @@ def load_contest_file(upload, sport):
102
  else:
103
  print(f"No player found for {pos}")
104
 
105
- # Second pass: fill OF positions
106
  of_positions = ['OF1', 'OF2', 'OF3']
107
  for pos in of_positions:
108
  for player in players:
109
- if is_eligible_for_position(player, 'OF'):
110
  print(f"Assigning {player} to {pos}")
111
  df.at[idx, pos] = player
112
  players.remove(player)
 
90
  print(f"\nProcessing lineup {idx}:")
91
  print(f"Players found: {players}")
92
 
93
+ # First pass: fill required positions (excluding OF)
94
  required_positions = ['SP1', 'SP2', 'C', '1B', '2B', '3B', 'SS']
95
  for pos in required_positions:
96
  for player in players:
 
102
  else:
103
  print(f"No player found for {pos}")
104
 
105
+ # Second pass: fill OF positions with remaining players
106
  of_positions = ['OF1', 'OF2', 'OF3']
107
  for pos in of_positions:
108
  for player in players:
109
+ if 'OF' in pos_dict.get(player, '').split('/'):
110
  print(f"Assigning {player} to {pos}")
111
  df.at[idx, pos] = player
112
  players.remove(player)