Mercurial > libervia-web
comparison src/browser/libervia_main.py @ 451:1a0cec9b0f1e
better PEP-8 compliance
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 20 May 2014 10:54:03 +0200 |
parents | 981ed669d3b3 |
children | 7b6506372466 |
comparison
equal
deleted
inserted
replaced
450:41aae13cab2b | 451:1a0cec9b0f1e |
---|---|
39 | 39 |
40 from register import RegisterBox | 40 from register import RegisterBox |
41 from contact import ContactPanel | 41 from contact import ContactPanel |
42 from base_widget import WidgetsPanel | 42 from base_widget import WidgetsPanel |
43 from panels import MicroblogItem | 43 from panels import MicroblogItem |
44 import panels, dialog | 44 import panels |
45 import dialog | |
45 from jid import JID | 46 from jid import JID |
46 from xmlui import XMLUI | 47 from xmlui import XMLUI |
47 from html_tools import html_sanitize | 48 from html_tools import html_sanitize |
48 from notification import Notification | 49 from notification import Notification |
49 | 50 |
395 def _actionCb(self, data): | 396 def _actionCb(self, data): |
396 if not data: | 397 if not data: |
397 # action was a one shot, nothing to do | 398 # action was a one shot, nothing to do |
398 pass | 399 pass |
399 elif "xmlui" in data: | 400 elif "xmlui" in data: |
400 ui = XMLUI(self, xml_data = data['xmlui']) | 401 ui = XMLUI(self, xml_data=data['xmlui']) |
401 options = ['NO_CLOSE'] if ui.type == 'form' else [] | 402 options = ['NO_CLOSE'] if ui.type == 'form' else [] |
402 _dialog = dialog.GenericDialog(ui.title, ui, options=options) | 403 _dialog = dialog.GenericDialog(ui.title, ui, options=options) |
403 ui.setCloseCb(_dialog.close) | 404 ui.setCloseCb(_dialog.close) |
404 _dialog.show() | 405 _dialog.show() |
405 else: | 406 else: |
496 | 497 |
497 def _ownBlogsFills(self, mblogs): | 498 def _ownBlogsFills(self, mblogs): |
498 #put our own microblogs in cache, then fill all panels with them | 499 #put our own microblogs in cache, then fill all panels with them |
499 for publisher in mblogs: | 500 for publisher in mblogs: |
500 for mblog in mblogs[publisher]: | 501 for mblog in mblogs[publisher]: |
501 if not mblog.has_key('content'): | 502 if 'content' not in mblog: |
502 log.warning("No content found in microblog [%s]" % mblog) | 503 log.warning("No content found in microblog [%s]" % mblog) |
503 continue | 504 continue |
504 if mblog.has_key('groups'): | 505 if 'groups' not in mblog: |
505 _groups = set(mblog['groups'].split() if mblog['groups'] else []) | 506 _groups = set(mblog['groups'].split() if mblog['groups'] else []) |
506 else: | 507 else: |
507 _groups = None | 508 _groups = None |
508 mblog_entry = MicroblogItem(mblog) | 509 mblog_entry = MicroblogItem(mblog) |
509 self.mblog_cache.append((_groups, mblog_entry)) | 510 self.mblog_cache.append((_groups, mblog_entry)) |
511 if len(self.mblog_cache) > MAX_MBLOG_CACHE: | 512 if len(self.mblog_cache) > MAX_MBLOG_CACHE: |
512 del self.mblog_cache[0:len(self.mblog_cache - MAX_MBLOG_CACHE)] | 513 del self.mblog_cache[0:len(self.mblog_cache - MAX_MBLOG_CACHE)] |
513 for lib_wid in self.libervia_widgets: | 514 for lib_wid in self.libervia_widgets: |
514 if isinstance(lib_wid, panels.MicroblogPanel): | 515 if isinstance(lib_wid, panels.MicroblogPanel): |
515 self.FillMicroblogPanel(lib_wid) | 516 self.FillMicroblogPanel(lib_wid) |
516 self.initialised = True # initialisation phase is finished here | 517 self.initialised = True # initialisation phase is finished here |
517 for event_data in self.init_cache: # so we have to send all the cached events | 518 for event_data in self.init_cache: # so we have to send all the cached events |
518 self._personalEventCb(*event_data) | 519 self._personalEventCb(*event_data) |
519 del self.init_cache | 520 del self.init_cache |
520 | 521 |
521 def _getProfileJidCB(self, jid): | 522 def _getProfileJidCB(self, jid): |
522 self.whoami = JID(jid) | 523 self.whoami = JID(jid) |
695 _target = JID(room_jid) | 696 _target = JID(room_jid) |
696 if _target not in self.room_list: | 697 if _target not in self.room_list: |
697 self.room_list.append(_target) | 698 self.room_list.append(_target) |
698 chat_panel = panels.ChatPanel(self, _target, type_='group') | 699 chat_panel = panels.ChatPanel(self, _target, type_='group') |
699 chat_panel.setUserNick(user_nick) | 700 chat_panel.setUserNick(user_nick) |
700 if _target.node.startswith('sat_tarot_'): #XXX: it's not really beautiful, but it works :) | 701 if _target.node.startswith('sat_tarot_'): # XXX: it's not really beautiful, but it works :) |
701 self.addTab("Tarot", chat_panel) | 702 self.addTab("Tarot", chat_panel) |
702 elif _target.node.startswith('sat_radiocol_'): | 703 elif _target.node.startswith('sat_radiocol_'): |
703 self.addTab("Radio collective", chat_panel) | 704 self.addTab("Radio collective", chat_panel) |
704 else: | 705 else: |
705 self.addTab(_target.node, chat_panel) | 706 self.addTab(_target.node, chat_panel) |
780 _dialog = None | 781 _dialog = None |
781 msg = HTML('The contact <b>%s</b> want to add you in his/her contact list, do you accept ?' % html_sanitize(entity)) | 782 msg = HTML('The contact <b>%s</b> want to add you in his/her contact list, do you accept ?' % html_sanitize(entity)) |
782 | 783 |
783 def ok_cb(ignore): | 784 def ok_cb(ignore): |
784 self.bridge.call('subscription', None, "subscribed", entity, '', _dialog.getSelectedGroups()) | 785 self.bridge.call('subscription', None, "subscribed", entity, '', _dialog.getSelectedGroups()) |
786 | |
785 def cancel_cb(ignore): | 787 def cancel_cb(ignore): |
786 self.bridge.call('subscription', None, "unsubscribed", entity, '', '') | 788 self.bridge.call('subscription', None, "unsubscribed", entity, '', '') |
787 | 789 |
788 _dialog = dialog.GroupSelector([msg], self.contact_panel.getGroups(), [], "Add", ok_cb, cancel_cb) | 790 _dialog = dialog.GroupSelector([msg], self.contact_panel.getGroups(), [], "Add", ok_cb, cancel_cb) |
789 _dialog.setHTML('<b>Add contact request</b>') | 791 _dialog.setHTML('<b>Add contact request</b>') |