aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xfatcat_scholar/grobid2json.py2
-rw-r--r--fatcat_scholar/issue_db.py2
-rw-r--r--fatcat_scholar/search.py2
-rw-r--r--fatcat_scholar/web.py8
-rw-r--r--tests/test_djvu_parse.py2
-rw-r--r--tests/test_grobid2json.py2
-rw-r--r--tests/test_issue_db.py4
-rw-r--r--tests/test_refs_transform.py2
-rw-r--r--tests/test_transform.py10
-rw-r--r--tests/test_work_pipeline.py2
10 files changed, 18 insertions, 18 deletions
diff --git a/fatcat_scholar/grobid2json.py b/fatcat_scholar/grobid2json.py
index 2c85047..5c44953 100755
--- a/fatcat_scholar/grobid2json.py
+++ b/fatcat_scholar/grobid2json.py
@@ -223,7 +223,7 @@ def main() -> None: # pragma no cover
args = parser.parse_args()
for filename in args.teifiles:
- content = open(filename).read()
+ content = open(filename, "r").read()
print(
json.dumps(
teixml2json(content, encumbered=(not args.no_encumbered)),
diff --git a/fatcat_scholar/issue_db.py b/fatcat_scholar/issue_db.py
index 057869b..3c55b51 100644
--- a/fatcat_scholar/issue_db.py
+++ b/fatcat_scholar/issue_db.py
@@ -167,7 +167,7 @@ class IssueDB:
PRAGMA main.synchronous = OFF;
"""
)
- with open("schema/issue_db.sql") as fschema:
+ with open("schema/issue_db.sql", "r") as fschema:
self.db.executescript(fschema.read())
def insert_sim_pub(self, pub: SimPubRow, cur: Any = None) -> None:
diff --git a/fatcat_scholar/search.py b/fatcat_scholar/search.py
index 5b45ba9..be362b7 100644
--- a/fatcat_scholar/search.py
+++ b/fatcat_scholar/search.py
@@ -387,7 +387,7 @@ def do_fulltext_search(
except elasticsearch.exceptions.TransportError as e:
# all other errors
logging.warn(f"elasticsearch non-200 status code: {e.info}")
- raise OSError(str(e.info)) from e
+ raise IOError(str(e.info)) from e
query_delta = datetime.datetime.now() - query_start
# convert from API objects to dicts
diff --git a/fatcat_scholar/web.py b/fatcat_scholar/web.py
index 43a733a..dce732b 100644
--- a/fatcat_scholar/web.py
+++ b/fatcat_scholar/web.py
@@ -106,7 +106,7 @@ async def search(query: FulltextQuery = Depends(FulltextQuery)) -> FulltextHits:
sentry_sdk.set_level("warning")
sentry_sdk.capture_exception(e)
raise HTTPException(status_code=400, detail=f"Query Error: {e}")
- except OSError as e:
+ except IOError as e:
sentry_sdk.capture_exception(e)
raise HTTPException(status_code=500, detail=f"Backend Error: {e}")
@@ -224,7 +224,7 @@ async def web_search(
sentry_sdk.capture_exception(e)
search_error = dict(type="query", message=str(e))
status_code = 400
- except OSError as e:
+ except IOError as e:
sentry_sdk.capture_exception(e)
search_error = dict(type="backend", message=str(e))
status_code = 500
@@ -282,8 +282,8 @@ async def favicon() -> Any:
)
-ROBOTS_ALLOW = open("fatcat_scholar/static/robots.allow.txt").read()
-ROBOTS_DISALLOW = open("fatcat_scholar/static/robots.disallow.txt").read()
+ROBOTS_ALLOW = open("fatcat_scholar/static/robots.allow.txt", "r").read()
+ROBOTS_DISALLOW = open("fatcat_scholar/static/robots.disallow.txt", "r").read()
@app.get("/robots.txt", include_in_schema=False)
diff --git a/tests/test_djvu_parse.py b/tests/test_djvu_parse.py
index f661f33..777f8bf 100644
--- a/tests/test_djvu_parse.py
+++ b/tests/test_djvu_parse.py
@@ -5,7 +5,7 @@ from fatcat_scholar.djvu import djvu_extract_leaf_texts
def test_djvu_extract_leaf_texts() -> None:
# https://archive.org/details/ERIC_ED441501
- with open("tests/files/ERIC_ED441501_djvu.xml") as f:
+ with open("tests/files/ERIC_ED441501_djvu.xml", "r") as f:
blob = f.read()
leaves = djvu_extract_leaf_texts(io.StringIO(blob), [3, 6])
diff --git a/tests/test_grobid2json.py b/tests/test_grobid2json.py
index bd5c0e4..345fd91 100644
--- a/tests/test_grobid2json.py
+++ b/tests/test_grobid2json.py
@@ -3,7 +3,7 @@ from fatcat_scholar.grobid2json import teixml2json
def test_grobid_teixml2json() -> None:
- with open("tests/files/example_grobid.tei.xml") as f:
+ with open("tests/files/example_grobid.tei.xml", "r") as f:
blob = f.read()
obj = teixml2json(blob, True)
diff --git a/tests/test_issue_db.py b/tests/test_issue_db.py
index d164ef6..9fdab94 100644
--- a/tests/test_issue_db.py
+++ b/tests/test_issue_db.py
@@ -16,8 +16,8 @@ def test_issue_db_basics() -> None:
issue_db = IssueDB(settings.SCHOLAR_ISSUEDB_PATH)
issue_db.init_db()
- with open("tests/files/sim_collections.json") as f:
+ with open("tests/files/sim_collections.json", "r") as f:
issue_db.load_pubs(f.readlines(), api)
- with open("tests/files/sim_items.json") as f:
+ with open("tests/files/sim_items.json", "r") as f:
issue_db.load_issues(f.readlines(), es_client)
diff --git a/tests/test_refs_transform.py b/tests/test_refs_transform.py
index 3b18557..c26ee1e 100644
--- a/tests/test_refs_transform.py
+++ b/tests/test_refs_transform.py
@@ -6,7 +6,7 @@ from fatcat_scholar.transform import refs_from_grobid
def test_transform_refs_grobid() -> None:
- with open("tests/files/example_grobid.tei.xml") as f:
+ with open("tests/files/example_grobid.tei.xml", "r") as f:
blob = f.read()
dummy_release = ReleaseEntity(
diff --git a/tests/test_transform.py b/tests/test_transform.py
index c5e189b..927c13b 100644
--- a/tests/test_transform.py
+++ b/tests/test_transform.py
@@ -7,7 +7,7 @@ from fatcat_scholar.transform import *
def test_es_release_from_release() -> None:
- with open("tests/files/release_hsmo6p4smrganpb3fndaj2lon4.json") as f:
+ with open("tests/files/release_hsmo6p4smrganpb3fndaj2lon4.json", "r") as f:
release = entity_from_json(f.read(), ReleaseEntity)
obj = es_release_from_release(release)
@@ -20,7 +20,7 @@ def test_es_release_from_release() -> None:
def test_es_biblio_from_release() -> None:
- with open("tests/files/release_hsmo6p4smrganpb3fndaj2lon4.json") as f:
+ with open("tests/files/release_hsmo6p4smrganpb3fndaj2lon4.json", "r") as f:
release = entity_from_json(f.read(), ReleaseEntity)
obj = es_biblio_from_release(release)
@@ -36,16 +36,16 @@ def test_es_biblio_from_release() -> None:
def test_run_refs() -> None:
- with open("tests/files/work_iarm6swodra2bcrzhxrfaah7py_bundle.json") as f:
+ with open("tests/files/work_iarm6swodra2bcrzhxrfaah7py_bundle.json", "r") as f:
run_refs(f.readlines())
def test_run_transform() -> None:
- with open("tests/files/work_iarm6swodra2bcrzhxrfaah7py_bundle.json") as f:
+ with open("tests/files/work_iarm6swodra2bcrzhxrfaah7py_bundle.json", "r") as f:
run_transform(f.readlines())
- with open("tests/files/sim_page_bundle.json") as f:
+ with open("tests/files/sim_page_bundle.json", "r") as f:
run_transform(f.readlines())
diff --git a/tests/test_work_pipeline.py b/tests/test_work_pipeline.py
index 39b09dc..e0e4a82 100644
--- a/tests/test_work_pipeline.py
+++ b/tests/test_work_pipeline.py
@@ -84,5 +84,5 @@ def test_run_transform(mocker: Any) -> None:
),
)
- with open("tests/files/release_hsmo6p4smrganpb3fndaj2lon4_sans.json") as f:
+ with open("tests/files/release_hsmo6p4smrganpb3fndaj2lon4_sans.json", "r") as f:
wp.run_releases(f.readlines())