File tree Expand file tree Collapse file tree 3 files changed +17
-16
lines changed
Expand file tree Collapse file tree 3 files changed +17
-16
lines changed Original file line number Diff line number Diff line change 1+ import os
2+ import json
3+
4+ def load_json (file ):
5+ """Load JSON file at app start"""
6+ here = os .path .dirname (os .path .abspath (__file__ ))
7+ with open (os .path .join (here , file )) as jfile :
8+ data = json .load (jfile )
9+ return data
10+
11+ TEAM_DATA = load_json ("teams.json" )["teams" ]
12+ TEAM_NAMES = {team ["code" ]: team ["id" ] for team in TEAM_DATA }
13+ LEAGUE_DATA = load_json ("leagues.json" )["leagues" ]
14+ LEAGUE_IDS = {league ["code" ]: league ["id" ] for league in LEAGUE_DATA }
15+ LEAGUE_PROPERTIES = {league ["code" ]: league ["properties" ] for league in LEAGUE_DATA if league ["properties" ] != "null" }
Original file line number Diff line number Diff line change 22import os
33import requests
44import sys
5- import json
65
76
87from soccer .exceptions import IncorrectParametersException , APIErrorException
98from soccer .writers import get_writer
9+ from soccer .jsonhandler import TEAM_NAMES , LEAGUE_IDS , LEAGUE_PROPERTIES
1010
1111
1212BASE_URL = 'http://api.football-data.org/alpha/'
1313LIVE_URL = 'http://soccer-cli.appspot.com/'
1414
1515
16- def load_json (file ):
17- """Load JSON file at app start"""
18- here = os .path .dirname (os .path .abspath (__file__ ))
19- with open (os .path .join (here , file )) as jfile :
20- data = json .load (jfile )
21- return data
22-
23-
24- TEAM_DATA = load_json ("teams.json" )["teams" ]
25- TEAM_NAMES = {team ["code" ]: team ["id" ] for team in TEAM_DATA }
26- LEAGUE_DATA = load_json ("leagues.json" )["leagues" ]
27- LEAGUE_IDS = {league ["code" ]: league ["id" ] for league in LEAGUE_DATA }
28- LEAGUE_PROPERTIES = {league ["code" ]: league ["properties" ] for league in LEAGUE_DATA if league ["properties" ] != "null" }
29-
3016
3117def get_input_key ():
3218 """Input API key and validate"""
Original file line number Diff line number Diff line change 88from itertools import groupby
99from collections import namedtuple
1010
11- from soccer .main import LEAGUE_IDS , LEAGUE_PROPERTIES
11+ from soccer .jsonhandler import LEAGUE_IDS , LEAGUE_PROPERTIES
1212
1313
1414def get_writer (output_format = 'stdout' , output_file = None ):
You can’t perform that action at this time.
0 commit comments