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

Rename the method Automaton.select_record as check_record.

parent f9bfd171
...@@ -16,7 +16,7 @@ MSG_TRANSFORM_PREPRINT = "Transform the preprint into an article" ...@@ -16,7 +16,7 @@ MSG_TRANSFORM_PREPRINT = "Transform the preprint into an article"
class Articles(Automaton): class Articles(Automaton):
"""Publications tool for articles. """Automaton for articles.
""" """
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
...@@ -170,6 +170,53 @@ class Articles(Automaton): ...@@ -170,6 +170,53 @@ class Articles(Automaton):
return (rec_id, 1) return (rec_id, 1)
def check_record(self, record):
"""Check the content of the article in order to fix non conformities.
@type record: L{Record}
@param record:
@rtype: bool
@return: C{False} when a non conformity is found and can not be
corrected.
"""
if not Automaton.check_record(self, record):
return False
if self.dbg:
print "select article record"
try:
self.check.clean_erratum(record)
if not record.is_published():
self.logs[-1].reject(MSG_NO_EDITOR, record.year())
return False
self.check.my_authors(record,
reference=self._my_author_list(record),
cmpFct=family_name_fr)
self.check.oai(record)
self.check.submitted(record)
self.check.year(record)
self.check.paper_reference(record)
self.check.format_editor(record)
except CheckException as e:
self.logs[-1].reject(e, record.year())
return False
except Exception as e:
self.logs[-1].reject(MSG_CRASH % e, record.year(), translate=False)
print traceback.format_exc()
return False
return True
def load_db(self, record): def load_db(self, record):
"""Load an article in the database. """Load an article in the database.
The method assume that erratum are removed. The method assume that erratum are removed.
...@@ -262,49 +309,3 @@ class Articles(Automaton): ...@@ -262,49 +309,3 @@ class Articles(Automaton):
self.logs[-1].load(MSG_LOAD, year) self.logs[-1].load(MSG_LOAD, year)
return 1 return 1
def select_record(self, record):
"""C{True} when the C{record} is published.
@type record: L{Record}
@param record:
@rtype: bool
"""
if not Automaton.select_record(self, record):
return False
if self.dbg:
print "select article record"
try:
self.check.clean_erratum(record)
if not record.is_published():
self.logs[-1].reject(MSG_NO_EDITOR, record.year())
return False
self.check.my_authors(record,
reference=self._my_author_list(record),
cmpFct=family_name_fr)
self.check.oai(record)
self.check.submitted(record)
self.check.year(record)
self.check.paper_reference(record)
self.check.format_editor(record)
except CheckException as e:
self.logs[-1].reject(e, record.year())
return False
except Exception as e:
self.logs[-1].reject(MSG_CRASH % e, record.year(), translate=False)
print traceback.format_exc()
return False
return True
...@@ -364,21 +364,28 @@ class Automaton(object): ...@@ -364,21 +364,28 @@ class Automaton(object):
return get_create_id(self.db.publishers, abbreviation=value) return get_create_id(self.db.publishers, abbreviation=value)
def select_record(self, record): def check_record(self, record):
"""C{True} when the C{record} is selected. """Check the content of the record in order to fix non conformities.
This method check and format the author field. Return False when a non conformities has been found and can not be
corrected.
@note: The checks depend on the type of publications and have to be @note: Some checks depend on the type of publications and have to be
implemented in inherited class. implemented in inherited class.
@note: The order of the checks matter. It should be oai,
temporary record, authors, my authors and then a series of checks
specific to the publication type.
@type record: L{Record} @type record: L{Record}
@param record: @param record:
@rtype: bool @rtype: bool
@return: C{False} when a non conformity is found and can not be
corrected.
""" """
if self.dbg: if self.dbg:
print "select record and check / format authors" print "check record"
try: try:
self.check.temporary_record(record) self.check.temporary_record(record)
...@@ -386,7 +393,7 @@ class Automaton(object): ...@@ -386,7 +393,7 @@ class Automaton(object):
self.check.format_authors(record, format_author_fr) self.check.format_authors(record, format_author_fr)
self.check.collaboration(record) self.check.collaboration(record)
except BaseException as e: except Exception as e:
self.logs[-1].reject(e, record.year()) self.logs[-1].reject(e, record.year())
return False return False
...@@ -557,10 +564,9 @@ class Automaton(object): ...@@ -557,10 +564,9 @@ class Automaton(object):
if not match: if not match:
self.logs[-1].reject(MSG_WELL_FORM_OAI, record.year()) self.logs[-1].reject(MSG_WELL_FORM_OAI, record.year())
# additional selection stage # check that the record is well formed
# at this step the validity of the record is checked # repair non-conformity as far as possible
# and non-conformities are repaired if not self.check_record(record):
if not self.select_record(record):
continue continue
if self.dbg: if self.dbg:
......
...@@ -12,9 +12,45 @@ from plugin_dbui import get_id, UNDEF_ID ...@@ -12,9 +12,45 @@ from plugin_dbui import get_id, UNDEF_ID
class Notes(Automaton): class Notes(Automaton):
"""Publications tool for notes. """Automaton for notes.
""" """
def check_record(self, record):
"""Check the content of the note in order to fix non conformities.
@type record: L{Record}
@param record:
@rtype: bool
@return: C{False} when a non conformity is found and can not be
corrected.
"""
if not Automaton.check_record(self, record):
return False
if self.dbg:
print "select note record"
try:
self.check.my_authors(record,
reference=self._my_author_list(record),
cmpFct=family_name_fr)
self.check.oai(record)
self.check.submitted(record)
self.check.year(record)
except CheckException as e:
self.logs[-1].reject(e, record.year())
return False
except Exception as e:
self.logs[-1].reject(MSG_CRASH % e, record.year(), translate=False)
print traceback.format_exc()
return False
return True
def load_db(self, record): def load_db(self, record):
"""Load a public note in the database. """Load a public note in the database.
...@@ -64,39 +100,3 @@ class Notes(Automaton): ...@@ -64,39 +100,3 @@ class Notes(Automaton):
self.logs[-1].load(MSG_LOAD, year) self.logs[-1].load(MSG_LOAD, year)
return 1 return 1
def select_record(self, record):
"""C{True} when the note is valid.
@type record: L{Record}
@param record:
@rtype: bool
"""
if not Automaton.select_record(self, record):
return False
if self.dbg:
print "select note record"
try:
self.check.my_authors(record,
reference=self._my_author_list(record),
cmpFct=family_name_fr)
self.check.oai(record)
self.check.submitted(record)
self.check.year(record)
except CheckException as e:
self.logs[-1].reject(e, record.year())
return False
except Exception as e:
self.logs[-1].reject(MSG_CRASH % e, record.year(), translate=False)
print traceback.format_exc()
return False
return True
...@@ -18,9 +18,61 @@ MSG_PREPRINT_NO_NUMBER = "Reject no preprint number" ...@@ -18,9 +18,61 @@ MSG_PREPRINT_NO_NUMBER = "Reject no preprint number"
class Preprints(Automaton): class Preprints(Automaton):
"""Publications tool for preprints. """Automaton for preprints.
""" """
def check_record(self, record):
"""Check the content of the preprint in order to fix non conformities.
@type record: L{Record}
@param record:
@rtype: bool
@return: C{False} when a non conformity is found and can not be
corrected.
"""
if not Automaton.check_record(self, record):
return False
if self.dbg:
print "select preprint record"
if record.is_published():
self.logs[-1].reject(MSG_PREPRINT_IS_PAPER, record.year())
return False
if isinstance(record, RecordConf):
self.logs[-1].reject(MSG_PREPRINT_IS_CONFERENCE, record.year())
return False
if isinstance(record, RecordThesis):
self.logs[-1].reject(MSG_PREPRINT_IS_THESIS, record.year())
return False
if not record.preprint_number():
self.logs[-1].reject(MSG_PREPRINT_NO_NUMBER, record.year())
return False
try:
self.check.my_authors(record,
reference=self._my_author_list(record),
cmpFct=family_name_fr)
self.check.oai(record)
self.check.submitted(record)
self.check.year(record)
except CheckException as e:
self.logs[-1].reject(e, record.year())
return False
except Exception as e:
self.logs[-1].reject(MSG_CRASH % e, record.year(), translate=False)
print traceback.format_exc()
return False
return True
def load_db(self, record): def load_db(self, record):
"""Load a preprint in the database. """Load a preprint in the database.
...@@ -78,52 +130,3 @@ class Preprints(Automaton): ...@@ -78,52 +130,3 @@ class Preprints(Automaton):
self.logs[-1].load(MSG_LOAD, year) self.logs[-1].load(MSG_LOAD, year)
return 1 return 1
def select_record(self, record):
"""C{True} when the preprint is valid.
@type record: L{Record}
@param record:
"""
if not Automaton.select_record(self, record):
return False
if self.dbg:
print "select preprint record"
if record.is_published():
self.logs[-1].reject(MSG_PREPRINT_IS_PAPER, record.year())
return False
if isinstance(record, RecordConf):
self.logs[-1].reject(MSG_PREPRINT_IS_CONFERENCE, record.year())
return False
if isinstance(record, RecordThesis):
self.logs[-1].reject(MSG_PREPRINT_IS_THESIS, record.year())
return False
if not record.preprint_number():
self.logs[-1].reject(MSG_PREPRINT_NO_NUMBER, record.year())
return False
try:
self.check.my_authors(record,
reference=self._my_author_list(record),
cmpFct=family_name_fr)
self.check.oai(record)
self.check.submitted(record)
self.check.year(record)
except CheckException as e:
self.logs[-1].reject(e, record.year())
return False
except Exception as e:
self.logs[-1].reject(MSG_CRASH % e, record.year(), translate=False)
print traceback.format_exc()
return False
return True
...@@ -12,9 +12,53 @@ from plugin_dbui import get_id, UNDEF_ID ...@@ -12,9 +12,53 @@ from plugin_dbui import get_id, UNDEF_ID
class Proceedings(Automaton): class Proceedings(Automaton):
"""Publications tool for conference proceedings. """Automaton for conference proceedings.
""" """
def check_record(self, record):
"""Check the content of the proceeding in order to fix non conformities.
@type record: L{Record}
@param record:
@rtype: bool
@return: C{False} when a non conformity is found and can not be
corrected.
"""
if not Automaton.check_record(self, record):
return False
if self.dbg:
print "select and check proceeding record"
try:
self.check.my_authors(record,
reference=self._my_author_list(record),
cmpFct=family_name_fr)
self.check.oai(record)
self.check.is_conference(record)
self.check.conference(record)
self.check.clean_erratum(record)
self.check.submitted(record)
self.check.year(record)
self.check.paper_reference(record)
self.check.format_editor(record)
except CheckException as e:
self.logs[-1].reject(e, record.year())
return False
except Exception as e:
self.logs[-1].reject(MSG_CRASH % e, record.year(), translate=False)
print traceback.format_exc()
return False
return True
def load_db(self, record): def load_db(self, record):
"""Load a conference proceeding in the database. """Load a conference proceeding in the database.
...@@ -108,45 +152,3 @@ class Proceedings(Automaton): ...@@ -108,45 +152,3 @@ class Proceedings(Automaton):
self.logs[-1].load(MSG_LOAD, year) self.logs[-1].load(MSG_LOAD, year)
return 1 return 1
def select_record(self, record):
"""C{True} when the C{record} is contains conference data.
@type record: L{Record}
@param record:
@rtype: bool
"""
if not Automaton.select_record(self, record):
return False
if self.dbg:
print "select and check proceeding record"
try:
self.check.my_authors(record,
reference=self._my_author_list(record),
cmpFct=family_name_fr)
self.check.oai(record)
self.check.is_conference(record)
self.check.conference(record)
self.check.clean_erratum(record)
self.check.submitted(record)
self.check.year(record)
self.check.paper_reference(record)
self.check.format_editor(record)
except CheckException as e:
self.logs[-1].reject(e, record.year())
return False
except Exception as e:
self.logs[-1].reject(MSG_CRASH % e, record.year(), translate=False)
print traceback.format_exc()
return False
return True
...@@ -15,9 +15,45 @@ MSG_REPORT_NO_NUMBER = "Reject no report number" ...@@ -15,9 +15,45 @@ MSG_REPORT_NO_NUMBER = "Reject no report number"
class Reports(Automaton): class Reports(Automaton):
"""Publications tool for reports to committee. """Automaton for reports to committee.
""" """
def check_record(self, record):
"""Check the content of the report in order to fix non conformities.
@type record: L{Record}
@param record:
@rtype: bool
@return: C{False} when a non conformity is found and can not be
corrected.
"""
if not Automaton.check_record(self, record):
return False
if self.dbg:
print "select report record"
if not record.report_number():
self.logs[-1].reject(MSG_REPORT_NO_NUMBER, record.year())
return False
try:
self.check.oai(record)
self.check.submitted(record)
self.check.year(record)
except CheckException as e:
self.logs[-1].reject(e, record.year())
return False
except Exception as e:
self.logs[-1].reject(MSG_CRASH % e, record.year(), translate=False)
print traceback.format_exc()
return False
return True
def load_db(self, record): def load_db(self, record):
"""Load a report in the database. """Load a report in the database.
...@@ -85,36 +121,3 @@ class Reports(Automaton): ...@@ -85,36 +121,3 @@ class Reports(Automaton):
self.logs[-1].load(MSG_LOAD, year) self.logs[-1].load(MSG_LOAD, year)
return 1 return 1
def select_record(self, record):
"""C{True} when the report is valid.
@type record: L{Record}
@param record:
"""
if not Automaton.select_record(self, record):
return False
if self.dbg:
print "select report record"
if not record.report_number():
self.logs[-1].reject(MSG_REPORT_NO_NUMBER, record.year())
return False
try:
self.check.oai(record)
self.check.submitted(record)
self.check.year(record)
except CheckException as e:
self.logs[-1].reject(e, record.year())
return False
except Exception as e:
self.logs[-1].reject(MSG_CRASH % e, record.year(), translate=False)
print traceback.format_exc()