comparison src/plugins/plugin_misc_maildir.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 3b1c5f723c4b
children 7a8a19e4fa6c
comparison
equal deleted inserted replaced
1408:8a7145138330 1409:3265a2639182
126 """Remove a reference to a box 126 """Remove a reference to a box
127 @param name: name of the box 127 @param name: name of the box
128 @param mailboxUser: MailboxUser instance""" 128 @param mailboxUser: MailboxUser instance"""
129 if boxname not in self.__mailboxes: 129 if boxname not in self.__mailboxes:
130 err_msg = _("Trying to remove an mailboxUser not referenced") 130 err_msg = _("Trying to remove an mailboxUser not referenced")
131 log.error(_("INTERNAL ERROR: ") + err_msg) 131 log.error(_(u"INTERNAL ERROR: ") + err_msg)
132 raise MaildirError(err_msg) 132 raise MaildirError(err_msg)
133 assert self.__mailboxes[profile][boxname] == mailboxUser 133 assert self.__mailboxes[profile][boxname] == mailboxUser
134 del self.__mailboxes[profile][boxname] 134 del self.__mailboxes[profile][boxname]
135 135
136 def _checkBoxReference(self, boxname, profile): 136 def _checkBoxReference(self, boxname, profile):
145 """Return the date of a box""" 145 """Return the date of a box"""
146 try: 146 try:
147 return self.data[profile][boxname] # the boxname MUST exist in the data 147 return self.data[profile][boxname] # the boxname MUST exist in the data
148 except KeyError: 148 except KeyError:
149 err_msg = _("Boxname doesn't exist in internal data") 149 err_msg = _("Boxname doesn't exist in internal data")
150 log.error(_("INTERNAL ERROR: ") + err_msg) 150 log.error(_(u"INTERNAL ERROR: ") + err_msg)
151 raise MaildirError(err_msg) 151 raise MaildirError(err_msg)
152 152
153 def getUid(self, boxname, message_id, profile): 153 def getUid(self, boxname, message_id, profile):
154 """Return an unique integer, always ascending, for a message 154 """Return an unique integer, always ascending, for a message
155 This is mainly needed for the IMAP protocol 155 This is mainly needed for the IMAP protocol
283 """Remove an observer of maildir box changes 283 """Remove an observer of maildir box changes
284 @param callback: method to remove from obervers 284 @param callback: method to remove from obervers
285 @param boxname: name of the box which was observed 285 @param boxname: name of the box which was observed
286 @param signal: which signal was observed by the caller""" 286 @param signal: which signal was observed by the caller"""
287 if (profile, boxname) not in self.__observed: 287 if (profile, boxname) not in self.__observed:
288 err_msg = _("Trying to remove an observer for an inexistant mailbox") 288 err_msg = _(u"Trying to remove an observer for an inexistant mailbox")
289 log.error(_("INTERNAL ERROR: ") + err_msg) 289 log.error(_(u"INTERNAL ERROR: ") + err_msg)
290 raise MaildirError(err_msg) 290 raise MaildirError(err_msg)
291 if signal not in self.__observed[(profile, boxname)]: 291 if signal not in self.__observed[(profile, boxname)]:
292 err_msg = _("Trying to remove an inexistant observer, no observer for this signal") 292 err_msg = _(u"Trying to remove an inexistant observer, no observer for this signal")
293 log.error(_("INTERNAL ERROR: ") + err_msg) 293 log.error(_(u"INTERNAL ERROR: ") + err_msg)
294 raise MaildirError(err_msg) 294 raise MaildirError(err_msg)
295 if not callback in self.__observed[(profile, boxname)][signal]: 295 if not callback in self.__observed[(profile, boxname)][signal]:
296 err_msg = _("Trying to remove an inexistant observer") 296 err_msg = _(u"Trying to remove an inexistant observer")
297 log.error(_("INTERNAL ERROR: ") + err_msg) 297 log.error(_(u"INTERNAL ERROR: ") + err_msg)
298 raise MaildirError(err_msg) 298 raise MaildirError(err_msg)
299 self.__observed[(profile, boxname)][signal].remove(callback) 299 self.__observed[(profile, boxname)][signal].remove(callback)
300 300
301 def emitSignal(self, profile, boxname, signal_name): 301 def emitSignal(self, profile, boxname, signal_name):
302 """Emit the signal to observer""" 302 """Emit the signal to observer"""
303 log.debug('emitSignal %s %s %s' % (profile, boxname, signal_name)) 303 log.debug(u'emitSignal %s %s %s' % (profile, boxname, signal_name))
304 try: 304 try:
305 for observer_cb in self.__observed[(profile, boxname)][signal_name]: 305 for observer_cb in self.__observed[(profile, boxname)][signal_name]:
306 observer_cb() 306 observer_cb()
307 except KeyError: 307 except KeyError:
308 pass 308 pass
334 """@param _maildir: the main MaildirBox instance 334 """@param _maildir: the main MaildirBox instance
335 @param name: name of the mailbox 335 @param name: name of the mailbox
336 @param profile: real profile (ie not a profile_key) 336 @param profile: real profile (ie not a profile_key)
337 THIS OBJECT MUST NOT BE USED DIRECTLY: use MaildirBox.accessMessageBox instead""" 337 THIS OBJECT MUST NOT BE USED DIRECTLY: use MaildirBox.accessMessageBox instead"""
338 if _maildir._checkBoxReference(name, profile): 338 if _maildir._checkBoxReference(name, profile):
339 log.error("INTERNAL ERROR: MailboxUser MUST NOT be instancied directly") 339 log.error(u"INTERNAL ERROR: MailboxUser MUST NOT be instancied directly")
340 raise MaildirError('double MailboxUser instanciation') 340 raise MaildirError('double MailboxUser instanciation')
341 if name != "INBOX": 341 if name != "INBOX":
342 raise NotImplementedError 342 raise NotImplementedError
343 self.name = name 343 self.name = name
344 self.profile = profile 344 self.profile = profile
352 self.mailbox = maildir.MaildirMailbox(mailbox_path) 352 self.mailbox = maildir.MaildirMailbox(mailbox_path)
353 self.observer = observer 353 self.observer = observer
354 self.__uid_table_update() 354 self.__uid_table_update()
355 355
356 if observer: 356 if observer:
357 log.debug("adding observer for %s (%s)" % (name, profile)) 357 log.debug(u"adding observer for %s (%s)" % (name, profile))
358 self.maildir.addObserver(observer, profile, name, "NEW_MESSAGE") 358 self.maildir.addObserver(observer, profile, name, "NEW_MESSAGE")
359 359
360 def __uid_table_update(self): 360 def __uid_table_update(self):
361 existant_id = [] 361 existant_id = []
362 for mess_idx in range(self.getMessageCount()): 362 for mess_idx in range(self.getMessageCount()):
365 self.getUid(mess_idx) 365 self.getUid(mess_idx)
366 self.maildir.cleanTable(self.name, existant_id, profile=self.profile) 366 self.maildir.cleanTable(self.name, existant_id, profile=self.profile)
367 367
368 def __del__(self): 368 def __del__(self):
369 if self.observer: 369 if self.observer:
370 log.debug("removing observer for %s" % self.name) 370 log.debug(u"removing observer for %s" % self.name)
371 self._maildir.removeObserver(self.observer, self.name, "NEW_MESSAGE") 371 self._maildir.removeObserver(self.observer, self.name, "NEW_MESSAGE")
372 self.maildir._removeBoxAccess(self.name, self, profile=self.profile) 372 self.maildir._removeBoxAccess(self.name, self, profile=self.profile)
373 373
374 def addMessage(self, message): 374 def addMessage(self, message):
375 """Add a message to the box 375 """Add a message to the box