From 5815406ba5e0ef4dd7343cb27f569998b14d504d Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Sun, 5 Nov 2023 11:19:40 -0500 Subject: [PATCH] pretty output of abstract lister --- news/l_abstracts_lists_meeting.rst | 23 ++++++++++++++++ regolith/helpers/l_abstracthelper.py | 13 +++++++-- tests/test_helpers.py | 40 ++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 news/l_abstracts_lists_meeting.rst diff --git a/news/l_abstracts_lists_meeting.rst b/news/l_abstracts_lists_meeting.rst new file mode 100644 index 000000000..79ee1f038 --- /dev/null +++ b/news/l_abstracts_lists_meeting.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* Abstract lister now outputs the meeting name and basic information about the meeting of the presentation + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/regolith/helpers/l_abstracthelper.py b/regolith/helpers/l_abstracthelper.py index a653d8f52..954f743ba 100644 --- a/regolith/helpers/l_abstracthelper.py +++ b/regolith/helpers/l_abstracthelper.py @@ -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 @@ -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""" @@ -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)) @@ -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 diff --git a/tests/test_helpers.py b/tests/test_helpers.py index 4136b0392..45898da2f 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -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"