Commit 75ff496f authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Migrate check and fix method to preprints

parent e98db28b
......@@ -2,18 +2,20 @@
"""
from .automaton import Automaton
from .base import MSG_CRASH, MSG_LOAD
from .base import MSG_CRASH, MSG_LOAD, T4
from .checkandfix import CheckException
from plugin_dbui import get_id, UNDEF_ID
from store_tools import RecordCdsConfPaper, RecordCdsThesis
from .recordcdsconfpaper import RecordCdsConfPaper
from .recordhepconfpaper import RecordHepConfPaper
from .recordcdsthesis import RecordCdsThesis
from .recordhepthesis import RecordHepThesis
MSG_NOT_ARTICLE = "Reject publication is not a preprint"
MSG_PREPRINT_IS_PAPER = "Reject preprint is a published paper"
MSG_PREPRINT_IS_CONFERENCE = "Reject preprint is a conference"
MSG_PREPRINT_IS_THESIS = "Reject preprint is a thesis"
MSG_PREPRINT_NO_NUMBER = "Reject no preprint number"
T4 = " "*4
class Preprints(Automaton):
"""Automaton for preprints.
......@@ -23,6 +25,12 @@ class Preprints(Automaton):
def check_record(self, record):
"""Check the content of the preprint in order to fix non conformities.
* is with authors form my institute
* standardise name of collaboration
* format authors according to my format
* extract authors form my institute signing the publication
* is submitted date well formed
Args:
record (RecordPubli):
record describing a preprint.
......@@ -33,20 +41,21 @@ class Preprints(Automaton):
corrected.
"""
if not Automaton.check_record(self, record):
return False
self.logger.debug(f"{T4}check and fix record (preprint)")
self.logger.debug(f"{T4}check record (preprint)")
if record.subtype() == "preprint":
self.logs[-1].reject(MSG_NOT_ARTICLE, record)
return False
if record.is_published():
self.logs[-1].reject(MSG_PREPRINT_IS_PAPER, record=record)
return False
if isinstance(record, RecordCdsConfPaper):
if isinstance(record, (RecordCdsConfPaper, RecordHepConfPaper)):
self.logs[-1].reject(MSG_PREPRINT_IS_CONFERENCE, record=record)
return False
if isinstance(record, RecordCdsThesis):
if isinstance(record, (RecordCdsThesis, RecordHepThesis)):
self.logs[-1].reject(MSG_PREPRINT_IS_THESIS, record=record)
return False
......@@ -55,10 +64,15 @@ class Preprints(Automaton):
return False
try:
self.check.submitted(record)
self.check.format_authors(record, fmt="F. Last")
self.check.get_my_authors(record, sort=True)
# is with authors form my institute
# standardise name of collaboration
# format authors according to my format
# extract authors form my institute signing the publication
# is submitted date well formed
record.check_and_fix(self.rex_institute,
fmt_author="F. Last",
sep_author=", ",
sort_author=True)
except CheckException as e:
self.logs[-1].reject(e, record=record)
......
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