changeset 988933a90557 in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=988933a90557
description: Small refactoring bits
diffstat:
src/common/contacts.py | 25 ++++++++-----------------
1 files changed, 8 insertions(+), 17 deletions(-)
diffs (82 lines):
diff -r 88ce17cd9d82 -r 988933a90557 src/common/contacts.py
--- a/src/common/contacts.py Sun Nov 29 23:08:17 2009 +0100
+++ b/src/common/contacts.py Mon Nov 30 12:53:26 2009 +0200
@@ -31,7 +31,7 @@
from common import caps
from common.account import Account
-import common.gajim
+import common.gajim
class XMPPEntity(object):
"""
@@ -175,9 +175,7 @@
def is_transport(self):
# if not '@' or '@' starts the jid then contact is transport
- if self.jid.find('@') <= 0:
- return True
- return False
+ return self.jid.find('@') <= 0
class GC_Contact(CommonContact):
@@ -443,18 +441,14 @@
"""
Remove all contacts for a given jid
"""
- if jid not in self._contacts:
- return
- del self._contacts[jid]
+ if jid in self._contacts:
+ del self._contacts[jid]
def get_contacts(self, jid):
"""
Return the list of contact instances for this jid
"""
- if jid in self._contacts:
- return self._contacts[jid]
- else:
- return []
+ return self._contacts.get(jid, [])
def get_contact(self, jid, resource=None):
### WARNING ###
@@ -472,7 +466,6 @@
for c in self._contacts[jid]:
if c.resource == resource:
return c
- return None
def iter_contacts(self):
for jid in self._contacts.keys():
@@ -492,7 +485,6 @@
def get_first_contact_from_jid(self, jid):
if jid in self._contacts:
return self._contacts[jid][0]
- return None
def get_contacts_from_group(self, group):
"""
@@ -538,9 +530,8 @@
del self._rooms[gc_contact.room_jid]
def remove_room(self, room_jid):
- if room_jid not in self._rooms:
- return
- del self._rooms[room_jid]
+ if room_jid in self._rooms:
+ del self._rooms[room_jid]
def get_gc_list(self):
return self._rooms.keys()
@@ -643,7 +634,7 @@
def remove_metacontact(self, account, jid):
if not account in self._metacontacts_tags:
- return None
+ return
found = None
for tag in self._metacontacts_tags[account]: