How joeyagreco/leeger works
Project Type and Purpose
• This project is a Python library designed to load fantasy football league data from various sites (ESPN, Fleaflicker, MyFantasyLeague, Sleeper, Yahoo) and process that data to generate instant stats either in Python objects (like AllTimeStatSheet and YearStatSheet) or into Excel spreadsheets.
• The README and file structure reveal that it supports different league loaders, has modular calculators for stats (both “all time” and “year” based), and includes extensive validation and utility modules.
Main Components
a. External Data Sources & League Loader:
• Fantasy football site as an external data provider.
• How the League Loader components (found under leeger/league_loader – e.g., ESPNLeagueLoader, FleaflickerLeagueLoader, etc.) fetch raw league data.
• That these loaders are responsible for converting external data into a standardized League object.
b. Core Domain Model:
• Central to the design is the League object. This object (and related classes under leeger/model/league) encapsulates the league data (teams, owners, matchups, weeks, years, etc.).
• Submodules for filters (e.g., AllTimeFilters, WeekFilters, YearFilters) and abstractions (UniqueId, EqualityCheck) from leeger/model/abstract.
c. Calculators & Stats Processing:
• There are two primary calculator families:
• All-Time Calculators (under leeger/calculator/all_time_calculator) – which process season-over-season or career-long stats.
• Year Calculators (under leeger/calculator/year_calculator) – which focus on stats for a single season.
• Both use the League object as input and generate output objects (like AllTimeStatSheet and YearStatSheet located in leeger/model/stat) used for stats reporting.
d. Validation & Exception Handling:
• Modules in leeger/validate and leeger/exception ensure that league data is correctly formatted and valid.
• These components check for consistency and trigger exceptions (e.g., InvalidLeagueFormatException, LeagueLoaderException).
e. Utility and Configuration:
• Under leeger/util, include ConfigReader, CustomLogger, Excel helper utilities, and navigators (for League, Week, Matchup, Year) that support the overall flow.
• These utilities play a role in reading configurations (from leeger/properties/app.properties) and formatting output (including Excel integration as seen in the example stat directory).
f. External Interfaces:
• Excel integration is an important feature – the utilities for Excel processing and examples in the ‘example/stat’ directory show how league stats are written to spreadsheets.
• There is also integration with the command-line (Makefile, setup.py) and CI/CD pipelines (under .github/workflows) for automated testing, formatting checks, and deployment.
Relationships and Data Flow
• The script calls a League Loader module which reaches out to an external fantasy site.
• Once data is loaded, the League object (core domain model) is populated.
• The League object is then fed into the Calculator modules; these process the raw league data and create statistic sheets.
• Validation components intercept the data flow to ensure the League object complies with expected formats.
• Processed results may then feed into Excel utilities to output data into spreadsheets.
• Utility modules (navigators, logging, configuration) are used throughout the process.
• Exception handling components catch any errors during the process.