Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
49ca2382
by Philipp Hörist at 2018-09-15T23:10:04Z
26 changed files:
- gajim/adhoc_commands.py
- gajim/atom_window.py
- gajim/chat_control.py
- gajim/chat_control_base.py
- gajim/common/app.py
- gajim/common/connection.py
- gajim/common/contacts.py
- gajim/common/helpers.py
- gajim/common/optparser.py
- gajim/common/socks5.py
- gajim/common/zeroconf/client_zeroconf.py
- gajim/dataforms_widget.py
- gajim/filetransfers_window.py
- gajim/gajim_remote.py
- gajim/groupchat_control.py
- gajim/gtk/dialogs.py
- gajim/gtk/preferences.py
- gajim/gtk/privacy_list.py
- gajim/gui_interface.py
- gajim/gui_menu_builder.py
- gajim/message_window.py
- gajim/music_track_listener.py
- gajim/roster_window.py
- gajim/search_window.py
- gajim/session.py
- gajim/statusicon.py
Changes:
| ... | ... | @@ -236,7 +236,7 @@ class CommandWindow: |
| 236 | 236 |
# close old stage
|
| 237 | 237 |
self.stage_finish()
|
| 238 | 238 |
|
| 239 |
- assert len(self.commandlist)>0
|
|
| 239 |
+ assert self.commandlist
|
|
| 240 | 240 |
|
| 241 | 241 |
self.stages_notebook.set_current_page(
|
| 242 | 242 |
self.stages_notebook.page_num(self.command_list_stage_vbox))
|
| ... | ... | @@ -48,7 +48,7 @@ class AtomWindow: |
| 48 | 48 |
"""
|
| 49 | 49 |
Create new window... only if we have anything to show
|
| 50 | 50 |
"""
|
| 51 |
- assert len(self.__class__.entries)
|
|
| 51 |
+ assert self.__class__.entries
|
|
| 52 | 52 |
|
| 53 | 53 |
self.entry = None # the entry actually displayed
|
| 54 | 54 |
|
| ... | ... | @@ -72,7 +72,7 @@ class AtomWindow: |
| 72 | 72 |
"""
|
| 73 | 73 |
Get next entry from the queue and display it in the window
|
| 74 | 74 |
"""
|
| 75 |
- assert len(self.__class__.entries)>0
|
|
| 75 |
+ assert self.__class__.entries
|
|
| 76 | 76 |
|
| 77 | 77 |
newentry = self.__class__.entries.pop(0)
|
| 78 | 78 |
|
| ... | ... | @@ -1377,7 +1377,7 @@ class ChatControl(ChatControlBase): |
| 1377 | 1377 |
local_old_kind = None
|
| 1378 | 1378 |
else:
|
| 1379 | 1379 |
local_old_kind = kind
|
| 1380 |
- if len(rows):
|
|
| 1380 |
+ if rows:
|
|
| 1381 | 1381 |
self.conv_textview.print_empty_line()
|
| 1382 | 1382 |
|
| 1383 | 1383 |
def read_queue(self):
|
| ... | ... | @@ -1222,7 +1222,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 1222 | 1222 |
else: # Not a GC
|
| 1223 | 1223 |
types_list = ['printed_' + type_, type_]
|
| 1224 | 1224 |
|
| 1225 |
- if not len(app.events.get_events(self.account, jid, types_list)):
|
|
| 1225 |
+ if not app.events.get_events(self.account, jid, types_list):
|
|
| 1226 | 1226 |
return
|
| 1227 | 1227 |
if not self.parent_win:
|
| 1228 | 1228 |
return
|
| ... | ... | @@ -481,7 +481,7 @@ def get_transport_name_from_jid(jid, use_config_setting = True): |
| 481 | 481 |
|
| 482 | 482 |
# host is now f.e. icq.foo.org or just icq (sometimes on hacky transports)
|
| 483 | 483 |
host_splitted = host.split('.')
|
| 484 |
- if len(host_splitted) != 0:
|
|
| 484 |
+ if host_splitted:
|
|
| 485 | 485 |
# now we support both 'icq.' and 'icq' but not icqsucks.org
|
| 486 | 486 |
host = host_splitted[0]
|
| 487 | 487 |
|
| ... | ... | @@ -1275,7 +1275,7 @@ class Connection(CommonConnection, ConnectionHandlers): |
| 1275 | 1275 |
for mech in auth_mechs:
|
| 1276 | 1276 |
if mech not in nbxmpp.auth_nb.SASL_AUTHENTICATION_MECHANISMS | set(['XEP-0078']):
|
| 1277 | 1277 |
log.warning("Unknown authentication mechanisms %s" % mech)
|
| 1278 |
- if len(auth_mechs) == 0:
|
|
| 1278 |
+ if not auth_mechs:
|
|
| 1279 | 1279 |
auth_mechs = None
|
| 1280 | 1280 |
else:
|
| 1281 | 1281 |
auth_mechs = set(auth_mechs)
|
| ... | ... | @@ -1453,7 +1453,7 @@ class Connection(CommonConnection, ConnectionHandlers): |
| 1453 | 1453 |
self._on_stun_resolved)
|
| 1454 | 1454 |
|
| 1455 | 1455 |
def _on_stun_resolved(self, host, result_array):
|
| 1456 |
- if len(result_array) != 0:
|
|
| 1456 |
+ if result_array:
|
|
| 1457 | 1457 |
self._stun_servers = self._hosts = [i for i in result_array]
|
| 1458 | 1458 |
|
| 1459 | 1459 |
@helpers.call_counter
|
| ... | ... | @@ -156,7 +156,7 @@ class Contact(CommonContact): |
| 156 | 156 |
return False
|
| 157 | 157 |
if self.sub in ('none', 'from') and self.ask == 'subscribe':
|
| 158 | 158 |
return False
|
| 159 |
- if self.sub in ('none', 'from') and (self.name or len(self.groups)):
|
|
| 159 |
+ if self.sub in ('none', 'from') and (self.name or self.groups):
|
|
| 160 | 160 |
return False
|
| 161 | 161 |
if _('Not in Roster') in self.groups:
|
| 162 | 162 |
return False
|
| ... | ... | @@ -486,7 +486,7 @@ class Contacts(): |
| 486 | 486 |
return
|
| 487 | 487 |
if contact in self._contacts[contact.jid]:
|
| 488 | 488 |
self._contacts[contact.jid].remove(contact)
|
| 489 |
- if len(self._contacts[contact.jid]) == 0:
|
|
| 489 |
+ if not self._contacts[contact.jid]:
|
|
| 490 | 490 |
del self._contacts[contact.jid]
|
| 491 | 491 |
|
| 492 | 492 |
def remove_jid(self, jid):
|
| ... | ... | @@ -626,7 +626,7 @@ class GC_Contacts(): |
| 626 | 626 |
return
|
| 627 | 627 |
del self._rooms[gc_contact.room_jid][gc_contact.name]
|
| 628 | 628 |
# It was the last nick in room ?
|
| 629 |
- if not len(self._rooms[gc_contact.room_jid]):
|
|
| 629 |
+ if not self._rooms[gc_contact.room_jid]:
|
|
| 630 | 630 |
del self._rooms[gc_contact.room_jid]
|
| 631 | 631 |
|
| 632 | 632 |
def remove_room(self, room_jid):
|
| ... | ... | @@ -214,7 +214,7 @@ def prep(user, server, resource): |
| 214 | 214 |
if server is not None:
|
| 215 | 215 |
if server.endswith('.'): # RFC7622, 3.2
|
| 216 | 216 |
server = server[:-1]
|
| 217 |
- if len(server) < 1 or len(server.encode('utf-8')) > 1023:
|
|
| 217 |
+ if not server or len(server.encode('utf-8')) > 1023:
|
|
| 218 | 218 |
raise InvalidFormat(_('Server must be between 1 and 1023 bytes'))
|
| 219 | 219 |
try:
|
| 220 | 220 |
from nbxmpp.stringprepare import nameprep
|
| ... | ... | @@ -225,7 +225,7 @@ def prep(user, server, resource): |
| 225 | 225 |
raise InvalidFormat(_('Server address required.'))
|
| 226 | 226 |
|
| 227 | 227 |
if user is not None:
|
| 228 |
- if len(user) < 1 or len(user.encode('utf-8')) > 1023:
|
|
| 228 |
+ if not user or len(user.encode('utf-8')) > 1023:
|
|
| 229 | 229 |
raise InvalidFormat(_('Username must be between 1 and 1023 bytes'))
|
| 230 | 230 |
try:
|
| 231 | 231 |
if HAS_PRECIS_I18N:
|
| ... | ... | @@ -239,7 +239,7 @@ def prep(user, server, resource): |
| 239 | 239 |
user = None
|
| 240 | 240 |
|
| 241 | 241 |
if resource is not None:
|
| 242 |
- if len(resource) < 1 or len(resource.encode('utf-8')) > 1023:
|
|
| 242 |
+ if not resource or len(resource.encode('utf-8')) > 1023:
|
|
| 243 | 243 |
raise InvalidFormat(_('Resource must be between 1 and 1023 bytes'))
|
| 244 | 244 |
try:
|
| 245 | 245 |
if HAS_PRECIS_I18N:
|
| ... | ... | @@ -1054,7 +1054,7 @@ def get_notification_icon_tooltip_text(): |
| 1054 | 1054 |
|
| 1055 | 1055 |
accounts = get_notification_icon_tooltip_dict()
|
| 1056 | 1056 |
|
| 1057 |
- if len(accounts) == 0:
|
|
| 1057 |
+ if not accounts:
|
|
| 1058 | 1058 |
# No configured account
|
| 1059 | 1059 |
return _('Gajim')
|
| 1060 | 1060 |
|
| ... | ... | @@ -126,11 +126,11 @@ class OptionsParser: |
| 126 | 126 |
def update_config(self, old_version, new_version):
|
| 127 | 127 |
old_version_list = old_version.split('.') # convert '0.x.y' to (0, x, y)
|
| 128 | 128 |
old = []
|
| 129 |
- while len(old_version_list):
|
|
| 129 |
+ while old_version_list:
|
|
| 130 | 130 |
old.append(int(old_version_list.pop(0)))
|
| 131 | 131 |
new_version_list = new_version.split('.')
|
| 132 | 132 |
new = []
|
| 133 |
- while len(new_version_list):
|
|
| 133 |
+ while new_version_list:
|
|
| 134 | 134 |
new.append(int(new_version_list.pop(0)))
|
| 135 | 135 |
|
| 136 | 136 |
if old < [0, 14, 0, 1] and new >= [0, 14, 0, 1]:
|
| ... | ... | @@ -426,7 +426,7 @@ class SocksQueue: |
| 426 | 426 |
self.remove_sender_by_key(key, do_disconnect=do_disconnect)
|
| 427 | 427 |
if not remove_all:
|
| 428 | 428 |
break
|
| 429 |
- if len(self.senders) == 0 and self.listener is not None:
|
|
| 429 |
+ if not self.senders and self.listener is not None:
|
|
| 430 | 430 |
self.listener.disconnect()
|
| 431 | 431 |
self.listener = None
|
| 432 | 432 |
self.connected -= 1
|
| ... | ... | @@ -646,7 +646,7 @@ class Socks5(object): |
| 646 | 646 |
except Exception:
|
| 647 | 647 |
add = b''
|
| 648 | 648 |
received += add
|
| 649 |
- if len(add) == 0:
|
|
| 649 |
+ if not add:
|
|
| 650 | 650 |
self.disconnect()
|
| 651 | 651 |
return add
|
| 652 | 652 |
|
| ... | ... | @@ -676,7 +676,7 @@ class Socks5(object): |
| 676 | 676 |
self.file_props.error = -7 # unable to read from file
|
| 677 | 677 |
return -1
|
| 678 | 678 |
buff = self.file.read(MAX_BUFF_LEN)
|
| 679 |
- if len(buff) > 0:
|
|
| 679 |
+ if buff:
|
|
| 680 | 680 |
lenn = 0
|
| 681 | 681 |
try:
|
| 682 | 682 |
lenn = self._send(buff)
|
| ... | ... | @@ -765,7 +765,7 @@ class Socks5(object): |
| 765 | 765 |
self.file_props.last_time
|
| 766 | 766 |
self.file_props.last_time = current_time
|
| 767 | 767 |
self.file_props.received_len += len(buff)
|
| 768 |
- if len(buff) == 0:
|
|
| 768 |
+ if not buff:
|
|
| 769 | 769 |
# Transfer stopped somehow:
|
| 770 | 770 |
# reset, paused or network error
|
| 771 | 771 |
self.rem_fd(fd)
|
| ... | ... | @@ -373,14 +373,16 @@ class P2PConnection(IdleObject, PlugIn): |
| 373 | 373 |
except socket.gaierror as e:
|
| 374 | 374 |
log.info('Lookup failure for %s: %s[%s]', self.host, e[1],
|
| 375 | 375 |
repr(e[0]), exc_info=True)
|
| 376 |
- if len(self.addresses_) > 0: return self.get_next_addrinfo()
|
|
| 376 |
+ if self.addresses_:
|
|
| 377 |
+ return self.get_next_addrinfo()
|
|
| 377 | 378 |
else:
|
| 378 | 379 |
self.connect_to_next_ip()
|
| 379 | 380 |
|
| 380 | 381 |
def connect_to_next_ip(self):
|
| 381 |
- if len(self.ais) == 0:
|
|
| 382 |
+ if not self.ais:
|
|
| 382 | 383 |
log.error('Connection failure to %s', str(self.host), exc_info=True)
|
| 383 |
- if len(self.addresses_) > 0: return self.get_next_addrinfo()
|
|
| 384 |
+ if self.addresses_:
|
|
| 385 |
+ return self.get_next_addrinfo()
|
|
| 384 | 386 |
self.disconnect()
|
| 385 | 387 |
return
|
| 386 | 388 |
ai = self.ais.pop(0)
|
| ... | ... | @@ -449,7 +451,7 @@ class P2PConnection(IdleObject, PlugIn): |
| 449 | 451 |
|
| 450 | 452 |
def read_timeout(self):
|
| 451 | 453 |
ids = self.client.conn_holder.ids_of_awaiting_messages
|
| 452 |
- if self.fd in ids and len(ids[self.fd]) > 0:
|
|
| 454 |
+ if self.fd in ids and ids[self.fd]:
|
|
| 453 | 455 |
for (id_, thread_id) in ids[self.fd]:
|
| 454 | 456 |
if hasattr(self._owner, 'Dispatcher'):
|
| 455 | 457 |
self._owner.Dispatcher.Event('', DATA_ERROR, (
|
| ... | ... | @@ -265,7 +265,7 @@ class DataFormWidget(Gtk.Alignment, object): |
| 265 | 265 |
self.up_button.set_sensitive(False)
|
| 266 | 266 |
self.down_button.set_sensitive(False)
|
| 267 | 267 |
|
| 268 |
- if len(model) == 0:
|
|
| 268 |
+ if not model:
|
|
| 269 | 269 |
self.clear_button.set_sensitive(False)
|
| 270 | 270 |
else:
|
| 271 | 271 |
self.clear_button.set_sensitive(True)
|
| ... | ... | @@ -532,7 +532,7 @@ class FileTransfersWindow: |
| 532 | 532 |
return _('%(hours)02.d:%(minutes)02.d:%(seconds)02.d') % times
|
| 533 | 533 |
|
| 534 | 534 |
def _get_eta_and_speed(self, full_size, transfered_size, file_props):
|
| 535 |
- if len(file_props.transfered_size) == 0:
|
|
| 535 |
+ if not file_props.transfered_size:
|
|
| 536 | 536 |
return 0., 0.
|
| 537 | 537 |
elif len(file_props.transfered_size) == 1:
|
| 538 | 538 |
speed = round(float(transfered_size) / file_props.elapsed_time)
|
| ... | ... | @@ -739,7 +739,7 @@ class FileTransfersWindow: |
| 739 | 739 |
Check if there are transfer rows and set cleanup_button sensitive, or
|
| 740 | 740 |
insensitive if model is empty
|
| 741 | 741 |
"""
|
| 742 |
- if len(self.model) == 0:
|
|
| 742 |
+ if not self.model:
|
|
| 743 | 743 |
self.cleanup_button.set_sensitive(False)
|
| 744 | 744 |
else:
|
| 745 | 745 |
self.cleanup_button.set_sensitive(True)
|
| ... | ... | @@ -369,7 +369,7 @@ class GajimRemote: |
| 369 | 369 |
str_ = _('Usage: %(basename)s %(command)s %(arguments)s \n\t %(help)s')\
|
| 370 | 370 |
% {'basename': BASENAME, 'command': command,
|
| 371 | 371 |
'arguments': arguments_str, 'help': command_props[0]}
|
| 372 |
- if len(command_props[1]) > 0:
|
|
| 372 |
+ if command_props[1]:
|
|
| 373 | 373 |
str_ += '\n\n' + _('Arguments:') + '\n'
|
| 374 | 374 |
for argument in command_props[1]:
|
| 375 | 375 |
str_ += ' ' + argument[0] + ' - ' + argument[1] + '\n'
|
| ... | ... | @@ -1702,8 +1702,7 @@ class GroupchatControl(ChatControlBase): |
| 1702 | 1702 |
gc_contact = app.contacts.get_gc_contact(self.account, self.room_jid,
|
| 1703 | 1703 |
nick)
|
| 1704 | 1704 |
theme = Gtk.IconTheme.get_default()
|
| 1705 |
- if len(app.events.get_events(self.account, self.room_jid + '/' + \
|
|
| 1706 |
- nick)):
|
|
| 1705 |
+ if app.events.get_events(self.account, self.room_jid + '/' + nick):
|
|
| 1707 | 1706 |
icon_name = gtkgui_helpers.get_iconset_name_for('event')
|
| 1708 | 1707 |
surface = theme.load_surface(icon_name, 16, self.scale_factor, None, 0)
|
| 1709 | 1708 |
else:
|
| ... | ... | @@ -1914,8 +1913,8 @@ class GroupchatControl(ChatControlBase): |
| 1914 | 1913 |
self.autorejoin = False
|
| 1915 | 1914 |
self.print_conversation(obj.reason, 'info', graphics=False)
|
| 1916 | 1915 |
|
| 1917 |
- if len(app.events.get_events(self.account, jid=obj.fjid,
|
|
| 1918 |
- types=['pm'])) == 0:
|
|
| 1916 |
+ if not app.events.get_events(
|
|
| 1917 |
+ self.account, jid=obj.fjid, types=['pm']):
|
|
| 1919 | 1918 |
self.remove_contact(obj.nick)
|
| 1920 | 1919 |
self.draw_all_roles()
|
| 1921 | 1920 |
else:
|
| ... | ... | @@ -2471,7 +2470,7 @@ class GroupchatControl(ChatControlBase): |
| 2471 | 2470 |
|
| 2472 | 2471 |
# nick completion
|
| 2473 | 2472 |
# check if tab is pressed with empty message
|
| 2474 |
- if len(splitted_text): # if there are any words
|
|
| 2473 |
+ if splitted_text: # if there are any words
|
|
| 2475 | 2474 |
begin = splitted_text[-1] # last word we typed
|
| 2476 | 2475 |
else:
|
| 2477 | 2476 |
begin = ''
|
| ... | ... | @@ -2485,7 +2484,7 @@ class GroupchatControl(ChatControlBase): |
| 2485 | 2484 |
gc_refer_to_nick_char + ' '):
|
| 2486 | 2485 |
with_refer_to_nick_char = True
|
| 2487 | 2486 |
after_nick_len = len(gc_refer_to_nick_char + ' ')
|
| 2488 |
- if len(self.nick_hits) and self.last_key_tabs and \
|
|
| 2487 |
+ if self.nick_hits and self.last_key_tabs and \
|
|
| 2489 | 2488 |
text[:-after_nick_len].endswith(self.nick_hits[0]):
|
| 2490 | 2489 |
# we should cycle
|
| 2491 | 2490 |
# Previous nick in list may had a space inside, so we check text
|
| ... | ... | @@ -2512,7 +2511,7 @@ class GroupchatControl(ChatControlBase): |
| 2512 | 2511 |
helpers.jid_is_blocked(self.account, fjid):
|
| 2513 | 2512 |
# the word is the beginning of a nick
|
| 2514 | 2513 |
self.nick_hits.append(nick)
|
| 2515 |
- if len(self.nick_hits):
|
|
| 2514 |
+ if self.nick_hits:
|
|
| 2516 | 2515 |
if len(splitted_text) < 2 or with_refer_to_nick_char:
|
| 2517 | 2516 |
# This is the 1st word of the line or no word or we are cycling
|
| 2518 | 2517 |
# at the beginning, possibly with a space in one nick
|
| ... | ... | @@ -727,7 +727,7 @@ class ChangeNickDialog(InputDialogCheck): |
| 727 | 727 |
app.config.get('gc_proposed_nick_char'))
|
| 728 | 728 |
|
| 729 | 729 |
def check_next(self):
|
| 730 |
- if len(self.room_queue) == 0:
|
|
| 730 |
+ if not self.room_queue:
|
|
| 731 | 731 |
self.cancel_handler = None
|
| 732 | 732 |
self.dialog.destroy()
|
| 733 | 733 |
if 'change_nick_dialog' in app.interface.instances:
|
| ... | ... | @@ -475,7 +475,7 @@ class Preferences(Gtk.ApplicationWindow): |
| 475 | 475 |
Return the value of the option opt if it's the same in all accounts else
|
| 476 | 476 |
returns "mixed"
|
| 477 | 477 |
"""
|
| 478 |
- if len(app.connections) == 0:
|
|
| 478 |
+ if not app.connections:
|
|
| 479 | 479 |
# a non existent key return default value
|
| 480 | 480 |
return app.config.get_per('accounts', '__default__', opt)
|
| 481 | 481 |
val = None
|
| ... | ... | @@ -153,7 +153,7 @@ class PrivacyListWindow: |
| 153 | 153 |
self.max_order = int(rule['order'])
|
| 154 | 154 |
self.global_rules[text_item] = rule
|
| 155 | 155 |
model.append([text_item])
|
| 156 |
- if len(rules) == 0:
|
|
| 156 |
+ if not rules:
|
|
| 157 | 157 |
self.title_hbox.set_sensitive(False)
|
| 158 | 158 |
self.list_of_rules_combobox.set_sensitive(False)
|
| 159 | 159 |
self.delete_rule_button.set_sensitive(False)
|
| ... | ... | @@ -474,7 +474,7 @@ class PrivacyListsWindow: |
| 474 | 474 |
self.draw_widgets()
|
| 475 | 475 |
|
| 476 | 476 |
def draw_widgets(self):
|
| 477 |
- if len(self.privacy_lists_save) == 0:
|
|
| 477 |
+ if not self.privacy_lists_save:
|
|
| 478 | 478 |
self.list_of_privacy_lists_combobox.set_sensitive(False)
|
| 479 | 479 |
self.open_privacy_list_button.set_sensitive(False)
|
| 480 | 480 |
self.delete_privacy_list_button.set_sensitive(False)
|
| ... | ... | @@ -1974,7 +1974,7 @@ class Interface: |
| 1974 | 1974 |
if s.control:
|
| 1975 | 1975 |
session = s
|
| 1976 | 1976 |
break
|
| 1977 |
- if not session and not len(sessions) == 0:
|
|
| 1977 |
+ if not session and sessions:
|
|
| 1978 | 1978 |
# there are no sessions with chat controls, just take the first
|
| 1979 | 1979 |
# one
|
| 1980 | 1980 |
session = sessions[0]
|
| ... | ... | @@ -2018,7 +2018,7 @@ class Interface: |
| 2018 | 2018 |
|
| 2019 | 2019 |
mw.new_tab(chat_control)
|
| 2020 | 2020 |
|
| 2021 |
- if len(app.events.get_events(account, fjid)):
|
|
| 2021 |
+ if app.events.get_events(account, fjid):
|
|
| 2022 | 2022 |
# We call this here to avoid race conditions with widget validation
|
| 2023 | 2023 |
chat_control.read_queue()
|
| 2024 | 2024 |
|
| ... | ... | @@ -2038,7 +2038,7 @@ class Interface: |
| 2038 | 2038 |
if not ctrl:
|
| 2039 | 2039 |
ctrl = self.new_chat(contact, account,
|
| 2040 | 2040 |
resource=resource)
|
| 2041 |
- if len(app.events.get_events(account, fjid)):
|
|
| 2041 |
+ if app.events.get_events(account, fjid):
|
|
| 2042 | 2042 |
ctrl.read_queue()
|
| 2043 | 2043 |
|
| 2044 | 2044 |
if message:
|
| ... | ... | @@ -2644,7 +2644,7 @@ class Interface: |
| 2644 | 2644 |
# except Exception:
|
| 2645 | 2645 |
# pass
|
| 2646 | 2646 |
# add default status messages if there is not in the config file
|
| 2647 |
- if len(app.config.get_per('statusmsg')) == 0:
|
|
| 2647 |
+ if not app.config.get_per('statusmsg'):
|
|
| 2648 | 2648 |
default = app.config.statusmsg_default
|
| 2649 | 2649 |
for msg in default:
|
| 2650 | 2650 |
app.config.add_per('statusmsg', msg)
|
| ... | ... | @@ -2662,7 +2662,7 @@ class Interface: |
| 2662 | 2662 |
default[msg][5])
|
| 2663 | 2663 |
|
| 2664 | 2664 |
# Add Tor proxy if there is not in the config
|
| 2665 |
- if len(app.config.get_per('proxies')) == 0:
|
|
| 2665 |
+ if not app.config.get_per('proxies'):
|
|
| 2666 | 2666 |
default = app.config.proxies_default
|
| 2667 | 2667 |
for proxy in default:
|
| 2668 | 2668 |
app.config.add_per('proxies', proxy)
|
| ... | ... | @@ -2807,7 +2807,7 @@ class PassphraseRequest: |
| 2807 | 2807 |
self.callbacks.remove((acct, cb))
|
| 2808 | 2808 |
else:
|
| 2809 | 2809 |
self.callbacks = []
|
| 2810 |
- if not len(self.callbacks):
|
|
| 2810 |
+ if not self.callbacks:
|
|
| 2811 | 2811 |
self.dialog.window.destroy()
|
| 2812 | 2812 |
|
| 2813 | 2813 |
def run_callback(self, account, callback):
|
| ... | ... | @@ -111,7 +111,7 @@ show_bookmarked=False, force_resource=False): |
| 111 | 111 |
for (c, a) in list_:
|
| 112 | 112 |
if c.supports(NS_MUC):
|
| 113 | 113 |
list2.append((c, a))
|
| 114 |
- if len(list2) > 0:
|
|
| 114 |
+ if list2:
|
|
| 115 | 115 |
invite_to_new_room_menuitem.connect('activate',
|
| 116 | 116 |
roster.on_invite_to_new_room, list2, None)
|
| 117 | 117 |
else:
|
| ... | ... | @@ -144,7 +144,7 @@ show_bookmarked=False, force_resource=False): |
| 144 | 144 |
app.gc_connected[acct][room_jid] and \
|
| 145 | 145 |
contacts_transport in ['jabber', None]:
|
| 146 | 146 |
rooms.append((room_jid, acct))
|
| 147 |
- if len(rooms):
|
|
| 147 |
+ if rooms:
|
|
| 148 | 148 |
item = Gtk.SeparatorMenuItem.new() # separator
|
| 149 | 149 |
invite_to_submenu.append(item)
|
| 150 | 150 |
for (room_jid, account) in rooms:
|
| ... | ... | @@ -570,7 +570,7 @@ class MessageWindow(object): |
| 570 | 570 |
|
| 571 | 571 |
del self._controls[ctrl.account][fjid]
|
| 572 | 572 |
|
| 573 |
- if len(self._controls[ctrl.account]) == 0:
|
|
| 573 |
+ if not self._controls[ctrl.account]:
|
|
| 574 | 574 |
del self._controls[ctrl.account]
|
| 575 | 575 |
|
| 576 | 576 |
self.check_tabs()
|
| ... | ... | @@ -155,7 +155,7 @@ class MusicTrackListener(GObject.GObject): |
| 155 | 155 |
info.title = meta.get('xesam:title')
|
| 156 | 156 |
info.album = meta.get('xesam:album')
|
| 157 | 157 |
artist = meta.get('xesam:artist')
|
| 158 |
- if artist is not None and len(artist):
|
|
| 158 |
+ if artist:
|
|
| 159 | 159 |
info.artist = artist[0]
|
| 160 | 160 |
else:
|
| 161 | 161 |
info.artist = None
|
| ... | ... | @@ -388,7 +388,7 @@ class RosterWindow: |
| 388 | 388 |
parent_iters = self._get_contact_iter(
|
| 389 | 389 |
big_brother_contact.jid, big_brother_account,
|
| 390 | 390 |
big_brother_contact, self.model)
|
| 391 |
- assert len(parent_iters) > 0, 'Big brother is not yet in roster!'
|
|
| 391 |
+ assert parent_iters, 'Big brother is not yet in roster!'
|
|
| 392 | 392 |
|
| 393 | 393 |
# Do not confuse get_contact_iter: Sync groups of family members
|
| 394 | 394 |
contact.groups = big_brother_contact.groups[:]
|
| ... | ... | @@ -445,8 +445,7 @@ class RosterWindow: |
| 445 | 445 |
if group not in app.groups[account]:
|
| 446 | 446 |
app.groups[account][group] = {'expand': is_expanded}
|
| 447 | 447 |
|
| 448 |
- assert len(added_iters), '%s has not been added to roster!' % \
|
|
| 449 |
- contact.jid
|
|
| 448 |
+ assert added_iters, '%s has not been added to roster!' % contact.jid
|
|
| 450 | 449 |
return added_iters
|
| 451 | 450 |
|
| 452 | 451 |
def _remove_entity(self, contact, account, groups=None):
|
| ... | ... | @@ -530,8 +529,8 @@ class RosterWindow: |
| 530 | 529 |
big_brother_contact = app.contacts.get_first_contact_from_jid(
|
| 531 | 530 |
big_brother_account, big_brother_jid)
|
| 532 | 531 |
|
| 533 |
- assert len(self._get_contact_iter(big_brother_jid,
|
|
| 534 |
- big_brother_account, big_brother_contact, self.model)) == 0, \
|
|
| 532 |
+ assert not self._get_contact_iter(big_brother_jid,
|
|
| 533 |
+ big_brother_account, big_brother_contact, self.model), \
|
|
| 535 | 534 |
'Big brother %s already in roster\n Family: %s' \
|
| 536 | 535 |
% (big_brother_jid, family)
|
| 537 | 536 |
self._add_entity(big_brother_contact, big_brother_account)
|
| ... | ... | @@ -549,8 +548,8 @@ class RosterWindow: |
| 549 | 548 |
# or brother already added
|
| 550 | 549 |
continue
|
| 551 | 550 |
|
| 552 |
- assert len(self._get_contact_iter(_jid, _account,
|
|
| 553 |
- _contact, self.model)) == 0, \
|
|
| 551 |
+ assert not self._get_contact_iter(_jid, _account,
|
|
| 552 |
+ _contact, self.model), \
|
|
| 554 | 553 |
"%s already in roster.\n Family: %s" % (_jid, nearby_family)
|
| 555 | 554 |
self._add_entity(_contact, _account,
|
| 556 | 555 |
big_brother_contact = big_brother_contact,
|
| ... | ... | @@ -600,8 +599,8 @@ class RosterWindow: |
| 600 | 599 |
|
| 601 | 600 |
ok = self._remove_entity(_contact, _account)
|
| 602 | 601 |
assert ok, '%s was not removed' % _jid
|
| 603 |
- assert len(self._get_contact_iter(_jid, _account, _contact,
|
|
| 604 |
- self.model)) == 0, '%s is removed but still in roster' % _jid
|
|
| 602 |
+ assert not self._get_contact_iter(_jid, _account, _contact,
|
|
| 603 |
+ self.model), '%s is removed but still in roster' % _jid
|
|
| 605 | 604 |
|
| 606 | 605 |
if not family_in_roster:
|
| 607 | 606 |
return False
|
| ... | ... | @@ -610,15 +609,15 @@ class RosterWindow: |
| 610 | 609 |
(nearby_family, family)
|
| 611 | 610 |
iters = self._get_contact_iter(old_big_jid, old_big_account,
|
| 612 | 611 |
old_big_contact, self.model)
|
| 613 |
- assert len(iters) > 0, 'Old Big Brother %s is not in roster anymore' % \
|
|
| 612 |
+ assert iters, 'Old Big Brother %s is not in roster anymore' % \
|
|
| 614 | 613 |
old_big_jid
|
| 615 | 614 |
assert not self.model.iter_children(iters[0]), \
|
| 616 | 615 |
'Old Big Brother %s still has children' % old_big_jid
|
| 617 | 616 |
|
| 618 | 617 |
ok = self._remove_entity(old_big_contact, old_big_account)
|
| 619 | 618 |
assert ok, "Old Big Brother %s not removed" % old_big_jid
|
| 620 |
- assert len(self._get_contact_iter(old_big_jid, old_big_account,
|
|
| 621 |
- old_big_contact, self.model)) == 0, \
|
|
| 619 |
+ assert not self._get_contact_iter(old_big_jid, old_big_account,
|
|
| 620 |
+ old_big_contact, self.model), \
|
|
| 622 | 621 |
'Old Big Brother %s is removed but still in roster' % old_big_jid
|
| 623 | 622 |
|
| 624 | 623 |
return True
|
| ... | ... | @@ -683,8 +682,8 @@ class RosterWindow: |
| 683 | 682 |
jid = app.get_jid_from_account(account)
|
| 684 | 683 |
contact = app.contacts.get_first_contact_from_jid(account, jid)
|
| 685 | 684 |
|
| 686 |
- assert len(self._get_contact_iter(jid, account, contact,
|
|
| 687 |
- self.model)) == 0, 'Self contact %s already in roster' % jid
|
|
| 685 |
+ assert not self._get_contact_iter(jid, account, contact,
|
|
| 686 |
+ self.model), 'Self contact %s already in roster' % jid
|
|
| 688 | 687 |
|
| 689 | 688 |
child_iterA = self._get_account_iter(account, self.model)
|
| 690 | 689 |
self._iters[account]['contacts'][jid] = [self.model.append(child_iterA,
|
| ... | ... | @@ -716,7 +715,7 @@ class RosterWindow: |
| 716 | 715 |
account -- the corresponding account.
|
| 717 | 716 |
"""
|
| 718 | 717 |
contact = app.contacts.get_contact_with_highest_priority(account, jid)
|
| 719 |
- if len(self._get_contact_iter(jid, account, contact, self.model)):
|
|
| 718 |
+ if self._get_contact_iter(jid, account, contact, self.model):
|
|
| 720 | 719 |
# If contact already in roster, do nothing
|
| 721 | 720 |
return
|
| 722 | 721 |
|
| ... | ... | @@ -1152,8 +1151,8 @@ class RosterWindow: |
| 1152 | 1151 |
to_hide = []
|
| 1153 | 1152 |
while(iterG):
|
| 1154 | 1153 |
parent = self.modelfilter.iter_parent(iterG)
|
| 1155 |
- if (not self.modelfilter.iter_has_child(iterG)) or (len(to_hide) > \
|
|
| 1156 |
- 0 and self.modelfilter.iter_n_children(iterG) == 1):
|
|
| 1154 |
+ if (not self.modelfilter.iter_has_child(iterG)) or (to_hide \
|
|
| 1155 |
+ and self.modelfilter.iter_n_children(iterG) == 1):
|
|
| 1157 | 1156 |
to_hide.append(iterG)
|
| 1158 | 1157 |
if not parent or self.modelfilter[parent][Column.TYPE] != \
|
| 1159 | 1158 |
'group':
|
| ... | ... | @@ -1300,7 +1299,7 @@ class RosterWindow: |
| 1300 | 1299 |
# a child has awaiting messages?
|
| 1301 | 1300 |
jidC = self.model[iterC][Column.JID]
|
| 1302 | 1301 |
accountC = self.model[iterC][Column.ACCOUNT]
|
| 1303 |
- if len(app.events.get_events(accountC, jidC)):
|
|
| 1302 |
+ if app.events.get_events(accountC, jidC):
|
|
| 1304 | 1303 |
icon_name = 'event'
|
| 1305 | 1304 |
break
|
| 1306 | 1305 |
iterC = self.model.iter_next(iterC)
|
| ... | ... | @@ -2583,7 +2582,7 @@ class RosterWindow: |
| 2583 | 2582 |
GLib.idle_add(ctrl.parent_win.set_active_tab, ctrl)
|
| 2584 | 2583 |
else:
|
| 2585 | 2584 |
ctrl = app.interface.new_chat(obj.contact, account)
|
| 2586 |
- if len(app.events.get_events(account, obj.jid)):
|
|
| 2585 |
+ if app.events.get_events(account, obj.jid):
|
|
| 2587 | 2586 |
ctrl.read_queue()
|
| 2588 | 2587 |
|
| 2589 | 2588 |
def _nec_gc_presence_received(self, obj):
|
| ... | ... | @@ -2718,7 +2717,7 @@ class RosterWindow: |
| 2718 | 2717 |
contact = app.contacts.get_contact(obj.conn.name, obj.jid)
|
| 2719 | 2718 |
obj.session.control = app.interface.new_chat(contact,
|
| 2720 | 2719 |
obj.conn.name, session=obj.session)
|
| 2721 |
- if len(app.events.get_events(obj.conn.name, obj.fjid)):
|
|
| 2720 |
+ if app.events.get_events(obj.conn.name, obj.fjid):
|
|
| 2722 | 2721 |
obj.session.control.read_queue()
|
| 2723 | 2722 |
|
| 2724 | 2723 |
if obj.show_in_roster:
|
| ... | ... | @@ -3196,7 +3195,7 @@ class RosterWindow: |
| 3196 | 3195 |
elif event.keyval == Gdk.KEY_Delete:
|
| 3197 | 3196 |
treeselection = self.tree.get_selection()
|
| 3198 | 3197 |
model, list_of_paths = treeselection.get_selected_rows()
|
| 3199 |
- if not len(list_of_paths):
|
|
| 3198 |
+ if not list_of_paths:
|
|
| 3200 | 3199 |
return
|
| 3201 | 3200 |
type_ = model[list_of_paths[0]][Column.TYPE]
|
| 3202 | 3201 |
account = model[list_of_paths[0]][Column.ACCOUNT]
|
| ... | ... | @@ -3535,7 +3534,7 @@ class RosterWindow: |
| 3535 | 3534 |
self.previous_status_combobox_active = active
|
| 3536 | 3535 |
return
|
| 3537 | 3536 |
accounts = list(app.connections.keys())
|
| 3538 |
- if len(accounts) == 0:
|
|
| 3537 |
+ if not accounts:
|
|
| 3539 | 3538 |
ErrorDialog(_('No account available'),
|
| 3540 | 3539 |
_('You must create an account before you can chat with other '
|
| 3541 | 3540 |
'contacts.'))
|
| ... | ... | @@ -3697,7 +3696,7 @@ class RosterWindow: |
| 3697 | 3696 |
# if a contact row is selected, update colors (eg. for status msg)
|
| 3698 | 3697 |
# because gtk engines may differ in bg when window is selected
|
| 3699 | 3698 |
# or not
|
| 3700 |
- if len(self._last_selected_contact):
|
|
| 3699 |
+ if self._last_selected_contact:
|
|
| 3701 | 3700 |
for (jid, account) in self._last_selected_contact:
|
| 3702 | 3701 |
self.draw_contact(jid, account, selected=True, focus=True)
|
| 3703 | 3702 |
|
| ... | ... | @@ -3705,7 +3704,7 @@ class RosterWindow: |
| 3705 | 3704 |
# if a contact row is selected, update colors (eg. for status msg)
|
| 3706 | 3705 |
# because gtk engines may differ in bg when window is selected
|
| 3707 | 3706 |
# or not
|
| 3708 |
- if len(self._last_selected_contact):
|
|
| 3707 |
+ if self._last_selected_contact:
|
|
| 3709 | 3708 |
for (jid, account) in self._last_selected_contact:
|
| 3710 | 3709 |
self.draw_contact(jid, account, selected=True, focus=False)
|
| 3711 | 3710 |
|
| ... | ... | @@ -3720,7 +3719,7 @@ class RosterWindow: |
| 3720 | 3719 |
# let message window close the tab
|
| 3721 | 3720 |
return
|
| 3722 | 3721 |
list_of_paths = self.tree.get_selection().get_selected_rows()[1]
|
| 3723 |
- if not len(list_of_paths) and not app.config.get(
|
|
| 3722 |
+ if not list_of_paths and not app.config.get(
|
|
| 3724 | 3723 |
'quit_on_roster_x_button') and ((app.interface.systray_enabled and\
|
| 3725 | 3724 |
app.config.get('trayicon') == 'always') or app.config.get(
|
| 3726 | 3725 |
'allow_hide_roster')):
|
| ... | ... | @@ -4385,7 +4384,7 @@ class RosterWindow: |
| 4385 | 4384 |
path = helpers.get_file_path_from_dnd_dropped_uri(a_uri)
|
| 4386 | 4385 |
if not os.path.isfile(path):
|
| 4387 | 4386 |
bad_uris.append(a_uri)
|
| 4388 |
- if len(bad_uris):
|
|
| 4387 |
+ if bad_uris:
|
|
| 4389 | 4388 |
ErrorDialog(_('Invalid file URI:'), '\n'.join(bad_uris))
|
| 4390 | 4389 |
return
|
| 4391 | 4390 |
def _on_send_files(account, jid, uris):
|
| ... | ... | @@ -5523,7 +5522,7 @@ class RosterWindow: |
| 5523 | 5522 |
except TypeError:
|
| 5524 | 5523 |
self.tree.get_selection().unselect_all()
|
| 5525 | 5524 |
return
|
| 5526 |
- if not len(list_of_paths):
|
|
| 5525 |
+ if not list_of_paths:
|
|
| 5527 | 5526 |
# no row is selected
|
| 5528 | 5527 |
return
|
| 5529 | 5528 |
if len(list_of_paths) > 1:
|
| ... | ... | @@ -209,7 +209,7 @@ class SearchWindow: |
| 209 | 209 |
return
|
| 210 | 210 |
|
| 211 | 211 |
self.dataform = dataforms.extend_form(node=obj.data)
|
| 212 |
- if len(self.dataform.items) == 0:
|
|
| 212 |
+ if not self.dataform.items:
|
|
| 213 | 213 |
# No result
|
| 214 | 214 |
self.label.set_text(_('No result'))
|
| 215 | 215 |
self.label.show()
|
| ... | ... | @@ -404,7 +404,7 @@ class ChatControlSession(object): |
| 404 | 404 |
self.control = app.interface.new_chat(contact,
|
| 405 | 405 |
self.conn.name, session=self)
|
| 406 | 406 |
|
| 407 |
- if len(app.events.get_events(self.conn.name, fjid)):
|
|
| 407 |
+ if app.events.get_events(self.conn.name, fjid):
|
|
| 408 | 408 |
self.control.read_queue()
|
| 409 | 409 |
else:
|
| 410 | 410 |
if no_queue: # We didn't have a queue: we change icons
|
| ... | ... | @@ -371,7 +371,7 @@ class StatusIcon: |
| 371 | 371 |
|
| 372 | 372 |
def on_left_click(self):
|
| 373 | 373 |
win = app.interface.roster.window
|
| 374 |
- if len(app.events.get_systray_events()) == 0:
|
|
| 374 |
+ if not app.events.get_systray_events():
|
|
| 375 | 375 |
# No pending events, so toggle visible/hidden for roster window
|
| 376 | 376 |
if win.get_property('visible') and (win.get_property(
|
| 377 | 377 |
'has-toplevel-focus') or os.name == 'nt'):
|