Mercurial > libervia-backend
comparison src/plugins/plugin_misc_imap.py @ 1409:3265a2639182
massive (preventive) addition of 'u' (unicode) before the strings passed to logging functions
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 16 Apr 2015 14:57:57 +0200 |
parents | 84d06701f5c4 |
children | 2daf7b4c6756 |
comparison
equal
deleted
inserted
replaced
1408:8a7145138330 | 1409:3265a2639182 |
---|---|
106 @param names: The names of the headers to retrieve or omit. | 106 @param names: The names of the headers to retrieve or omit. |
107 @param negate: If True, indicates that the headers listed in names | 107 @param negate: If True, indicates that the headers listed in names |
108 should be omitted from the return value, rather than included. | 108 should be omitted from the return value, rather than included. |
109 @return: A mapping of header field names to header field values | 109 @return: A mapping of header field names to header field values |
110 """ | 110 """ |
111 log.debug('getHeaders %s - %s' % (negate, names)) | 111 log.debug(u'getHeaders %s - %s' % (negate, names)) |
112 final_dict = {} | 112 final_dict = {} |
113 to_check = [name.lower() for name in names] | 113 to_check = [name.lower() for name in names] |
114 for header in self.message.keys(): | 114 for header in self.message.keys(): |
115 if (negate and not header.lower() in to_check) or \ | 115 if (negate and not header.lower() in to_check) or \ |
116 (not negate and header.lower() in to_check): | 116 (not negate and header.lower() in to_check): |
149 implements(imap4.IMailbox) | 149 implements(imap4.IMailbox) |
150 | 150 |
151 def __init__(self, host, name, profile): | 151 def __init__(self, host, name, profile): |
152 self.host = host | 152 self.host = host |
153 self.listeners = set() | 153 self.listeners = set() |
154 log.debug('Mailbox init (%s)' % name) | 154 log.debug(u'Mailbox init (%s)' % name) |
155 if name != "INBOX": | 155 if name != "INBOX": |
156 raise imap4.MailboxException("Only INBOX is managed for the moment") | 156 raise imap4.MailboxException("Only INBOX is managed for the moment") |
157 self.mailbox = self.host.plugins["Maildir"].accessMessageBox(name, self.newMessage, profile) | 157 self.mailbox = self.host.plugins["Maildir"].accessMessageBox(name, self.newMessage, profile) |
158 | 158 |
159 def newMessage(self): | 159 def newMessage(self): |
178 def getUID(self, message): | 178 def getUID(self, message): |
179 """Return the UID of a message in the mailbox | 179 """Return the UID of a message in the mailbox |
180 @param message: The message sequence number | 180 @param message: The message sequence number |
181 @return: The UID of the message. | 181 @return: The UID of the message. |
182 """ | 182 """ |
183 log.debug('getUID (%i)' % message) | 183 log.debug(u'getUID (%i)' % message) |
184 #return self.mailbox.getUid(message-1) #XXX: it seems that this method get uid and not message sequence number | 184 #return self.mailbox.getUid(message-1) #XXX: it seems that this method get uid and not message sequence number |
185 return message | 185 return message |
186 | 186 |
187 def getMessageCount(self): | 187 def getMessageCount(self): |
188 """Return the number of messages in this mailbox. | 188 """Return the number of messages in this mailbox. |
234 | 234 |
235 @type listener: Any object which implements C{IMailboxListener} | 235 @type listener: Any object which implements C{IMailboxListener} |
236 @param listener: An object to add to the set of those which will | 236 @param listener: An object to add to the set of those which will |
237 be notified when the contents of this mailbox change. | 237 be notified when the contents of this mailbox change. |
238 """ | 238 """ |
239 log.debug('addListener %s' % listener) | 239 log.debug(u'addListener %s' % listener) |
240 self.listeners.add(listener) | 240 self.listeners.add(listener) |
241 | 241 |
242 def removeListener(self, listener): | 242 def removeListener(self, listener): |
243 """Remove a mailbox change listener | 243 """Remove a mailbox change listener |
244 | 244 |
279 """Retrieve one or more messages. | 279 """Retrieve one or more messages. |
280 @param messages: The identifiers of messages to retrieve information | 280 @param messages: The identifiers of messages to retrieve information |
281 about | 281 about |
282 @param uid: If true, the IDs specified in the query are UIDs; | 282 @param uid: If true, the IDs specified in the query are UIDs; |
283 """ | 283 """ |
284 log.debug('fetch (%s, %s)' % (messages, uid)) | 284 log.debug(u'fetch (%s, %s)' % (messages, uid)) |
285 if uid: | 285 if uid: |
286 messages.last = self.mailbox.getMaxUid() | 286 messages.last = self.mailbox.getMaxUid() |
287 messages.getnext = self.mailbox.getNextExistingUid | 287 messages.getnext = self.mailbox.getNextExistingUid |
288 for mess_uid in messages: | 288 for mess_uid in messages: |
289 if mess_uid is None: | 289 if mess_uid is None: |
434 | 434 |
435 def startedConnecting(self, connector): | 435 def startedConnecting(self, connector): |
436 log.debug(_("IMAP server connection started")) | 436 log.debug(_("IMAP server connection started")) |
437 | 437 |
438 def clientConnectionLost(self, connector, reason): | 438 def clientConnectionLost(self, connector, reason): |
439 log.debug(_("IMAP server connection lost (reason: %s)"), reason) | 439 log.debug(_(u"IMAP server connection lost (reason: %s)"), reason) |
440 | 440 |
441 def buildProtocol(self, addr): | 441 def buildProtocol(self, addr): |
442 log.debug("Building protocol") | 442 log.debug("Building protocol") |
443 prot = protocol.ServerFactory.buildProtocol(self, addr) | 443 prot = protocol.ServerFactory.buildProtocol(self, addr) |
444 prot.portal = portal.Portal(ImapRealm(self.host)) | 444 prot.portal = portal.Portal(ImapRealm(self.host)) |