1:
msg = "Please open one message at a time"
else:
msg = "Please select a message to open"
dialog(root, "Can't Open Message", msg, "", 0, "OK")
return
cursor = scanbox['cursor']
scanbox['cursor'] = 'watch'
tk.call('update', 'idletasks')
i = sel[0]
line = scanbox.get(i)
if scanparser.match(line) >= 0:
num = string.atoi(scanparser.group(1))
m = mhf.openmessage(num)
if viewer: viewer.destroy()
from MimeViewer import MimeViewer
viewer = MimeViewer(bot, '+%s/%d' % (folder, num), m)
viewer.pack()
viewer.show()
scanbox['cursor'] = cursor
def interestingheader(header):
return header != 'received'
def remove_message(e=None):
itop = scanbox.nearest(0)
sel = scanbox.curselection()
if not sel:
dialog(root, "No Message To Remove",
"Please select a message to remove", "", 0, "OK")
return
todo = []
for i in sel:
line = scanbox.get(i)
if scanparser.match(line) >= 0:
todo.append(string.atoi(scanparser.group(1)))
mhf.removemessages(todo)
rescan()
fixfocus(min(todo), itop)
lastrefile = ''
tofolder = None
def refile_message(e=None):
global lastrefile, tofolder
itop = scanbox.nearest(0)
sel = scanbox.curselection()
if not sel:
dialog(root, "No Message To Refile",
"Please select a message to refile", "", 0, "OK")
return
foldersel = folderbox.curselection()
if len(foldersel) != 1:
if not foldersel:
msg = "Please select a folder to refile to"
else:
msg = "Please select exactly one folder to refile to"
dialog(root, "No Folder To Refile", msg, "", 0, "OK")
return
refileto = folderbox.get(foldersel[0])
todo = []
for i in sel:
line = scanbox.get(i)
if scanparser.match(line) >= 0:
todo.append(string.atoi(scanparser.group(1)))
if lastrefile != refileto or not tofolder:
lastrefile = refileto
tofolder = None
tofolder = mh.openfolder(lastrefile)
mhf.refilemessages(todo, tofolder)
rescan()
fixfocus(min(todo), itop)
def fixfocus(near, itop):
n = scanbox.size()
for i in range(n):
line = scanbox.get(repr(i))
if scanparser.match(line) >= 0:
num = string.atoi(scanparser.group(1))
if num >= near:
break
else:
i = 'end'
scanbox.select_from(i)
scanbox.yview(itop)
def setfolders():
folderbox.delete(0, 'end')
for fn in mh.listallfolders():
folderbox.insert('end', fn)
def rescan():
global viewer
if viewer:
viewer.destroy()
viewer = None
scanbox.delete(0, 'end')
for line in scanfolder(folder, seq):
scanbox.insert('end', line)
def scanfolder(folder = 'inbox', sequence = 'all'):
return map(
lambda line: line[:-1],
os.popen('scan +%s %s' % (folder, sequence), 'r').readlines())
main()