factorize aum's Contact.get_text() and boobmsg formatter into ICapContact
This commit is contained in:
parent
06cdb82476
commit
a40643bf40
3 changed files with 42 additions and 75 deletions
|
|
@ -29,7 +29,7 @@ from lxml import etree
|
|||
from weboob.core import CallErrors
|
||||
from weboob.capabilities.messages import ICapMessages, Message, Thread
|
||||
from weboob.capabilities.account import ICapAccount
|
||||
from weboob.capabilities.contact import ICapContact, Contact
|
||||
from weboob.capabilities.contact import ICapContact
|
||||
from weboob.tools.application.repl import ReplApplication, defaultcount
|
||||
from weboob.tools.application.formatters.iformatter import IFormatter
|
||||
from weboob.tools.misc import html2text
|
||||
|
|
@ -228,41 +228,8 @@ class ProfileFormatter(IFormatter):
|
|||
def flush(self):
|
||||
pass
|
||||
|
||||
def print_node(self, node, level=1):
|
||||
result = u''
|
||||
if node.flags & node.SECTION:
|
||||
result += u'\t' * level + node.label + '\n'
|
||||
for sub in node.value.itervalues():
|
||||
result += self.print_node(sub, level+1)
|
||||
else:
|
||||
if isinstance(node.value, (tuple,list)):
|
||||
value = ', '.join(unicode(v) for v in node.value)
|
||||
else:
|
||||
value = node.value
|
||||
result += u'\t' * level + u'%-20s %s\n' % (node.label + ':', value)
|
||||
return result
|
||||
|
||||
def format_obj(self, obj, alias):
|
||||
result = u'Nickname: %s\n' % obj.name
|
||||
if obj.status & Contact.STATUS_ONLINE:
|
||||
s = 'online'
|
||||
elif obj.status & Contact.STATUS_OFFLINE:
|
||||
s = 'offline'
|
||||
elif obj.status & Contact.STATUS_AWAY:
|
||||
s = 'away'
|
||||
else:
|
||||
s = 'unknown'
|
||||
result += u'Status: %s (%s)\n' % (s, obj.status_msg)
|
||||
result += u'Photos:\n'
|
||||
for name, photo in obj.photos.iteritems():
|
||||
result += u'\t%s%s\n' % (photo, ' (hidden)' if photo.hidden else '')
|
||||
result += u'Profile:\n'
|
||||
for head in obj.profile.itervalues():
|
||||
result += self.print_node(head)
|
||||
result += u'Description:\n'
|
||||
for s in obj.summary.split('\n'):
|
||||
result += u'\t%s\n' % s
|
||||
return result
|
||||
def format_obj(self, obj, alias=None):
|
||||
return obj.get_text()
|
||||
|
||||
|
||||
class Boobmsg(ReplApplication):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue