Fix "show" for threads in boobmsg

This commit is contained in:
Florent 2014-10-10 14:56:40 +02:00
commit 768be7fcc6

View file

@ -27,6 +27,7 @@ from tempfile import NamedTemporaryFile
from lxml import etree
from weboob.core import CallErrors
from weboob.capabilities.base import empty
from weboob.capabilities.messages import CapMessages, Message, Thread
from weboob.capabilities.account import CapAccount
from weboob.capabilities.contact import CapContact
@ -281,8 +282,8 @@ class Boobmsg(ReplApplication):
results = {}
for field in self.do('get_account_status',
backends=backend_name,
caps=CapAccount):
backends=backend_name,
caps=CapAccount):
if field.backend in results:
results[field.backend].append(field)
else:
@ -419,7 +420,7 @@ class Boobmsg(ReplApplication):
cmd = self.do('get_thread', _id, backends=backend_name)
self.start_format()
for thread in cmd:
if thread is not None :
if thread is not None:
for msg in thread.iter_all_messages():
self.format(msg)
@ -437,11 +438,22 @@ class Boobmsg(ReplApplication):
try:
message = self.messages[int(arg) - 1]
except (IndexError, ValueError):
id, backend_name = self.parse_id(arg)
cmd = self.do('get_thread', id, backends=backend_name)
for thread in cmd:
if thread is not None:
# The message is not is the cache, we have now two cases:
# 1) the user uses a number to get a thread in the cache
# 2) the user gives a thread id
try:
thread = self.threads[int(arg) - 1]
if not empty(thread.root):
message = thread.root
else:
for thread in self.do('get_thread', thread.id, backends=thread.backend):
if thread is not None:
message = thread.root
except (IndexError, ValueError):
_id, backend_name = self.parse_id(arg)
for thread in self.do('get_thread', _id, backends=backend_name):
if thread is not None:
message = thread.root
if message is not None:
self.start_format()
self.format(message)