summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2017-05-03 16:07:11 +0100
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2017-05-03 16:07:11 +0100
commit7228c9cf6d78d855afab90c8ce95850dd2712c14 (patch)
treea8ed13d648f0160e99752b4cf20ab242e723696d
parent7d00b94f16c94d2f27c097ed675fb02487b7c0aa (diff)
downloadpoezio-7228c9cf6d78d855afab90c8ce95850dd2712c14.tar.gz
poezio-7228c9cf6d78d855afab90c8ce95850dd2712c14.tar.bz2
poezio-7228c9cf6d78d855afab90c8ce95850dd2712c14.tar.xz
poezio-7228c9cf6d78d855afab90c8ce95850dd2712c14.zip
Avoid some deprecation warnings when casting raw XML into bool. (thanks pypy3)
-rw-r--r--poezio/core/handlers.py18
-rw-r--r--poezio/xhtml.py4
2 files changed, 11 insertions, 11 deletions
diff --git a/poezio/core/handlers.py b/poezio/core/handlers.py
index d56f451c..156f6b57 100644
--- a/poezio/core/handlers.py
+++ b/poezio/core/handlers.py
@@ -201,7 +201,7 @@ class HandlerCore:
When receiving private message from a muc OR a normal message
(from one of our contacts)
"""
- if message.xml.find('{http://jabber.org/protocol/muc#user}x/{http://jabber.org/protocol/muc#user}invite') != None:
+ if message.xml.find('{http://jabber.org/protocol/muc#user}x/{http://jabber.org/protocol/muc#user}invite') is not None:
return
if message['type'] == 'groupchat':
return
@@ -362,7 +362,7 @@ class HandlerCore:
if not contact:
return
item = message['pubsub_event']['items']['item']
- if item.xml.find('{http://jabber.org/protocol/nick}nick'):
+ if item.xml.find('{http://jabber.org/protocol/nick}nick') is not None:
contact.name = item['nick']['nick']
else:
contact.name = ''
@@ -377,7 +377,7 @@ class HandlerCore:
return
item = message['pubsub_event']['items']['item']
old_gaming = contact.gaming
- if item.xml.find('{urn:xmpp:gaming:0}gaming'):
+ if item.xml.find('{urn:xmpp:gaming:0}gaming') is not None:
item = item['gaming']
# only name and server_address are used for now
contact.gaming = {
@@ -412,7 +412,7 @@ class HandlerCore:
roster.modified()
item = message['pubsub_event']['items']['item']
old_mood = contact.mood
- if item.xml.find('{http://jabber.org/protocol/mood}mood'):
+ if item.xml.find('{http://jabber.org/protocol/mood}mood') is not None:
mood = item['mood']['value']
if mood:
mood = pep.MOODS.get(mood, mood)
@@ -445,7 +445,7 @@ class HandlerCore:
roster.modified()
item = message['pubsub_event']['items']['item']
old_activity = contact.activity
- if item.xml.find('{http://jabber.org/protocol/activity}activity'):
+ if item.xml.find('{http://jabber.org/protocol/activity}activity') is not None:
try:
activity = item['activity']['value']
except ValueError:
@@ -484,7 +484,7 @@ class HandlerCore:
roster.modified()
item = message['pubsub_event']['items']['item']
old_tune = contact.tune
- if item.xml.find('{http://jabber.org/protocol/tune}tune'):
+ if item.xml.find('{http://jabber.org/protocol/tune}tune') is not None:
item = item['tune']
contact.tune = {
'artist': item['artist'],
@@ -822,7 +822,7 @@ class HandlerCore:
### Presence-related handlers ###
def on_presence(self, presence):
- if presence.match('presence/muc') or presence.xml.find('{http://jabber.org/protocol/muc#user}x'):
+ if presence.match('presence/muc') or presence.xml.find('{http://jabber.org/protocol/muc#user}x') is not None:
return
jid = presence['from']
contact = roster[jid.bare]
@@ -862,7 +862,7 @@ class HandlerCore:
"""
A JID got offline
"""
- if presence.match('presence/muc') or presence.xml.find('{http://jabber.org/protocol/muc#user}x'):
+ if presence.match('presence/muc') or presence.xml.find('{http://jabber.org/protocol/muc#user}x') is not None:
return
jid = presence['from']
if not logger.log_roster_change(jid.bare, 'got offline'):
@@ -887,7 +887,7 @@ class HandlerCore:
"""
A JID got online
"""
- if presence.match('presence/muc') or presence.xml.find('{http://jabber.org/protocol/muc#user}x'):
+ if presence.match('presence/muc') or presence.xml.find('{http://jabber.org/protocol/muc#user}x') is not None:
return
jid = presence['from']
contact = roster[jid.bare]
diff --git a/poezio/xhtml.py b/poezio/xhtml.py
index 59c2ac7c..3d988806 100644
--- a/poezio/xhtml.py
+++ b/poezio/xhtml.py
@@ -198,10 +198,10 @@ def get_body_from_message_stanza(message, use_xhtml=False,
if not use_xhtml:
return message['body']
xhtml = message.xml.find('{http://jabber.org/protocol/xhtml-im}html')
- if not xhtml:
+ if xhtml is not None:
return message['body']
xhtml_body = xhtml.find('{http://www.w3.org/1999/xhtml}body')
- if not xhtml_body:
+ if xhtml_body is not None:
return message['body']
content = xhtml_to_poezio_colors(xhtml_body, tmp_dir=tmp_dir,
extract_images=extract_images)