diff options
author | Bryan Newbold <bnewbold@archive.org> | 2020-05-20 18:17:43 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@archive.org> | 2020-05-20 18:17:43 -0700 |
commit | 1ccd50eca45667aaf232f3bfb6a5aafadf17fc09 (patch) | |
tree | 13e5bcc999f76938d8de65ec0f20fb2e1b8c19ce /fatcat_scholar/issue_db.py | |
parent | 73cde66c9ab0bcae733097e53f1b6c4f00a8ea86 (diff) | |
download | fatcat-scholar-1ccd50eca45667aaf232f3bfb6a5aafadf17fc09.tar.gz fatcat-scholar-1ccd50eca45667aaf232f3bfb6a5aafadf17fc09.zip |
fixes to release+sim pipeline
Diffstat (limited to 'fatcat_scholar/issue_db.py')
-rw-r--r-- | fatcat_scholar/issue_db.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/fatcat_scholar/issue_db.py b/fatcat_scholar/issue_db.py index 5278750..4f5ff53 100644 --- a/fatcat_scholar/issue_db.py +++ b/fatcat_scholar/issue_db.py @@ -25,6 +25,20 @@ class SimPubRow: def tuple(self): return (self.sim_pubid, self.pub_collection, self.title, self.issn, self.pub_type, self.publisher, self.container_issnl, self.container_ident, self.wikidata_qid) + @classmethod + def from_tuple(cls, row: Any) -> "SimPubRow": + return SimPubRow( + sim_pubid=row[0], + pub_collection=row[1], + title=row[2], + issn=row[3], + pub_type=row[4], + publisher=row[5], + container_issnl=row[6], + container_ident=row[7], + wikidata_qid=row[8], + ) + @dataclass class SimIssueRow: """ @@ -45,7 +59,7 @@ class SimIssueRow: return (self.issue_item, self.sim_pubid, self.year, self.volume, self.issue, self.first_page, self.last_page, self.release_count) @classmethod - def from_tuple(self, row: Any): + def from_tuple(cls, row: Any) -> "SimIssueRow": return SimIssueRow( issue_item=row[0], sim_pubid=row[1], @@ -166,6 +180,12 @@ class IssueDB(): return None return SimIssueRow.from_tuple(row[0]) + def lookup_pub(self, sim_pubid: str) -> Optional[SimPubRow]: + row = list(self.db.execute("SELECT * FROM sim_pub WHERE sim_pubid = ?;", [sim_pubid])) + if not row: + return None + return SimPubRow.from_tuple(row[0]) + def load_pubs(self, json_lines: Sequence[str], api: Any): """ Reads a file (or some other iterator) of JSON lines, parses them into a |