small fixes and improvements
This commit is contained in:
@@ -73,7 +73,7 @@ class MailThread(Base):
|
||||
a=[]
|
||||
# print "maildicts: "+ str(self.mails())
|
||||
for m in self.mails():
|
||||
m.compile_envelope()
|
||||
# m.compile_envelope()
|
||||
a.append(m.dict_envelope())
|
||||
return a
|
||||
|
||||
@@ -85,6 +85,9 @@ class MailThread(Base):
|
||||
for i in range(0,len(dc)):
|
||||
for k, v in dc[i].iteritems():
|
||||
d["mail_"+str(i)+"_"+k]=v
|
||||
for k, v in dc[-1].iteritems():
|
||||
d["mail_last_"+k]=v
|
||||
|
||||
return d
|
||||
|
||||
def subject(self):
|
||||
@@ -103,30 +106,13 @@ class MailThread(Base):
|
||||
self.date=self.mails()[0].date
|
||||
|
||||
def print_text(self,filter="all"):
|
||||
a=u""
|
||||
def mail_txt(m):
|
||||
#txt ="Gesendet von: "+ str(m.from_mailbox)+"@"+str(m.from_host) +"\n"
|
||||
txt=""
|
||||
fr=yaml.load(m.from_)
|
||||
txt= txt+ "Gesendet von: "+str(fr[0]["mail"])+"@"+str(fr[0]["host"])+" am "+ str(m.date) + "\n"
|
||||
t=yaml.load(m.text)
|
||||
if type(t) is unicode:
|
||||
#txt=txt
|
||||
txt=txt+t
|
||||
else:
|
||||
t=t.decode("ISO-8859-1")
|
||||
txt=txt+t
|
||||
return txt
|
||||
|
||||
a=[]
|
||||
if filter=="all":
|
||||
mm=self.mails()
|
||||
for m in mm:
|
||||
a=a+mail_txt(m)+"\n****........................................***\n"
|
||||
a.append(m.print_text())
|
||||
elif filter=="first":
|
||||
a=mail_txt(m[0])
|
||||
a=re.sub(r'\n\s*\n',r'\n',a)
|
||||
a=re.sub(r'<!--.*-->',r'',a,flags=re.MULTILINE|re.DOTALL)
|
||||
a=re.sub(r'\s*>+ .*\n',r'',a)
|
||||
a.append(m[0].print_text())
|
||||
return a
|
||||
def text(self,filter="all"):
|
||||
a=u""
|
||||
@@ -143,7 +129,7 @@ class MailThread(Base):
|
||||
for m in mm:
|
||||
a=a+mail_txt(m)+"\n****........................................***\n"
|
||||
elif filter=="first":
|
||||
a=mail_txt(m[0])
|
||||
a=mail_txt(mm[0])
|
||||
a=re.sub(r'\n\s*\n',r'\n',a)
|
||||
a=re.sub(r'<!--.*-->',r'',a,flags=re.MULTILINE|re.DOTALL)
|
||||
a=re.sub(r'\s*>+ .*\n',r'',a)
|
||||
|
||||
Reference in New Issue
Block a user