Skip to content

Commit

Permalink
Correct calling of method
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinywlui committed Aug 4, 2019
1 parent f7f051e commit f277e03
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 30 deletions.
2 changes: 1 addition & 1 deletion caleb/app.py
Expand Up @@ -38,7 +38,7 @@ def go(self, take_first=False, method="crossref"):

for cit in missing_cits:
logging.info("Working on: {}".format(cit))
new_bib = Reference(cit)
new_bib = Reference(cit, method=method)
if not new_bib.exists():
logging.warning("No results found for: {}".format(cit))
continue
Expand Down
16 changes: 10 additions & 6 deletions caleb/reference.py
@@ -1,5 +1,5 @@
"""This module is used obtaining citations from references. We mainly use the
crossref api but it'll be good to add more sources in the future.
"""This module is used obtaining citations from references. Currently, this
module can use both the crossref api and can scrape the AMS page.
"""

import requests
Expand All @@ -18,7 +18,7 @@ class Reference:
"""

def __init__(self, key):
def __init__(self, key, method="crossref"):
self.key = key

# replace underscore by space
Expand All @@ -27,11 +27,15 @@ def __init__(self, key):
# data for query
self.pieces = spaced_key.split(":")

def _get_bibtex(self, method="ams"):
if method == "crossref":
self.method = method

def _get_bibtex(self):
if self.method == "crossref":
return self._get_bibtex_crossref()
elif method == "ams":
elif self.method == "ams":
return self._get_bibtex_ams()
else:
raise NotImplementedError()

def _get_bibtex_ams(self):
"""Fetch the bibtex entry from amsmrlookup.
Expand Down
48 changes: 25 additions & 23 deletions setup.py
Expand Up @@ -11,38 +11,40 @@

import os.path

readme = ''
readme = ""
here = os.path.abspath(os.path.dirname(__file__))
readme_path = os.path.join(here, 'README.rst')
readme_path = os.path.join(here, "README.rst")
if os.path.exists(readme_path):
with open(readme_path, 'rb') as stream:
readme = stream.read().decode('utf8')
with open(readme_path, "rb") as stream:
readme = stream.read().decode("utf8")

setup(
long_description=readme,
name='caleb',
version='0.5.0',
description='A tool to automatically retrieve bibtex entries',
python_requires='==3.*,>=3.7.0',
project_urls={'homepage': 'https://github.com/kevinywlui/caleb'},
author='kevin lui',
author_email='kevinywlui@gmail.com',
license='MIT',
keywords='latex python crossref',
name="caleb",
version="0.5.0",
description="A tool to automatically retrieve bibtex entries",
python_requires="==3.*,>=3.7.0",
project_urls={"homepage": "https://github.com/kevinywlui/caleb"},
author="kevin lui",
author_email="kevinywlui@gmail.com",
license="MIT",
keywords="latex python crossref",
classifiers=[
'Topic :: Text Processing :: Markup :: LaTeX',
'Programming Language :: Python :: 3',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent'
"Topic :: Text Processing :: Markup :: LaTeX",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
entry_points={'console_scripts': ['caleb = caleb.cmdline:launch']},
packages=['caleb'],
entry_points={"console_scripts": ["caleb = caleb.cmdline:launch"]},
packages=["caleb"],
package_data={},
install_requires=['crossref-commons==0.*,>=0.0.5'],
install_requires=["crossref-commons==0.*,>=0.0.5"],
extras_require={
'dev': [
'black==18.*,>=18.3.0', 'pytest==5.*,>=5.0.0',
'pytest-cov==2.*,>=2.7.0', 'python-coveralls==2.*,>=2.9.0'
"dev": [
"black==18.*,>=18.3.0",
"pytest==5.*,>=5.0.0",
"pytest-cov==2.*,>=2.7.0",
"python-coveralls==2.*,>=2.9.0",
]
},
)

0 comments on commit f277e03

Please sign in to comment.