Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update for final pre-production testing #34

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions examples/parse_zenodo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"""
This uses the new infrastructure developed for ADSManualParser, including
* ADSIngestParser
* ADSIngestEnrichment

-MT 2023 November 08
"""

import argparse
import os
from adsingestp.parsers.datacite import DataciteParser
from adsmanparse import translator, classic_serializer
from adsputils import setup_logging

logger = setup_logging('zenodo-parser')

def get_args():

parser = argparse.ArgumentParser("Parse a Zenodo record")

parser.add_argument("-f",
"--infile",
dest="infile",
action="store",
default=None,
help="Full path to input file")

args = parser.parse_args()
return args


def parse(infile):
try:
with open(infile, "r") as fin:
rawdata = fin.read()
parser = DataciteParser()
record = parser.parse(rawdata)

xlator = translator.Translator()
xlator.translate(record)

seri = classic_serializer.ClassicSerializer()
tagged_output = seri.output(xlator.output)

return tagged_output
except Exception as err:
logger.warning("Parsing failed for file %s: %s" % (infile, err))



def main():
args=get_args()

if args.infile:
if os.path.exists(args.infile):
tagged_record = parse(args.infile)
print("%s\n" % tagged_record)
else:
logger.error("The file %s does not exist." % args.infile)
else:
logger.error("You must supply a filename to parse")


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
git+https://github.com/adsabs/[email protected]
git+https://github.com/adsabs/ADSIngestEnrichment@v0.1.11
git+https://github.com/adsabs/ADSIngestEnrichment@v0.9.0
adsputils==1.4.3
habanero==0.7.4
namedentities==1.9.4
Expand Down