File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -892,10 +892,32 @@ def processUnixMailbox(self, archfile):
892892 """Process a Unix mailbox file."""
893893 from email import message_from_file
894894 from mailbox import mbox
895- mbox = mbox (archfile )
896- for key in mbox .keys ():
897- msg = message_from_file (mbox .get_file (key ))
898- self .add_article (msg )
895+
896+ # If archfile is a file object, we need to read it directly
897+ if hasattr (archfile , 'read' ):
898+ # Read the entire file content
899+ content = archfile .read ()
900+ # Create a temporary file to store the content
901+ import tempfile
902+ with tempfile .NamedTemporaryFile (mode = 'w+' , delete = False ) as tmp :
903+ tmp .write (content )
904+ tmp_path = tmp .name
905+
906+ try :
907+ # Process the temporary file
908+ mbox = mbox (tmp_path )
909+ for key in mbox .keys ():
910+ msg = message_from_file (mbox .get_file (key ))
911+ self .add_article (msg )
912+ finally :
913+ # Clean up the temporary file
914+ os .unlink (tmp_path )
915+ else :
916+ # If it's a path, use it directly
917+ mbox = mbox (archfile )
918+ for key in mbox .keys ():
919+ msg = message_from_file (mbox .get_file (key ))
920+ self .add_article (msg )
899921
900922 def format_article (self , article ):
901923 """Format an article for HTML display."""
You can’t perform that action at this time.
0 commit comments