diff cagou/plugins/plugin_wid_contact_list.py @ 312:772c170b47a9

Python3 port: /!\ Cagou now runs with Python 3.6+ Port has been done in the same way as for backend (check backend commit b2d067339de3 message for details).
author Goffi <goffi@goffi.org>
date Tue, 13 Aug 2019 19:14:22 +0200
parents 1b835bcfa663
children e2b51663d8b8
line wrap: on
line diff
--- a/cagou/plugins/plugin_wid_contact_list.py	Mon Aug 05 11:21:54 2019 +0200
+++ b/cagou/plugins/plugin_wid_contact_list.py	Tue Aug 13 19:14:22 2019 +0200
@@ -38,10 +38,10 @@
 
 
 PLUGIN_INFO = {
-    "name": _(u"contacts"),
+    "name": _("contacts"),
     "main": "ContactList",
-    "description": _(u"list of contacts"),
-    "icon_medium": u"{media}/icons/muchoslava/png/contact_list_no_border_blue_44.png"
+    "description": _("list of contacts"),
+    "icon_medium": "{media}/icons/muchoslava/png/contact_list_no_border_blue_44.png"
 }
 
 
@@ -53,7 +53,7 @@
     def __init__(self, **kwargs):
         super(AddContactMenu, self).__init__(**kwargs)
         if self.profile is None:
-            log.warning(_(u"profile not set in AddContactMenu"))
+            log.warning(_("profile not set in AddContactMenu"))
             self.profile = next(iter(G.host.profiles))
 
     def addContact(self, contact_jid):
@@ -67,15 +67,15 @@
         if not contact_jid or not re.match(r"[^@ ]+@[^@ ]+", contact_jid):
             return
         contact_jid = jid.JID(contact_jid).bare
-        G.host.bridge.addContact(unicode(contact_jid),
+        G.host.bridge.addContact(str(contact_jid),
             self.profile,
             callback=lambda: G.host.addNote(
-                _(u"contact request"),
-                _(u"a contact request has been sent to {contact_jid}").format(
+                _("contact request"),
+                _("a contact request has been sent to {contact_jid}").format(
                     contact_jid=contact_jid)),
             errback=partial(G.host.errback,
-                title=_(u"can't add contact"),
-                message=_(u"error while trying to add contact: {msg}")))
+                title=_("can't add contact"),
+                message=_("error while trying to add contact: {msg}")))
 
 
 class DelContactMenu(SideMenu):
@@ -88,15 +88,15 @@
 
     def do_delete_contact(self):
         self.hide()
-        G.host.bridge.delContact(unicode(self.contact_item.jid.bare),
+        G.host.bridge.delContact(str(self.contact_item.jid.bare),
         self.contact_item.profile,
         callback=lambda: G.host.addNote(
-            _(u"contact removed"),
-            _(u"{contact_jid} has been removed from your contacts list").format(
+            _("contact removed"),
+            _("{contact_jid} has been removed from your contacts list").format(
                 contact_jid=self.contact_item.jid.bare)),
         errback=partial(G.host.errback,
-            title=_(u"can't remove contact"),
-            message=_(u"error while trying to remove contact: {msg}")))
+            title=_("can't remove contact"),
+            message=_("error while trying to remove contact: {msg}")))
 
 
 
@@ -117,11 +117,11 @@
         assert self.profile
         # XXX: for now clicking on an item launch the corresponding Chat widget
         #      behaviour should change in the future
-        G.host.doAction(u'chat', jid.JID(self.jid), [self.profile])
+        G.host.doAction('chat', jid.JID(self.jid), [self.profile])
 
     def getMenuChoices(self):
         choices = []
-        choices.append(dict(text=_(u'delete'),
+        choices.append(dict(text=_('delete'),
                             index=len(choices)+1,
                             callback=self.main_wid.removeContact))
         return choices
@@ -180,7 +180,7 @@
         if type_ == None or type_ == C.UPDATE_STRUCTURE:
             log.debug("full contact list update")
             self.layout.clear_widgets()
-            for bare_jid, data in self.items_sorted.iteritems():
+            for bare_jid, data in self.items_sorted.items():
                 wid = ContactItem(profile=profile, data=data, jid=bare_jid, main_wid=self)
                 self.layout.add_widget(wid)
                 self._wid_map[(profile, bare_jid)] = wid