You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ClinicalTrialsDataProcessing/history_downloader/tests/download_tests.py

45 lines
1.3 KiB
Python

import downloader as download
def print_response_to_file(r):
pass
def pretty_print_response(r):
pass
def trial_downloads(nct_id):
"""
Mirrors `download_and_handle_errors` and , without writing to a database
Instead it writes to files
"""
print("downloading {}".format(nct_id))
r = download.make_request(nct_id,1,2)
responses = [ r ]
print(r.url)
v = download.get_highest_version_number(r)
if v == 2:
pass
elif v%2 == 0:
for version_a, version_b in download.step_generator(v):
print("\t versions {} & {}".format(version_a,version_b))
req = download.make_request(nct_id,version_a,version_b)
responses.append(req)
elif v %2 == 1:
for version_a, version_b in download.step_generator(v):
print("\t downloading versions {} & {}".format(version_a,version_b))
req = download.make_request(nct_id,version_a,version_b)
responses.append(req)
responses.append(download.make_reqauest(nct_id,1,v))
print("\tDownloaded {} versions".format(v))
return responses
if __name__ == "__main__":
test_list = ['NCT01303796', 'NCT01371708', 'NCT01374906', 'NCT01382602', 'NCT01384539', 'NCT01391546', 'NCT01392469', 'NCT01413178', 'NCT01416441', 'NCT01418339']
for t in test_list:
resp = trial_downloads(t)