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

Code cleaning.

parent be39ed6d
......@@ -259,26 +259,31 @@ class Articles(Automaton):
# The latter is useful to cover the case where the record
# is entered by hand or by another harvester.
#
rec_id, status = self.get_record_by_origin(id_publisher=id_publisher,
my_authors=my_authors,
oai_url=oai_url,
pages=pages,
publication_url=publication_url,
title=title,
volume=volume,
year=year)
fields = dict(id_publisher=id_publisher,
my_authors=my_authors,
oai_url=oai_url,
pages=pages,
publication_url=publication_url,
title=title,
volume=volume,
year=year)
rec_id, status = self.get_record_by_origin(**fields)
if rec_id:
return status
rec_id, status = self.get_record_by_fields(id_publisher=id_publisher,
my_authors=my_authors,
oai_url=oai_url,
pages=pages,
publication_url=publication_url,
preprint_number=preprint_number,
title=title,
volume=volume,
year=year)
fields = dict(id_publisher=id_publisher,
my_authors=my_authors,
oai_url=oai_url,
pages=pages,
publication_url=publication_url,
preprint_number=preprint_number,
title=title,
volume=volume,
year=year)
rec_id, status = self.get_record_by_fields(**fields)
if rec_id:
return status
......@@ -287,25 +292,25 @@ class Articles(Automaton):
ret = 1
if not self.dry_run:
ret = self._insert_in_db(log_year=year,
authors=record.authors(),
authors_institute=my_authors,
first_author=first_author,
id_categories=self.id_category,
id_collaborations=id_collaboration,
id_projects=self.id_project,
id_publishers=id_publisher,
id_status=UNDEF_ID,
id_teams=self.id_team,
origin=oai_url,
pages=pages,
preprint=preprint_number,
publication_url=publication_url,
submitted=submitted,
title=title,
volume=volume,
year=year)
fields = dict(authors=record.authors(),
authors_institute=my_authors,
first_author=first_author,
id_categories=self.id_category,
id_collaborations=id_collaboration,
id_projects=self.id_project,
id_publishers=id_publisher,
id_status=UNDEF_ID,
id_teams=self.id_team,
origin=oai_url,
pages=pages,
preprint=preprint_number,
publication_url=publication_url,
submitted=submitted,
title=title,
volume=volume,
year=year)
ret = self._insert_in_db(log_year=year, **fields)
if ret == 1:
learn_my_authors(db,
authors=record.my_authors,
......
......@@ -256,7 +256,7 @@ class Automaton(object):
so='d') # descending order
return dic
def check_record(self, record, cmpFct=None):
def check_record(self, record):
"""Check the content of the record in order to fix non conformities.
Return False when a non conformities has been found and can not be
corrected.
......
......@@ -8,7 +8,7 @@ import traceback
from automaton import Automaton
from base import family_name_fr, MSG_CRASH, MSG_LOAD
from invenio_tools import CheckException
from plugin_dbui import get_id, UNDEF_ID
from plugin_dbui import UNDEF_ID
class Notes(Automaton):
......@@ -72,33 +72,36 @@ class Notes(Automaton):
year = record.year()
# get existing notes
rec_id, status = self.get_record_by_fields(first_author=first_author,
id_categories=self.id_category,
id_projects=self.id_project,
id_teams=self.id_team,
oai_url=oai_url,
title=title,
year=year)
fields = dict(first_author=first_author,
id_categories=self.id_category,
id_projects=self.id_project,
id_teams=self.id_team,
oai_url=oai_url,
title=title,
year=year)
rec_id, status = self.get_record_by_fields(**fields)
if rec_id:
return status
# eventually insert a new report
ret = 1
if not self.dry_run:
ret = self._insert_in_db(log_year=year,
authors=record.authors(),
authors_institute=record.my_authors,
first_author=first_author,
id_categories=self.id_category,
id_projects=self.id_project,
id_status=UNDEF_ID,
id_teams=self.id_team,
origin=oai_url,
publication_url=record.paper_url(),
report_numbers=record.report_number(),
submitted=record.submitted()[0],
title=title,
year=year)
fields = dict(authors=record.authors(),
authors_institute=record.my_authors,
first_author=first_author,
id_categories=self.id_category,
id_projects=self.id_project,
id_status=UNDEF_ID,
id_teams=self.id_team,
origin=oai_url,
publication_url=record.paper_url(),
report_numbers=record.report_number(),
submitted=record.submitted()[0],
title=title,
year=year)
ret = self._insert_in_db(log_year=year, **fields)
if ret == 1:
self.logs[-1].load(MSG_LOAD, year)
......
......@@ -85,8 +85,6 @@ class Preprints(Automaton):
zero otherwise.
"""
db = self.db
# alias
first_author = record.first_author()
oai_url = record.oai_url()
......@@ -99,35 +97,38 @@ class Preprints(Automaton):
id_collaboration = self.get_create_collaboration(record.collaboration())
# get existing preprint or article
rec_id, status = self.get_record_by_fields(first_author=first_author,
id_projects=self.id_project,
id_teams=self.id_team,
oai_url=oai_url,
preprint=preprint,
submitted=submitted,
title=title,
year=year)
fields = dict(first_author=first_author,
id_projects=self.id_project,
id_teams=self.id_team,
oai_url=oai_url,
preprint=preprint,
submitted=submitted,
title=title,
year=year)
rec_id, status = self.get_record_by_fields(**fields)
if rec_id:
return status
# eventually insert a new preprint
ret = 1
if not self.dry_run:
ret = self._insert_in_db(log_year=year,
authors=record.authors(),
authors_institute=record.my_authors,
first_author=first_author,
id_categories=self.id_category,
id_collaborations=id_collaboration,
id_projects=self.id_project,
id_status=UNDEF_ID,
id_teams=self.id_team,
origin=oai_url,
preprint=preprint,
publication_url=record.paper_url(),
submitted=submitted,
title=title,
year=year)
fields = dict(authors=record.authors(),
authors_institute=record.my_authors,
first_author=first_author,
id_categories=self.id_category,
id_collaborations=id_collaboration,
id_projects=self.id_project,
id_status=UNDEF_ID,
id_teams=self.id_team,
origin=oai_url,
preprint=preprint,
publication_url=record.paper_url(),
submitted=submitted,
title=title,
year=year)
ret = self._insert_in_db(log_year=year, **fields)
if ret == 1:
self.logs[-1].load(MSG_LOAD, year)
......
......@@ -102,19 +102,21 @@ class Proceedings(Automaton):
id_publisher = self.get_create_publisher(editor)
# get an already published proceeding
rec_id, status = self.get_record_by_fields(authors=authors,
conference_title=conference_title,
first_author=first_author,
id_publishers=id_publisher,
oai_url=oai_url,
preprint=preprint,
pages=pages,
publication_url=url,
report_numbers=report_numbers,
submitted=submitted,
volume=volume,
title=title,
year=year)
fields = dict(authors=authors,
conference_title=conference_title,
first_author=first_author,
id_publishers=id_publisher,
oai_url=oai_url,
preprint=preprint,
pages=pages,
publication_url=url,
report_numbers=report_numbers,
submitted=submitted,
volume=volume,
title=title,
year=year)
rec_id, status = self.get_record_by_fields(**fields)
if rec_id:
return status
......@@ -122,32 +124,32 @@ class Proceedings(Automaton):
ret = 1
if not self.dry_run:
dic = dict(authors=authors,
authors_institute=record.my_authors,
conference_dates=conference_dates,
conference_speaker=first_author,
conference_title=conference_title,
conference_town=record.conference_town(),
conference_url=record.conference_url(),
first_author=first_author,
id_categories=self.id_category,
id_collaborations=id_collaboration,
id_countries=id_country,
id_projects=self.id_project,
id_publishers=id_publisher,
id_status=UNDEF_ID,
id_teams=self.id_team,
origin=oai_url,
pages=pages,
preprint=preprint,
publication_url=url,
report_numbers=report_numbers,
submitted=submitted,
title=title,
volume=volume,
year=year)
ret = self._insert_in_db(log_year=year, **di)
fields = dict(authors=authors,
authors_institute=record.my_authors,
conference_dates=conference_dates,
conference_speaker=first_author,
conference_title=conference_title,
conference_town=record.conference_town(),
conference_url=record.conference_url(),
first_author=first_author,
id_categories=self.id_category,
id_collaborations=id_collaboration,
id_countries=id_country,
id_projects=self.id_project,
id_publishers=id_publisher,
id_status=UNDEF_ID,
id_teams=self.id_team,
origin=oai_url,
pages=pages,
preprint=preprint,
publication_url=url,
report_numbers=report_numbers,
submitted=submitted,
title=title,
volume=volume,
year=year)
ret = self._insert_in_db(log_year=year, **fields)
if ret == 1:
self.logs[-1].load(MSG_LOAD, year)
......
......@@ -91,35 +91,37 @@ class Reports(Automaton):
id_collaboration = self.get_create_collaboration(record.collaboration())
# get an already published reports
rec_id, status = self.get_record_by_fields(id_categories=self.id_category,
id_projects=self.id_project,
id_teams=self.id_team,
oai_url=oai_url,
title=title,
year=year)
fields = dict(id_categories=self.id_category,
id_projects=self.id_project,
id_teams=self.id_team,
oai_url=oai_url,
title=title,
year=year)
rec_id, status = self.get_record_by_fields(**fields)
if rec_id:
return status
# eventually insert a new report
ret = 1
if not self.dry_run:
ret = self._insert_in_db(log_year=year,
authors=authors,
authors_institute=authors_institute,
first_author=first_author,
id_categories=self.id_category,
id_collaborations=id_collaboration,
id_projects=self.id_project,
id_status=id_status,
id_teams=self.id_team,
origin=oai_url,
preprint=record.preprint_number(),
publication_url=record.paper_url(),
report_numbers=record.report_number(),
submitted=record.submitted()[0],
title=title,
year=year)
fields = dict(authors=authors,
authors_institute=authors_institute,
first_author=first_author,
id_categories=self.id_category,
id_collaborations=id_collaboration,
id_projects=self.id_project,
id_status=id_status,
id_teams=self.id_team,
origin=oai_url,
preprint=record.preprint_number(),
publication_url=record.paper_url(),
report_numbers=record.report_number(),
submitted=record.submitted()[0],
title=title,
year=year)
ret = self._insert_in_db(log_year=year, **fields)
if ret == 1:
self.logs[-1].load(MSG_LOAD, year)
......
......@@ -84,37 +84,40 @@ class Talks(Automaton):
id_collaboration = self.get_create_collaboration(record.collaboration())
# get an already published talk
rec_id, status = self.get_record_by_fields(conference_title=conference_title,
first_author=first_author,
oai_url=oai_url,
title=title,
year=year)
fields = dict(conference_title=conference_title,
first_author=first_author,
oai_url=oai_url,
title=title,
year=year)
rec_id, status = self.get_record_by_fields(**fields)
if rec_id:
return status
# eventually insert a new talk
ret = 1
if not self.dry_run:
ret = self._insert_in_db(log_year=year,
authors=record.authors(),
authors_institute=record.my_authors,
conference_dates=conference_dates,
conference_speaker=first_author,
conference_title=conference_title,
conference_town=record.conference_town(),
conference_url=record.conference_url(),
first_author=first_author,
id_categories=self.id_category,
id_collaborations=id_collaboration,
id_countries=id_country,
id_projects=self.id_project,
id_status=UNDEF_ID,
id_teams=self.id_team,
origin=oai_url,
submitted=submitted,
title=title,
year=year)
fields = dict(authors=record.authors(),
authors_institute=record.my_authors,
conference_dates=conference_dates,
conference_speaker=first_author,
conference_title=conference_title,
conference_town=record.conference_town(),
conference_url=record.conference_url(),
first_author=first_author,
id_categories=self.id_category,
id_collaborations=id_collaboration,
id_countries=id_country,
id_projects=self.id_project,
id_status=UNDEF_ID,
id_teams=self.id_team,
origin=oai_url,
submitted=submitted,
title=title,
year=year)
ret = self._insert_in_db(log_year=year, **fields)
if ret == 1:
self.logs[-1].load(MSG_LOAD, year)
......
......@@ -88,21 +88,22 @@ class Thesis(Automaton):
year = re.search(r"(\d\d\d\d)", defense_date).group(1)
# get an already published thesis
rec_id, status = self.get_record_by_fields(first_author=first_author,
defense=defense_date,
id_projects=self.id_project,
id_teams=self.id_team,
oai_url=oai_url,
title=title,
year=year)
fields = dict(first_author=first_author,
defense=defense_date,
id_projects=self.id_project,
id_teams=self.id_team,
oai_url=oai_url,
title=title,
year=year)
rec_id, status = self.get_record_by_fields(**fields)
if rec_id:
return status
# eventually insert a new thesis
ret = 1
if not self.dry_run:
ret = self._insert_in_db(log_year=year,
authors=first_author,
fields = dict(authors=first_author,
authors_institute=first_author,
defense=defense_date,
directors=record.these_directors(),
......@@ -118,6 +119,8 @@ class Thesis(Automaton):
universities=universities,
year=year)
ret = self._insert_in_db(log_year=year, **fields)
if ret == 1:
self.logs[-1].load(MSG_LOAD, year)
return 1
......
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