Skip to content

Commit

Permalink
pretty output of abstract lister
Browse files Browse the repository at this point in the history
  • Loading branch information
sbillinge committed Nov 5, 2023
1 parent 05a000b commit 5815406
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 2 deletions.
23 changes: 23 additions & 0 deletions news/l_abstracts_lists_meeting.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* <news item>

**Changed:**

* Abstract lister now outputs the meeting name and basic information about the meeting of the presentation

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
13 changes: 11 additions & 2 deletions regolith/helpers/l_abstracthelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from regolith.tools import (
all_docs_from_collection,
get_pi_id,
get_person_contact
get_person_contact, dereference_institution
)
from gooey import GooeyParser

Expand Down Expand Up @@ -48,7 +48,7 @@ class AbstractListerHelper(SoutHelperBase):
"""
# btype must be the same as helper target in helper.py
btype = HELPER_TARGET
needed_colls = [f'{TARGET_COLL}', 'people', 'contacts']
needed_colls = [f'{TARGET_COLL}', 'people', 'contacts', 'institutions']

def construct_global_ctx(self):
"""Constructs the global context"""
Expand All @@ -75,6 +75,7 @@ def sout(self):
rc = self.rc

presentations = self.gtx["presentations"]
institutions = self.gtx["institutions"]
SEMINAR_TYPES = ['seminar', 'colloquium']
filtered_title, filtered_authors, filtered_years, filtered_inst, filtered_loc = ([] for i in range(5))

Expand Down Expand Up @@ -128,6 +129,14 @@ def sout(self):
flat_filtered_presentations = list({talk['_id']: talk for talk in filtered_presentations}.values())

for presentation in flat_filtered_presentations:
if presentation.get("type") in SEMINAR_TYPES:
dereference_institution(presentation, institutions)
meeting_info = f"{presentation.get('type').title()} {presentation.get('department')}, {presentation.get('institution')}"
else:
meeting_info = f"{presentation.get('meeting_name')}, {presentation.get('location')}"
meeting_date = get_dates(presentation).get('date', get_dates(presentation).get('end_date', get_dates(presentation).get('begin_date'))).isoformat()
print("---------------------------------------")
print(f"{meeting_date} - {meeting_info}")
print("---------------------------------------")
print(f"Title: {presentation.get('title')}\n")
author_list = [author
Expand Down
40 changes: 40 additions & 0 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,104 +262,144 @@
" -A. B. Friend\n -AB Friend\n -Tony Friend\n"
),
(["helper", "l_abstract", "--year", "2018", "--author", "afriend"],
"---------------------------------------\n"
"2018-05-22 - Meeting to check flexibility on dates, Upton NY\n"
"---------------------------------------\n"
"Title: Graphitic Dephenestration\n\n"
"Anthony Scopatz, Anthony B Friend\n\n"
"Abstract: We pulled apart graphite with tape\n"
),
(["helper", "l_abstract", "--year", "2018", "--title", "nanostructure"],
"---------------------------------------\n"
"2018-05-22 - Colloquium Department of Physics, Columbia University\n"
"---------------------------------------\n"
"Title: Nanostructure challenges and successes from 16th Century warships to 21st Century energy\n\n"
"Anthony Scopatz\n\n"
"Abstract: We made the case for local structure\n"
),
(["helper", "l_abstract", "--title", "graphitic"],
"---------------------------------------\n"
"2018-05-22 - Meeting to check flexibility on dates, Upton NY\n"
"---------------------------------------\n"
"Title: Graphitic Dephenestration\n\n"
"Anthony Scopatz, Anthony B Friend\n\n"
"Abstract: We pulled apart graphite with tape\n"
),
(["helper", "l_abstract", "--title", "graphitic", "--loc-inst", "upton"],
"---------------------------------------\n"
"2018-05-22 - Meeting to check flexibility on dates, Upton NY\n"
"---------------------------------------\n"
"Title: Graphitic Dephenestration\n\n"
"Anthony Scopatz, Anthony B Friend\n\n"
"Abstract: We pulled apart graphite with tape\n"
),
(["helper", "l_abstract", "--loc-inst", "upton"],
"---------------------------------------\n"
"2018-05-22 - 2018 NSLS-II and CFN Users Meeting, Upton NY\n"
"---------------------------------------\n"
"Title: ClusterMining: extracting core structures of metallic nanoparticles from the atomic pair distribution function\n\n"
"Anthony Scopatz\n\n"
"Abstract: We pulled apart graphite with tape\n"
"---------------------------------------\n"
"2018-05-22 - Meeting to check flexibility on dates, Upton NY\n"
"---------------------------------------\n"
"Title: Graphitic Dephenestration\n\n"
"Anthony Scopatz, Anthony B Friend\n\n"
"Abstract: We pulled apart graphite with tape\n"
),
(["helper", "l_abstract", "--loc-inst", "upton", "--year", "2018"],
"---------------------------------------\n"
"2018-05-22 - 2018 NSLS-II and CFN Users Meeting, Upton NY\n"
"---------------------------------------\n"
"Title: ClusterMining: extracting core structures of metallic nanoparticles from the atomic pair distribution function\n\n"
"Anthony Scopatz\n\n"
"Abstract: We pulled apart graphite with tape\n"
"---------------------------------------\n"
"2018-05-22 - Meeting to check flexibility on dates, Upton NY\n"
"---------------------------------------\n"
"Title: Graphitic Dephenestration\n\n"
"Anthony Scopatz, Anthony B Friend\n\n"
"Abstract: We pulled apart graphite with tape\n"
),
(["helper", "l_abstract", "--year", "2018"],
"---------------------------------------\n"
"2018-05-22 - Colloquium Department of Physics, Columbia University\n"
"---------------------------------------\n"
"Title: Nanostructure challenges and successes from 16th Century warships to 21st Century energy\n\n"
"Anthony Scopatz\n\n"
"Abstract: We made the case for local structure\n"
"---------------------------------------\n"
"2018-05-22 - 2018 NSLS-II and CFN Users Meeting, Upton NY\n"
"---------------------------------------\n"
"Title: ClusterMining: extracting core structures of metallic nanoparticles from the atomic pair distribution function\n\n"
"Anthony Scopatz\n\n"
"Abstract: We pulled apart graphite with tape\n"
"---------------------------------------\n"
"2018-05-22 - Meeting to check flexibility on dates, Upton NY\n"
"---------------------------------------\n"
"Title: Graphitic Dephenestration\n\n"
"Anthony Scopatz, Anthony B Friend\n\n"
"Abstract: We pulled apart graphite with tape\n"
),
(["helper", "l_abstract", "--author", "scopatz"],
"---------------------------------------\n"
"2018-05-22 - Colloquium Department of Physics, Columbia University\n"
"---------------------------------------\n"
"Title: Nanostructure challenges and successes from 16th Century warships to 21st Century energy\n\n"
"Anthony Scopatz\n\n"
"Abstract: We made the case for local structure\n"
"---------------------------------------\n"
"2018-05-22 - 2018 NSLS-II and CFN Users Meeting, Upton NY\n"
"---------------------------------------\n"
"Title: ClusterMining: extracting core structures of metallic nanoparticles from the atomic pair distribution function\n\n"
"Anthony Scopatz\n\n"
"Abstract: We pulled apart graphite with tape\n"
"---------------------------------------\n"
"2018-05-22 - Meeting to check flexibility on dates, Upton NY\n"
"---------------------------------------\n"
"Title: Graphitic Dephenestration\n\n"
"Anthony Scopatz, Anthony B Friend\n\n"
"Abstract: We pulled apart graphite with tape\n"
),
(["helper", "l_abstract", "--loc-inst", "upton", "--year", "2018"],
"---------------------------------------\n"
"2018-05-22 - 2018 NSLS-II and CFN Users Meeting, Upton NY\n"
"---------------------------------------\n"
"Title: ClusterMining: extracting core structures of metallic nanoparticles from the atomic pair distribution function\n\n"
"Anthony Scopatz\n\n"
"Abstract: We pulled apart graphite with tape\n"
"---------------------------------------\n"
"2018-05-22 - Meeting to check flexibility on dates, Upton NY\n"
"---------------------------------------\n"
"Title: Graphitic Dephenestration\n\n"
"Anthony Scopatz, Anthony B Friend\n\n"
"Abstract: We pulled apart graphite with tape\n"
),
(["helper", "l_abstract", "--author", "scopatz", "--loc-inst", "upton"],
"---------------------------------------\n"
"2018-05-22 - 2018 NSLS-II and CFN Users Meeting, Upton NY\n"
"---------------------------------------\n"
"Title: ClusterMining: extracting core structures of metallic nanoparticles from the atomic pair distribution function\n"
"\nAnthony Scopatz\n"
"\nAbstract: We pulled apart graphite with tape\n"
"---------------------------------------\n"
"2018-05-22 - Meeting to check flexibility on dates, Upton NY\n"
"---------------------------------------\n"
"Title: Graphitic Dephenestration\n\n"
"Anthony Scopatz, Anthony B Friend\n\n"
"Abstract: We pulled apart graphite with tape\n"
),
(["helper", "l_abstract", "--author", "scopatz", "--year", "2018", "--loc-inst", "upton", "--title", "graphitic"],
"---------------------------------------\n"
"2018-05-22 - Meeting to check flexibility on dates, Upton NY\n"
"---------------------------------------\n"
"Title: Graphitic Dephenestration\n\n"
"Anthony Scopatz, Anthony B Friend\n\n"
"Abstract: We pulled apart graphite with tape\n"
),
(["helper", "l_abstract", "--loc-inst", "columbiau"],
"---------------------------------------\n"
"2018-05-22 - Colloquium Department of Physics, Columbia University\n"
"---------------------------------------\n"
"Title: Nanostructure challenges and successes from 16th Century warships to 21st Century energy\n\n"
"Anthony Scopatz\n\n"
Expand Down

0 comments on commit 5815406

Please sign in to comment.