Commit 344482e0 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

The class CheckAndFix used the function search_synonym.

parent 739e4103
...@@ -480,7 +480,9 @@ ...@@ -480,7 +480,9 @@
'Reject': 'Rejeter', 'Reject': 'Rejeter',
'Reject article is not published': "Rejeté l'article n'est pas publié", 'Reject article is not published': "Rejeté l'article n'est pas publié",
'Reject collaboration is not well formed': 'Rejeté la collaboration est mal formatté', 'Reject collaboration is not well formed': 'Rejeté la collaboration est mal formatté',
'Reject collaborations is not defined': "Rejeté la collaboration n'est pas définie",
'Reject conference dates is not well formed': 'Rejecté les dates de la conférence dates sont mal formatté', 'Reject conference dates is not well formed': 'Rejecté les dates de la conférence dates sont mal formatté',
'Reject countries is not defined': "Rejeté le pays n'est pas définie",
'Reject editor is not well formed': "Rejeté l'éditeur est mal formatté", 'Reject editor is not well formed': "Rejeté l'éditeur est mal formatté",
'Reject incomplete paper reference': 'Rejeté la référence du papier est incomplète', 'Reject incomplete paper reference': 'Rejeté la référence du papier est incomplète',
'Reject invalid country': 'Rejeté pays inconnu', 'Reject invalid country': 'Rejeté pays inconnu',
...@@ -502,11 +504,15 @@ ...@@ -502,11 +504,15 @@
'Reject preprint is a conference': 'Rejeté ce preprint est une conférence', 'Reject preprint is a conference': 'Rejeté ce preprint est une conférence',
'Reject preprint is a published paper': 'Rejeté ce preprint est un article publié', 'Reject preprint is a published paper': 'Rejeté ce preprint est un article publié',
'Reject preprint is a thesis': 'Rejeté ce preprint est une thèse', 'Reject preprint is a thesis': 'Rejeté ce preprint est une thèse',
'Reject publishers is not defined': "Rejeté la revue n'est pas définie",
'Reject submission date is not well formed': "Rejeté la date de soumission n'est pas correcte", 'Reject submission date is not well formed': "Rejeté la date de soumission n'est pas correcte",
'Reject the talk match a proceeding': 'Rejeté cette présentation correspond à un actes de conférence', 'Reject the talk match a proceeding': 'Rejeté cette présentation correspond à un actes de conférence',
'Reject to many first author': 'Rejeté trop de premier autheur', 'Reject to many first author': 'Rejeté trop de premier autheur',
'Reject to many submit date': 'Rejeté plusieurs date de soumission', 'Reject to many submit date': 'Rejeté plusieurs date de soumission',
'Reject to many year': 'Rejeté plusieurs année', 'Reject to many year': 'Rejeté plusieurs année',
'Reject too many collaborations synonyms': 'Rejeté synonyme de collaboration défini plusieurs fois',
'Reject too many countries synonyms': 'Rejeté synonyme de pays défini plusieurs fois',
'Reject too many publishers synonyms': 'Rejeté synonyme de revue défini plusieurs fois',
'Reject XML is not well formed': "Rejeté la chaine XML n'est pas correcte", 'Reject XML is not well formed': "Rejeté la chaine XML n'est pas correcte",
'Rejected': 'Rejeté', 'Rejected': 'Rejeté',
"Rejeté la chaine XML n'est pas correcte": "Rejeté la chaine XML n'est pas correcte", "Rejeté la chaine XML n'est pas correcte": "Rejeté la chaine XML n'est pas correcte",
......
...@@ -13,8 +13,8 @@ MSG_CRASH = "Crash: %s" ...@@ -13,8 +13,8 @@ MSG_CRASH = "Crash: %s"
MSG_FIX_ORIGIN = "Fixed the origin field" MSG_FIX_ORIGIN = "Fixed the origin field"
MSG_IN_DB = "Already in the database" MSG_IN_DB = "Already in the database"
MSG_LOAD = "Load in the database" MSG_LOAD = "Load in the database"
MSG_NO_ENTRY = "Reject %s is not defined." MSG_NO_ENTRY = "Reject %s is not defined"
MSG_TOOMANY_SYNONYM = "Reject too many %s synonyms." MSG_TOOMANY_SYNONYM = "Reject too many %s synonyms"
def family_name_fr(full_name): def family_name_fr(full_name):
......
...@@ -5,12 +5,10 @@ ...@@ -5,12 +5,10 @@
import re import re
import regex import regex
from base import search_synonym
from exception import CheckException from exception import CheckException
from invenio_tools import (load_record, from invenio_tools import (load_record,
MSG_NO_COUNTRY,
MSG_NO_CONF, MSG_NO_CONF,
MSG_NO_PUBLISHER,
MSG_WELL_FORMED_COLLABORATION,
MSG_NO_THESIS, MSG_NO_THESIS,
OAI_URL, OAI_URL,
RecordConf, RecordConf,
...@@ -358,21 +356,16 @@ class CheckAndFix(object): ...@@ -358,21 +356,16 @@ class CheckAndFix(object):
record (RecordPubli): record describing a publication. record (RecordPubli): record describing a publication.
Raises: Raises:
CheckException: when the collaboration value is not well formed ToolException: when the collaboration value is defined
and not entered as a synonym. nor entered as a synonym.
""" """
val = record.collaboration() val = record.collaboration()
if not val: if not val:
return return
if REG_COLLABORATION.match(val): db = self.db
return search_synonym(db.collaborations, "collaboration", val)
if self._is_synonym("collaborations", val):
return
raise CheckException(MSG_WELL_FORMED_COLLABORATION)
def country(self, record): def country(self, record):
"""Check conference country. """Check conference country.
...@@ -382,8 +375,8 @@ class CheckAndFix(object): ...@@ -382,8 +375,8 @@ class CheckAndFix(object):
record (RecordConf): record describing a talk or a proceeding. record (RecordConf): record describing a talk or a proceeding.
Raises: Raises:
CheckException: when the country is not defined ToolException: when the country is not defined
and not entered as a synonym. nor entered as a synonym.
""" """
if not isinstance(record, RecordConf): if not isinstance(record, RecordConf):
...@@ -391,15 +384,7 @@ class CheckAndFix(object): ...@@ -391,15 +384,7 @@ class CheckAndFix(object):
db = self.db db = self.db
val = record.conference_country() val = record.conference_country()
search_synonym(db.countries, "country", val)
id_country = get_id(db.countries, country=val)
if id_country:
return
if self._is_synonym("countries", val):
return
raise CheckException(MSG_NO_COUNTRY)
def conference_date(self, record): def conference_date(self, record):
"""Check conference date. """Check conference date.
...@@ -774,8 +759,8 @@ class CheckAndFix(object): ...@@ -774,8 +759,8 @@ class CheckAndFix(object):
record (RecordPubli): record describing a publication. record (RecordPubli): record describing a publication.
Raises: Raises:
CheckException: when the publisher is not defined ToolException: when the publisher is not defined
and not entered as a synonym. nor entered as a synonym.
""" """
db = self.db db = self.db
...@@ -787,14 +772,7 @@ class CheckAndFix(object): ...@@ -787,14 +772,7 @@ class CheckAndFix(object):
if isinstance(val, list): if isinstance(val, list):
val = val[0] val = val[0]
id_publisher = get_id(db.publishers, abbreviation=val) search_synonym(db.publishers, "abbreviation", val)
if id_publisher:
return
if self._is_synonym("publishers", val):
return
raise CheckException(MSG_NO_PUBLISHER)
def recover_oai(self, record, host): def recover_oai(self, record, host):
"""Recover the OAI identifier when it is not defined """Recover the OAI identifier when it is not defined
......
...@@ -5,12 +5,14 @@ ...@@ -5,12 +5,14 @@
import json import json
from base import MSG_NO_ENTRY, MSG_TOOMANY_SYNONYM
from gluon import current from gluon import current
from gluon.storage import Storage from gluon.storage import Storage
from invenio_tools import (MSG_NO_COUNTRY, from invenio_tools import OAI_URL
MSG_NO_PUBLISHER,
MSG_WELL_FORMED_COLLABORATION,
OAI_URL) MSGS = (MSG_NO_ENTRY, MSG_TOOMANY_SYNONYM)
TABLES = ("collaborations", "countries", "publishers")
class Msg(Storage): class Msg(Storage):
...@@ -117,13 +119,14 @@ class Msg(Storage): ...@@ -117,13 +119,14 @@ class Msg(Storage):
self.action = 'reject' self.action = 'reject'
if record is not None: if record is not None:
if str(txt) == MSG_NO_COUNTRY: for msg in MSGS:
self.synonym = record.country() for tablename in TABLES:
if str(txt) == msg % tablename:
elif str(txt) == MSG_WELL_FORMED_COLLABORATION: if tablename == "collaborations":
self.synonym = record.collaboration() self.synonym = record.collaboration()
elif tablename == "countries":
elif str(txt) == MSG_NO_PUBLISHER: self.synonym = record.country()
elif tablename == "publishers":
self.synonym = record.publisher() self.synonym = record.publisher()
if year is None and record is not None: if year is None and record is not None:
......
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