Mercurial > libervia-web
diff browser_side/contact.py @ 226:744426c2b699
browser_side, misc: better PEP8 compliance
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 26 Sep 2013 14:32:24 +0200 |
parents | 0f5c2f799913 |
children | 266e9678eec0 |
line wrap: on
line diff
--- a/browser_side/contact.py Thu Sep 26 11:39:54 2013 +0200 +++ b/browser_side/contact.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.ScrollPanel import ScrollPanel from pyjamas.ui.VerticalPanel import VerticalPanel @@ -54,7 +54,7 @@ self.host = host self.name = name or jid self.waiting = False - self.jid=jid + self.jid = jid self._fill() self.setStyleName('contact') DragLabel.__init__(self, jid, "CONTACT") @@ -94,7 +94,7 @@ for wid in self: if isinstance(wid, GroupLabel) and wid.group == group: VerticalPanel.remove(self, wid) - + class ContactList(VerticalPanel): def __init__(self, host): @@ -151,6 +151,7 @@ elif type == 'messageWaiting': _item.setMessageWaiting(state) + class ContactTitleLabel(DragLabel, Label, ClickHandler): def __init__(self, host, text): Label.__init__(self, text) #, Element=DOM.createElement('div') @@ -166,15 +167,15 @@ class ContactPanel(SimplePanel): """Manage the contacts and groups""" - + def __init__(self, host): SimplePanel.__init__(self) self.scroll_panel = ScrollPanel() - + self.host = host - self.groups={} - self.connected = {} #jid connected as key and their status + self.groups = {} + self.connected = {} # jid connected as key and their status self.vPanel = VerticalPanel() _title = ContactTitleLabel(host, 'Contacts') @@ -184,7 +185,7 @@ self._contact_list.setStyleName('contactList') self._groupList = GroupList(self) self._groupList.setStyleName('groupList') - + self.vPanel.add(_title) self.vPanel.add(self._groupList) self.vPanel.add(self._contact_list) @@ -200,11 +201,11 @@ print ("ERROR: no TabBar found, it should exist !") tab_bar_h = height else: - tab_bar_h = DOM.getAbsoluteTop( _elts.item(0)) or height #getAbsoluteTop can be 0 if tabBar is hidden + tab_bar_h = DOM.getAbsoluteTop(_elts.item(0)) or height # getAbsoluteTop can be 0 if tabBar is hidden ideal_height = tab_bar_h - DOM.getAbsoluteTop(contact_panel_elt) - 5 self.scroll_panel.setHeight("%s%s" % (ideal_height, "px")); - + def updateContact(self, jid, attributes, groups): """Add a contact to the panel if it doesn't exist, update it else @@ -216,39 +217,39 @@ _key = "@%s: " for group in _current_groups.difference(_new_groups): - #We remove the contact from the groups where he isn't anymore + # We remove the contact from the groups where he isn't anymore self.groups[group].remove(jid) if not self.groups[group]: - #The group is now empty, we must remove it + # The group is now empty, we must remove it del self.groups[group] self._groupList.remove(group) self.host.uni_box.removeKey(_key % group) for group in _new_groups.difference(_current_groups): - #We add the contact to the groups he joined + # We add the contact to the groups he joined if not self.groups.has_key(group): self.groups[group] = set() self._groupList.add(group) self.host.uni_box.addKey(_key % group) self.groups[group].add(jid) - - #We add the contact to contact list, it will check if contact already exists + + # We add the contact to contact list, it will check if contact already exists self._contact_list.add(jid) def removeContact(self, jid): """Remove contacts from groups where he is and contact list""" - self.updateContact(jid, {}, []) #we remove contact from every group + self.updateContact(jid, {}, []) # we remove contact from every group self._contact_list.remove(jid) def setConnected(self, jid, resource, availability, priority, statuses): """Set connection status""" - if availability=='unavailable': + if availability == 'unavailable': if self.connected.has_key(jid): if self.connected[jid].has_key(resource): del self.connected[jid][resource] if not self.connected[jid]: del self.connected[jid] - else: + else: if not self.connected.has_key(jid): self.connected[jid] = {} self.connected[jid][resource] = (availability, priority, statuses) @@ -260,8 +261,6 @@ @param waiting: True if message are waiting""" self._contact_list.setState(jid, "messageWaiting", waiting) - - def getConnected(self): """return a list of all jid (bare jid) connected""" return self.connected.keys() @@ -271,7 +270,7 @@ @param group: string of single group, or list of string @param contact_jid: jid to test """ - result=set() + result = set() for group in self.groups: if self.isContactInGroup(group, contact_jid): result.add(group) @@ -301,7 +300,7 @@ def onMouseMove(self, sender, x, y): pass - + def onMouseDown(self, sender, x, y): pass @@ -313,7 +312,7 @@ for contact in self._contact_list: if contact.jid in self.groups[sender.group]: contact.addStyleName("selected") - + def onMouseLeave(self, sender): if isinstance(sender, GroupLabel): for contact in self._contact_list: