Commit adb42593 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Fix Record.conf.conference_dates for record from inspirehep.

parent 822ff81e
......@@ -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::
......@@ -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