Commit 6aff9622 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Merge branch 'master' into 'production'

Release 0.9.5.1

* fix a bug in `duplicate_conference`

See merge request !57
parents dcd0baef eeb0649d
......@@ -55,7 +55,7 @@ USER = 'user'
GIT = '/usr/bin/git'
JSDUCK = os.path.expandvars("$HOME/bin/jsduck")
PDFLATEX = '/usr/bin/pdflatex'
SENCHA = os.path.expandvars("$HOME/bin/sencha")
SENCHA = os.path.expandvars("$HOME/lib/Sencha/Cmd/latest/sencha")
SPHINX = '/usr/bin/sphinx-build'
MSG_RELEASE = 'Enter the new release: '
......
......@@ -131,11 +131,11 @@ def INHIBIT_DUPLICATE_PUBLICATION(publication):
"""
db, T = current.globalenv['db'], current.T
categories = db.categories
id_category = publication['id_categories']
# articles
id_cats = (get_id(db.categories, code='ACL'),
get_id(db.categories, code='ACLN'))
id_cats = (get_id(categories, code='ACL'), get_id(categories, code='ACLN'))
if id_category in id_cats:
ids = duplicate_article(publication)
......@@ -152,12 +152,12 @@ def INHIBIT_DUPLICATE_PUBLICATION(publication):
return True
# talks and proceedings
id_cats = (get_id(db.categories, code='ACTI'),
get_id(db.categories, code='ACTN'),
get_id(db.categories, code='COM'))
id_cats = (get_id(categories, code='ACTI'),
get_id(categories, code='ACTN'),
get_id(categories, code='COM'))
if id_category in id_cats:
ids = duplicate_conference(publication)
ids = duplicate_conference(publication, id_category != id_cats[2])
if ids:
db.publications[CALLBACK_ERRORS] = [
......@@ -171,7 +171,7 @@ def INHIBIT_DUPLICATE_PUBLICATION(publication):
return True
# reports
id_cats = (get_id(db.categories, code='AP'),)
id_cats = (get_id(categories, code='AP'),)
if id_category in id_cats:
ids = duplicate_report(publication)
......
......@@ -23,7 +23,7 @@ def check_publication(row):
Args:
row (gluon.dal.Row): record defining a publication.
Its contains the publications table as well as its foreign tables.
Its contains the publication table as well as its foreign tables.
Returns:
tuple:
......@@ -33,55 +33,62 @@ def check_publication(row):
"""
T, li, idset = current.T, [], set()
categories = row.categories
category_code = categories.code
category_usual = categories.usual
publication = row.publications
# status code
if row.status.code == '???':
text = T("The status is ???")
li.append(text)
# category
if row.categories.code == UNDEF:
if category_code == UNDEF:
text = T("The category is undefined")
li.append(text)
# team
if row.publications.id_teams == UNDEF_ID:
if publication.id_teams == UNDEF_ID:
text = T("The team is undefined")
li.append(text)
# project
if row.publications.id_projects == UNDEF_ID:
if publication.id_projects == UNDEF_ID:
text = T("The project is undefined")
li.append(text)
# authors list
if 'et al' in row.publications.authors:
if 'et al' in publication.authors:
text = T("'et al.' in authors")
li.append(text)
# CPPM authors (team name, ...)
if row.teams.team in row.publications.authors_institute:
if row.teams.team in publication.authors_institute:
text = T("The institute authors contains the team name?")
li.append(text)
# submitted date
if not row.publications.submitted:
submitted = publication.submitted
if not submitted:
text = T("Submitted date is not defined")
li.append(text)
if row.publications.submitted:
if not REG_SUBMITTED.match(row.publications.submitted):
if submitted:
if not REG_SUBMITTED.match(submitted):
text = T("Submitted date is not valid")
li.append(text)
# publication URL
if row.publications.publication_url:
if 'pdf' not in row.publications.publication_url:
publication_url = publication.publication_url
if publication_url:
if 'pdf' not in publication_url:
text = \
T("Check that the publication URL corresponds to a pdf file.")
li.append(text)
# latex syntax
title = row.publications.title
title = publication.title
rules = "√" in title or \
("^" in title and "$" not in title) or \
("→" in title and "$" not in title) or \
......@@ -94,7 +101,7 @@ def check_publication(row):
li.append(text)
# "Note :" in report number
value = row.publications.report_numbers
value = publication.report_numbers
rules = "Note :" in value or \
"Note:" in value or \
";" in value
......@@ -104,81 +111,82 @@ def check_publication(row):
li.append(text)
# duplicate by origin
ids = duplicate_origin(row.publications)
ids = duplicate_origin(publication)
if len(ids):
idset = idset.union(ids)
text = T("Entries with duplicate origin")
li.append(text)
# specific fields for article
if row.categories.code in ('ACL', 'ACLN'):
if category_code in ('ACL', 'ACLN'):
if row.publications.id_publishers == UNDEF_ID:
if publication.id_publishers == UNDEF_ID:
text = T("Publishers is not defined")
li.append(text)
if not row.publications.volume:
if not publication.volume:
text = T("Volume number is not defined")
li.append(text)
if not row.publications.pages:
if not publication.pages:
text = T("Pages range is not defined")
li.append(text)
if not row.publications.preprint:
if not publication.preprint:
text = T("Preprint number is not defined")
li.append(text)
ids = duplicate_article(row.publications)
ids = duplicate_article(publication)
if ids:
idset = idset.union(ids)
text = T("Possible duplicate entries")
li.append(text)
# specific fields for preprint
if row.categories.code == 'PRE':
if category_code == 'PRE':
if not row.publications.preprint:
if not publication.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 category_usual in ('proceeding', 'talk'):
if not row.publications.conference_title:
if not publication.conference_title:
text = T("Conference title is not defined")
li.append(text)
if not row.publications.conference_dates:
if not publication.conference_dates:
text = T("Conference dates is not defined")
li.append(text)
if not row.publications.conference_town:
if not publication.conference_town:
text = T("Conference town is not defined")
li.append(text)
if not row.publications.id_countries:
if not publication.id_countries:
text = T("Conference country is not defined")
li.append(text)
if not row.publications.conference_speaker:
if not publication.conference_speaker:
text = T("Conference speaker is missing")
li.append(text)
ids = duplicate_conference(row.publications)
ids = duplicate_conference(publication,
category_usual == 'proceeding')
if ids:
idset = idset.union(ids)
text = T("Possible duplicate entries")
li.append(text)
# specific fields for report
if row.categories.usual == 'report':
if category_usual == 'report':
if not row.publications.report_numbers:
if not publication.report_numbers:
text = T("Report number is missing")
li.append(text)
ids = duplicate_report(row.publications)
ids = duplicate_report(publication)
if ids:
idset = idset.union(ids)
text = T("Possible duplicate entries")
......@@ -261,7 +269,7 @@ def duplicate_article(publication):
return ids
def duplicate_conference(publication):
def duplicate_conference(publication, proceeding=False):
"""Look for duplicate talk / proceeding.
The comparison is performed on conference talk/proceeding published
......@@ -274,6 +282,7 @@ def duplicate_conference(publication):
Args:
publication (dict or gluon.storage.Storage): contains the publication
fields and theirs values.
proceeding (bool): tag the publication either as talk or a proceeding.
Returns:
list: list of *ids* corresponding to duplicate entries.
......@@ -285,36 +294,34 @@ def duplicate_conference(publication):
categories = db.categories
publications = db.publications
qcat = (categories.code == 'ACTI') | \
(categories.code == 'ACTN') | \
(categories.code == 'COM')
if proceeding:
qcat = (categories.code == 'ACTI') | (categories.code == 'ACTN')
else:
qcat = categories.code == 'COM'
qmain = get_where_query(publications)
qmain = ((qmain) & (qcat))
qmain = ((qmain) & (publications.id_teams == publication['id_teams']))
qmain = ((qmain) & (publications.title == publication['title']))
qmain &= qcat
qmain &= publications.id_teams == publication['id_teams']
qmain &= publications.title == publication['title']
if 'id' in publication and publication['id']:
qmain = ((qmain) & (publications.id != publication['id']))
qmain &= publications.id != publication['id']
# title, conference title, conference date and conference town
qtitle = publications.conference_title == publication['conference_title']
qdates = publications.conference_dates == publication['conference_dates']
qtown = publications.conference_town == publication['conference_town']
query = ((qmain) & (qtitle))
query = ((query) & (qdates))
query = ((query) & (qtown))
query = ((qmain) & (qtitle) & (qdates) & (qtown))
extend_ids(db, query, ids)
# title, conference date and conference town
query = ((query) & (qdates))
query = ((query) & (qtown))
query = ((qmain) & (qdates) & (qtown))
extend_ids(db, query, ids)
# title, conference title and conference town
query = ((qmain) & (qtitle))
query = ((query) & (qtown))
query = ((qmain) & (qtitle) & (qtown))
extend_ids(db, query, ids)
return ids
......
# -*- coding: utf-8 -*-
""" NAME
fix_acti2com_cppm
SYNOPSIS
Copy ACTI to COM for the CPPM database.
DESCRIPTION
Up to the end of 2014 a talk to a conference (COM) is transformed
into a proceeding (ACTI) when the later is published.
In 2015, the policy changes, COM and ACTI are kept as separated
publications
This script implement the new policy for the publications registered
before 2015. It mainly copy the ACTI into COM for the year from
2009 up to 2014.
OPTIONS
-h, --help
Display the help and exit.
EXAMPLE
> cd ...track_publications/scripts
> ./run -S test_publications script fix_acti2com_cppm.py
> ./run -S track_publications script fix_acti2com_cppm.py
AUTHOR
R. Le Gac -- Jan 2016
"""
import re
REG_ORIGIN = re.compile("https?://([a-z\.]+)/record/(\d+)")
if __name__ == "__main__":
import sys
from argparse import ArgumentParser, FileType
from invenio_tools import load_record, OAI_URL
from plugin_dbui import CALLBACK_ERRORS, get_id
# command line options
parser = ArgumentParser()
args = parser.parse_args()
# get the ACTI / COM identifier
id_acti = get_id(db.categories, code="ACTI")
id_com = get_id(db.categories, code="COM")
# build the query
query = db.publications.id_categories == id_acti
query &= db.publications.year >= 2009
query &= db.publications.year <= 2014
# scan the publications table
for row in db(query).select():
data = row.as_dict()
# skip if the the speaker is not from CPPM
if data["conference_speaker"] not in data["authors_institute"]:
continue
# remove publisher information
data["id_publishers"] = 1
data["pages"] = ""
data["volume"] = ""
data["submitted"] = ""
data["publication_url"] = ""
data["preprint"] = ""
# the year is the one of the conference
conference_dates = data["conference_dates"]
if conference_dates:
data["year"] = int(data["conference_dates"][-4:])
else:
print "No conferences dates", data["id"]
# change the category and the status
data["id_categories"] = id_com
data["id_status"] = 1
# change the origin
val = data["origin"]
if val:
origin = val.split(',')[0].strip()
match = REG_ORIGIN.match(origin)
host, rec_id = match.group(1), match.group(2)
proceeding = load_record(host, rec_id)
talk_id = proceeding.reference_conference_talk()
data["origin"] = (OAI_URL % (host, talk_id) if talk_id else "")
# insert the new record in the database
id_rec = data["id"],
del data["id"]
id_new = db.publications.insert(**data)
print "Copy", id_rec, "→",
if id_new:
print id_new
elif CALLBACK_ERRORS in db.publications:
print " ".join(db.publications._callback_errors)
else:
print "???"
# commit change
rep = raw_input("Commit change in the database? [y/N]:")
if rep == 'y':
print "The database is modified."
db.commit()
# close
sys.exit(0)
......@@ -2,6 +2,9 @@
HEAD
0.9.5.1 (Jan 2016)
- Fix a bug in the function duplicate_conference.
0.9.5 (Dec 2015)
- Require plugin_dbui 0.8.1 and libreoffice.
- Few modifications to be compliant with the navigator Chrome.
......
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