Skip to content

Commit

Permalink
Zenodo downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelever committed Apr 25, 2019
1 parent aeeef47 commit 749a159
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pubrunner/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,11 @@ def download(self):

return thisResourceDir
elif url.startswith('https://zenodo.org/record/'):
assert isinstance(resourceInfo['record'], int), 'The Zenodo record must be an integer'
recordNo = int(url[len('https://zenodo.org/record/'):])

print(" Starting Zenodo download...")
downloadZenodo(resourceInfo['record'],thisResourceDir)
pubrunner.download.downloadZenodo(recordNo,self.downloadDirectory)

return thisResourceDir
else:
#if 'filter' in resourceInfo:
# fileSuffixFilter = resourceInfo['filter']
Expand Down
13 changes: 13 additions & 0 deletions tests/test_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ def test_download_ftp():
assert f in expectedFileHashes
assert fileHash == expectedFileHashes[f]

def test_download_zenodo():
with TempDir() as allResourcesDirectory, TempDir() as workingDirectory:
resource = pubrunner.Resource(allResourcesDirectory,workingDirectory,'test','https://zenodo.org/record/2643199')
resource.download()

directory = resource.downloadDirectory

expectedFileHashes = {'TheOpenAIREResearchGraphDataModel_v_1_3.pdf':'ed5a789f07091f86e8816d244a7593fa3aee4be67e585c0875983a4333527e71'}
for f in os.listdir(directory):
fileHash = calcSHA256(os.path.join(directory,f))
assert f in expectedFileHashes
assert fileHash == expectedFileHashes[f]

def te_resourceByName():
resource = pubrunner.Resource.byName('PUBMED')

Expand Down

0 comments on commit 749a159

Please sign in to comment.