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
655a173d
Commit
655a173d
authored
Jan 15, 2021
by
LE GAC Renaud
Browse files
Update RecordCdsConfPaper to add the attribute conference
parent
87714257
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
120 additions
and
16 deletions
+120
-16
modules/store_tools/recordcdsconfpaper.py
modules/store_tools/recordcdsconfpaper.py
+120
-16
No files found.
modules/store_tools/recordcdsconfpaper.py
View file @
655a173d
""" 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.
...
...
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