Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
limbra
limbra
Commits
adc8d2b5
Commit
adc8d2b5
authored
Jan 13, 2021
by
LE GAC Renaud
Browse files
Rename Record and friends as RecordCds
parent
bcab4702
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
82 additions
and
82 deletions
+82
-82
controllers/harvest.py
controllers/harvest.py
+4
-4
modules/harvest_tools/checkandfix.py
modules/harvest_tools/checkandfix.py
+34
-34
modules/harvest_tools/preprints.py
modules/harvest_tools/preprints.py
+3
-3
modules/store_tools/__init__.py
modules/store_tools/__init__.py
+7
-7
modules/store_tools/factory.py
modules/store_tools/factory.py
+9
-9
modules/store_tools/recordcds.py
modules/store_tools/recordcds.py
+2
-2
modules/store_tools/recordcdsconf.py
modules/store_tools/recordcdsconf.py
+3
-3
modules/store_tools/recordcdspubli.py
modules/store_tools/recordcdspubli.py
+4
-4
modules/store_tools/recordcdsthesis.py
modules/store_tools/recordcdsthesis.py
+3
-3
tests/basis/test_02_factory_tools.py
tests/basis/test_02_factory_tools.py
+7
-7
tests/basis/test_03_Record.py
tests/basis/test_03_Record.py
+3
-3
tests/basis/test_04_RecordPubli.py
tests/basis/test_04_RecordPubli.py
+3
-3
No files found.
controllers/harvest.py
View file @
adc8d2b5
...
...
@@ -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
)
RecordC
dsC
onf
,
Record
Cds
Thesis
)
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
,
RecordC
dsC
onf
):
values
[
"PublicationsConference_title"
]
=
\
record
.
conference_title
()
...
...
@@ -301,7 +301,7 @@ def edit_insert():
#
if
selector
.
controller
==
"theses"
:
if
isinstance
(
record
,
RecordThesis
):
if
isinstance
(
record
,
Record
Cds
Thesis
):
values
[
"PublicationsUniversities"
]
=
\
record
.
these_universities
()
...
...
modules/harvest_tools/checkandfix.py
View file @
adc8d2b5
...
...
@@ -12,13 +12,13 @@ from gluon import current
from
store_tools
import
(
MSG_NO_CONF
,
MSG_NO_THESIS
,
OAI_URL
,
Record
,
RecordConf
,
Record
Cds
,
RecordC
dsC
onf
,
RecordHep
,
RecordHepConf
,
RecordHepThesis
,
RecordPubli
,
RecordThesis
,
Record
Cds
Publi
,
Record
Cds
Thesis
,
REG_OAI
,
REG_YEAR
)
...
...
@@ -103,7 +103,7 @@ class CheckAndFix(object):
"""Return the opening and closing dates of a conference.
Args:
record (RecordConf):
record (RecordC
dsC
onf):
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 (Record
Cds
Publi):
record describing a publication.
id_project (int):
...
...
@@ -306,7 +306,7 @@ class CheckAndFix(object):
information.
Args:
record (RecordPubli):
record (Record
Cds
Publi):
record describing a publication.
Returns:
...
...
@@ -316,7 +316,7 @@ class CheckAndFix(object):
"""
val
=
""
if
isinstance
(
record
,
RecordConf
):
if
isinstance
(
record
,
RecordC
dsC
onf
):
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
,
Record
Cds
Thesis
)):
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
,
(
RecordC
dsC
onf
,
Record
Cds
Publi
,
Record
Cds
Thesis
)):
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 (Record
Cds
Publi):
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 (Record
Cds
Publi):
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 (Record
Cds
Publi):
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
,
RecordC
dsC
onf
):
return
val
=
record
.
conference_country
()
...
...
@@ -473,7 +473,7 @@ class CheckAndFix(object):
"""Check conference date exists and well formatted.
Args:
record (RecordConf):
record (RecordC
dsC
onf):
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
,
RecordC
dsC
onf
):
return
val
=
record
.
conference_dates
()
...
...
@@ -523,7 +523,7 @@ class CheckAndFix(object):
to new one.
Args:
record (RecordPubli):
record (Record
Cds
Publi):
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 (Record
Cds
Publi): record describing a publication.
Returns:
bool:
...
...
@@ -576,7 +576,7 @@ class CheckAndFix(object):
"""Format the author names.
Args:
record (RecordPubli):
record (Record
Cds
Publi):
record describing a publication.
fmt (str):
...
...
@@ -599,7 +599,7 @@ class CheckAndFix(object):
Standardise the answer as ``Phys. Lett. B``.
Args:
record (RecordPubli):
record (Record
Cds
Publi):
record describing a publication.
Raises:
...
...
@@ -638,14 +638,14 @@ class CheckAndFix(object):
* Replace U. by University
Args:
record (RecordThesis):
record (Record
Cds
Thesis):
record describing a thesis.
"""
self
.
logger
.
debug
(
f
"
{
T6
}
format university"
)
# protection
if
not
isinstance
(
record
,
RecordThesis
):
if
not
isinstance
(
record
,
Record
Cds
Thesis
):
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 Record
Cds
object via the attribute
``my_authors``.
Args:
record (RecordPubli):
record (Record
Cds
Publi):
record describing a publication.
sep (str):
...
...
@@ -729,7 +729,7 @@ class CheckAndFix(object):
"""Check that the record contains conference data.
Args:
record (RecordPubli):
record (Record
Cds
Publi):
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
,
RecordC
dsC
onf
):
if
"meeting_name"
in
record
:
return
...
...
@@ -753,7 +753,7 @@ class CheckAndFix(object):
"""Check that the record described a thesis.
Args:
record (RecordPubli):
record (Record
Cds
Publi):
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
,
Record
Cds
Thesis
):
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 (Record
Cds
Publi):
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 (Record
Cds
Publi):
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 (Record
Cds
Publi):
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 (Record
Cds
Publi):
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
,
Record
Cds
):
# 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 (Record
Cds
Publi):
record describing a publication.
Raises:
...
...
modules/harvest_tools/preprints.py
View file @
adc8d2b5
...
...
@@ -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
RecordC
dsC
onf
,
Record
Cds
Thesis
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
,
RecordC
dsC
onf
):
self
.
logs
[
-
1
].
reject
(
MSG_PREPRINT_IS_CONFERENCE
,
record
=
record
)
return
False
if
isinstance
(
record
,
RecordThesis
):
if
isinstance
(
record
,
Record
Cds
Thesis
):
self
.
logs
[
-
1
].
reject
(
MSG_PREPRINT_IS_THESIS
,
record
=
record
)
return
False
...
...
modules/store_tools/__init__.py
View file @
adc8d2b5
...
...
@@ -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
.record
cds
import
Record
Cds
from
store_tools
.recordc
dsc
onf
import
RecordC
dsC
onf
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
.record
cds
publi
import
Record
Cds
Publi
from
store_tools
.record
cds
thesis
import
Record
Cds
Thesis
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
Record
Cds
:
either RecordC
dsC
onf, RecordHepConf, RecodHepPubli, RecordHepInst,
RecordHepThesis, RecordHepInst, Record
Cds
Publi or Record
Cds
Thesis
Raises:
StoreException::
...
...
modules/store_tools/factory.py
View file @
adc8d2b5
...
...
@@ -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
.recordc
dsc
onf
import
RecordC
dsC
onf
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
.record
cds
publi
import
Record
Cds
Publi
from
.record
cds
thesis
import
Record
Cds
Thesis
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 RecordC
dsC
onf, RecordHepConf, RecodHepPubli, RecordHepInst,
RecordHepThesis, RecordHepInst, Record
Cds
Publi or Record
Cds
Thesis
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
=
RecordC
dsC
onf
(
recjson
)
elif
is_institute
(
recjson
):
raise
RecordException
(
MSG_ERROR_INST
)
elif
is_thesis
(
recjson
):
upcast_record
=
RecordThesis
(
recjson
)
upcast_record
=
Record
Cds
Thesis
(
recjson
)
else
:
upcast_record
=
RecordPubli
(
recjson
)
upcast_record
=
Record
Cds
Publi
(
recjson
)
else
:
if
is_conference
(
recjson
)
and
shelf
==
"literature"
:
...
...
modules/store_tools/record.py
→
modules/store_tools/record
cds
.py
View file @
adc8d2b5
""" store_tools.record
""" store_tools.record
cds
"""
import
pprint
...
...
@@ -6,7 +6,7 @@ import pprint
from
.base
import
OAI
,
OAI_URL
,
REG_OAI
class
Record
(
dict
):
class
Record
Cds
(
dict
):
"""Base class for JSON record coming from cds.cern.ch or old.inspirehep.net.
It is a dictionary with the following structure::
...
...
modules/store_tools/recordconf.py
→
modules/store_tools/recordc
dsc
onf.py
View file @
adc8d2b5
""" store_tools.recordconf
""" store_tools.recordc
dsc
onf
"""
from
.base
import
REG_CONF
,
REG_YEAR
from
plugin_dbui
import
CLEAN_SPACES
from
.recordpubli
import
RecordPubli
from
store_tools
.record
cds
publi
import
Record
Cds
Publi
class
RecordConf
(
RecordPubli
):
class
RecordC
dsC
onf
(
Record
Cds
Publi
):
"""The record describing a conference talk or a proceeding.
Additional field describing the conference data are:
...
...
modules/store_tools/recordpubli.py
→
modules/store_tools/record
cds
publi.py
View file @
adc8d2b5
""" store_tools.recordpubli
""" store_tools.record
cds
publi
"""
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
.record
cds
import
Record
Cds
def
to_str
(
x
):
return
(
"|"
.
join
(
x
)
if
isinstance
(
x
,
list
)
else
x
)
class
RecordPubli
(
Record
,
AuthorsMixin
,
PublicationInfoMixin
):
class
Record
Cds
Publi
(
Record
Cds
,
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
)
Record
Cds
.
__init__
(
self
,
*
args
)
self
.
_process_authors
()
self
.
_process_publication_info
()
...
...
modules/store_tools/recordthesis.py
→
modules/store_tools/record
cds
thesis.py
View file @
adc8d2b5
""" store_tools.recordthesis
""" store_tools.record
cds
thesis
"""
from
.base
import
THESIS_DIR
from
filters
import
CLEAN_THESIS_DEFENSE
from
.recordpubli
import
RecordPubli
from
store_tools
.record
cds
publi
import
Record
Cds
Publi
class
RecordThesis
(
RecordPubli
):
class
Record
Cds
Thesis
(
Record
Cds
Publi
):
"""The record describing a thesis.
Additional fields describing the thesis are:
...
...
tests/basis/test_02_factory_tools.py
View file @
adc8d2b5
...
...
@@ -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
,
RecordC
dsC
onf
)
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
,
RecordC
dsC
onf
)
# ............................................................................
#
...
...
@@ -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
,
Record
Cds
Publi
)
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
,
Record
Cds
Thesis
)
def
test_thesis_ins_02031
():
...
...
tests/basis/test_03_Record.py
View file @
adc8d2b5
"""test_03_Record
Test all methods of the Record class for a given article:
Test all methods of the Record
Cds
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.record
cds
import
Record
Cds
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
Record
Cds
(
recjson
)
@
pytest
.
fixture
(
scope
=
"module"
)
...
...
tests/basis/test_04_RecordPubli.py
View file @
adc8d2b5
"""test_04_RecordPubli
Test all methods of the RecordPubli class for a given article:
Test all methods of the Record
Cds
Publi 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.record
cds
publi
import
Record
Cds
Publi
@
pytest
.
fixture
(
scope
=
"module"
)
...
...
@@ -33,7 +33,7 @@ def record():
def
test_upcast_cds_04001
(
record
):
assert
isinstance
(
record
,
RecordPubli
)
assert
isinstance
(
record
,
Record
Cds
Publi
)
def
test_constructor_cds_04002
(
record
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment