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

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

Migrate RecordThesis.

parent e9e676b2
......@@ -7,27 +7,15 @@ from .recordpubli import format_names, RecordPubli
from pandas import DataFrame
def is_thesis_dir(x):
x (dict): correspond to the field 100 or 700 for one author
return "e" in x and x["e"] == THESIS_DIR
class RecordThesis(RecordPubli):
"""The MARC record describing a thesis.
The relation between methods and MARC fields are the following::
| these defence | 500 a | |
| these level | 502 a | |
| these director | 700 a | |
| these universities | 502 b | |
"""The record describing a thesis.
Additional fields describing the thesis are::
| field | subfield |
| dissertation_note | defense_date, diploma, university |
def _process_authors(self):
......@@ -54,19 +42,23 @@ class RecordThesis(RecordPubli):
def authors_as_list(self, sort=False):
"""The list of author(s) signing the publication.
supersede the base class sinve the authors field contains
the author as well as names of director.
sort (bool): sort authors by first name when true.
list: the list is empty when authors are not defined.
the list is empty when authors are not defined.
df = self["700"]
# for a thesis, the authors field contains names of author
# as well as those of directors. The latter have to be removed.
df = self[u"authors"]
# for a thesis, the author field 700 contains names of author
# as well as directors. The latter have to be removed.
if "e" in df.columns:
df = df[df.e != THESIS_DIR]
query = df.relator_name != THESIS_DIR
if sort:
li = (df[["last_name", "fmt_name"]]
......@@ -110,14 +102,13 @@ class RecordThesis(RecordPubli):
"""The defence date for a master/phd thesis.
* The pattern is ``5 March 2012``.
* The pattern it is not standardise
* The pattern is not standardise
and can varies between records and between stores.
* The filter CLEAN_THESIS_DEFENSE is applied.
val = self._get("500", "a")
val = self._get(u"dissertation_note", u"defense_date")
def these_level(self):
......@@ -131,7 +122,7 @@ class RecordThesis(RecordPubli):
* Empty string when not defined
return self._get("502", "a")
return self._get(u"dissertation_note", u"diploma")
def these_directors(self, sep=", "):
"""The list of director(s)
......@@ -144,30 +135,20 @@ class RecordThesis(RecordPubli):
# for a thesis, the author field 700 field contains
# names of the director as well as the name of authors
for df in (self.get("700"), self.get("701")):
if (df is None) or ("e" not in df.columns):
df = self[u"authors"]
df = df.loc[df.e == THESIS_DIR]
query = df.relator_name == THESIS_DIR
df = df.loc[query]
return (sep.join(df.fmt_name) if len(df) > 0 else "")
def these_town(self):
"""The town where the thesis took place.
str: empty string when the town is not defined.
return self._get("260", "a")
def these_universities(self):
"""The university(ies) delivering the thesis diploma.
list: empty list when university is not defined
- empty when university(ies) is not defined
- several univeristy are separated by ``&`` character.
return self._get("502", "b", force_list=True)
return self._get(u"dissertation_note", u"university")
# -*- coding: utf-8 -*-
Test all methods of the RecordThesis class for a given proceeding:
Measurement of $t\bar{t}$ spin correlation and W polarization with
the $t\bar{t}$ di-leptonic channel events at ATLAS
L. Chen
10 Dec 2013
No corrections are applied to the record.
Allow to test the brute force decoding with its mistakes.
* Only the first author is defined
* Record submitted is not defined
* The year is not defined
import pytest
from invenio_tools import load_record
def reccds():
return load_record("", 1632177)
def test_authors_as_list(reccds):
assert reccds.authors_as_list() == [u'Chen, Liming']
def test_these_defense(reccds):
assert reccds.these_defense() == "2013-12-10"
def test_these_level(reccds):
assert reccds.these_level() == "PhD"
def test_these_directors(reccds):
assert reccds.these_directors(sep=u"|") == \
"He, Mao|Monnier, Emmanuel|Zhu, Chengguang"
def test_these_universities(reccds):
assert reccds.these_universities() == "Shandong U. & Marseille, CPPM"
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