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
6409d1e6
Commit
6409d1e6
authored
Sep 24, 2015
by
LE GAC Renaud
Browse files
Bug fix when rejecting record with invalid OAI.
parent
b09c6dd3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
13 deletions
+16
-13
modules/harvest_tools/automaton.py
modules/harvest_tools/automaton.py
+8
-5
modules/invenio_tools/checkandfix.py
modules/invenio_tools/checkandfix.py
+8
-8
No files found.
modules/harvest_tools/automaton.py
View file @
6409d1e6
...
...
@@ -450,7 +450,7 @@ class Automaton(object):
# the search is perform on a range of creation date
# if not defined all element are return
#
# The method use here minimi
s
e the memory usage
# The method use here minimi
z
e the memory usage
# on the server as well as on the client side
for
collection
in
collections
:
...
...
@@ -511,8 +511,9 @@ class Automaton(object):
if
self
.
dbg
:
print
"process xml record"
# NOTE: BaseException and inherited class
# are catched by the previous stage
# NOTE
# BaseException and inherited class
# are caught by the previous stage
records
=
self
.
marc12
(
xml
)
# process individual record
...
...
@@ -529,13 +530,15 @@ class Automaton(object):
# reject record with undefined OAI field
oai
=
record
.
oai
()
if
not
oai
:
if
oai
is
None
:
self
.
logs
[
-
1
].
reject
(
MSG_NO_OAI
,
record
.
year
())
continue
# reject record is not well
form OAI
# reject
the
record
when the OAI
is not well
match
=
REG_OAI
.
match
(
oai
)
if
not
match
:
self
.
logs
[
-
1
].
reject
(
MSG_WELL_FORM_OAI
,
record
.
year
())
continue
# check that the record is well formed
# repair non-conformity as far as possible
...
...
modules/invenio_tools/checkandfix.py
View file @
6409d1e6
...
...
@@ -409,26 +409,26 @@ class CheckAndFix(object):
raise
CheckException
(
MSG_WELL_FORMED_CONF_DATES
)
def
is_bad_oai_used
(
self
,
record
):
"""The id in the OAI field might be different from the record id.
It happens when an old record is redirected to new one for obscure
reasons.
Return C{TRue} if the "bad OAI" is found in the database.
"""The id in the OAI field is different from the record id.
This happens when an old record is redirected to new one
for obscure reasons. The method return C{True} when a record
with the bad OAI is found in the database.
@type record: L{Record}
@param record:
@rtype: bool
@return: C{True} when a record is found in the database with
the bad OAI.
"""
value
=
record
.
oai
()
match
=
REG_OAI
.
match
(
value
)
myid
=
record
.
id
()
if
match
.
group
(
2
)
!=
myid
:
if
match
.
group
(
2
)
!=
record
.
id
()
:
db
=
self
.
db
#
The bad OAI is already used
in the database
#
a record with the bad OAI exists
in the database
bad_oai_url
=
OAI_URL
%
(
match
.
group
(
1
),
match
.
group
(
2
))
if
get_id
(
db
.
publications
,
origin
=
bad_oai_url
):
return
True
...
...
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