Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
requests_cache.install_cache(args.requests_cache_path, include_get_headers=True)
cache = requests_cache.get_cache()
if args.clear_requests_cache:
logging.info('Clearing requests-cache')
requests_cache.clear()
logging.info(f'requests-cache starting with {len(cache.responses)} cached responses')
csl_items = list()
failures = list()
for citation in citation_df.standard_citation.unique():
if citation in manual_refs:
csl_items.append(manual_refs[citation])
continue
try:
citeproc = citation_to_citeproc(citation)
csl_items.append(citeproc)
except Exception as error:
logging.exception(f'Citeproc retrieval failure for {citation}')
failures.append(citation)
logging.info(f'requests-cache finished with {len(cache.responses)} cached responses')
requests_cache.uninstall_cache()
if failures:
message = 'Citeproc retrieval failed for:\n{}'.format(
'\n'.join(failures))
logging.error(message)
# Write JSON CSL bibliography for Pandoc.
with args.references_path.open('w') as write_file:
json.dump(csl_items, write_file, indent=2, ensure_ascii=False)