예제 #1
0
 def get(self, option, name):
     try:
         stats = pd.read_csv(
             FILE_DIR +
             '/nbastats/static/data/players_{}.csv'.format(option),
             index_col='PLAYER')
     except IOError as e:
         raise tornado.web.HTTPError(500)
     player = utility.url_to_name(
         name)  # convert from url-friendly to formal name
     img_src = stats.ix[player]['IMG']  # get player headshot address
     if not img_src:
         img_src = None  # handle missing img url, currently do nothing. Can use a default image instead
     years = stats.ix[player]['YEARS'].strip().split()
     last_year = years[-1]  # display most recent year stats for the player
     try:
         stats = pd.read_csv(
             FILE_DIR +
             '/nbastats/static/data/stats_{}.csv'.format(last_year),
             index_col='PLAYER')
     except IOError:
         raise tornado.web.HTTPError(500)
     self.write(
         rendering.render_player(player, stats, years, last_year, option,
                                 img_src, TEMPLATE_DIR, 'player.html'))
예제 #2
0
 def test_lebron(self):
     urls = [
         'lebron-james', 'tracy-mcgrady', 'antonio-mcdyess', 'desagana-diop'
     ]
     names = [
         'LeBron James', 'Tracy McGrady', 'Antonio McDyess', 'DeSagana Diop'
     ]
     for i in xrange(len(urls)):
         self.assertEqual(url_to_name(urls[i]), names[i])
예제 #3
0
 def get(self, option, name, year):
     try:
         stats = pd.read_csv(FILE_DIR + '/nbastats/static/data/players_{}.csv'.format(option), index_col='PLAYER')
     except IOError:
         raise tornado.web.HTTPError(500)            
     player = utility.url_to_name(name)    # convert from url-friendly to formal name
     img_src = stats.ix[player]['IMG']    # get player headshot address
     years = stats.ix[player]['YEARS'].strip().split()
     try:
         stats = pd.read_csv(FILE_DIR + '/nbastats/static/data/stats_{}.csv'.format(year), index_col='PLAYER')
     except IOError:
         raise tornado.web.HTTPError(500)            
     self.write(rendering.render_player(player, stats, years, year, option, img_src, TEMPLATE_DIR, 'player.html'))
예제 #4
0
 def get(self, option, name):
     try:
         stats = pd.read_csv(FILE_DIR + '/nbastats/static/data/players_{}.csv'.format(option), index_col='PLAYER')
     except IOError as e:
         raise tornado.web.HTTPError(500)
     player = utility.url_to_name(name)    # convert from url-friendly to formal name
     img_src = stats.ix[player]['IMG']    # get player headshot address
     if not img_src:
         img_src = None    # handle missing img url, currently do nothing. Can use a default image instead
     years = stats.ix[player]['YEARS'].strip().split()
     last_year = years[-1]    # display most recent year stats for the player
     try:
         stats = pd.read_csv(FILE_DIR + '/nbastats/static/data/stats_{}.csv'.format(last_year), index_col='PLAYER')
     except IOError:
         raise tornado.web.HTTPError(500)            
     self.write(rendering.render_player(player, stats, years, last_year, option, img_src, TEMPLATE_DIR, 'player.html'))
예제 #5
0
 def get(self, option, name, year):
     try:
         stats = pd.read_csv(
             FILE_DIR +
             '/nbastats/static/data/players_{}.csv'.format(option),
             index_col='PLAYER')
     except IOError:
         raise tornado.web.HTTPError(500)
     player = utility.url_to_name(
         name)  # convert from url-friendly to formal name
     img_src = stats.ix[player]['IMG']  # get player headshot address
     years = stats.ix[player]['YEARS'].strip().split()
     try:
         stats = pd.read_csv(
             FILE_DIR + '/nbastats/static/data/stats_{}.csv'.format(year),
             index_col='PLAYER')
     except IOError:
         raise tornado.web.HTTPError(500)
     self.write(
         rendering.render_player(player, stats, years, year, option,
                                 img_src, TEMPLATE_DIR, 'player.html'))
예제 #6
0
 def test_dash(self):
     urls = ['darius-johnson-odom', 'al-farouq-aminu']
     names = ['Darius Johnson-Odom', 'Al-Farouq Aminu']
     for i in xrange(len(urls)):
         self.assertEqual(url_to_name(urls[i]), names[i])
예제 #7
0
 def test_normal(self):
     urls = ['steve-nash', 'kobe-bryant', 'yao-ming']
     names = ['Steve Nash', 'Kobe Bryant', 'Yao Ming']
     for i in xrange(len(urls)):
         self.assertEqual(url_to_name(urls[i]), names[i])
예제 #8
0
 def test_iii(self):
     self.assertEqual(url_to_name('john-lucas-iii'), 'John Lucas III')
예제 #9
0
 def test_apostrophe(self):
     urls = ["shaq-o'neal", "terry-o'quinn"]
     names = ["Shaq O'Neal", "Terry O'Quinn"]
     for i in xrange(len(urls)):
         self.assertEqual(url_to_name(urls[i]), names[i])
예제 #10
0
 def test_iii(self):
     self.assertEqual(url_to_name('john-lucas-iii'), 'John Lucas III')
예제 #11
0
 def test_lebron(self):
     urls = ['lebron-james', 'tracy-mcgrady', 'antonio-mcdyess', 'desagana-diop']
     names = ['LeBron James', 'Tracy McGrady', 'Antonio McDyess', 'DeSagana Diop']
     for i in xrange(len(urls)):
         self.assertEqual(url_to_name(urls[i]), names[i])
예제 #12
0
 def test_apostrophe(self):
     urls = ["shaq-o'neal", "terry-o'quinn"]
     names = ["Shaq O'Neal", "Terry O'Quinn"]
     for i in xrange(len(urls)):
         self.assertEqual(url_to_name(urls[i]), names[i])
예제 #13
0
 def test_dash(self):
     urls = ['darius-johnson-odom', 'al-farouq-aminu']
     names = ['Darius Johnson-Odom', 'Al-Farouq Aminu']
     for i in xrange(len(urls)):
         self.assertEqual(url_to_name(urls[i]), names[i])
예제 #14
0
 def test_normal(self):
     urls = ['steve-nash', 'kobe-bryant', 'yao-ming']
     names = ['Steve Nash', 'Kobe Bryant', 'Yao Ming']
     for i in xrange(len(urls)):
         self.assertEqual(url_to_name(urls[i]), names[i])