Skip to content

Commit

Permalink
Merge pull request #1049 from sbillinge/l_abstracts_lists_meeting
Browse files Browse the repository at this point in the history
pretty output of abstract lister
  • Loading branch information
sbillinge authored Nov 5, 2023
2 parents 1471ed7 + 74e137a commit ab68ed3
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 4 deletions.
24 changes: 24 additions & 0 deletions news/l_abstracts_lists_meeting.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
**Added:**

* <news item>

**Changed:**

* Abstract lister now outputs the meeting name and basic information about the meeting of the presentation
* Abstract lister now lists in date order

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
20 changes: 16 additions & 4 deletions regolith/helpers/l_abstracthelper.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import operator

from regolith.dates import get_dates
from regolith.helpers.basehelper import SoutHelperBase
from regolith.fsclient import _id_key
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 +50,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 +77,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 @@ -125,9 +128,18 @@ def sout(self):
for talk in presentations
if all(talk in presentations
for presentations in nonempty_filtered_presentations_by_args)]
flat_filtered_presentations = list({talk['_id']: talk for talk in filtered_presentations}.values())

for talk in filtered_presentations:
talk.update({"meeting_date": get_dates(talk).get('date', get_dates(talk).get('end_date', get_dates(talk).get('begin_date')))})
filtered_presentations_sorted = sorted(filtered_presentations, key=operator.itemgetter('meeting_date'))
flat_filtered_presentations = list({talk['_id']: talk for talk in filtered_presentations_sorted}.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')}"
print("\n---------------------------------------")
print(f"{presentation.get('meeting_date').isoformat()} - {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---------------------------------------\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---------------------------------------\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---------------------------------------\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---------------------------------------\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---------------------------------------\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---------------------------------------\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---------------------------------------\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---------------------------------------\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---------------------------------------\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---------------------------------------\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---------------------------------------\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---------------------------------------\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---------------------------------------\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---------------------------------------\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---------------------------------------\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---------------------------------------\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---------------------------------------\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---------------------------------------\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---------------------------------------\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---------------------------------------\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 ab68ed3

Please sign in to comment.