Closed thurask closed 8 years ago
Good idea. One comment though:
There's a couple of teamnames().get
, which will cause the json file to be read every single time. We can probably memoize that function since that data won't change between calls.
Now that I think about it, is there a reason why we can't just put the teams into a dictionary instead of a json file? It would save us the trouble of having to read the file and parse it ourselves.
Okay, the app loads teams.json once now.
As for using a dict, I prefer using JSON/some other actual DB system for something as big as this team list.
Did you use a script to build the new JSON? Was there a lot of manual work involved in its creation?
Mostly script. A little manual cleanup at the end (manually removed duplicates that were in the Champions League, changed some team codes).
https://gist.github.com/thurask/0ece25eccaca963707a018413650e68b
Replaces teamnames.py and teamcodes.json with teams.json.
Inside teams.json is a list of entries like so:
Rewrites
main.py
to accomodate JSON changes. Addsteam_names()
function to replicate functionality of formerTEAM_NAMES
global, at least for now.New JSON is both much larger than old database, and human-readable, explaining the size increase. Many more team codes added, some changed ("Int" -> "INT", "Watfordfc" -> "WAT", "EFFZEH" -> "FCK" notably) without affecting functionality.
As a result of new JSON, team code listing is now able to be grouped by league:
It is also colorized, as well as the team code lookup.
Lastly, add missing help text to
--apikey
argument.