diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-12-23 18:14:07 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-12-23 18:18:40 -0800 |
commit | f9ffc6d99c53a2ead4b3486e25f0342b6ebc5cdc (patch) | |
tree | b13f19a3c8d4e1a847adbe04b701da6c1258f14c /python/fatcat_tools | |
parent | 05ce151586ec69edc8450ea7d901045798de19f6 (diff) | |
download | fatcat-f9ffc6d99c53a2ead4b3486e25f0342b6ebc5cdc.tar.gz fatcat-f9ffc6d99c53a2ead4b3486e25f0342b6ebc5cdc.zip |
pubmed: improve warning and stderr formatting
Diffstat (limited to 'python/fatcat_tools')
-rw-r--r-- | python/fatcat_tools/importers/pubmed.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/python/fatcat_tools/importers/pubmed.py b/python/fatcat_tools/importers/pubmed.py index ced78d5d..8019e36a 100644 --- a/python/fatcat_tools/importers/pubmed.py +++ b/python/fatcat_tools/importers/pubmed.py @@ -466,17 +466,17 @@ class PubmedImporter(EntityImporter): int(pub_date.Day.string)) release_date = release_date.isoformat() except ValueError as ve: - sys.stderr.write("bad date, skipping: {}\n".format(ve)) + print("bad date, skipping: {}".format(ve), file=sys.stderr) release_date = None elif pub_date.MedlineDate: medline_date = pub_date.MedlineDate.string.strip() if len(medline_date) >= 4 and medline_date[:4].isdigit(): release_year = int(medline_date[:4]) if release_year < 1300 or release_year > 2040: - print("bad medline year, skipping: {}\n".format(release_year), file=sys.stderr) + print("bad medline year, skipping: {}".format(release_year), file=sys.stderr) release_year = None else: - print("unparsable medline date, skipping: {}\n".format(medline_date), file=sys.stderr) + print("unparsable medline date, skipping: {}".format(medline_date), file=sys.stderr) if journal.find("Title"): container_name = journal.Title.string @@ -708,8 +708,9 @@ class PubmedImporter(EntityImporter): if err.status != 404: raise err if existing and existing.ext_ids.pmid and existing.ext_ids.pmid != re.ext_ids.pmid: - warnings.warn("PMID/DOI mismatch: release {}, pmid {} != {}".format( - existing.ident, existing.ext_ids.pmid, re.ext_ids.pmid)) + warn_str = "PMID/DOI mismatch: release {}, pmid {} != {}".format( + existing.ident, existing.ext_ids.pmid, re.ext_ids.pmid) + warnings.warn(warn_str) self.counts['warn-pmid-doi-mismatch'] += 1 # don't clobber DOI, but do group together re.ext_ids.doi = None |