Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 138 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,143 @@
# Byte-compiled / optimized / DLL files
*.py[cod]
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# Byte-compiled / optimized / DLL files
*.doctree
*.pickle

Expand All @@ -21,7 +158,6 @@ setup_notes.md
#logging
*.log


#dev testing
vic.py
.env
Expand Down
27 changes: 23 additions & 4 deletions scholarly/_scholarly.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import copy
import csv
import pprint
import datetime
import itertools
import warnings
from typing import Dict, List
from ._navigator import Navigator
from ._proxy_generator import ProxyGenerator
Expand Down Expand Up @@ -255,13 +258,29 @@ def citedby(self, object: Publication)->_SearchScholarIterator:
:param object: The Publication object for the bibtex exportation
:type object: Publication
"""
if object['container_type'] == "Publication":
publication_parser = PublicationParser(self.__nav)
return publication_parser.citedby(object)
else:

if object['container_type'] != "Publication":
self.logger.warning("Object not supported for bibtex exportation")
return

if object["bib"]["citedby"] < 999:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be <= 1000

return PublicationParser(self.__nav).citedby(object)
else:
try:
year_low = int(object["bib"]["pub_year"])
year_end = int(datetime.date.today().year)
except KeyError:
self.logger.warning("Unknown publication year for paper %s, may result in incorrect number of citedby papers.", object["bib"]["title"])
return PublicationParser(self.__nav).citedby(object)

pub_id = int(object["citedby_url"].split("=")[1].split("&")[0])
iter_list = []
while year_low < year_end:
iter_list.append(self.search_citedby(publication_id=pub_id, year_low=year_low, year_high=year_low+1))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

year_high should be the same as year_low. This actually fetches citations from two years instead of one year.

year_low += 1

return itertools.chain(*iter_list)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using yield from syntax would be much cleaner and would avoid importing itertools.


def search_author_id(self, id: str, filled: bool = False, sortby: str = "citedby", publication_limit: int = 0)->Author:
"""Search by author id and return a single Author object
:param sortby: select the order of the citations in the author page. Either by 'citedby' or 'year'. Defaults to 'citedby'.
Expand Down