Skip to content

Instantly share code, notes, and snippets.

@kusano
Created May 29, 2018 15:20
Show Gist options
  • Save kusano/eb5e34d972896628e43c19573096868a to your computer and use it in GitHub Desktop.
Save kusano/eb5e34d972896628e43c19573096868a to your computer and use it in GitHub Desktop.
import sys
import re
mail = []
reform = re.compile(r"^From - \w{3} \w{3} \d\d \d\d:\d\d:\d\d \d\d\d\d\r?$")
restatus = re.compile(r"^(X-Mozilla-Status: )(\d\d\d\d)(\r?)$")
output = open("deleted", "wb")
def process():
deleted = False
for i in range(len(mail)):
m = restatus.match(mail[i])
if m:
status = int(m.group(2), 16)
if status & 0x8:
mail[i] = m.group(1)+"%04x"%(status^0x8)+m.group(3)
deleted = True
break
if deleted:
for m in mail:
output.write(m)
for line in open(r"xxx\Inbox", "rb"):
m = reform.match(line)
if m:
if len(mail)>=1 and (mail[-1]=="\n" or mail[-1]=="\r\n"):
process()
mail = []
mail += [line]
process()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment