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

Rename Record and friends as RecordCds

parent bcab4702
......@@ -21,8 +21,8 @@ from plugin_dbui import (inline_alert,
from requests.exceptions import RequestException
from store_tools import (load_record,
OAI_URL,
RecordConf,
RecordThesis)
RecordCdsConf,
RecordCdsThesis)
MODE_DRY_RUN = T(DRY_RUN)
MSG_GREMLIN = "Oops a gremlin..."
......@@ -267,7 +267,7 @@ def edit_insert():
logger.debug(str(e))
pass
if isinstance(record, RecordConf):
if isinstance(record, RecordCdsConf):
values["PublicationsConference_title"] = \
record.conference_title()
......@@ -301,7 +301,7 @@ def edit_insert():
#
if selector.controller == "theses":
if isinstance(record, RecordThesis):
if isinstance(record, RecordCdsThesis):
values["PublicationsUniversities"] = \
record.these_universities()
......
......@@ -12,13 +12,13 @@ from gluon import current
from store_tools import (MSG_NO_CONF,
MSG_NO_THESIS,
OAI_URL,
Record,
RecordConf,
RecordCds,
RecordCdsConf,
RecordHep,
RecordHepConf,
RecordHepThesis,
RecordPubli,
RecordThesis,
RecordCdsPubli,
RecordCdsThesis,
REG_OAI,
REG_YEAR)
......@@ -103,7 +103,7 @@ class CheckAndFix(object):
"""Return the opening and closing dates of a conference.
Args:
record (RecordConf):
record (RecordCdsConf):
record describing a conference proceeding or talk.
Returns:
......@@ -210,7 +210,7 @@ class CheckAndFix(object):
"""Get the rescue list for my authors.
Args:
record (RecordPubli):
record (RecordCdsPubli):
record describing a publication.
id_project (int):
......@@ -306,7 +306,7 @@ class CheckAndFix(object):
information.
Args:
record (RecordPubli):
record (RecordCdsPubli):
record describing a publication.
Returns:
......@@ -316,7 +316,7 @@ class CheckAndFix(object):
"""
val = ""
if isinstance(record, RecordConf):
if isinstance(record, RecordCdsConf):
opening = self._get_conference_dates(record)[0]
val = opening.strftime("%Y-%m-%d")
......@@ -327,7 +327,7 @@ class CheckAndFix(object):
if opening is not None:
val = opening.strftime("%Y-%m-%d")
elif isinstance(record, (RecordHepThesis, RecordThesis)):
elif isinstance(record, (RecordHepThesis, RecordCdsThesis)):
val = record.these_defense()
# try with a preprint number
......@@ -340,7 +340,7 @@ class CheckAndFix(object):
# last change use the creation date for the record
if val == "" or len(val) < 7:
if isinstance(record, (RecordConf, RecordPubli, RecordThesis)):
if isinstance(record, (RecordCdsConf, RecordCdsPubli, RecordCdsThesis)):
val = record["creation_date"][0:7]
else:
......@@ -355,7 +355,7 @@ class CheckAndFix(object):
* first author is not like ATLAS Collaboration
Args:
record (RecordPubli):
record (RecordCdsPubli):
record describing a publication.
Raises:
......@@ -375,7 +375,7 @@ class CheckAndFix(object):
"""Check synonyms for collaboration by using by the proper value.
Args:
record (RecordPubli):
record (RecordCdsPubli):
record describing a publication.
Raises:
......@@ -424,7 +424,7 @@ class CheckAndFix(object):
"""Check synonyms for conference country by using by the proper value.
Args:
record (RecordPubli):
record (RecordCdsPubli):
record describing a publication.
Raises:
......@@ -435,7 +435,7 @@ class CheckAndFix(object):
"""
self.logger.debug(f"{T6}check country")
if not isinstance(record, RecordConf):
if not isinstance(record, RecordCdsConf):
return
val = record.conference_country()
......@@ -473,7 +473,7 @@ class CheckAndFix(object):
"""Check conference date exists and well formatted.
Args:
record (RecordConf):
record (RecordCdsConf):
record describing a talk or a proceeding.
Raises:
......@@ -484,7 +484,7 @@ class CheckAndFix(object):
self.logger.debug(f"{T6}check conference date")
# conference information are available, i.e proceeding
if not isinstance(record, RecordConf):
if not isinstance(record, RecordCdsConf):
return
val = record.conference_dates()
......@@ -523,7 +523,7 @@ class CheckAndFix(object):
to new one.
Args:
record (RecordPubli):
record (RecordCdsPubli):
record describing a publication.
Returns:
......@@ -554,7 +554,7 @@ class CheckAndFix(object):
make sense only for record from cds.cern.ch or old.inspirehep.net
Args:
record (RecordPubli): record describing a publication.
record (RecordCdsPubli): record describing a publication.
Returns:
bool:
......@@ -576,7 +576,7 @@ class CheckAndFix(object):
"""Format the author names.
Args:
record (RecordPubli):
record (RecordCdsPubli):
record describing a publication.
fmt (str):
......@@ -599,7 +599,7 @@ class CheckAndFix(object):
Standardise the answer as ``Phys. Lett. B``.
Args:
record (RecordPubli):
record (RecordCdsPubli):
record describing a publication.
Raises:
......@@ -638,14 +638,14 @@ class CheckAndFix(object):
* Replace U. by University
Args:
record (RecordThesis):
record (RecordCdsThesis):
record describing a thesis.
"""
self.logger.debug(f"{T6}format university")
# protection
if not isinstance(record, RecordThesis):
if not isinstance(record, RecordCdsThesis):
return
values = record["dissertation_note"]["university"]
......@@ -683,11 +683,11 @@ class CheckAndFix(object):
def get_my_authors(self, record, sep=", ", sort=False):
"""Get authors of my institutes signing the record.
The information is append to the Record object via the attribute
The information is append to the RecordCds object via the attribute
``my_authors``.
Args:
record (RecordPubli):
record (RecordCdsPubli):
record describing a publication.
sep (str):
......@@ -729,7 +729,7 @@ class CheckAndFix(object):
"""Check that the record contains conference data.
Args:
record (RecordPubli):
record (RecordCdsPubli):
record describing a publication.
Raises:
......@@ -739,7 +739,7 @@ class CheckAndFix(object):
"""
self.logger.debug(f"{T6}is conference")
if isinstance(record, RecordConf):
if isinstance(record, RecordCdsConf):
if "meeting_name" in record:
return
......@@ -753,7 +753,7 @@ class CheckAndFix(object):
"""Check that the record described a thesis.
Args:
record (RecordPubli):
record (RecordCdsPubli):
record describing a publication.
Raises:
......@@ -763,7 +763,7 @@ class CheckAndFix(object):
"""
self.logger.debug(f"{T6}is thesis")
if not isinstance(record, RecordThesis):
if not isinstance(record, RecordCdsThesis):
raise CheckException(MSG_NO_THESIS)
def my_affiliation(
......@@ -779,7 +779,7 @@ class CheckAndFix(object):
It is based on the author rescue list stored in the database.
Args:
record (RecordPubli):
record (RecordCdsPubli):
record describing a publication.
id_project (int):
......@@ -851,7 +851,7 @@ class CheckAndFix(object):
for a published paper. Repair it from doi when possible.
Args:
record (RecordPubli):
record (RecordCdsPubli):
record describing a publication.
Raises:
......@@ -911,7 +911,7 @@ class CheckAndFix(object):
"""Check synonyms for publisher by replacing by the abbreviation value.
Args:
record (RecordPubli):
record (RecordCdsPubli):
record describing a publication.
Raises:
......@@ -950,7 +950,7 @@ class CheckAndFix(object):
After this check the year submitted contains one entry.
Args:
record (RecordPubli):
record (RecordCdsPubli):
record describing a publication.
Raises:
......@@ -986,7 +986,7 @@ class CheckAndFix(object):
date = '%s-%02i-%02i' % data
# update
if isinstance(record, Record):
if isinstance(record, RecordCds):
# in some case we have to deal with a list (see cds 2234042)
# in some case it is not defined (e.g. phd thesis)
if "prepublication" in record:
......@@ -1011,7 +1011,7 @@ class CheckAndFix(object):
since this information is not there anymore.
Args:
record (RecordPubli):
record (RecordCdsPubli):
record describing a publication.
Raises:
......
......@@ -5,7 +5,7 @@ from .automaton import Automaton
from .base import MSG_CRASH, MSG_LOAD
from .checkandfix import CheckException
from plugin_dbui import get_id, UNDEF_ID
from store_tools import RecordConf, RecordThesis
from store_tools import RecordCdsConf, RecordCdsThesis
MSG_PREPRINT_IS_PAPER = "Reject preprint is a published paper"
MSG_PREPRINT_IS_CONFERENCE = "Reject preprint is a conference"
......@@ -42,11 +42,11 @@ class Preprints(Automaton):
self.logs[-1].reject(MSG_PREPRINT_IS_PAPER, record=record)
return False
if isinstance(record, RecordConf):
if isinstance(record, RecordCdsConf):
self.logs[-1].reject(MSG_PREPRINT_IS_CONFERENCE, record=record)
return False
if isinstance(record, RecordThesis):
if isinstance(record, RecordCdsThesis):
self.logs[-1].reject(MSG_PREPRINT_IS_THESIS, record=record)
return False
......
......@@ -29,15 +29,15 @@ from .factory import build_record, build_store
from .inspirehepstore import InspirehepStore
from .publicationinfomixin import PublicationInfoMixin
from store_tools.cdsstore import CdsStore
from .record import Record
from .recordconf import RecordConf
from store_tools.recordcds import RecordCds
from store_tools.recordcdsconf import RecordCdsConf
from .recordhep import RecordHep
from .recordhepconf import RecordHepConf
from .recordhepinst import RecordHepInst
from .recordheppubli import RecordHepPubli
from .recordhepthesis import RecordHepThesis
from .recordpubli import RecordPubli
from .recordthesis import RecordThesis
from store_tools.recordcdspubli import RecordCdsPubli
from store_tools.recordcdsthesis import RecordCdsThesis
def load_record(host, record_id, shelf=None):
......@@ -69,9 +69,9 @@ def load_record(host, record_id, shelf=None):
Returns:
Record:
either RecordConf, RecordHepConf, RecodHepPubli, RecordHepInst,
RecordHepThesis, RecordHepInst, RecordPubli or RecordThesis
RecordCds:
either RecordCdsConf, RecordHepConf, RecodHepPubli, RecordHepInst,
RecordHepThesis, RecordHepInst, RecordCdsPubli or RecordCdsThesis
Raises:
StoreException::
......
......@@ -14,15 +14,15 @@ from .base import (CDS,
from datetime import datetime
from .exception import RecordException, StoreException
from store_tools.cdsstore import CdsStore
from .cdsstore import CdsStore
from .inspirehepstore import InspirehepStore, SHELFS
from .recordconf import RecordConf
from .recordcdsconf import RecordCdsConf
from .recordhepconf import RecordHepConf
from .recordheppubli import RecordHepPubli
from .recordhepinst import RecordHepInst
from .recordhepthesis import RecordHepThesis
from .recordpubli import RecordPubli
from .recordthesis import RecordThesis
from .recordcdspubli import RecordCdsPubli
from .recordcdsthesis import RecordCdsThesis
REX_T = "\$\$t([\w, ]+)"
REX_U = "\$\$u([\w, ]+)"
......@@ -185,8 +185,8 @@ def build_record(recjson, shelf=None):
Return
Record:
either RecordConf, RecordHepConf, RecodHepPubli, RecordHepInst,
RecordHepThesis, RecordHepInst, RecordPubli or RecordThesis
either RecordCdsConf, RecordHepConf, RecodHepPubli, RecordHepInst,
RecordHepThesis, RecordHepInst, RecordCdsPubli or RecordCdsThesis
Raises:
RecordException
......@@ -199,16 +199,16 @@ def build_record(recjson, shelf=None):
if shelf is None:
if is_conference(recjson):
add_conference_data(recjson)
upcast_record = RecordConf(recjson)
upcast_record = RecordCdsConf(recjson)
elif is_institute(recjson):
raise RecordException(MSG_ERROR_INST)
elif is_thesis(recjson):
upcast_record = RecordThesis(recjson)
upcast_record = RecordCdsThesis(recjson)
else:
upcast_record = RecordPubli(recjson)
upcast_record = RecordCdsPubli(recjson)
else:
if is_conference(recjson) and shelf == "literature":
......
""" store_tools.record
""" store_tools.recordcds
"""
import pprint
......@@ -6,7 +6,7 @@ import pprint
from .base import OAI, OAI_URL, REG_OAI
class Record(dict):
class RecordCds(dict):
"""Base class for JSON record coming from cds.cern.ch or old.inspirehep.net.
It is a dictionary with the following structure::
......
""" store_tools.recordconf
""" store_tools.recordcdsconf
"""
from .base import REG_CONF, REG_YEAR
from plugin_dbui import CLEAN_SPACES
from .recordpubli import RecordPubli
from store_tools.recordcdspubli import RecordCdsPubli
class RecordConf(RecordPubli):
class RecordCdsConf(RecordCdsPubli):
"""The record describing a conference talk or a proceeding.
Additional field describing the conference data are:
......
""" store_tools.recordpubli
""" store_tools.recordcdspubli
"""
import logging
......@@ -9,14 +9,14 @@ from filters import CLEAN_COLLABORATION
from pandas import concat, DataFrame
from plugin_dbui import CLEAN_SPACES
from .publicationinfomixin import PublicationInfoMixin
from .record import Record
from store_tools.recordcds import RecordCds
def to_str(x):
return ("|".join(x) if isinstance(x, list) else x)
class RecordPubli(Record, AuthorsMixin, PublicationInfoMixin):
class RecordCdsPubli(RecordCds, AuthorsMixin, PublicationInfoMixin):
"""Article, preprint, proceeding, report and talk from cds.cern.ch or
old.inspirehep.net.
......@@ -126,7 +126,7 @@ class RecordPubli(Record, AuthorsMixin, PublicationInfoMixin):
self._last_fmt_author = "Last, First"
self.logger = logging.getLogger("web2py.app.limbra")
Record.__init__(self, *args)
RecordCds.__init__(self, *args)
self._process_authors()
self._process_publication_info()
......
""" store_tools.recordthesis
""" store_tools.recordcdsthesis
"""
from .base import THESIS_DIR
from filters import CLEAN_THESIS_DEFENSE
from .recordpubli import RecordPubli
from store_tools.recordcdspubli import RecordCdsPubli
class RecordThesis(RecordPubli):
class RecordCdsThesis(RecordCdsPubli):
"""The record describing a thesis.
Additional fields describing the thesis are:
......
......@@ -15,13 +15,13 @@ from store_tools.factory import (add_conference_data,
get_conference_data)
from store_tools.authorsmixin import to_initial
from store_tools.recordconf import RecordConf
from store_tools.recordcdsconf import RecordCdsConf
from store_tools.recordcdspubli import RecordCdsPubli
from store_tools.recordcdsthesis import RecordCdsThesis
from store_tools.recordhepconf import RecordHepConf
from store_tools.recordhepinst import RecordHepInst
from store_tools.recordheppubli import RecordHepPubli
from store_tools.recordhepthesis import RecordHepThesis
from store_tools.recordpubli import RecordPubli
from store_tools.recordthesis import RecordThesis
# ............................................................................
......@@ -104,7 +104,7 @@ def test_conference_cds_02006():
assert not is_thesis(recjson)
record = build_record(recjson)
assert isinstance(record, RecordConf)
assert isinstance(record, RecordCdsConf)
def test_conference_ins_02007():
......@@ -130,7 +130,7 @@ def test_talk_cds_02008():
assert not is_thesis(recjson)
record = build_record(recjson)
assert isinstance(record, RecordConf)
assert isinstance(record, RecordCdsConf)
# ............................................................................
#
......@@ -168,7 +168,7 @@ def test_article_cds_02021():
assert not is_thesis(recjson)
record = build_record(recjson)
assert isinstance(record, RecordPubli)
assert isinstance(record, RecordCdsPubli)
def test_article_inspirehep_02022():
......@@ -199,7 +199,7 @@ def test_thesis_cds_02030():
assert is_thesis(recjson)
record = build_record(recjson)
assert isinstance(record, RecordThesis)
assert isinstance(record, RecordCdsThesis)
def test_thesis_ins_02031():
......
"""test_03_Record
Test all methods of the Record class for a given article:
Test all methods of the RecordCds class for a given article:
https://cds.cern.ch/record/1951625.
same as https://old.inspirehep.net/record/1319638
......@@ -15,7 +15,7 @@ Test all methods of the Record class for a given article:
import pytest
from store_tools.factory import build_store
from store_tools.record import Record
from store_tools.recordcds import RecordCds
from store_tools.recordhep import RecordHep
......@@ -23,7 +23,7 @@ from store_tools.recordhep import RecordHep
def reccds():
store = build_store("cds.cern.ch")
recjson = store.get_record(1951625)
return Record(recjson)
return RecordCds(recjson)
@pytest.fixture(scope="module")
......
"""test_04_RecordPubli
Test all methods of the RecordPubli class for a given article:
Test all methods of the RecordCdsPubli class for a given article:
https://cds.cern.ch/record/1951625
(same as https://inspirehep.net/api/literature/1319638)
......@@ -24,7 +24,7 @@ import pandas as pd
import pytest
from store_tools import load_record
from store_tools.recordpubli import RecordPubli
from store_tools.recordcdspubli import RecordCdsPubli
@pytest.fixture(scope="module")
......@@ -33,7 +33,7 @@ def record():
def test_upcast_cds_04001(record):
assert isinstance(record, RecordPubli)
assert isinstance(record, RecordCdsPubli)
def test_constructor_cds_04002(record):
......
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