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
921aa615
Commit
921aa615
authored
Sep 19, 2016
by
LE GAC Renaud
Browse files
Update RecordThesis in order to use author iterators.
parent
de6390e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
59 deletions
+16
-59
modules/invenio_tools/recordthesis.py
modules/invenio_tools/recordthesis.py
+16
-59
No files found.
modules/invenio_tools/recordthesis.py
View file @
921aa615
...
...
@@ -4,9 +4,15 @@
"""
from
base
import
REG_AUTHOR
,
THESIS_DIR
from
filters
import
CLEAN_THESIS_DEFENSE
from
iterauthors
import
author_name
,
iter_author_fields
from
itertools
import
ifilter
,
ifilterfalse
,
imap
from
recordpubli
import
RecordPubli
# the argument x is a dict corresponding to the field 100 or 700 for one author
is_thesis_dir
=
lambda
x
:
"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::
...
...
@@ -28,50 +34,11 @@ class RecordThesis(RecordPubli):
list: the list is empty when authors are not defined.
"""
authors
=
[]
first_author
=
self
.
first_author
()
# NOTE
# the content of the 700 field depend on the record type.
# For thesis it also contains the name of the director
if
u
"700"
in
self
and
isinstance
(
self
[
u
"700"
],
dict
):
if
not
(
"e"
in
self
[
u
"700"
]
and
self
[
u
"700"
][
"e"
]
==
THESIS_DIR
):
if
"a"
in
self
[
u
"700"
]:
authors
.
append
(
self
[
u
"700"
][
"a"
])
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
:
continue
if
"a"
in
di
:
author
=
di
[
"a"
]
# PROTECTION
# in most of the case the author is a string
# but it can be a list, e.g inspirehep.net/138663:
# [u'Zuniga, J.', u'(the A.N.T.ARES. Collaboration)']
if
isinstance
(
author
,
unicode
):
authors
.
append
(
di
[
"a"
])
elif
isinstance
(
author
,
list
):
for
elt
in
author
:
if
REG_AUTHOR
.
match
(
elt
):
authors
.
append
(
elt
)
break
# the first author is defined not the other one
elif
u
"100"
in
self
:
authors
.
append
(
first_author
)
# sometime the first author is missing
if
len
(
authors
)
==
0
:
authors
=
[
first_author
]
elif
first_author
!=
authors
[
0
]:
authors
.
insert
(
0
,
first_author
)
return
authors
# for a thesis, the author field 700 can contains names of director.
# they have to be removed.
iter_filter
=
ifilterfalse
(
is_thesis_dir
,
iter_author_fields
(
self
))
return
list
(
imap
(
author_name
,
iter_filter
))
def
these_defense
(
self
):
"""The defence date for a master/phd thesis.
...
...
@@ -109,21 +76,11 @@ class RecordThesis(RecordPubli):
* Empty string when it is 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
:
if
"a"
in
self
[
u
"700"
]:
li
.
append
(
self
[
u
"700"
][
"a"
])
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
:
if
"a"
in
di
:
li
.
append
(
di
[
"a"
])
return
', '
.
join
(
li
)
# for a thesis, the author field 700 field can contains
# names of the director.
iter_filter
=
ifilter
(
is_thesis_dir
,
iter_author_fields
(
self
))
return
u
", "
.
join
(
list
(
imap
(
author_name
,
iter_filter
)))
def
these_town
(
self
):
"""The town where the thesis 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