-
Notifications
You must be signed in to change notification settings - Fork 264
/
nfldb-mk-stat-table
executable file
·70 lines (49 loc) · 1.88 KB
/
nfldb-mk-stat-table
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python2
from __future__ import absolute_import, division, print_function
import nfldb
tpl_body = '''
The following is a list of statistical categories available on `nfldb`
instances of the [Play](https://pdoc.burntsushi.net/nfldb#nfldb.Play) and
[PlayPlayer](https://pdoc.burntsushi.net/nfldb#nfldb.PlayPlayer) classes.
They are listed here to prevent them from cluttering the API documentation.
Note that this list *complements* the instance variables in the API
documentation.
**Note to contributors**: Do not edit this page manually. It is automatically
generated by the
[nfldb-mk-stat-table](https://github.com/BurntSushi/nfldb/blob/master/scripts/nfldb-mk-stat-table)
script.
### Play statistics
{table_play}
### Player statistics
{table_player}
The following fields are derived statistics computed from a combination
of some of the fields above. They may be used just like regular fields
in searching and sorting criteria.
{table_player_derived}
'''.strip()
tpl_table = '''
Field | Description
--- | ---
{rows}
'''.strip()
tpl_row = '''
{field} | {desc}
'''.strip()
def mk_row(field, desc):
return tpl_row.format(field=field, desc=desc.replace('\n', ' '))
play_rows, player_rows = [], []
for cat in nfldb.stat_categories.values():
row = mk_row(cat.category_id, cat.description)
if cat.category_type == nfldb.Enums.category_scope.player:
player_rows.append(row)
else:
play_rows.append(row)
player_derived_rows = []
for field in nfldb.PlayPlayer._sql_derived:
var = '_PlayPlayer.%s' % field
player_derived_rows.append(mk_row(field, nfldb.__pdoc__[var]))
tplay = tpl_table.format(rows='\n'.join(play_rows))
tplayer = tpl_table.format(rows='\n'.join(player_rows))
tdplayer = tpl_table.format(rows='\n'.join(player_derived_rows))
print(tpl_body.format(table_play=tplay, table_player=tplayer,
table_player_derived=tdplayer))