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
Docker-in-Docker (DinD) capabilities of public runners deactivated.
More info
Open sidebar
limbra
limbra
Commits
b070f03d
Commit
b070f03d
authored
Sep 23, 2015
by
LE GAC Renaud
Browse files
Add the method RecordPubli.find_affiliation.
parent
a128635b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
0 deletions
+41
-0
modules/invenio_tools/recordpubli.py
modules/invenio_tools/recordpubli.py
+36
-0
tests/harvester/Record/test_acl_cds1951625.py
tests/harvester/Record/test_acl_cds1951625.py
+5
-0
No files found.
modules/invenio_tools/recordpubli.py
View file @
b070f03d
...
...
@@ -118,6 +118,42 @@ class RecordPubli(Record):
li
=
self
.
_get
(
u
"710"
,
'g'
,
force_list
=
True
)
return
CLEAN_COLLABORATION
(
', '
.
join
(
li
))
def
find_affiliation
(
self
,
pattern
):
"""Find author affiliation matching the regular expression C{pattern}.
@type pattern: unicode
@param pattern: regular expression defining the affiliation names.
@rtype: unicode
@return:
- the affiliation
- empty string when nothing is found.
"""
reg_affiliation
=
re
.
compile
(
pattern
)
for
field
in
(
u
"100"
,
u
"700"
):
if
field
not
in
self
:
continue
dictionaries
=
self
[
field
]
if
isinstance
(
dictionaries
,
dict
):
dictionaries
=
[
dictionaries
]
for
di
in
dictionaries
:
if
"u"
not
in
di
:
continue
li
=
di
[
"u"
]
if
isinstance
(
li
,
unicode
):
li
=
[
li
]
for
affiliation
in
li
:
if
reg_affiliation
.
search
(
affiliation
):
return
affiliation
return
u
""
def
find_authors
(
self
,
pattern
):
"""Find authors matching the regular expression C{pattern}.
...
...
tests/harvester/Record/test_acl_cds1951625.py
View file @
b070f03d
...
...
@@ -59,6 +59,11 @@ def test_collaboration(record):
assert
record
.
collaboration
()
==
"LHCb Collaboration"
def
test_find_affiliation
(
record
):
affiliation
=
record
.
find_affiliation
(
r
"Marseille, CPPM|CPPM, Marseille"
)
assert
affiliation
==
"Marseille, CPPM"
def
test_first_author
(
record
):
assert
record
.
first_author
()
==
"Aaij, Roel"
...
...
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