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
009c5f94
Commit
009c5f94
authored
Sep 12, 2015
by
LE GAC Renaud
Browse files
Use the preference inspireshep_institute_in in harvesters.
parent
8f8ba09c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
24 deletions
+42
-24
models/db0_preferences.py
models/db0_preferences.py
+5
-0
modules/invenio_tools/__init__.py
modules/invenio_tools/__init__.py
+1
-19
modules/invenio_tools/checkandfix.py
modules/invenio_tools/checkandfix.py
+35
-4
tests/harvester/CheckAndFix/test_acl_cds1951625_fix.py
tests/harvester/CheckAndFix/test_acl_cds1951625_fix.py
+1
-1
No files found.
models/db0_preferences.py
View file @
009c5f94
...
...
@@ -22,4 +22,9 @@ app = Storage()
for
row
in
db
(
db
.
preferences
).
select
():
app
[
row
.
property
]
=
row
.
value
# add local variable
app
[
"reg_institute"
]
=
""
app
[
"institute"
]
=
None
current
.
app
=
app
modules/invenio_tools/__init__.py
View file @
009c5f94
...
...
@@ -14,26 +14,8 @@ from exception import (CdsException,
RecordException
,
XmlException
)
from
checkandfix
import
CheckAndFix
from
checkandfix
import
CheckAndFix
,
load_record
from
institute
import
Institute
from
inveniostore
import
InvenioStore
from
marc12
import
Marc12
from
record
import
Record
def
load_record
(
host
,
record_id
):
"""Load a record from an invenio store
Args:
host (str): host of the store. Either cds.cern.ch or inspirhep.net.
record_id (integer): the record identifier
Returns:
Record: the decoded record
"""
store
=
InvenioStore
(
host
)
xml
=
store
.
get_record
(
record_id
)
svc
=
Marc12
()
return
svc
(
xml
)[
0
]
modules/invenio_tools/checkandfix.py
View file @
009c5f94
...
...
@@ -6,9 +6,9 @@ import re
import
regex
from
base
import
OAI_URL
,
REG_OAI
,
REG_YEAR
from
gluon
import
current
from
exception
import
CheckException
from
filters
import
CLEAN_REVIEW
from
gluon
import
current
from
inveniostore
import
InvenioStore
from
marc12
import
Marc12
from
plugin_dbui
import
get_id
...
...
@@ -75,6 +75,24 @@ REG_CONF_DATES = re.compile(regex.REG_CONF_DATES)
REG_SUBMITTED
=
re
.
compile
(
regex
.
REG_SUBMITTED
)
def
load_record
(
host
,
record_id
):
"""Helper function to load a single record from an invenio store.
Args:
host (str): host of the store. Either cds.cern.ch or inspirhep.net.
record_id (integer): the record identifier
Returns:
Record: the decoded record
"""
store
=
InvenioStore
(
host
)
xml
=
store
.
get_record
(
record_id
)
svc
=
Marc12
()
return
svc
(
xml
)[
0
]
class
CheckAndFix
(
object
):
"""Tool to check and repair the content of the Marc12 record:
...
...
@@ -482,10 +500,23 @@ class CheckAndFix(object):
"""
# alias
institute
=
current
.
app
.
reg_institute
app
=
current
.
app
reg_institute
=
app
.
reg_institute
# regular expression for the institute is not defined
# find it using the institute definition in inspirehep
# store the regular expression in current.app for a later use
if
not
reg_institute
:
institute_id
=
app
.
inspirehep_institute_id
institute
=
load_record
(
"inspirehep.net"
,
institute_id
)
reg_institute
=
institute
.
rex
()
app
.
institute
=
institute
app
.
reg_institute
=
reg_institute
# find authors of my institute signing the record
s
=
record
.
find_authors_by_institute
(
institute
,
cmpFct
)
s
=
record
.
find_authors_by_institute
(
reg_
institute
,
cmpFct
)
# nothing found try with the rescue list
if
not
s
and
reference
:
...
...
@@ -502,7 +533,7 @@ class CheckAndFix(object):
record
.
my_authors
=
s
return
raise
CheckException
(
MSG_NO_MY_AUTHOR
%
institute
.
encode
(
"utf8"
))
raise
CheckException
(
MSG_NO_MY_AUTHOR
%
reg_
institute
.
encode
(
"utf8"
))
def
oai
(
self
,
record
):
"""Check that the OAI field is defined and well formed.
...
...
tests/harvester/CheckAndFix/test_acl_cds1951625_fix.py
View file @
009c5f94
...
...
@@ -65,7 +65,7 @@ def test_authors(record):
def
test_find_authors_by_institute
(
record
):
rex
=
current
.
app
.
reg_institute
assert
rex
==
"
CPPM
"
assert
rex
==
"
Marseille, CPPM|CPPM, Marseille
"
authors
=
record
.
find_authors_by_institute
(
rex
,
family_name_fr
)
authors
=
authors
.
split
(
", "
)
...
...
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