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

Add the module check_tools.

More stringent tests in the validation procedure.
parent c96c5186
......@@ -4,6 +4,7 @@
import re
from check_tools import check_publication
from gluon.storage import Storage
from harvest_tools import DRY_RUN
from plugin_dbui import Selector
......@@ -16,7 +17,7 @@ MSG_NO_AUTHORS = "<br><br>Removing affiliation failed.<br>"\
def check_validate():
"""Check and validate records.
"""Check and validate publication records.
"""
logs = []
......@@ -50,58 +51,8 @@ def check_validate():
msg.title = row.publications.title
msg.year = row.publications.year
msg.txt = []
# publication to be checked
if row.status.code == '???':
text = T("Check record, the status is ???")
msg.txt.append(text)
continue
# authors list
if 'et al' in row.publications.authors:
text = T("'et al.' in authors")
msg.txt.append(text)
# submitted date
if not row.publications.submitted:
text = T("Submitted date is not defined")
msg.txt.append(text)
if not re.match('^\d{4}(-\d{2})?(-\d{2})?$', row.publications.submitted):
text = T("Submitted date is not valid")
msg.txt.append(text)
# check latex syntax
title = row.publications.title
if ("^" in title and not "$") or "√" in title:
text = T("Check latex syntax")
msg.txt.append(text)
# specific fields for article
if row.categories.usual == 'article':
pass
# specific fields for proceeding
elif row.categories.usual == 'proceeding':
if not row.publications.conference_speaker:
text = T("Conference speaker is missing")
msg.txt.append(text)
# specific fields for talk
elif row.categories.usual == 'report':
if not row.publications.report_numbers:
text = T("Report number is missing")
msg.txt.append(text)
# specific fields for report
elif row.categories.usual == 'talk':
if not row.publications.conference_speaker:
text = T("Conference speaker is missing")
msg.txt.append(text)
# check the record
msg.txt = check_publication(row)
# update publication status
if not msg.txt:
......
......@@ -65,7 +65,7 @@
'Chapter(s)': 'Chaptitre(s)',
'Check and validate': 'Vérifier et valider',
'check and validate': 'vérifier et valider',
'Check latex syntax': 'Vérifier la syntaxe latex',
'Check latex syntax in the title': 'Vérifier la syntaxe latex dans le titre',
'Check to delete': 'Check to delete',
'Click on the link %(link)s to verify your email': 'Click on the link %(link)s to verify your email',
'Click on the link http://localhost:8000/track_publications/default/user/reset_password/%(key)s to reset your password': 'Click on the link http://localhost:8000/track_publications/default/user/reset_password/%(key)s to reset your password',
......@@ -253,6 +253,7 @@
'Postprocessing': 'Postprocessing',
'Preprint': 'Preprint',
'Preprint identifier separated by comma: arXiv:0906.1516': 'Numéro(s) du preprint séparé par des virgules: arXiv:0906.1516',
'Preprint number is not defined': "Le preprint n'est pas défini",
'Preprints': 'Preprints',
'Proceedings': 'Actes de conférence',
'Process': 'Analyser',
......@@ -342,6 +343,8 @@
'String containing blabla and the database fields to be displayed. The substitution mechanism is: {tablename.fieldname} or {foreigntablename.fieldname}': 'String containing blabla and the database fields to be displayed. The substitution mechanism is: {tablename.fieldname} or {foreigntablename.fieldname}',
'String containing the author names with their institutes number.': 'Chaîne de caractère contenant le nom des auteurs avec le numéro de leurs instituts.',
'Submitted': 'Soumis',
'Submitted date is not defined': "La date de soumission n'est pas défini",
'Submitted date is not valid': "La date de soumission n'est pas valide",
'Substitute': 'Substitution',
'substitution mechanism: {tablename.fieldname} or {foreigntablename.fieldname}': 'régle de substitution : {tablename.fieldname} or {foreigntablename.fieldname}',
'table': 'table',
......@@ -359,6 +362,7 @@
'The name of the speaker: P.-Y. Smith': "Nom de l'orateur : P.-Y. Smith",
'The name of the web2py controller running the search: articles, proceedings,...': 'Nom du controller web2py qui effectut la recherche : articles, proceedings,...',
'The name of the web2py controller to run a search: articles, proceedings,...': 'The name of the web2py controller to run a search: articles, proceedings,...',
'The status is ???': 'Le status est "???"',
'The title of conference. Use the latex syntax for symbol: $\alpha$': 'The title of conference. Use the latex syntax for symbol: $\alpha$',
'The title of conference. Use the latex syntax for symbol: $\\alpha$': 'The title of conference. Use the latex syntax for symbol: $\\alpha$',
'The title of the publication. Use the latex syntax for symbol: $\alpha$': 'The title of the publication. Use the latex syntax for symbol: $\alpha$',
......
# -*- coding: utf-8 -*-
"""a collection of tools to check rows.
@author: R. Le Gac
"""
import re
from gluon import current
from plugin_dbui import UNDEF, UNDEF_ID
# syntax for the submission date YYYY or YYYY-MM or YYYY-MM-DD
REG_SUBMITTED = re.compile('^\d{4}(-\d{2})?(-\d{2})?$')
# HTML code like &gt;
REG_HTML = re.compile('&[a-z]+;')
def check_publication(row):
"""Check the fields of a publication.
@type row: gluon.dal.Row
@param row: record defineing a publication. Its contains the publications
table as well as its reference tables.
@rtype: list
@return: list of warnings
"""
T, li = current.T, []
# status code
if row.status.code == '???':
text = T("The status is ???")
li.append(text)
# category
if row.categories.code == UNDEF:
text = T("The category is undefined")
li.append(text)
# authors list
if 'et al' in row.publications.authors:
text = T("'et al.' in authors")
li.append(text)
# CPPM authors (team name, ...)
if row.teams.team in row.publications.authors_cppm:
text = T("The cppm authors contains the team name?")
li.append(text)
# submitted date
if not row.publications.submitted:
text = T("Submitted date is not defined")
li.append(text)
if row.publications.submitted:
if not REG_SUBMITTED.match(row.publications.submitted):
text = T("Submitted date is not valid")
li.append(text)
# latex syntax
title = row.publications.title
rules = "√" in title or \
("^" in title and "$" not in title) or \
("→" in title and "$" not in title) or \
REG_HTML.search(title)
if rules:
text = T("Check latex syntax in the title")
li.append(text)
# specific fields for article
if row.categories.usual == 'article':
if row.publications.id_publishers == UNDEF_ID:
text = T("Publishers is not defined")
li.append(text)
if not row.publications.volume:
text = T("Volume number is not defined")
li.append(text)
if not row.publications.pages:
text = T("Pages range is not defined")
li.append(text)
if not row.publications.preprint:
text = T("Preprint number is not defined")
li.append(text)
# specific fields for proceeding and talk
if row.categories.usual in ('proceeding', 'talk'):
if not row.publications.conference_title:
text = T("Conference title is not defined")
li.append(text)
if not row.publications.conference_dates:
text = T("Conference dates is not defined")
li.append(text)
if not row.publications.conference_town:
text = T("Conference town is not defined")
li.append(text)
if not row.publications.id_countries:
text = T("Conference country is not defined")
li.append(text)
if not row.publications.conference_speaker:
text = T("Conference speaker is missing")
li.append(text)
# specific fields for report
if row.categories.usual == 'report':
if not row.publications.report_numbers:
text = T("Report number is missing")
li.append(text)
return li
\ No newline at end of file
--------------------------------- CHANGELOG ----------------------------------
HEAD
- Migrate to plugin_dbui 0.4.13.1
- Add the module check_tools.
- More stringent tests in the validation procedure
0.8.2 (Apr 2013)
- Consolidation version.
......
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