Skip to content

Commit

Permalink
Merge pull request #74 from Coleridge-Initiative/el3220/Issue_73_Open…
Browse files Browse the repository at this point in the history
…AIRE

OPENAire: Removing None fields from meta
  • Loading branch information
ernestogimeno authored Aug 20, 2020
2 parents 012e055 + 2b6160a commit ab0f897
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
20 changes: 16 additions & 4 deletions richcontext/scholapi/scholapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,22 @@ def title_search (self, title):
result_title = self._get_xml_node_value(result, "title")

if self.title_match(title, result_title):
meta["doi"] = self._get_xml_node_value(result, "pid", {"classname": "doi"})
meta["title"] = self._get_xml_node_value(result, "title")
meta["url"] = self._get_xml_node_value(result, "url")
meta["authors"] = [a.text for a in result.find_all("creator")]
val = self._get_xml_node_value(result, "pid", {"classname": "doi"})
if val:
meta["doi"] = val

val = self._get_xml_node_value(result, "title")
if val:
meta["title"] = val

val = self._get_xml_node_value(result, "url")
if val:
meta["url"] = val

val = [a.text for a in result.find_all("creator")]
if val:
meta["authors"] = val

meta["open"] = len(result.find_all("bestaccessright", {"classid": "OPEN"})) > 0

timing = self._mark_elapsed_time(t0)
Expand Down
6 changes: 6 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ def test_openaire_title_search (self):
self.assertTrue(response.authors() == authors)
self.assertTrue(response.meta["open"])

title = "Quantitative easing, portfolio rebalancing and credit growth: Micro evidence from Germany"
if source.has_credentials():
response = source.title_search(title)
source.report_perf(response.timing)
self.assertTrue("doi" not in response.meta)
self.assertTrue(response.title() == title)

def test_openaire_fulltext_search (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
Expand Down

0 comments on commit ab0f897

Please sign in to comment.