diff browser_side/panels.py @ 226:744426c2b699

browser_side, misc: better PEP8 compliance
author souliane <souliane@mailoo.org>
date Thu, 26 Sep 2013 14:32:24 +0200
parents 624a87377412
children 266e9678eec0
line wrap: on
line diff
--- a/browser_side/panels.py	Thu Sep 26 11:39:54 2013 +0200
+++ b/browser_side/panels.py	Thu Sep 26 14:32:24 2013 +0200
@@ -19,7 +19,7 @@
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
 
-import pyjd # this is dummy in pyjs
+import pyjd  # this is dummy in pyjs
 from pyjamas.ui.SimplePanel import SimplePanel
 from pyjamas.ui.AbsolutePanel import AbsolutePanel
 from pyjamas.ui.VerticalPanel import VerticalPanel
@@ -117,7 +117,7 @@
             self._popup.addStyleName(style)
 
         left = 0
-        top = 0 #max(0, self.getAbsoluteTop() - contents.getOffsetHeight() - 2)
+        top = 0  # max(0, self.getAbsoluteTop() - contents.getOffsetHeight() - 2)
         self._popup.setPopupPosition(left, top)
         self._popup.show()
 
@@ -138,7 +138,7 @@
         def getSelectedOrStatus():
             if target:
                 _type, msg = target.getWarningData()
-                target_hook = None # we use the selected widget, not a hook
+                target_hook = None  # we use the selected widget, not a hook
             else:
                 _type, msg = "STATUS", "This will be your new status message"
                 target_hook = (txt, None)
@@ -155,7 +155,7 @@
             if _end == -1:
                 target_hook, _type, msg = getSelectedOrStatus()
             else:
-                group = txt[1:_end] #only one target group is managed for the moment
+                group = txt[1:_end]  # only one target group is managed for the moment
                 if not group or not group in self.host.contact_panel.getGroups():
                     # the group doesn't exists, we ignore the key
                     group = None
@@ -163,7 +163,7 @@
                 else:
                     _type = "GROUP"
                     msg = MicroblogPanel.warning_msg_group % group
-                    target_hook = (txt[_end+2:], group)
+                    target_hook = (txt[_end + 2:], group)
         else:
             print "ERROR: Unknown target"
             target_hook, _type, msg = getSelectedOrStatus()
@@ -171,7 +171,7 @@
         return (target_hook, _type, msg)
 
     def onBrowserEvent(self, event):
-        #XXX: woraroung a pyjamas bug: self.currentEvent is not set
+        # XXX: woraroung a pyjamas bug: self.currentEvent is not set
         #     so the TextBox's cancelKey doens't work. This is a workaround
         #     FIXME: fix the bug upstream
         self.currentEvent = event
@@ -183,12 +183,12 @@
         if not self._popup:
             self.showWarning(target)
         elif target != self._popup.target_data:
-            self._timeCb(None) #we remove the popup
+            self._timeCb(None)  # we remove the popup
             self.showWarning(target)
 
         self._timer.schedule(2000)
 
-        #if keycode == KEY_ENTER and not self.visible:
+        # if keycode == KEY_ENTER and not self.visible:
         if keycode == KEY_ENTER:
             if _txt:
                 target_hook, _type, msg = target
@@ -202,10 +202,10 @@
                         self.host.bridge.call('setStatus', None, parsed_txt)
                     else:
                         print "ERROR: Unknown target hook type"
-                else: #we send the message to the selected target
+                else:  # we send the message to the selected target
                     self._selected_cache.onTextEntered(_txt)
             self.setText('')
-            self._timeCb(None) #we remove the popup
+            self._timeCb(None)  # we remove the popup
             sender.cancelKey()
         else:
             self.__onComposing()
@@ -232,14 +232,14 @@
 
 
 class MicroblogItem():
-    #XXX: should be moved in a separated module
+    # XXX: should be moved in a separated module
 
     def __init__(self, data):
         self.id = data['id']
         self.type = data.get('type', 'main_item')
         self.content = data['content']
         self.author = data['author']
-        self.timestamp = float(data.get('timestamp', 0)) #XXX: int doesn't work here
+        self.timestamp = float(data.get('timestamp', 0))  # XXX: int doesn't work here
         self.comments = data.get('comments', False)
         if self.comments:
             try:
