Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit 28aae2f0 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Merge branch '66-no-conference-date' into 'master'

66 no conference date

* Fix `RecordConf.conference_dates` for record from inspirehep.net.
* Modify the logic to check and validate conference dates. It now depends on the record host.
* Close #66 

See merge request !66
parents f08371a2 1d5db947
......@@ -216,7 +216,7 @@ def edit_insert():
try:
check.country(record)
check.conference_date(record)
check.conference_date(record, selector.host)
except CheckException:
pass
......
......@@ -395,11 +395,13 @@ class CheckAndFix(object):
except ToolException as e:
raise CheckException(*e.args)
def conference_date(self, record):
def conference_date(self, record, host):
"""Check conference date.
Args:
record (RecordConf): record describing a talk or a proceeding.
host (str): possible values ares ``cds.cern.ch``
or ``inspirehep.net``
Raises:
CheckException: when dates are not found or not well formed.
......@@ -409,11 +411,20 @@ class CheckAndFix(object):
if not isinstance(record, RecordConf):
return
# check and fix conference date
# inspirehep.net
if host == "inspirehep.net":
value = record.conference_dates()
if len(value) == 0:
raise CheckException(MSG_NO_CONF_DATE)
return
# cds.cern.ch
if not (u"111" in record and "d" in record[u"111"]):
raise CheckException(MSG_NO_CONF_DATE)
value = record[u"111"]["d"]
m = REG_CONF_DATES.match(value)
if not m:
......
......@@ -35,7 +35,7 @@ class Proceedings(Automaton):
try:
self.check.is_conference(record)
self.check.country(record)
self.check.conference_date(record)
self.check.conference_date(record, self.harvester.host)
self.check.clean_erratum(record)
self.check.submitted(record)
......
......@@ -35,7 +35,7 @@ class Talks(Automaton):
try:
self.check.is_conference(record)
self.check.country(record)
self.check.conference_date(record)
self.check.conference_date(record, self.harvester.host)
self.check.submitted(record)
self.check.year(record)
......
......@@ -6,7 +6,6 @@ import pprint
from base import OAI, OAI_URL, REG_OAI
from __builtin__ import isinstance
class Record(dict):
......
......@@ -2,11 +2,18 @@
""" invenio_tools.recordconf
"""
import re
from base import REG_YEAR
from datetime import datetime
from plugin_dbui import CLEAN_SPACES
from recordpubli import RecordPubli
REG_DATE = re.compile(r"(\d{4}-\d{2}-\d{2})")
class RecordConf(RecordPubli):
"""The MARC record describing a conference talk or a proceeding.
The relation between methods and MARC fields are the following::
......@@ -14,8 +21,8 @@ class RecordConf(RecordPubli):
+-----------------------+---------+----------+
| | CDS | INSPIREP |
+-----------------------+---------+----------+
| conference date | 111 d | |
| conference end | 111 z | None |
| conference date | 111 d | None |
| conference end | 111 z | 111 y |
| conference key | 111 g | |
| conference location | 111 c | |
| conference title | 111 a | |
......@@ -38,7 +45,27 @@ class RecordConf(RecordPubli):
standardise.
"""
return self._get(u"111", "d")
if self.host().startswith("inspirehep"):
start = self._get(u"111", "x")
end = self._get(u"111", "y")
if not (REG_DATE.match(start) and REG_DATE.match(end)):
return u''
ds = datetime.strptime(start, "%Y-%m-%d")
de = datetime.strptime(end, "%Y-%m-%d")
if ds.month == de.month:
value = "%i-%i %s" % (ds.day, de.day, ds.strftime("%b %Y"))
else:
tpl = (ds.strftime("%d %b"), de.strftime("%d %b %Y"))
value = "%s - %s" % tpl
else:
value = self._get(u"111", "d")
return value
def conference_country(self):
"""The country where the conference took place.
......
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