Skip to content

Commit

Permalink
fix for some failing cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommos0 committed Sep 27, 2017
1 parent 9e198b9 commit aa6745d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pyzenodo/zenodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,19 @@ def _row_to_version(row):
}

def get_versions(self):
"""Get version details from Zenodo webpage (it is not available in the REST api)
"""
"""Get version details from Zenodo webpage (it is not available in the REST api)"""
res = requests.get('https://zenodo.org/record/'+self.data['conceptrecid'])
soup = BeautifulSoup(res.text, 'html.parser')
version_rows = soup.select('.well.metadata > table.table tr')
return [self._row_to_version(row) for row in version_rows]
if len(version_rows) == 0: # when only 1 version
return [{
'recid': self.data['id'],
'name': '1',
'doi': self.data['doi'],
'date': self.data['created'],
'original_version': self.original_version()
}]
return [self._row_to_version(row) for row in version_rows if len(row.select('td')) > 1]

def original_version(self):
for identifier in self.data['metadata']['related_identifiers']:
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Scientific/Engineering',
],
packages=find_packages(),
install_requires=['requests', 'Beautifulsoup4'],
Expand Down

0 comments on commit aa6745d

Please sign in to comment.