[PATCH dim 1/2] dim: Add support for multiple messages in extract-tags

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Make extract-tags process tags from all messages in the supplied
mbox. This allows the user to tag multiple replies and extract
all tags at once.

Signed-off-by: Sean Paul <seanpaul@xxxxxxxxxxxx>
---
 dim | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/dim b/dim
index 989674a..43ea794 100755
--- a/dim
+++ b/dim
@@ -342,25 +342,27 @@ if message_id is not None:
 EOF
 }
 
-message_print_body ()
+mbox_cat_messages ()
 {
 	python2 <<EOF
 import email
+import mailbox
 
 def print_part(part):
     mtype = part.get_content_maintype()
     if mtype == 'text':
         print(part.get_payload(decode=True))
 
-def print_msg(file):
-    msg = email.message_from_file(file)
+def print_msg(msg):
     if msg.is_multipart():
         for part in msg.get_payload():
             print_part(part)
     else:
         print_part(msg)
 
-print_msg(open('$1', 'r'))
+mbox = mailbox.mbox('$1', create=False)
+for m in mbox.values():
+    print_msg(m)
 EOF
 }
 
@@ -1157,7 +1159,7 @@ function dim_extract_tags
 
 	cat > $file
 
-	tags=$(message_print_body "$file" | grep -ai '^[^>]*[A-Za-z-]\+: [^ ]')
+	tags=$(mbox_cat_messages "$file" | grep -ai '^[^>]*[A-Za-z-]\+: [^ ]')
 
 	rm -f $file
 
-- 
2.12.1.500.gab5fba24ee-goog

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux