Commit e4ed5623 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Remove method check_paper_reference in RecordCdsPubli and RecordHepPubli

parent 2297f17a
......@@ -240,7 +240,6 @@ def edit_insert():
try:
record.format_editor()
record.check_paper_reference()
recId = UNDEF_ID
recId = search_synonym(db.publishers,
......
......@@ -73,7 +73,6 @@ class Articles(Automaton):
record.format_editor()
record.check_publisher(self.db)
record.check_paper_reference()
except CheckException as e:
self.logs[-1].reject(e, record=record)
......
......@@ -61,7 +61,6 @@ class Proceedings(Automaton):
record.check_conference_date()
record.format_editor()
record.check_publisher(self.db)
record.check_paper_reference()
except CheckException as e:
self.logs[-1].reject(e, record=record)
......
......@@ -442,67 +442,6 @@ class RecordCdsPubli(dict, AuthorsMixin, PublicationInfoMixin):
if len(value) == 0:
raise CheckException(MSG_NO_MY_AUTHOR)
def check_paper_reference(self):
"""Check that editor, page, volume and paper year are defined
for a published paper. Repair it from doi when possible.
Args:
record (RecordCdsPubli):
record describing a publication.
Raises:
CheckException:
the paper reference is not well formed.
"""
self.logger.debug(f"{T6}check paper reference")
if self.is_published():
return
# paper reference can be incomplete or missing
# is the paper published ? In that case the doi is defined
if "doi" not in self:
return
# what information is missing ?
# * df.columns are title, volume, year and pagination
# * df can contains one or more rows due to erratum.
# * assume that the first row is the oldest one and corresponds tp
# the first publication
# * the row contains empty string when the record is not published.
# * iloc[0] returns a serie where the index are the column's name
#
columns = (self.df_info.iloc[0]
.replace("", np.nan)
.dropna()
.index)
missing = PAPER_REFERENCE_KEYS.difference(columns)
# try to recover from the doi when it has the form
# xx.yyyy/Publisher.Volume.Page
m = REG_DOI.match(self["doi"])
if not m:
raise CheckException(MSG_NO_REF + str(list(missing)))
for subfield in missing:
if subfield == "title":
# transform PhysRevD in Phys. Rev. D
li = re.split(r"([A-Z][a-z]+)", m.group(1))
title = ". ".join([el for el in li if len(el) > 0])
self.df_info.loc[0, "title"] = title
elif subfield == "volume":
self.df_info.loc[0, "volume"] = m.group(2)
elif subfield == "pagination":
self.df_info.loc[0, "pagination"] = m.group(3)
elif subfield == "year":
raise CheckException(MSG_NO_REF + "[year]")
def check_submitted_date(self):
"""Standardise the submitted date as ``YYYY-MM`` or ``YYYY-MM-DD``.
Look for alternative when it is not defined.
......
......@@ -270,11 +270,6 @@ class RecordHepPubli(dict, AuthorsMixin, PublicationInfoMixin):
if len(value) == 0:
raise CheckException(MSG_NO_MY_AUTHOR)
def check_paper_reference(self):
"""Check_paper_reference is a dummy method to preserve interface
"""
def check_submitted_date(self):
"""Check that submitted date is either ``YYYY-MM`` or ``YYYY-MM-DD``.
......
......@@ -117,6 +117,4 @@ def test_check_publisher_13021(record):
def test_check_paper_reference_13022(record):
# check_paper_reference is a dummy method to preserve interface
assert record.paper_reference() == "Phys. Rev. D 95 2017 052005"
assert record.check_paper_reference() is None
......@@ -117,7 +117,4 @@ def test_check_publisher_14021(record):
def test_check_paper_reference_14022(record):
# check_paper_reference is a dummy method to preserve interface
assert record.paper_reference() == "Phys. Rev. D 95 2017 052005"
assert record.check_paper_reference() is None
......@@ -120,6 +120,4 @@ def test_check_publisher_15023(record):
def test_check_paper_reference_15024(record):
# check_paper_reference is a dummy method to preserve interface
assert record.paper_reference() == "J. Phys.: Conf. Ser. 335 2011 012042"
assert record.check_paper_reference() is None
......@@ -121,7 +121,4 @@ def test_check_publisher_16023(record):
def test_check_paper_reference_16024(record):
# check_paper_reference is a dummy method to preserve interface
assert record.paper_reference() == "J. Phys. Conf. Ser. 335 2011 012042"
assert record.check_paper_reference() is None
assert record.paper_reference() == "J. Phys. Conf. Ser. 335 2011 012042"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment