Commit 336fb685 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Re-implement the procedure to fix missing OAI.

parent 79a58da4
......@@ -25,6 +25,8 @@ MSG_NO_TEAM = 'Select a "team" !!!'
MSG_INSERT_FAIL = "Fail to insert the new record in the database."
OAI = u"oai:%s:%i"
# search collection when using inspirehep
# require for "Hal Hidden"
REG_COLLECTION = re.compile(r"cc([A-Za-z ]+)(and|$)")
......@@ -389,7 +391,10 @@ class Automaton(object):
print("check record")
try:
self.check.is_oai(record)
# fix record with a missing OAI
if not self.check.is_oai(record):
oai = OAI % (self.harvester.host, record.id)
record[u"oai"] = {u"value": oai}
if self.check.is_bad_oai_used(record):
self.logs[-1].idle(MSG_IN_DB, record.submitted())
......
......@@ -529,14 +529,14 @@ class CheckAndFix(object):
return False
def is_oai(self, record):
"""Raise exception when the OAI is not defined.
"""``True`` when the OAI is not defined in the record.
Args:
record (RecordPubli): record describing a publication.
Raise:
ToolException:
OAI is not defined
Returns:
bool:
``True`` when the OAI is not defined in the record.
"""
if self.dbg:
print "\t\tCheck is oai"
......@@ -545,8 +545,7 @@ class CheckAndFix(object):
test = (u"oai" in record and u"value" in record[u"oai"]) or \
(u"FIXME_OAI" in record and u"id" in record[u"FIXME_OAI"])
if not test:
raise ToolException(MSG_NO_OAI)
return test
def format_authors(self, record, fmt="Last, First"):
"""Format the author names.
......
......@@ -35,7 +35,7 @@ def test_constructor(svc):
def test_is_oai(svc, reccds):
assert svc.is_oai(reccds) is None
assert svc.is_oai(reccds)
def test_is_bad_oai(svc, reccds):
......
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