Пример #1
0
    def setup(self):
        """
        Loads entries from the database and makes a list of all teams
        and a dictionary for the followed players.

        This was designed with the thought of how long it takes to laod all
        the entries of a given tournament.  Because I don't want a long load time
        each time a new tournament is selected, I designed this method to only pass
        through the entries of the tournament once for all the users and do several
        operations though out, which will sacrifice the look and modularity of the
        code a bit.
        :return:
        """
        entries = self.model.query("SELECT * FROM entries WHERE game_id = %s", (self.game_id,))

        # Use default dict for cleaner code and to boost performace a litte.

        self.all_counts = defaultdict(dict)
        self.following_lineups = defaultdict(list)
        self.my_players = []

        my_name = NameWin.get_cur_name().lower()

        for lineup in entries:
            # lineup[1] = username, lineup[3:] = team of username
            for n, player in enumerate(lineup[3:]):
                position = Game.POSITIONS[n]
                self.all_counts[player][position] = self.all_counts[player].get(position, 0) + 1

            username = lineup[1].lower()
            if username in self.following:
                self.following_lineups[username].append(lineup[3:])
            elif username == my_name:
                self.my_players.append(lineup[3:])
Пример #2
0
 def load_myname(self):
     """Loads my username"""
     try:
         name = NameWin.get_cur_name()
         assert name
         return name
     except:
         # If there is no username file or file is blank, open dialog to create it, then reload.
         self.open_myname()
         self.load_myname()
Пример #3
0
 def load_myname(self):
     """Loads my username"""
     try:
         name = NameWin.get_cur_name()
         assert name
         return name
     except:
         # If there is no username file or file is blank, open dialog to create it, then reload.
         self.open_myname()
         self.load_myname()
Пример #4
0
 def open_myname(self):
     nw = NameWin(self)
     nw.exec_()
Пример #5
0
 def open_myname(self):
     nw = NameWin(self)
     nw.exec_()