@@ -249,7 +249,7 @@
             except KeyError:
                 print "Warning: can't manage comment [%s], some keys are missing in microblog data (%s)" % (data["comments"], data.keys())
                 self.comments = False
-        if set(("service","node")).issubset(data.keys()):
+        if set(("service", "node")).issubset(data.keys()):
             self.service = data["service"]
             self.node = data["node"]
             self.hash = (self.service, self.node)
@@ -431,14 +431,14 @@
             parent_idx = self.vpanel.getWidgetIndex(parent)
             # we find or create the panel where the comment must be inserted
             try:
-                sub_panel = self.vpanel.getWidget(parent_idx+1)
+                sub_panel = self.vpanel.getWidget(parent_idx + 1)
             except IndexError:
                 sub_panel = None
             if not sub_panel or not isinstance(sub_panel, VerticalPanel):
                 sub_panel = VerticalPanel()
                 sub_panel.setStyleName('microblogPanel')
                 sub_panel.addStyleName('subPanel')
-                self.vpanel.insert(sub_panel, parent_idx+1)
+                self.vpanel.insert(sub_panel, parent_idx + 1)
 
             # we want comments to be inserted in chronological order
             self._chronoInsert(sub_panel, _entry, reverse=False)
@@ -518,7 +518,7 @@
         self.setHTML(self.__getContent())
 
     def onClick(self, sender):
-        #As status is the default target of uniBar, we don't want to select anything if click on it
+        # As status is the default target of uniBar, we don't want to select anything if click on it
         self.host.setSelected(None)
 
 
@@ -625,7 +625,7 @@
     def createChat(cls, host, item):
         _contact = JID(item)
         host.contact_panel.setContactMessageWaiting(_contact.bare, False)
-        _new_panel = ChatPanel(host, _contact) #XXX: pyjamas doesn't seems to support creating with cls directly
+        _new_panel = ChatPanel(host, _contact)  # XXX: pyjamas doesn't seems to support creating with cls directly
         _new_panel.historyPrint()
         return _new_panel
 
@@ -702,7 +702,7 @@
         """Print message in chat window. Must be implemented by child class"""
         _jid = JID(from_jid)
         nick = _jid.node if self.type == 'one2one' else _jid.resource
-        mymess = _jid.resource == self.nick if self.type == "group" else _jid.bare == self.host.whoami.bare #mymess = True if message comes from local user
+        mymess = _jid.resource == self.nick if self.type == "group" else _jid.bare == self.host.whoami.bare  # mymess = True if message comes from local user
         if msg.startswith('/me '):
             self.printInfo('* %s %s' % (nick, msg[4:]), type='me')
             return
@@ -718,7 +718,7 @@
             self.vpanel.insert(self.tarot_panel, 0)
             self.vpanel.setCellHeight(self.tarot_panel, self.tarot_panel.getHeight())
         elif game_type == "RadioCol":
-            #XXX: We can have double panel if we join quickly enough to have the group chat start signal
+            # XXX: We can have double panel if we join quickly enough to have the group chat start signal
             #     on invitation + the one triggered on room join
             if hasattr(self, "radiocol_panel"):
                 return
@@ -728,7 +728,7 @@
 
     def getGame(self, game_type):
         """Return class managing the game type"""
-        #TODO: check that the game is launched, and manage errors
+        # TODO: check that the game is launched, and manage errors
         if game_type == "Tarot":
             return self.tarot_panel
         elif game_type == "RadioCol":
@@ -773,17 +773,17 @@
         self.host = host
         AbsolutePanel.__init__(self)
 
-        #menu
+        # menu
         self.menu = Menu(host)
 
-        #unibox
+        # unibox
         unibox_panel = UniBoxPanel(host)
         self.host.setUniBox(unibox_panel.unibox)
 
-        #status bar
+        # status bar
         status = host.status_panel
 
-        #contacts
+        # contacts
         _contacts = HorizontalPanel()
         _contacts.addStyleName('globalLeftArea')
         contacts_switch = Button(u'«', self._contactsSwitch)
@@ -791,7 +791,7 @@
         _contacts.add(contacts_switch)
         _contacts.add(self.host.contact_panel)
 
-        #tabs
+        # tabs
         self.tab_panel = base_widget.MainTabPanel(host)
         self.discuss_panel = base_widget.WidgetsPanel(self.host, locked=True)
         self.tab_panel.add(self.discuss_panel, "Discussions")