Skip to content

Commit bc0ab17

Browse files
Merge pull request #242 from scholarly-python-package/develop
Develop
2 parents d6c95a7 + b14073f commit bc0ab17

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

scholarly/_scholarly.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ def set_timeout(self, timeout: int):
5959
def search_pubs(self,
6060
query: str, patents: bool = True,
6161
citations: bool = True, year_low: int = None,
62-
year_high: int = None, sortby_date: str = None)->_SearchScholarIterator:
62+
year_high: int = None, sort_by: str = "relevance",
63+
include_last_year: str = "abstracts")->_SearchScholarIterator:
6364
"""Searches by query and returns a generator of Publication objects
6465
6566
:param query: terms to be searched
@@ -72,8 +73,10 @@ def search_pubs(self,
7273
:type year_low: int, optional
7374
:param year_high: maximum year of publication, defaults to None
7475
:type year_high: int, optional
75-
:param sortby_date: 'abstracts' for abstracts, 'everything' for all results
76-
:type sortyby_date: string, optional
76+
:param sort_by: 'relevance' or 'date', defaults to 'relevance'
77+
:type sort_by: string, optional
78+
:param include_last_year: 'abstracts' or 'everything', defaults to 'abstracts' and only applies if 'sort_by' is 'date'
79+
:type include_last_year: string, optional
7780
:returns: Generator of Publication objects
7881
:rtype: Iterator[:class:`Publication`]
7982
@@ -124,10 +127,18 @@ def search_pubs(self,
124127
patents = '&as_sdt={0},33'.format(1 - int(patents))
125128
sortby = ''
126129

127-
if sortby_date == 'abstract':
128-
sortby = '&scisbd=1'
129-
elif sortby_date == 'everything':
130-
sortby = '&scisbd=2'
130+
if sort_by == "date":
131+
if include_last_year == "abstracts":
132+
sortby = '&scisbd=1'
133+
elif include_last_year == "everything":
134+
sortby = '&scisbd=2'
135+
else:
136+
print("Invalid option for 'include_last_year', available options: 'everything', 'abstracts'")
137+
return
138+
elif sort_by != "relevance":
139+
print("Invalid option for 'sort_by', available options: 'relevance', 'date'")
140+
return
141+
131142
# improve str below
132143
url = url + yr_lo + yr_hi + citations + patents + sortby
133144
return self.__nav.search_publications(url)

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name='scholarly',
8-
version='1.0.4',
8+
version='1.0.5',
99
author='Steven A. Cholewiak, Panos Ipeirotis, Victor Silva',
1010
author_email='steven@cholewiak.com, panos@stern.nyu.edu, vsilva@ualberta.ca',
1111
description='Simple access to Google Scholar authors and citations',
@@ -36,6 +36,7 @@
3636
'python-dotenv',
3737
'free-proxy',
3838
'sphinx_rtd_theme',
39+
'typing_extensions'
3940
],
4041
test_suite="test_module.py"
4142
)

0 commit comments

Comments
 (0)