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

Jats email problem iop.20250117 #159

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions adsingestp/parsers/base.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import html
import re
import warnings
from datetime import datetime

import bs4
from bs4 import MarkupResemblesLocatorWarning

from adsingestp.ingest_exceptions import WrongFormatException

Expand All @@ -21,6 +23,7 @@ class IngestBase(object):
]

def __init__(self, xml_ref=True):
warnings.filterwarnings("ignore", category=MarkupResemblesLocatorWarning, module="bs4")
self.xml_ref = xml_ref

def _clean_empty(self, input_to_clean, keys_to_keep=required_keys):
Expand Down
24 changes: 18 additions & 6 deletions adsingestp/parsers/jats.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,25 @@ def _fix_email(self, email):
for em in email:
if " " in em:
for e in em.strip().split():
if email_format.search(e):
email_new.add(email_format.search(e).group(0))
email_parsed = True
try:
if email_format.search(e):
email_new.add(email_format.search(e).group(0))
email_parsed = True
except Exception as err:
logger.warning("Bad format in _fix_email: %s" % err)
else:
if email_format.search(em):
email_new.add(email_format.search(em).group(0))
email_parsed = True
try:
if type(em) == str:
if email_format.search(em):
email_new.add(email_format.search(em).group(0))
email_parsed = True
elif type(em) == list:
for e in em:
if email_format.search(e):
email_new.add(email_format.search(e).group(0))
email_parsed = True
except Exception as err:
logger.warning("Bad format in _fix_email: %s" % err)

if not email_parsed:
logger.warning("Email not verified as valid. Input email list: %s", str(email))
Expand Down
529 changes: 529 additions & 0 deletions tests/stubdata/input/jats_iop_list_embedded_email.xml

Large diffs are not rendered by default.

Loading
Loading