From 0b1314fcfaa60d68c47441a9ef6cfe02ec302058 Mon Sep 17 00:00:00 2001 From: Dazhi Jiao Date: Sun, 7 Apr 2019 22:47:19 -0400 Subject: [PATCH 1/5] Add a missing comma to the end of the long description line --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 3d44240..181005a 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ name = 'elsapy', version = version, description = "A Python module for use with Elsevier's APIs: Scopus, ScienceDirect, others - see https://api.elsevier.com", - long_description = "See https://github.com/ElsevierDev/elsapy for the latest information / background to this project." + long_description = "See https://github.com/ElsevierDev/elsapy for the latest information / background to this project.", author = 'Elsevier, Inc.', author_email = 'integrationsupport@elsevier.com', url = 'https://github.com/ElsevierDev/elsapy', From adfa887943f26ce5d1677c0b1bb29e2353c6b522 Mon Sep 17 00:00:00 2001 From: Dazhi Jiao Date: Mon, 8 Apr 2019 08:43:31 -0400 Subject: [PATCH 2/5] Added property to get parent of the affiliation --- elsapy/elsprofile.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/elsapy/elsprofile.py b/elsapy/elsprofile.py index bac0c9c..14ea5db 100644 --- a/elsapy/elsprofile.py +++ b/elsapy/elsprofile.py @@ -180,7 +180,11 @@ def __init__(self, uri = '', affil_id = ''): @property def name(self): """Gets the affiliation's name""" - return self.data["affiliation-name"]; + return self.data["affiliation-name"] + + @property + def parent(self): + return self.data.get('institution-profile', {}).get('@parent', None) # modifier functions def read(self, els_client = None): From c333a7cc8f2926dd75b51120fac91545bba43990 Mon Sep 17 00:00:00 2001 From: Dazhi Jiao Date: Mon, 8 Apr 2019 08:44:01 -0400 Subject: [PATCH 3/5] Added ElsAbstract and ElsSerial --- elsapy/elsdoc.py | 70 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/elsapy/elsdoc.py b/elsapy/elsdoc.py index 453d10c..f3abb4d 100644 --- a/elsapy/elsdoc.py +++ b/elsapy/elsdoc.py @@ -85,4 +85,72 @@ def read(self, els_client = None): if super().read(self.__payload_type, els_client): return True else: - return False \ No newline at end of file + return False + + +class ElsAbstract(ElsEntity): + """A document with abstract and other information such as authors. It's retrieved from the abstract service""" + + # static variables + __payload_type = u'abstracts-retrieval-response' + __uri_base = u'https://api.elsevier.com/content/abstract/' + + @property + def authors(self): + """Get the document's authors""" + return self.data['authors']['author'] + + def __init__(self, uri='', scopus_id='', doi='', params={}): + """Initializes a document given a Scopus ID.""" + if uri and not scopus_id and not doi: + s_uri = uri + elif scopus_id and not uri and not doi: + s_uri = self.__uri_base + 'scopus_id/' + str(scopus_id) + if params: + s_uri += '?' + parse.urlencode(params) + elif doi and not uri and not scopus_id: + s_uri = self.__uri_base + 'doi/' + str(doi) + if params: + s_uri += '?' + parse.urlencode(params) + else: + raise ValueError('Multiple identifiers specified; just need one.') + if s_uri is None: + raise ValueError('No URI, Scopus ID or DOI specified') + super().__init__(s_uri) + + def read(self, els_client=None): + """Reads the JSON representation of the document from ELSAPI. + Returns True if successful; else, False.""" + if super().read(self.__payload_type, els_client): + return True + else: + return False + + +class ElsSerial(ElsEntity): + """A serial(Journal, conference proceeding etc.) in Scopus""" + + # static variables + __payload_type = u'serial-metadata-response' + __uri_base = u'http://api.elsevier.com/content/serial/title' + + # constructors + def __init__(self, uri='', scopus_id='', params={}): + if uri and not scopus_id: + s_uri = uri + super().__init__(uri) + elif scopus_id and not uri: + params['source-id'] = scopus_id + s_uri = self.__uri_base + '?' + parse.urlencode(params) + elif not uri and not scopus_id: + raise ValueError('No URI or scopus id specified') + else: + raise ValueError('Both URI and scopus id specified; just need one.') + print(s_uri) + super().__init__(s_uri) + + def read(self, els_client=None): + if super().read(self.__payload_type, els_client): + return True + else: + return False From 8e7ba8fa4052842e11d12645edb4a6668c33f7a5 Mon Sep 17 00:00:00 2001 From: Dazhi Jiao Date: Mon, 8 Apr 2019 12:33:25 -0400 Subject: [PATCH 4/5] Added serial title search --- elsapy/elssearch.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/elsapy/elssearch.py b/elsapy/elssearch.py index 7b832ee..e6c740b 100644 --- a/elsapy/elssearch.py +++ b/elsapy/elssearch.py @@ -5,6 +5,7 @@ * https://api.elsevier.com""" from . import log_util +from urllib import parse logger = log_util.get_logger(__name__) @@ -87,3 +88,30 @@ def hasAllResults(self): """Returns true if the search object has retrieved all results for the query from the index (i.e. num_res equals tot_num_res).""" return (self.num_res is self.tot_num_res) + + +class ElsSerialTitleSearch(ElsSearch): + """Represents a search to the serial title search""" + + __base_url = u'https://api.elsevier.com/content/serial/title' + + def __init__(self, title, params={}): + super.__init__() + """Initializes a search object with a query and target index.""" + self._title = title + self._params = params + # There is a bug in scopus API. Params are dropped in links if they appear in front of the 'query' param. + # Make sure query appear the first in the query string in the URL + self._uri = self.__base_url + '?' + parse.urlencode({'title': title, **params}) + + @property + def title(self): + return self._title + + @title.setter + def title(self, title): + self._title = title + + def execute(self, els_client=None): + api_response = els_client.exec_request(self._uri) + self._results = api_response['serial-metadata-response']['entry'] From 2869158c4d2c82e5cc4c70e3d327d702b6ca7b28 Mon Sep 17 00:00:00 2001 From: Dazhi Jiao Date: Mon, 8 Apr 2019 23:54:52 -0400 Subject: [PATCH 5/5] Added missing import --- elsapy/elsdoc.py | 1 + 1 file changed, 1 insertion(+) diff --git a/elsapy/elsdoc.py b/elsapy/elsdoc.py index f3abb4d..3966b9d 100644 --- a/elsapy/elsdoc.py +++ b/elsapy/elsdoc.py @@ -6,6 +6,7 @@ from . import log_util from .elsentity import ElsEntity +from urllib import parse logger = log_util.get_logger(__name__)