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:
@@ -193,19 +193,19 @@ class MailConnection(object):
|
|||||||
result = u"From : "
|
result = u"From : "
|
||||||
for i in range(len(from_decoded)):
|
for i in range(len(from_decoded)):
|
||||||
if from_decoded[i][1]:
|
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:
|
else:
|
||||||
result += from_decoded[i][0]
|
result += unicode(from_decoded[i][0])
|
||||||
result += "\n"
|
result += "\n"
|
||||||
|
|
||||||
subject_decoded = email.Header.decode_header(email_msg["Subject"])
|
subject_decoded = email.Header.decode_header(email_msg["Subject"])
|
||||||
result += u"Subject : "
|
result += u"Subject : "
|
||||||
for i in range(len(subject_decoded)):
|
for i in range(len(subject_decoded)):
|
||||||
if subject_decoded[i][1]:
|
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:
|
else:
|
||||||
result += subject_decoded[i][0]
|
result += unicode(subject_decoded[i][0])
|
||||||
result += "\n\n"
|
result += u"\n\n"
|
||||||
|
|
||||||
if include_body:
|
if include_body:
|
||||||
action = {
|
action = {
|
||||||
@@ -215,7 +215,7 @@ class MailConnection(object):
|
|||||||
for part in email_msg.walk():
|
for part in email_msg.walk():
|
||||||
content_type = part.get_content_type()
|
content_type = part.get_content_type()
|
||||||
if action.has_key(content_type):
|
if action.has_key(content_type):
|
||||||
result += action[content_type](part) + '\n'
|
result += unicode(action[content_type](part)) + u'\n'
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def format_message_summary(self, email_msg):
|
def format_message_summary(self, email_msg):
|
||||||
@@ -226,7 +226,7 @@ class MailConnection(object):
|
|||||||
|
|
||||||
def get_status_msg(self):
|
def get_status_msg(self):
|
||||||
return self.get_type() + "://" + self.login + "@" + self.host + ":" + \
|
return self.get_type() + "://" + self.login + "@" + self.host + ":" + \
|
||||||
str(self.port)
|
unicode(self.port)
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
pass
|
pass
|
||||||
|
|||||||
12
run_test.py
12
run_test.py
@@ -1,10 +1,10 @@
|
|||||||
##
|
##
|
||||||
## test.py
|
## run_test.py
|
||||||
## Login : <adro8400@claralinux>
|
## Login : <david.rousselie@happycoders.org>
|
||||||
## Started on Wed May 18 13:33:03 2005 adro8400
|
## Started on Wed May 18 13:33:03 2005 David Rousselie
|
||||||
## $Id: run_test.py,v 1.2 2005/09/18 20:24:07 dax Exp $
|
## $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
|
## 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
|
## it under the terms of the GNU General Public License as published by
|
||||||
## the Free Software Foundation; either version 2 of the License, or
|
## the Free Software Foundation; either version 2 of the License, or
|
||||||
@@ -63,7 +63,7 @@ if __name__ == '__main__':
|
|||||||
component2_suite, \
|
component2_suite, \
|
||||||
storage_suite, \
|
storage_suite, \
|
||||||
dbmstorage_suite))
|
dbmstorage_suite))
|
||||||
test_support.run_suite(dbmstorage_suite)
|
test_support.run_suite(mail_connection_suite)
|
||||||
|
|
||||||
# coverage.stop()
|
# coverage.stop()
|
||||||
# coverage.analysis(jabber.mailconnection_factory)
|
# coverage.analysis(jabber.mailconnection_factory)
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
# -*- coding: iso-8859-15 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##
|
##
|
||||||
## mailconnection_test.py
|
## mailconnection_test.py
|
||||||
## Login : <adro8400@claralinux>
|
## Login : David Rousselie <david.rousselie@happycoders.org>
|
||||||
## Started on Fri May 13 11:32:51 2005 adro8400
|
## Started on Fri May 13 11:32:51 2005 David Rousselie
|
||||||
## $Id: test_mailconnection.py,v 1.2 2005/09/18 20:24:07 dax Exp $
|
## $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
|
## 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
|
## it under the terms of the GNU General Public License as published by
|
||||||
## the Free Software Foundation; either version 2 of the License, or
|
## 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 = \
|
test_get_decoded_part_encoded = \
|
||||||
make_test((True, False, False), \
|
make_test((True, False, False), \
|
||||||
lambda self, email: self.connection.get_decoded_part(email), \
|
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 = \
|
test_format_message_summary_not_encoded = \
|
||||||
make_test((False, False, True), \
|
make_test((False, False, True), \
|
||||||
@@ -64,8 +64,8 @@ class MailConnection_TestCase(unittest.TestCase):
|
|||||||
test_format_message_summary_encoded = \
|
test_format_message_summary_encoded = \
|
||||||
make_test((True, False, True), \
|
make_test((True, False, True), \
|
||||||
lambda self, email: self.connection.format_message_summary(email), \
|
lambda self, email: self.connection.format_message_summary(email), \
|
||||||
u"From : encoded from (<EFBFBD><EFBFBD><EFBFBD>)\nSubject : encoded subject " + \
|
u"From : encoded from (éàê)\nSubject : encoded subject " + \
|
||||||
u"(<EFBFBD><EFBFBD><EFBFBD>)\n\n")
|
u"(éàê)\n\n")
|
||||||
|
|
||||||
test_format_message_summary_partial_encoded = \
|
test_format_message_summary_partial_encoded = \
|
||||||
make_test((True, False, True), \
|
make_test((True, False, True), \
|
||||||
@@ -77,8 +77,8 @@ class MailConnection_TestCase(unittest.TestCase):
|
|||||||
"\"" + str(email["From"]) \
|
"\"" + str(email["From"]) \
|
||||||
+ "\" not encoded part") or \
|
+ "\" not encoded part") or \
|
||||||
self.connection.format_message_summary(email), \
|
self.connection.format_message_summary(email), \
|
||||||
u"From : \"encoded from (<EFBFBD><EFBFBD><EFBFBD>)\" not encoded part\nSubject " + \
|
u"From : \"encoded from (éàê)\" not encoded part\nSubject " + \
|
||||||
u": \"encoded subject (<EFBFBD><EFBFBD><EFBFBD>)\" not encoded part\n\n")
|
u": \"encoded subject (éàê)\" not encoded part\n\n")
|
||||||
|
|
||||||
test_format_message_single_not_encoded = \
|
test_format_message_single_not_encoded = \
|
||||||
make_test((False, False, True), \
|
make_test((False, False, True), \
|
||||||
@@ -89,9 +89,9 @@ class MailConnection_TestCase(unittest.TestCase):
|
|||||||
test_format_message_single_encoded = \
|
test_format_message_single_encoded = \
|
||||||
make_test((True, False, True), \
|
make_test((True, False, True), \
|
||||||
lambda self, email: self.connection.format_message(email), \
|
lambda self, email: self.connection.format_message(email), \
|
||||||
u"From : encoded from (<EFBFBD><EFBFBD><EFBFBD>)\nSubject : encoded subject " + \
|
u"From : encoded from (éàê)\nSubject : encoded subject " + \
|
||||||
u"(<EFBFBD><EFBFBD><EFBFBD>)\n\nEncoded single part with 'iso-8859-15' charset" + \
|
u"(éàê)\n\nEncoded single part with 'iso-8859-15' charset" + \
|
||||||
u" (\xe9\xe0\xea)\n")
|
u" (éàê)\n")
|
||||||
|
|
||||||
test_format_message_multi_not_encoded = \
|
test_format_message_multi_not_encoded = \
|
||||||
make_test((False, True, True), \
|
make_test((False, True, True), \
|
||||||
@@ -102,9 +102,9 @@ class MailConnection_TestCase(unittest.TestCase):
|
|||||||
test_format_message_multi_encoded = \
|
test_format_message_multi_encoded = \
|
||||||
make_test((True, True, True), \
|
make_test((True, True, True), \
|
||||||
lambda self, email: self.connection.format_message(email), \
|
lambda self, email: self.connection.format_message(email), \
|
||||||
u"From : encoded from (<EFBFBD><EFBFBD><EFBFBD>)\nSubject : encoded subject (<EFBFBD><EFBFBD>" + \
|
u"From : encoded from (éàê)\nSubject : encoded subject (éà" + \
|
||||||
u"<EFBFBD>)\n\nEncoded multipart1 with 'iso-8859-15' charset (<EFBFBD><EFBFBD><EFBFBD>" + \
|
u"ê)\n\nEncoded multipart1 with 'iso-8859-15' charset (éàê" + \
|
||||||
u")\nEncoded multipart2 with 'iso-8859-15' charset (<EFBFBD><EFBFBD><EFBFBD>)\n")
|
u")\nEncoded multipart2 with 'iso-8859-15' charset (éàê)\n")
|
||||||
|
|
||||||
|
|
||||||
class POP3Connection_TestCase(unittest.TestCase):
|
class POP3Connection_TestCase(unittest.TestCase):
|
||||||
|
|||||||
Reference in New Issue
Block a user