Skip to content

Commit

Permalink
Merge pull request #266 from scholarly-python-package/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
programize-admin committed Feb 22, 2021
2 parents 8a3f431 + ecff82b commit 00fbcef
Show file tree
Hide file tree
Showing 8 changed files with 553 additions and 505 deletions.
497 changes: 2 additions & 495 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Welcome to scholarly's documentation!
========================================

.. toctree::
:maxdepth: 2
:maxdepth: 5
:caption: Index

quickstart
Expand Down
528 changes: 522 additions & 6 deletions docs/quickstart.rst

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion scholarly/_scholarly.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,14 @@ def pprint(self, object: Author or Publication)->None:
print(pprint.pformat(to_print))

def search_org(self, name: str, fromauthor: bool = False) -> list:
"""Search by organization name and return a list of possible disambiguations
"""
Search by organization name and return a list of possible disambiguations
:Example::
.. testcode::
search_query = scholarly.search_org('ucla')
print(search_query)
:Output::
.. testoutput::
[{'Organization': 'University of California, Los Angeles',
Expand Down
5 changes: 4 additions & 1 deletion scholarly/author_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ def _fill_basics(self, soup, author):
if "avatar_scholar" in picture:
picture = _HOST.format(picture)
author['url_picture'] = picture

index = soup.find_all('td', class_='gsc_rsb_std')
if index:
author['citedby'] = int(index[0].text)

def _fill_indices(self, soup, author):
index = soup.find_all('td', class_='gsc_rsb_std')
if index:
Expand Down
9 changes: 9 additions & 0 deletions scholarly/publication_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def __init__(self, nav, url: str):
self._url = url
self._nav = nav
self._load_url(url)
self.total_results = self._get_total_results()
self.pub_parser = PublicationParser(self._nav)

def _load_url(self, url: str):
Expand All @@ -59,6 +60,14 @@ def _load_url(self, url: str):
self._pos = 0
self._rows = self._soup.find_all('div', class_='gs_r gs_or gs_scl')

def _get_total_results(self):
for x in self._soup.find_all('div', class_='gs_ab_mdw'):
# Decimal separator is set by Google independent of language setting
match = re.match(pattern=r'(^|\s*About)\s*([0-9,\.]+)', string=x.text)
if match:
return int(re.sub(pattern=r'[,\.]',repl='', string=match.group(2)))
return None

# Iterator protocol

def __iter__(self):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name='scholarly',
version='1.0.7',
version='1.1.0',
author='Steven A. Cholewiak, Panos Ipeirotis, Victor Silva',
author_email='steven@cholewiak.com, panos@stern.nyu.edu, vsilva@ualberta.ca',
description='Simple access to Google Scholar authors and citations',
Expand Down
10 changes: 10 additions & 0 deletions test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,16 @@ def test_search_pubs(self):

self.assertIn('Visual perception of the physical stability of asymmetric three-dimensional objects', pubs)

def test_search_pubs_total_results(self):
"""
As of February 4, 2021 there are 32 pubs that fit the search term:
["naive physics" stability "3d shape"].
Check that the total results for that search term equals 32.
"""
pubs = scholarly.search_pubs('"naive physics" stability "3d shape"')
self.assertGreaterEqual(pubs.total_results, 32)

def test_search_pubs_filling_publication_contents(self):
'''
This process checks the process of filling a publication that is derived
Expand Down

0 comments on commit 00fbcef

Please sign in to comment.