def donations(filename='donationdata.pickle'):
try:
print("donation data pickled already. Grabbing data from donationdata.picke")
with open(filename, 'rb') as handle:
donations = pickle.load(handle)
return donations
except EOFError:
print("donation data not pickled, grabbing directly from FEC and ProPublica APIs")
donations = donations_helper()
with open(filename, 'wb') as handle:
pickle.dump(donations, handle, protocol=pickle.HIGHEST_PROTOCOL)
return donations
评论列表
文章目录