Commit 2e792df6 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add the methods RecordPubli.is_authors, is_affiliations.

parent 96316ea2
......@@ -244,6 +244,40 @@ class RecordPubli(Record):
return li
def is_affiliations(self):
"""C{True} when affiliations are defined for authors.
This is a fast algorithm checking only first and last authors.
To check that the affiliation is defined for all authors,
uses the method is_affiliation_for_all.
@rtype: bool
for field in (u"100", u"700"):
if field in self:
if isinstance(self[field], dict):
if "u" not in self[field]:
return False
elif isinstance(self[field], list):
for i in (1, -1):
if "u" not in self[field][i]:
return False
return True
def is_authors(self):
"""C{True} when authors are defined.
@rtype: bool
return u"100" in self or u"700" in self
def is_institute_defined(self):
"""C{True} when institutes are defined for all authors.
......@@ -32,6 +32,9 @@ def record():
def test_authors(record):
assert record.is_authors() == True
authors = record.authors_as_list()
assert len(authors) == 703
......@@ -61,13 +64,15 @@ def test_id(record):
def test_institutes(record):
assert record.is_affiliations() == True
assert record.is_institute_defined() == True
institutes = record.institutes()
assert institutes[0] == "AGH-UST, Cracow"
assert institutes[44] == "MIT"
assert institutes[-1] == "Zurich U."
assert record.is_institute_defined() == True
def test_is_article(record):
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