From 4dfb974a69150e18334ac1dd357c2282679dbce2 Mon Sep 17 00:00:00 2001 From: benne238 Date: Tue, 29 Jun 2021 13:22:59 -0400 Subject: [PATCH] add assignment parsing to item.py --- src/webqueue2api/parser/item.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/webqueue2api/parser/item.py b/src/webqueue2api/parser/item.py index 82119be..4f6c585 100644 --- a/src/webqueue2api/parser/item.py +++ b/src/webqueue2api/parser/item.py @@ -228,6 +228,9 @@ def __parse_sections(self) -> list: if section["type"] == "initial_message": body_sections[index] = self.__add_initial_message_headers(section) break + + # Add assignment sections to all the other sections + body_sections.extend(self.__get_assignments()) body_sections = self.__get_sorted_sections(body_sections) @@ -302,6 +305,22 @@ def __get_sorted_sections(self, sectionsList: list) -> list: return sortedSections + def __get_assignments(self) -> list: + assignment_list = [] + + for index, header in enumerate(self.headers): + if header["type"] == "Assigned-To": + assignment = { + "type": "assignment", + "to": self.headers[index]["content"], + "datetime": self.headers[index + 1]["content"], + "by": self.headers[index + 2]["content"] + + } + assignment_list.append(assignment) + + return assignment_list + def __check_is_locked(self) -> Union[str, bool]: """Returns a string info about the lock if true and a bool False if false