Skip to content

Commit

Permalink
initialize saving and reading ids from tdlist
Browse files Browse the repository at this point in the history
  • Loading branch information
victor-zheng-codes committed Jan 9, 2024
1 parent 2a864dd commit f176328
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions bin/generate_CFC.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ def __init__(self, get_new_data: bool) -> None:
:param get_new_data: indicates whether to get new data from the cfc api or use the current one in the cache.
"""

self.output_file = Path(
__file__).parent.parent / "src" / "ratings_calculator" / "assets" / "cache" / "cfc" / f"tdlist.txt"

# if get_new_data, then save the latest files.
if get_new_data:
self.save_td_list()
Expand All @@ -74,12 +77,22 @@ def save_td_list(self) -> None:
r = requests.get(file_loc, allow_redirects=True)

# output file will be in cache
output_file = Path(__file__).parent.parent / "src" / "ratings_calculator" / "assets" / "cache" / "cfc" / f"tdlist.txt"
open(output_file, 'wb').write(r.content)
open(self.output_file, 'wb').write(r.content)

except Exception:
print("Failed to connect to API, check connection to requests library")

def generate_cfc_ids_list(self) -> []:
"""
Generate and return a list of all active cfc ids
"""

id_list = []
with open(self.output_file, 'r') as f:
while f.readline() != "":
id_list.append()



class CFCPlayerData:
"""Using fideparser library to generate files for exporting FIDE data.
Expand Down

0 comments on commit f176328

Please sign in to comment.