def test_with_scissor(self): patch = self._load_msg_from_file("scissor/patch.eml") reply = self._load_msg_from_file("scissor/reply.eml") thread = emailthreads.parse(reply, [patch]) got = self._normalize(str(thread)) want = self._read_file("scissor/output.txt") self.assertEqual(got, want)
def test_with_multiple_replies(self): patch = self._load_msg_from_file("multiple-replies/patch.eml") reply1 = self._load_msg_from_file("multiple-replies/reply1.eml") reply2 = self._load_msg_from_file("multiple-replies/reply2.eml") reply3 = self._load_msg_from_file("multiple-replies/reply3.eml") thread = emailthreads.parse(reply3, [patch, reply1, reply2]) got = self._normalize(str(thread)) want = self._read_file("multiple-replies/output3.txt") self.assertEqual(got, want)
import sys import emailthreads from email import message_from_file if __name__ == '__main__': if len(sys.argv) < 2: print("usage: python3 -m emailthreads <files...>", file=sys.stderr) sys.exit(1) files = sys.argv[1:] messages = [] for path in files: with open(path) as f: msg = message_from_file(f) messages.append(msg) thread = emailthreads.parse(messages) print(str(thread))