From 89d63f768f54f61056d0d4cec37800ac4dd9a0bc Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Fri, 25 Aug 2023 01:27:26 +1200 Subject: [PATCH] buildmimetree.py: list only becomes mp/mixed if len>1 --- .config/neomutt/buildmimetree.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.config/neomutt/buildmimetree.py b/.config/neomutt/buildmimetree.py index 4ab7a54..779f60b 100755 --- a/.config/neomutt/buildmimetree.py +++ b/.config/neomutt/buildmimetree.py @@ -350,9 +350,11 @@ class MIMETreeDFWalker: Recursive function to implement a depth-dirst walk of the MIME-tree rooted at `root`. """ - if isinstance(root, list): - root = Multipart("mixed", children=root) + if len(root) > 1: + root = Multipart("mixed", children=root) + else: + root = root[0] self._walk( root, @@ -723,14 +725,17 @@ try: assert items[4][0].subtype == "relative" assert items[4][1] == 0 - def test_MIMETreeDFWalker_list_to_mixed(self, basic_mime_tree): + def test_MIMETreeDFWalker_list_to_mixed(self, const1): mimetree = MIMETreeDFWalker() items = [] def visitor_fn(item, stack, debugprint): items.append(item) - mimetree.walk([basic_mime_tree], visitor_fn=visitor_fn) + p = Part("text", "plain", const1) + mimetree.walk([p], visitor_fn=visitor_fn) + assert items[-1].subtype == "plain" + mimetree.walk([p, p], visitor_fn=visitor_fn) assert items[-1].subtype == "mixed" def test_MIMETreeDFWalker_visitor_in_constructor( -- 2.39.5