def __next__(self):
     print 'YAY'
     try:
         yay = next(self.reader)
     except StopIteration:
         raise StopIteration()
     return Player(*yay)
Ejemplo n.º 2
0
 def __next__(self):
     try:
         self._next_line = next(self._reader)
         return Player(*self._next_line)
     except StopIteration:
         self._file.close()
         raise StopIteration
Ejemplo n.º 3
0
 def search_generator(self, country=None, year=None, age=None, position=None):
     """Generator version of FootballExplorer.search()"""
     str_year_and_age = self.__check_search_args(country, year, age, position)
     year = str_year_and_age['str_year']
     age = str_year_and_age['str_age']
     with open(self.file_path) as f:
         reader = csv.reader(f)
         for line in reader:
             if any([country and country != line[6], year and year != line[8], 
                     age and age != line[3], position and position != line[1]]):
                 continue
             yield(Player(*line))
Ejemplo n.º 4
0
 def __next__(self):
     try:
         while True:
             self._next_line = next(self._reader)
             if any([self._country and self._country != self._next_line[6], 
                     self._year and self._year != self._next_line[8], 
                     self._age and self._age != self._next_line[3], 
                     self._position and self._position != self._next_line[1]]):
                 continue
             return Player(*self._next_line)
     except StopIteration:
         self._file.close()
         raise StopIteration
 def __next__(self):
     print 'YAY'
     try:
         yay = next(self.reader)
         print Player(*yay).name
     except StopIteration:
         raise StopIteration()
     next_player = Player(*yay)
     player_args = [
         next_player.country, next_player.year, next_player.date_of_birth,
         next_player.position
     ]
     print player_args
     conditions = [i for i, e in enumerate(self.arglist) if e != None]
     good = False
     for j in range(0, len(conditions)):
         good = (self.arglist[j] == player_args[j])
         print player_args[j]
     if good == True:
         print 'nope'
         return next_player
     else:
         print 'oops'
         self.__next__()
import csv
from football_explorer.models import Player

with open('squads.csv') as fp:
    reader = csv.reader(fp)
    for line in reader:
        player = Player(*line)
        print(player)
Ejemplo n.º 7
0
 def all_generator(self):
     """Generator version of FootballExplorer.all()"""
     with open(self.file_path) as f:
         reader = csv.reader(f)
         for line in reader:
             yield Player(*line)