def fetch(outfile):
"""The main function for downloading all scripts from github."""
if not os.path.exists(REQUESTS_CACHE):
os.makedirs(REQUESTS_CACHE)
requests_cache.install_cache(REQUESTS_CACHE)
result = []
label_counts = defaultdict(int)
print('Fetching scripts')
for label, url in DATA_URLS.items():
print(url)
scripts = fetch_scripts(url)
for script in scripts:
try:
result.append({
'tree': build_tree(script), 'metadata': {'label': label}
})
label_counts[label] += 1
except Exception as err:
print(err)
print('Label counts: ', label_counts)
print('Dumping scripts')
with open(outfile, 'wb') as file_handler:
pickle.dump(result, file_handler)
评论列表
文章目录