Unicode everything

- Convert every strings to be sent in jabber messages in MailConnection to unicode.

darcs-hash:20060129133009-86b55-f5ea2d43f4187dd33383fa940108e23df4c3bec7.gz
This commit is contained in:
David Rousselie
2006-01-29 14:30:09 +01:00
parent 8fdd9d3be4
commit 6bbdb0be31
3 changed files with 29 additions and 29 deletions

View File

@@ -193,19 +193,19 @@ class MailConnection(object):
result = u"From : "
for i in range(len(from_decoded)):
if from_decoded[i][1]:
result += from_decoded[i][0].decode(from_decoded[i][1])
result += unicode(from_decoded[i][0].decode(from_decoded[i][1]))
else:
result += from_decoded[i][0]
result += unicode(from_decoded[i][0])
result += "\n"
subject_decoded = email.Header.decode_header(email_msg["Subject"])
result += u"Subject : "
for i in range(len(subject_decoded)):
if subject_decoded[i][1]:
result += subject_decoded[i][0].decode(subject_decoded[i][1])
result += unicode(subject_decoded[i][0].decode(subject_decoded[i][1]))
else:
result += subject_decoded[i][0]
result += "\n\n"
result += unicode(subject_decoded[i][0])
result += u"\n\n"
if include_body:
action = {
@@ -215,7 +215,7 @@ class MailConnection(object):
for part in email_msg.walk():
content_type = part.get_content_type()
if action.has_key(content_type):
result += action[content_type](part) + '\n'
result += unicode(action[content_type](part)) + u'\n'
return result
def format_message_summary(self, email_msg):
@@ -226,7 +226,7 @@ class MailConnection(object):
def get_status_msg(self):
return self.get_type() + "://" + self.login + "@" + self.host + ":" + \
str(self.port)
unicode(self.port)
def connect(self):
pass

View File

@@ -1,10 +1,10 @@
##
## test.py
## Login : <adro8400@claralinux>
## Started on Wed May 18 13:33:03 2005 adro8400
## $Id: run_test.py,v 1.2 2005/09/18 20:24:07 dax Exp $
## run_test.py
## Login : <david.rousselie@happycoders.org>
## Started on Wed May 18 13:33:03 2005 David Rousselie
## $Id: run_test.py,v 1.2 2005/09/18 20:24:07 David Rousselie Exp $
##
## Copyright (C) 2005 adro8400
## Copyright (C) 2005 David Rousselie
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
@@ -63,7 +63,7 @@ if __name__ == '__main__':
component2_suite, \
storage_suite, \
dbmstorage_suite))
test_support.run_suite(dbmstorage_suite)
test_support.run_suite(mail_connection_suite)
# coverage.stop()
# coverage.analysis(jabber.mailconnection_factory)

View File

@@ -1,11 +1,11 @@
# -*- coding: iso-8859-15 -*-
# -*- coding: utf-8 -*-
##
## mailconnection_test.py
## Login : <adro8400@claralinux>
## Started on Fri May 13 11:32:51 2005 adro8400
## $Id: test_mailconnection.py,v 1.2 2005/09/18 20:24:07 dax Exp $
## Login : David Rousselie <david.rousselie@happycoders.org>
## Started on Fri May 13 11:32:51 2005 David Rousselie
## $Id: test_mailconnection.py,v 1.2 2005/09/18 20:24:07 David Rousselie Exp $
##
## Copyright (C) 2005 adro8400
## Copyright (C) 2005 David Rousselie
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
@@ -54,7 +54,7 @@ class MailConnection_TestCase(unittest.TestCase):
test_get_decoded_part_encoded = \
make_test((True, False, False), \
lambda self, email: self.connection.get_decoded_part(email), \
u"Encoded single part with 'iso-8859-15' charset (<EFBFBD><EFBFBD><EFBFBD>)")
u"Encoded single part with 'iso-8859-15' charset (éàê)")
test_format_message_summary_not_encoded = \
make_test((False, False, True), \
@@ -64,8 +64,8 @@ class MailConnection_TestCase(unittest.TestCase):
test_format_message_summary_encoded = \
make_test((True, False, True), \
lambda self, email: self.connection.format_message_summary(email), \
u"From : encoded from (<EFBFBD><EFBFBD><EFBFBD>)\nSubject : encoded subject " + \
u"(<EFBFBD><EFBFBD><EFBFBD>)\n\n")
u"From : encoded from (éàê)\nSubject : encoded subject " + \
u"(éàê)\n\n")
test_format_message_summary_partial_encoded = \
make_test((True, False, True), \
@@ -77,8 +77,8 @@ class MailConnection_TestCase(unittest.TestCase):
"\"" + str(email["From"]) \
+ "\" not encoded part") or \
self.connection.format_message_summary(email), \
u"From : \"encoded from (<EFBFBD><EFBFBD><EFBFBD>)\" not encoded part\nSubject " + \
u": \"encoded subject (<EFBFBD><EFBFBD><EFBFBD>)\" not encoded part\n\n")
u"From : \"encoded from (éàê)\" not encoded part\nSubject " + \
u": \"encoded subject (éàê)\" not encoded part\n\n")
test_format_message_single_not_encoded = \
make_test((False, False, True), \
@@ -89,9 +89,9 @@ class MailConnection_TestCase(unittest.TestCase):
test_format_message_single_encoded = \
make_test((True, False, True), \
lambda self, email: self.connection.format_message(email), \
u"From : encoded from (<EFBFBD><EFBFBD><EFBFBD>)\nSubject : encoded subject " + \
u"(<EFBFBD><EFBFBD><EFBFBD>)\n\nEncoded single part with 'iso-8859-15' charset" + \
u" (\xe9\xe0\xea)\n")
u"From : encoded from (éàê)\nSubject : encoded subject " + \
u"(éàê)\n\nEncoded single part with 'iso-8859-15' charset" + \
u" (éàê)\n")
test_format_message_multi_not_encoded = \
make_test((False, True, True), \
@@ -102,9 +102,9 @@ class MailConnection_TestCase(unittest.TestCase):
test_format_message_multi_encoded = \
make_test((True, True, True), \
lambda self, email: self.connection.format_message(email), \
u"From : encoded from (<EFBFBD><EFBFBD><EFBFBD>)\nSubject : encoded subject (<EFBFBD><EFBFBD>" + \
u"<EFBFBD>)\n\nEncoded multipart1 with 'iso-8859-15' charset (<EFBFBD><EFBFBD><EFBFBD>" + \
u")\nEncoded multipart2 with 'iso-8859-15' charset (<EFBFBD><EFBFBD><EFBFBD>)\n")
u"From : encoded from (éàê)\nSubject : encoded subject (éà" + \
u"ê)\n\nEncoded multipart1 with 'iso-8859-15' charset (éàê" + \
u")\nEncoded multipart2 with 'iso-8859-15' charset (éàê)\n")
class POP3Connection_TestCase(unittest.TestCase):