def doCompile(self):

        # First, we get a list of team-seasons recorded in the data
        s = Season()
        s.connectDB()
        self.seasons = s.loadAll()
        self.log.message(str(len(self.seasons)) + ' seasons')

        # Second, for each team-season:
        for item in self.seasons:

            print(str(item))
            self.log.message(str(item))

            # Get the list of players to have appeared in this season
            self.players = s.loadPlayerList(item)

            # If we have records for fewer than two players, then there
            # are no combinations to calculate - so we skip to the next season
            if(len(self.players) < 2):
                self.log.message('')
                print('')
                continue

            self.log.message(str(len(self.players)) + ' players this season')
            print(str(len(self.players)) + ' players')

            # Iterate over the list of players, building player pairs
            self.combos = self.assembleCombos(self.players)
            self.log.message(str(len(self.combos)) + ' combos this season')
            print(str(len(self.combos)) + ' combos')

            # Make sure each pair is recorded initially
            self.lookupCombos()

            # print(str(self.combos))

            # Build data for each pair

            # Store data for each pair

            # Delay a bit so the database can keep up
            time.sleep(0.1)

            self.log.message('')
            print('\n')

        s.disconnectDB()

        return True
Beispiel #2
0
def test_season_loadPlayerList():
    s = Season()
    s.connectDB()
    needle = {
        'TeamID': 1,
        'Season': 1894
    }
    s.data = s.loadPlayerList(needle)
    assert len(s.data) == 0
    needle = {
        'TeamID': 2,
        'Season': 1980
    }
    s.data = s.loadPlayerList(needle)
    assert len(s.data) == 1
Beispiel #3
0
def test_season_loadAll():
    s = Season()
    s.connectDB()
    s.data = s.loadAll()
    assert len(s.data) == 2
Beispiel #4
0
def test_season_disconnect():
    s = Season()
    s.connectDB()
    assert hasattr(s, 'db')
    s.disconnectDB()
    assert hasattr(s, 'db') is False