Skip to content

Commit b15ccfd

Browse files
StephenKrewsonrlmv
authored andcommitted
Add Python3 compatibility (#4)
1 parent 518d8a1 commit b15ccfd

File tree

8 files changed

+122
-16
lines changed

8 files changed

+122
-16
lines changed

.gitignore

+104-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,105 @@
1-
/Untitled.ipynb
2-
/.ipynb_checkpoints/
3-
/hathitrust_api/__pycache__/*
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
MANIFEST
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a template
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
.hypothesis/
48+
.pytest_cache/
49+
50+
# Translations
51+
*.mo
52+
*.pot
53+
54+
# Django stuff:
55+
*.log
56+
local_settings.py
57+
db.sqlite3
58+
59+
# Flask stuff:
60+
instance/
61+
.webassets-cache
62+
63+
# Scrapy stuff:
64+
.scrapy
65+
66+
# Sphinx documentation
67+
docs/_build/
68+
69+
# PyBuilder
70+
target/
71+
72+
# Jupyter Notebook
73+
.ipynb_checkpoints
74+
75+
# pyenv
76+
.python-version
77+
78+
# celery beat schedule file
79+
celerybeat-schedule
80+
81+
# SageMath parsed files
82+
*.sage.py
83+
84+
# Environments
85+
.env
86+
.venv
87+
env/
88+
venv/
89+
ENV/
90+
env.bak/
91+
venv.bak/
92+
93+
# Spyder project settings
94+
.spyderproject
95+
.spyproject
96+
97+
# Rope project settings
98+
.ropeproject
99+
100+
# mkdocs documentation
101+
/site
102+
103+
# mypy
104+
.mypy_cache/
4105

__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22

3-
from hathitrust_api import BibAPI, DataAPI, SolrAPI
3+
from .hathitrust_api import BibAPI, DataAPI, SolrAPI

hathitrust_api/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

22

3-
from bib_api import BibAPI
4-
from data_api import DataAPI
5-
from solr_api import SolrAPI
3+
from .bib_api import BibAPI
4+
from .data_api import DataAPI
5+
from .solr_api import SolrAPI

hathitrust_api/bib_api.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
from __future__ import absolute_import
2+
13

24
import requests
35

4-
from constants import BIB_BASEURL
6+
from .constants import BIB_BASEURL
57

68

79
class BibAPI(object):

hathitrust_api/constants.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11

2-
32
# constants for bibliographic api
43
BIB_BASEURL = 'http://catalog.hathitrust.org/api/volumes/'
54

hathitrust_api/data_api.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
from __future__ import absolute_import
12

23
import requests
34
from requests_oauthlib import OAuth1
45

5-
from constants import DATA_BASEURL, SECURE_DATA_BASEURL
6+
from .constants import DATA_BASEURL, SECURE_DATA_BASEURL
67

78

89
class DataAPI(object):

hathitrust_api/solr_api.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
from __future__ import absolute_import
2+
from __future__ import print_function
3+
14

25
import sys
36
import json
47
import zipfile
5-
from string import replace
68

79
import requests
810

9-
from constants import QUERY_BASEURL, MARC_BASEURL
11+
from .constants import QUERY_BASEURL, MARC_BASEURL
1012

1113

1214
class SolrAPI(object):
@@ -133,10 +135,10 @@ def _cleanquery(querystring):
133135
it will regard terms surrounded with '...' as separate
134136
queryterms, but "..." as a single concatenated phrase.
135137
"""
136-
return replace(querystring, '\'', '\"')
138+
return querystring.replace('\'', '\"')
137139

138140

139141
if __name__ == "__main__":
140142
#ids = [ 'mdp.39015026997125', 'uc1.31822021576848', 'uc2.ark:/13960/t3902080r']
141143

142-
print _cleanquery("author : 'new zealand'")
144+
print(_cleanquery("author : 'new zealand'"))

setup.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
url='github.com/rlmv/hathitrust-api',
77
description='Python wrappers for the HathiTrust APIs',
88
author='Robert Marchman',
9-
packages=['hathitrust_api']
10-
)
9+
packages=['hathitrust_api'],
10+
install_requires=['requests', 'requests-oauthlib']
11+
)

0 commit comments

Comments
 (0)