recordthesis.py 2.69 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
# -*- coding: utf-8 -*-
""" invenio_tools.recordthesis

"""
from base import THESIS_DIR
from filters import CLEAN_THESIS_DEFENSE
from recordpubli import RecordPubli


class RecordThesis(RecordPubli):
    """MARC record describing a thesis.
    The relation between methods and MARC fields are the following::

                              |  CDS    | INSPIREP
        ----------------------+---------+----------
        these defense         | 500 a   |
        these level           | 502 a   |
        these director        | 700 a   |
        these universities    | 502 b   |
        ----------------------+---------+----------

    """
    def these_defense(self):
        """The defense date for a master/phd thesis.

        @rtype: unicode
        @return:
            - The format is '5 March 2012'.
            - The format is not standardize and can varies
              between records and between stores.
            - The value is not a standardize C{date}.
            - The filter L{CLEAN_THESIS_DEFENSE} is applied.

        """
        val = self._get(u"500", "a")
        return CLEAN_THESIS_DEFENSE(val)

    def these_level(self):
        """The level of the thesis.

        @rtype: unicode
        @return:
            - The format is "master" or "PhD".
            - The format is not standardize and can varies
              between records and between stores.
            - Empty string when not defined

        """
        return self._get(u"502", "a")

    def these_directors(self):
        """The list of director(s)

        @rtype: unicode
        @return:
            - Names are separated by ", ".
            - Empty string when not defined.

        """
        # NOTE director are stored in the author field
        # the first author is not a director !
        li = []
        if u"700" in self and isinstance(self[u"700"], dict):
            if "e" in self[u"700"] and self[u"700"]["e"] == THESIS_DIR:
65 66
                if "a" in self[u"700"]:
                    li.append(self[u"700"]["a"])
67 68 69 70

        elif u"700" in self and isinstance(self[u"700"], list):
            for di in self[u"700"]:
                if "e" in di and di["e"] == THESIS_DIR:
71 72
                    if "a" in di:
                        li.append(di["a"])
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94

        return ', '.join(li)

    def these_town(self):
        """The town where the thesis took place.

        @rtype: unicode
        @return:
            - Empty string when not defined.

        """
        return self._get(u"260", "a")

    def these_universities(self):
        """The university(ies) delivering the thesis diploma.

        @rtype: list
        @return:
            - Empty list when not defined

        """
        return self._get(u"502", "b", force_list=True)