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

Commit 655a173d authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update RecordCdsConfPaper to add the attribute conference

parent 87714257
""" store_tools.recordcdsconfpaper
"""
from .base import REG_CONF, REG_YEAR
import re
from .base import REG_CONF, REG_YEAR, T4, T6
from .cdsstore import CdsStore
from plugin_dbui import CLEAN_SPACES
from store_tools.recordcdspubli import RecordCdsPubli
from .recordcdspubli import RecordCdsPubli
REX_DATE8 = re.compile(r"(\d{4})(\d{2})(\d{2})")
class RecordCdsConfPaper(RecordCdsPubli):
"""The record describing a conference talk or a proceeding.
Additional field describing the conference data are:
+----------------+-----------------------------------------------+
| field | subfield |
+================+===============================================+
| meeting_name | closing_date, coference_code, country, date, |
| | location, opening_date, year |
+----------------+-----------------------------------------------+
Attributes:
conference (dict or None):
the conference metadata:
* addresses: [{cities: [], country: str, ...}, ...]
* cnum: str
* control_number: int
* closing_date: str
* opening_date: str
* titles: [{value: str}, ...]
* urls: [{value: str}, ...]
* year
One field is added by limbra:
"""
+----------------+-----------------------------------------------+
| field (limbra) | subfield |
+================+===============================================+
| meeting_note | recid, url |
+----------------+-----------------------------------------------+
def __init__(self, recjson):
"""
super().__init__(recjson)
self.conference = None
self._process_conference_data()
def _process_conference_data(self):
"""Append the conference data to the record.
"""
logger = self.logger
logger.debug(f"{T4}process conference data")
if "aleph_linking_page" not in self:
logger.debug(f"{T6}no field 'aleph_linking_page'")
return
dct = self.get("aleph_linking_page", {})
conf_id = dct.get("sysno", None)
conf_key = dct.get("up_link", None)
if conf_id is None and conf_key is None:
logger.debug(f"{T6}no conference id and key")
return
# ........................................................................
#
# Get conference data first id and then by key
#
store = CdsStore("cds.cern.ch")
if conf_id is not None:
logger.debug(f"{T6}search by conference by id {conf_id}")
recjson = store.get_record(conf_id)
if recjson["recid"] != conf_id:
logger.debug(f"{T6}failed to retrieve conference by id")
if recjson.get("meeting_name", None) is None:
logger.debug(f"{T6}no field 'meeting_name'")
return
elif conf_key is not None:
logger.debug(f"{T6}search by conference by key {conf_key}")
ids = store.get_ids(p=conf_key)
mtch = False
for cid in ids:
recjson = store.get_record(cid)
for elt in recjson.get("meeting_name", []):
ck = elt.get("coference_code", "")
if ck == conf_key:
mtch = True
break
if mtch is True:
break
if mtch is False:
logger.debug(f"{T6}failed to retrieve conference by key")
return
# ........................................................................
#
# Decode conference data
# Convert structure to the one provides by the new inspirehep.net
#
data = None
for elt in recjson["meeting_name"]:
if "year" in elt:
data = elt
break
if data is None:
logger.debug(f"{T6}conference data not found")
return
city, country = data.get("location", ",").split(",")
dct = {
"addresses": [{
"cities": [city.strip()],
"country": country.strip()}],
"cnum": data.get("coference_code"),
"closing_date": data.get("closing_date", None),
"opening_date": data.get("opening_date", None),
"titles": [{"value": data.get("meeting", None)}],
"urls": [recjson.get("url", {}).get("url", None)],
"year": data.get("year", None)}
# date format issue YYYYMMDD to YYYY-MM-DD
for k in ("closing_date", "opening_date"):
mtch = REX_DATE8.match(dct[k])
if mtch:
dct[k] = "-".join(mtch.groups())
# ........................................................................
#
# Append conference data
self.conference = dct
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