Skip to content

Commit

Permalink
feat: add authors list to descirbe function in regtap
Browse files Browse the repository at this point in the history
  • Loading branch information
ManonMarchand committed Oct 2, 2023
1 parent 93d264d commit 2f646af
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
15 changes: 11 additions & 4 deletions pyvo/registry/regtap.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,12 +835,19 @@ def describe(self, verbose=False, width=78, file=None):
file=file)

if verbose:
if self.reference_url:
print("More info: " + self.reference_url, file=file)
if self.source_value:
print(f"\nSource: {self.source_value}", file=file)
if self.creators:
nmax_authors = 5
if len(self.creators) <= nmax_authors:
print(f"Authors: {', '.join(self.creators)}", file=file)
else:
print(f"Authors: {', '.join(self.creators[:nmax_authors])} et al.\n"
"See creators attribute for the complete list of authors.", file=file)
if self.alt_identifier:
print(f"Alternative identifier: {self.alt_identifier}", file=file)
if self.source_value:
print(f"Source: {self.source_value}", file=file)
if self.reference_url:
print("More info: " + self.reference_url, file=file)

def get_contact(self):
"""
Expand Down
22 changes: 21 additions & 1 deletion pyvo/registry/tests/test_regtap.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,28 @@ def test_describe_multi(self, flash_service):
" ssa, tap#aux, web" in output)
assert "Multi-capability service" in output
assert "Source: 1996A&A...312..539S" in output
assert "More info: http://dc.zah" in output
assert "Authors: Wolf" in output
assert "Alternative identifier: doi:10.21938/" in output
assert "More info: http://dc.zah" in output

def test_describe_long_authors_list(self):
# generate a registry record with minimum
# information for the describe method and
# a long list of authors
rsc = _makeRegistryRecord(
access_urls=[],
standard_ids=["ivo://pyvo/test"],
short_name=["name"],
intf_types=[],
intf_roles=[],
creator_seq=["a;" * 6],
res_title=["title"]
)
out = io.StringIO()
rsc.describe(verbose=True, file=out)
output = out.getvalue()
# output should cut at 5 authors
assert "Authors: a, a, a, a, a et al." in output

def test_no_access_url(self):
rsc = _makeRegistryRecord(
Expand Down

0 comments on commit 2f646af

Please sign in to comment.