Fix len-as-condition pylint errors
This commit is contained in:
parent
e953820ff8
commit
a3c687dae1
|
@ -236,7 +236,7 @@ class CommandWindow:
|
||||||
# close old stage
|
# close old stage
|
||||||
self.stage_finish()
|
self.stage_finish()
|
||||||
|
|
||||||
assert len(self.commandlist)>0
|
assert self.commandlist
|
||||||
|
|
||||||
self.stages_notebook.set_current_page(
|
self.stages_notebook.set_current_page(
|
||||||
self.stages_notebook.page_num(self.command_list_stage_vbox))
|
self.stages_notebook.page_num(self.command_list_stage_vbox))
|
||||||
|
|
|
@ -48,7 +48,7 @@ class AtomWindow:
|
||||||
"""
|
"""
|
||||||
Create new window... only if we have anything to show
|
Create new window... only if we have anything to show
|
||||||
"""
|
"""
|
||||||
assert len(self.__class__.entries)
|
assert self.__class__.entries
|
||||||
|
|
||||||
self.entry = None # the entry actually displayed
|
self.entry = None # the entry actually displayed
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ class AtomWindow:
|
||||||
"""
|
"""
|
||||||
Get next entry from the queue and display it in the window
|
Get next entry from the queue and display it in the window
|
||||||
"""
|
"""
|
||||||
assert len(self.__class__.entries)>0
|
assert self.__class__.entries
|
||||||
|
|
||||||
newentry = self.__class__.entries.pop(0)
|
newentry = self.__class__.entries.pop(0)
|
||||||
|
|
||||||
|
|
|
@ -1377,7 +1377,7 @@ class ChatControl(ChatControlBase):
|
||||||
local_old_kind = None
|
local_old_kind = None
|
||||||
else:
|
else:
|
||||||
local_old_kind = kind
|
local_old_kind = kind
|
||||||
if len(rows):
|
if rows:
|
||||||
self.conv_textview.print_empty_line()
|
self.conv_textview.print_empty_line()
|
||||||
|
|
||||||
def read_queue(self):
|
def read_queue(self):
|
||||||
|
|
|
@ -1222,7 +1222,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
|
||||||
else: # Not a GC
|
else: # Not a GC
|
||||||
types_list = ['printed_' + type_, type_]
|
types_list = ['printed_' + type_, type_]
|
||||||
|
|
||||||
if not len(app.events.get_events(self.account, jid, types_list)):
|
if not app.events.get_events(self.account, jid, types_list):
|
||||||
return
|
return
|
||||||
if not self.parent_win:
|
if not self.parent_win:
|
||||||
return
|
return
|
||||||
|
|
|
@ -481,7 +481,7 @@ def get_transport_name_from_jid(jid, use_config_setting = True):
|
||||||
|
|
||||||
# host is now f.e. icq.foo.org or just icq (sometimes on hacky transports)
|
# host is now f.e. icq.foo.org or just icq (sometimes on hacky transports)
|
||||||
host_splitted = host.split('.')
|
host_splitted = host.split('.')
|
||||||
if len(host_splitted) != 0:
|
if host_splitted:
|
||||||
# now we support both 'icq.' and 'icq' but not icqsucks.org
|
# now we support both 'icq.' and 'icq' but not icqsucks.org
|
||||||
host = host_splitted[0]
|
host = host_splitted[0]
|
||||||
|
|
||||||
|
|
|
@ -1275,7 +1275,7 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
for mech in auth_mechs:
|
for mech in auth_mechs:
|
||||||
if mech not in nbxmpp.auth_nb.SASL_AUTHENTICATION_MECHANISMS | set(['XEP-0078']):
|
if mech not in nbxmpp.auth_nb.SASL_AUTHENTICATION_MECHANISMS | set(['XEP-0078']):
|
||||||
log.warning("Unknown authentication mechanisms %s" % mech)
|
log.warning("Unknown authentication mechanisms %s" % mech)
|
||||||
if len(auth_mechs) == 0:
|
if not auth_mechs:
|
||||||
auth_mechs = None
|
auth_mechs = None
|
||||||
else:
|
else:
|
||||||
auth_mechs = set(auth_mechs)
|
auth_mechs = set(auth_mechs)
|
||||||
|
@ -1453,7 +1453,7 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
self._on_stun_resolved)
|
self._on_stun_resolved)
|
||||||
|
|
||||||
def _on_stun_resolved(self, host, result_array):
|
def _on_stun_resolved(self, host, result_array):
|
||||||
if len(result_array) != 0:
|
if result_array:
|
||||||
self._stun_servers = self._hosts = [i for i in result_array]
|
self._stun_servers = self._hosts = [i for i in result_array]
|
||||||
|
|
||||||
@helpers.call_counter
|
@helpers.call_counter
|
||||||
|
|
|
@ -156,7 +156,7 @@ class Contact(CommonContact):
|
||||||
return False
|
return False
|
||||||
if self.sub in ('none', 'from') and self.ask == 'subscribe':
|
if self.sub in ('none', 'from') and self.ask == 'subscribe':
|
||||||
return False
|
return False
|
||||||
if self.sub in ('none', 'from') and (self.name or len(self.groups)):
|
if self.sub in ('none', 'from') and (self.name or self.groups):
|
||||||
return False
|
return False
|
||||||
if _('Not in Roster') in self.groups:
|
if _('Not in Roster') in self.groups:
|
||||||
return False
|
return False
|
||||||
|
@ -486,7 +486,7 @@ class Contacts():
|
||||||
return
|
return
|
||||||
if contact in self._contacts[contact.jid]:
|
if contact in self._contacts[contact.jid]:
|
||||||
self._contacts[contact.jid].remove(contact)
|
self._contacts[contact.jid].remove(contact)
|
||||||
if len(self._contacts[contact.jid]) == 0:
|
if not self._contacts[contact.jid]:
|
||||||
del self._contacts[contact.jid]
|
del self._contacts[contact.jid]
|
||||||
|
|
||||||
def remove_jid(self, jid):
|
def remove_jid(self, jid):
|
||||||
|
@ -626,7 +626,7 @@ class GC_Contacts():
|
||||||
return
|
return
|
||||||
del self._rooms[gc_contact.room_jid][gc_contact.name]
|
del self._rooms[gc_contact.room_jid][gc_contact.name]
|
||||||
# It was the last nick in room ?
|
# It was the last nick in room ?
|
||||||
if not len(self._rooms[gc_contact.room_jid]):
|
if not self._rooms[gc_contact.room_jid]:
|
||||||
del self._rooms[gc_contact.room_jid]
|
del self._rooms[gc_contact.room_jid]
|
||||||
|
|
||||||
def remove_room(self, room_jid):
|
def remove_room(self, room_jid):
|
||||||
|
|
|
@ -214,7 +214,7 @@ def prep(user, server, resource):
|
||||||
if server is not None:
|
if server is not None:
|
||||||
if server.endswith('.'): # RFC7622, 3.2
|
if server.endswith('.'): # RFC7622, 3.2
|
||||||
server = server[:-1]
|
server = server[:-1]
|
||||||
if len(server) < 1 or len(server.encode('utf-8')) > 1023:
|
if not server or len(server.encode('utf-8')) > 1023:
|
||||||
raise InvalidFormat(_('Server must be between 1 and 1023 bytes'))
|
raise InvalidFormat(_('Server must be between 1 and 1023 bytes'))
|
||||||
try:
|
try:
|
||||||
from nbxmpp.stringprepare import nameprep
|
from nbxmpp.stringprepare import nameprep
|
||||||
|
@ -225,7 +225,7 @@ def prep(user, server, resource):
|
||||||
raise InvalidFormat(_('Server address required.'))
|
raise InvalidFormat(_('Server address required.'))
|
||||||
|
|
||||||
if user is not None:
|
if user is not None:
|
||||||
if len(user) < 1 or len(user.encode('utf-8')) > 1023:
|
if not user or len(user.encode('utf-8')) > 1023:
|
||||||
raise InvalidFormat(_('Username must be between 1 and 1023 bytes'))
|
raise InvalidFormat(_('Username must be between 1 and 1023 bytes'))
|
||||||
try:
|
try:
|
||||||
if HAS_PRECIS_I18N:
|
if HAS_PRECIS_I18N:
|
||||||
|
@ -239,7 +239,7 @@ def prep(user, server, resource):
|
||||||
user = None
|
user = None
|
||||||
|
|
||||||
if resource is not None:
|
if resource is not None:
|
||||||
if len(resource) < 1 or len(resource.encode('utf-8')) > 1023:
|
if not resource or len(resource.encode('utf-8')) > 1023:
|
||||||
raise InvalidFormat(_('Resource must be between 1 and 1023 bytes'))
|
raise InvalidFormat(_('Resource must be between 1 and 1023 bytes'))
|
||||||
try:
|
try:
|
||||||
if HAS_PRECIS_I18N:
|
if HAS_PRECIS_I18N:
|
||||||
|
@ -1054,7 +1054,7 @@ def get_notification_icon_tooltip_text():
|
||||||
|
|
||||||
accounts = get_notification_icon_tooltip_dict()
|
accounts = get_notification_icon_tooltip_dict()
|
||||||
|
|
||||||
if len(accounts) == 0:
|
if not accounts:
|
||||||
# No configured account
|
# No configured account
|
||||||
return _('Gajim')
|
return _('Gajim')
|
||||||
|
|
||||||
|
|
|
@ -126,11 +126,11 @@ class OptionsParser:
|
||||||
def update_config(self, old_version, new_version):
|
def update_config(self, old_version, new_version):
|
||||||
old_version_list = old_version.split('.') # convert '0.x.y' to (0, x, y)
|
old_version_list = old_version.split('.') # convert '0.x.y' to (0, x, y)
|
||||||
old = []
|
old = []
|
||||||
while len(old_version_list):
|
while old_version_list:
|
||||||
old.append(int(old_version_list.pop(0)))
|
old.append(int(old_version_list.pop(0)))
|
||||||
new_version_list = new_version.split('.')
|
new_version_list = new_version.split('.')
|
||||||
new = []
|
new = []
|
||||||
while len(new_version_list):
|
while new_version_list:
|
||||||
new.append(int(new_version_list.pop(0)))
|
new.append(int(new_version_list.pop(0)))
|
||||||
|
|
||||||
if old < [0, 14, 0, 1] and new >= [0, 14, 0, 1]:
|
if old < [0, 14, 0, 1] and new >= [0, 14, 0, 1]:
|
||||||
|
|
|
@ -426,7 +426,7 @@ class SocksQueue:
|
||||||
self.remove_sender_by_key(key, do_disconnect=do_disconnect)
|
self.remove_sender_by_key(key, do_disconnect=do_disconnect)
|
||||||
if not remove_all:
|
if not remove_all:
|
||||||
break
|
break
|
||||||
if len(self.senders) == 0 and self.listener is not None:
|
if not self.senders and self.listener is not None:
|
||||||
self.listener.disconnect()
|
self.listener.disconnect()
|
||||||
self.listener = None
|
self.listener = None
|
||||||
self.connected -= 1
|
self.connected -= 1
|
||||||
|
@ -646,7 +646,7 @@ class Socks5(object):
|
||||||
except Exception:
|
except Exception:
|
||||||
add = b''
|
add = b''
|
||||||
received += add
|
received += add
|
||||||
if len(add) == 0:
|
if not add:
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
return add
|
return add
|
||||||
|
|
||||||
|
@ -676,7 +676,7 @@ class Socks5(object):
|
||||||
self.file_props.error = -7 # unable to read from file
|
self.file_props.error = -7 # unable to read from file
|
||||||
return -1
|
return -1
|
||||||
buff = self.file.read(MAX_BUFF_LEN)
|
buff = self.file.read(MAX_BUFF_LEN)
|
||||||
if len(buff) > 0:
|
if buff:
|
||||||
lenn = 0
|
lenn = 0
|
||||||
try:
|
try:
|
||||||
lenn = self._send(buff)
|
lenn = self._send(buff)
|
||||||
|
@ -765,7 +765,7 @@ class Socks5(object):
|
||||||
self.file_props.last_time
|
self.file_props.last_time
|
||||||
self.file_props.last_time = current_time
|
self.file_props.last_time = current_time
|
||||||
self.file_props.received_len += len(buff)
|
self.file_props.received_len += len(buff)
|
||||||
if len(buff) == 0:
|
if not buff:
|
||||||
# Transfer stopped somehow:
|
# Transfer stopped somehow:
|
||||||
# reset, paused or network error
|
# reset, paused or network error
|
||||||
self.rem_fd(fd)
|
self.rem_fd(fd)
|
||||||
|
|
|
@ -373,14 +373,16 @@ class P2PConnection(IdleObject, PlugIn):
|
||||||
except socket.gaierror as e:
|
except socket.gaierror as e:
|
||||||
log.info('Lookup failure for %s: %s[%s]', self.host, e[1],
|
log.info('Lookup failure for %s: %s[%s]', self.host, e[1],
|
||||||
repr(e[0]), exc_info=True)
|
repr(e[0]), exc_info=True)
|
||||||
if len(self.addresses_) > 0: return self.get_next_addrinfo()
|
if self.addresses_:
|
||||||
|
return self.get_next_addrinfo()
|
||||||
else:
|
else:
|
||||||
self.connect_to_next_ip()
|
self.connect_to_next_ip()
|
||||||
|
|
||||||
def connect_to_next_ip(self):
|
def connect_to_next_ip(self):
|
||||||
if len(self.ais) == 0:
|
if not self.ais:
|
||||||
log.error('Connection failure to %s', str(self.host), exc_info=True)
|
log.error('Connection failure to %s', str(self.host), exc_info=True)
|
||||||
if len(self.addresses_) > 0: return self.get_next_addrinfo()
|
if self.addresses_:
|
||||||
|
return self.get_next_addrinfo()
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
return
|
return
|
||||||
ai = self.ais.pop(0)
|
ai = self.ais.pop(0)
|
||||||
|
@ -449,7 +451,7 @@ class P2PConnection(IdleObject, PlugIn):
|
||||||
|
|
||||||
def read_timeout(self):
|
def read_timeout(self):
|
||||||
ids = self.client.conn_holder.ids_of_awaiting_messages
|
ids = self.client.conn_holder.ids_of_awaiting_messages
|
||||||
if self.fd in ids and len(ids[self.fd]) > 0:
|
if self.fd in ids and ids[self.fd]:
|
||||||
for (id_, thread_id) in ids[self.fd]:
|
for (id_, thread_id) in ids[self.fd]:
|
||||||
if hasattr(self._owner, 'Dispatcher'):
|
if hasattr(self._owner, 'Dispatcher'):
|
||||||
self._owner.Dispatcher.Event('', DATA_ERROR, (
|
self._owner.Dispatcher.Event('', DATA_ERROR, (
|
||||||
|
|
|
@ -265,7 +265,7 @@ class DataFormWidget(Gtk.Alignment, object):
|
||||||
self.up_button.set_sensitive(False)
|
self.up_button.set_sensitive(False)
|
||||||
self.down_button.set_sensitive(False)
|
self.down_button.set_sensitive(False)
|
||||||
|
|
||||||
if len(model) == 0:
|
if not model:
|
||||||
self.clear_button.set_sensitive(False)
|
self.clear_button.set_sensitive(False)
|
||||||
else:
|
else:
|
||||||
self.clear_button.set_sensitive(True)
|
self.clear_button.set_sensitive(True)
|
||||||
|
|
|
@ -532,7 +532,7 @@ class FileTransfersWindow:
|
||||||
return _('%(hours)02.d:%(minutes)02.d:%(seconds)02.d') % times
|
return _('%(hours)02.d:%(minutes)02.d:%(seconds)02.d') % times
|
||||||
|
|
||||||
def _get_eta_and_speed(self, full_size, transfered_size, file_props):
|
def _get_eta_and_speed(self, full_size, transfered_size, file_props):
|
||||||
if len(file_props.transfered_size) == 0:
|
if not file_props.transfered_size:
|
||||||
return 0., 0.
|
return 0., 0.
|
||||||
elif len(file_props.transfered_size) == 1:
|
elif len(file_props.transfered_size) == 1:
|
||||||
speed = round(float(transfered_size) / file_props.elapsed_time)
|
speed = round(float(transfered_size) / file_props.elapsed_time)
|
||||||
|
@ -739,7 +739,7 @@ class FileTransfersWindow:
|
||||||
Check if there are transfer rows and set cleanup_button sensitive, or
|
Check if there are transfer rows and set cleanup_button sensitive, or
|
||||||
insensitive if model is empty
|
insensitive if model is empty
|
||||||
"""
|
"""
|
||||||
if len(self.model) == 0:
|
if not self.model:
|
||||||
self.cleanup_button.set_sensitive(False)
|
self.cleanup_button.set_sensitive(False)
|
||||||
else:
|
else:
|
||||||
self.cleanup_button.set_sensitive(True)
|
self.cleanup_button.set_sensitive(True)
|
||||||
|
|
|
@ -369,7 +369,7 @@ class GajimRemote:
|
||||||
str_ = _('Usage: %(basename)s %(command)s %(arguments)s \n\t %(help)s')\
|
str_ = _('Usage: %(basename)s %(command)s %(arguments)s \n\t %(help)s')\
|
||||||
% {'basename': BASENAME, 'command': command,
|
% {'basename': BASENAME, 'command': command,
|
||||||
'arguments': arguments_str, 'help': command_props[0]}
|
'arguments': arguments_str, 'help': command_props[0]}
|
||||||
if len(command_props[1]) > 0:
|
if command_props[1]:
|
||||||
str_ += '\n\n' + _('Arguments:') + '\n'
|
str_ += '\n\n' + _('Arguments:') + '\n'
|
||||||
for argument in command_props[1]:
|
for argument in command_props[1]:
|
||||||
str_ += ' ' + argument[0] + ' - ' + argument[1] + '\n'
|
str_ += ' ' + argument[0] + ' - ' + argument[1] + '\n'
|
||||||
|
|
|
@ -1702,8 +1702,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
gc_contact = app.contacts.get_gc_contact(self.account, self.room_jid,
|
gc_contact = app.contacts.get_gc_contact(self.account, self.room_jid,
|
||||||
nick)
|
nick)
|
||||||
theme = Gtk.IconTheme.get_default()
|
theme = Gtk.IconTheme.get_default()
|
||||||
if len(app.events.get_events(self.account, self.room_jid + '/' + \
|
if app.events.get_events(self.account, self.room_jid + '/' + nick):
|
||||||
nick)):
|
|
||||||
icon_name = gtkgui_helpers.get_iconset_name_for('event')
|
icon_name = gtkgui_helpers.get_iconset_name_for('event')
|
||||||
surface = theme.load_surface(icon_name, 16, self.scale_factor, None, 0)
|
surface = theme.load_surface(icon_name, 16, self.scale_factor, None, 0)
|
||||||
else:
|
else:
|
||||||
|
@ -1914,8 +1913,8 @@ class GroupchatControl(ChatControlBase):
|
||||||
self.autorejoin = False
|
self.autorejoin = False
|
||||||
self.print_conversation(obj.reason, 'info', graphics=False)
|
self.print_conversation(obj.reason, 'info', graphics=False)
|
||||||
|
|
||||||
if len(app.events.get_events(self.account, jid=obj.fjid,
|
if not app.events.get_events(
|
||||||
types=['pm'])) == 0:
|
self.account, jid=obj.fjid, types=['pm']):
|
||||||
self.remove_contact(obj.nick)
|
self.remove_contact(obj.nick)
|
||||||
self.draw_all_roles()
|
self.draw_all_roles()
|
||||||
else:
|
else:
|
||||||
|
@ -2471,7 +2470,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
|
|
||||||
# nick completion
|
# nick completion
|
||||||
# check if tab is pressed with empty message
|
# check if tab is pressed with empty message
|
||||||
if len(splitted_text): # if there are any words
|
if splitted_text: # if there are any words
|
||||||
begin = splitted_text[-1] # last word we typed
|
begin = splitted_text[-1] # last word we typed
|
||||||
else:
|
else:
|
||||||
begin = ''
|
begin = ''
|
||||||
|
@ -2485,7 +2484,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
gc_refer_to_nick_char + ' '):
|
gc_refer_to_nick_char + ' '):
|
||||||
with_refer_to_nick_char = True
|
with_refer_to_nick_char = True
|
||||||
after_nick_len = len(gc_refer_to_nick_char + ' ')
|
after_nick_len = len(gc_refer_to_nick_char + ' ')
|
||||||
if len(self.nick_hits) and self.last_key_tabs and \
|
if self.nick_hits and self.last_key_tabs and \
|
||||||
text[:-after_nick_len].endswith(self.nick_hits[0]):
|
text[:-after_nick_len].endswith(self.nick_hits[0]):
|
||||||
# we should cycle
|
# we should cycle
|
||||||
# Previous nick in list may had a space inside, so we check text
|
# Previous nick in list may had a space inside, so we check text
|
||||||
|
@ -2512,7 +2511,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
helpers.jid_is_blocked(self.account, fjid):
|
helpers.jid_is_blocked(self.account, fjid):
|
||||||
# the word is the beginning of a nick
|
# the word is the beginning of a nick
|
||||||
self.nick_hits.append(nick)
|
self.nick_hits.append(nick)
|
||||||
if len(self.nick_hits):
|
if self.nick_hits:
|
||||||
if len(splitted_text) < 2 or with_refer_to_nick_char:
|
if len(splitted_text) < 2 or with_refer_to_nick_char:
|
||||||
# This is the 1st word of the line or no word or we are cycling
|
# This is the 1st word of the line or no word or we are cycling
|
||||||
# at the beginning, possibly with a space in one nick
|
# at the beginning, possibly with a space in one nick
|
||||||
|
|
|
@ -727,7 +727,7 @@ class ChangeNickDialog(InputDialogCheck):
|
||||||
app.config.get('gc_proposed_nick_char'))
|
app.config.get('gc_proposed_nick_char'))
|
||||||
|
|
||||||
def check_next(self):
|
def check_next(self):
|
||||||
if len(self.room_queue) == 0:
|
if not self.room_queue:
|
||||||
self.cancel_handler = None
|
self.cancel_handler = None
|
||||||
self.dialog.destroy()
|
self.dialog.destroy()
|
||||||
if 'change_nick_dialog' in app.interface.instances:
|
if 'change_nick_dialog' in app.interface.instances:
|
||||||
|
|
|
@ -475,7 +475,7 @@ class Preferences(Gtk.ApplicationWindow):
|
||||||
Return the value of the option opt if it's the same in all accounts else
|
Return the value of the option opt if it's the same in all accounts else
|
||||||
returns "mixed"
|
returns "mixed"
|
||||||
"""
|
"""
|
||||||
if len(app.connections) == 0:
|
if not app.connections:
|
||||||
# a non existent key return default value
|
# a non existent key return default value
|
||||||
return app.config.get_per('accounts', '__default__', opt)
|
return app.config.get_per('accounts', '__default__', opt)
|
||||||
val = None
|
val = None
|
||||||
|
|
|
@ -153,7 +153,7 @@ class PrivacyListWindow:
|
||||||
self.max_order = int(rule['order'])
|
self.max_order = int(rule['order'])
|
||||||
self.global_rules[text_item] = rule
|
self.global_rules[text_item] = rule
|
||||||
model.append([text_item])
|
model.append([text_item])
|
||||||
if len(rules) == 0:
|
if not rules:
|
||||||
self.title_hbox.set_sensitive(False)
|
self.title_hbox.set_sensitive(False)
|
||||||
self.list_of_rules_combobox.set_sensitive(False)
|
self.list_of_rules_combobox.set_sensitive(False)
|
||||||
self.delete_rule_button.set_sensitive(False)
|
self.delete_rule_button.set_sensitive(False)
|
||||||
|
@ -474,7 +474,7 @@ class PrivacyListsWindow:
|
||||||
self.draw_widgets()
|
self.draw_widgets()
|
||||||
|
|
||||||
def draw_widgets(self):
|
def draw_widgets(self):
|
||||||
if len(self.privacy_lists_save) == 0:
|
if not self.privacy_lists_save:
|
||||||
self.list_of_privacy_lists_combobox.set_sensitive(False)
|
self.list_of_privacy_lists_combobox.set_sensitive(False)
|
||||||
self.open_privacy_list_button.set_sensitive(False)
|
self.open_privacy_list_button.set_sensitive(False)
|
||||||
self.delete_privacy_list_button.set_sensitive(False)
|
self.delete_privacy_list_button.set_sensitive(False)
|
||||||
|
|
|
@ -1974,7 +1974,7 @@ class Interface:
|
||||||
if s.control:
|
if s.control:
|
||||||
session = s
|
session = s
|
||||||
break
|
break
|
||||||
if not session and not len(sessions) == 0:
|
if not session and sessions:
|
||||||
# there are no sessions with chat controls, just take the first
|
# there are no sessions with chat controls, just take the first
|
||||||
# one
|
# one
|
||||||
session = sessions[0]
|
session = sessions[0]
|
||||||
|
@ -2018,7 +2018,7 @@ class Interface:
|
||||||
|
|
||||||
mw.new_tab(chat_control)
|
mw.new_tab(chat_control)
|
||||||
|
|
||||||
if len(app.events.get_events(account, fjid)):
|
if app.events.get_events(account, fjid):
|
||||||
# We call this here to avoid race conditions with widget validation
|
# We call this here to avoid race conditions with widget validation
|
||||||
chat_control.read_queue()
|
chat_control.read_queue()
|
||||||
|
|
||||||
|
@ -2038,7 +2038,7 @@ class Interface:
|
||||||
if not ctrl:
|
if not ctrl:
|
||||||
ctrl = self.new_chat(contact, account,
|
ctrl = self.new_chat(contact, account,
|
||||||
resource=resource)
|
resource=resource)
|
||||||
if len(app.events.get_events(account, fjid)):
|
if app.events.get_events(account, fjid):
|
||||||
ctrl.read_queue()
|
ctrl.read_queue()
|
||||||
|
|
||||||
if message:
|
if message:
|
||||||
|
@ -2644,7 +2644,7 @@ class Interface:
|
||||||
# except Exception:
|
# except Exception:
|
||||||
# pass
|
# pass
|
||||||
# add default status messages if there is not in the config file
|
# add default status messages if there is not in the config file
|
||||||
if len(app.config.get_per('statusmsg')) == 0:
|
if not app.config.get_per('statusmsg'):
|
||||||
default = app.config.statusmsg_default
|
default = app.config.statusmsg_default
|
||||||
for msg in default:
|
for msg in default:
|
||||||
app.config.add_per('statusmsg', msg)
|
app.config.add_per('statusmsg', msg)
|
||||||
|
@ -2662,7 +2662,7 @@ class Interface:
|
||||||
default[msg][5])
|
default[msg][5])
|
||||||
|
|
||||||
# Add Tor proxy if there is not in the config
|
# Add Tor proxy if there is not in the config
|
||||||
if len(app.config.get_per('proxies')) == 0:
|
if not app.config.get_per('proxies'):
|
||||||
default = app.config.proxies_default
|
default = app.config.proxies_default
|
||||||
for proxy in default:
|
for proxy in default:
|
||||||
app.config.add_per('proxies', proxy)
|
app.config.add_per('proxies', proxy)
|
||||||
|
@ -2807,7 +2807,7 @@ class PassphraseRequest:
|
||||||
self.callbacks.remove((acct, cb))
|
self.callbacks.remove((acct, cb))
|
||||||
else:
|
else:
|
||||||
self.callbacks = []
|
self.callbacks = []
|
||||||
if not len(self.callbacks):
|
if not self.callbacks:
|
||||||
self.dialog.window.destroy()
|
self.dialog.window.destroy()
|
||||||
|
|
||||||
def run_callback(self, account, callback):
|
def run_callback(self, account, callback):
|
||||||
|
|
|
@ -111,7 +111,7 @@ show_bookmarked=False, force_resource=False):
|
||||||
for (c, a) in list_:
|
for (c, a) in list_:
|
||||||
if c.supports(NS_MUC):
|
if c.supports(NS_MUC):
|
||||||
list2.append((c, a))
|
list2.append((c, a))
|
||||||
if len(list2) > 0:
|
if list2:
|
||||||
invite_to_new_room_menuitem.connect('activate',
|
invite_to_new_room_menuitem.connect('activate',
|
||||||
roster.on_invite_to_new_room, list2, None)
|
roster.on_invite_to_new_room, list2, None)
|
||||||
else:
|
else:
|
||||||
|
@ -144,7 +144,7 @@ show_bookmarked=False, force_resource=False):
|
||||||
app.gc_connected[acct][room_jid] and \
|
app.gc_connected[acct][room_jid] and \
|
||||||
contacts_transport in ['jabber', None]:
|
contacts_transport in ['jabber', None]:
|
||||||
rooms.append((room_jid, acct))
|
rooms.append((room_jid, acct))
|
||||||
if len(rooms):
|
if rooms:
|
||||||
item = Gtk.SeparatorMenuItem.new() # separator
|
item = Gtk.SeparatorMenuItem.new() # separator
|
||||||
invite_to_submenu.append(item)
|
invite_to_submenu.append(item)
|
||||||
for (room_jid, account) in rooms:
|
for (room_jid, account) in rooms:
|
||||||
|
|
|
@ -570,7 +570,7 @@ class MessageWindow(object):
|
||||||
|
|
||||||
del self._controls[ctrl.account][fjid]
|
del self._controls[ctrl.account][fjid]
|
||||||
|
|
||||||
if len(self._controls[ctrl.account]) == 0:
|
if not self._controls[ctrl.account]:
|
||||||
del self._controls[ctrl.account]
|
del self._controls[ctrl.account]
|
||||||
|
|
||||||
self.check_tabs()
|
self.check_tabs()
|
||||||
|
|
|
@ -155,7 +155,7 @@ class MusicTrackListener(GObject.GObject):
|
||||||
info.title = meta.get('xesam:title')
|
info.title = meta.get('xesam:title')
|
||||||
info.album = meta.get('xesam:album')
|
info.album = meta.get('xesam:album')
|
||||||
artist = meta.get('xesam:artist')
|
artist = meta.get('xesam:artist')
|
||||||
if artist is not None and len(artist):
|
if artist:
|
||||||
info.artist = artist[0]
|
info.artist = artist[0]
|
||||||
else:
|
else:
|
||||||
info.artist = None
|
info.artist = None
|
||||||
|
|
|
@ -388,7 +388,7 @@ class RosterWindow:
|
||||||
parent_iters = self._get_contact_iter(
|
parent_iters = self._get_contact_iter(
|
||||||
big_brother_contact.jid, big_brother_account,
|
big_brother_contact.jid, big_brother_account,
|
||||||
big_brother_contact, self.model)
|
big_brother_contact, self.model)
|
||||||
assert len(parent_iters) > 0, 'Big brother is not yet in roster!'
|
assert parent_iters, 'Big brother is not yet in roster!'
|
||||||
|
|
||||||
# Do not confuse get_contact_iter: Sync groups of family members
|
# Do not confuse get_contact_iter: Sync groups of family members
|
||||||
contact.groups = big_brother_contact.groups[:]
|
contact.groups = big_brother_contact.groups[:]
|
||||||
|
@ -445,8 +445,7 @@ class RosterWindow:
|
||||||
if group not in app.groups[account]:
|
if group not in app.groups[account]:
|
||||||
app.groups[account][group] = {'expand': is_expanded}
|
app.groups[account][group] = {'expand': is_expanded}
|
||||||
|
|
||||||
assert len(added_iters), '%s has not been added to roster!' % \
|
assert added_iters, '%s has not been added to roster!' % contact.jid
|
||||||
contact.jid
|
|
||||||
return added_iters
|
return added_iters
|
||||||
|
|
||||||
def _remove_entity(self, contact, account, groups=None):
|
def _remove_entity(self, contact, account, groups=None):
|
||||||
|
@ -530,8 +529,8 @@ class RosterWindow:
|
||||||
big_brother_contact = app.contacts.get_first_contact_from_jid(
|
big_brother_contact = app.contacts.get_first_contact_from_jid(
|
||||||
big_brother_account, big_brother_jid)
|
big_brother_account, big_brother_jid)
|
||||||
|
|
||||||
assert len(self._get_contact_iter(big_brother_jid,
|
assert not self._get_contact_iter(big_brother_jid,
|
||||||
big_brother_account, big_brother_contact, self.model)) == 0, \
|
big_brother_account, big_brother_contact, self.model), \
|
||||||
'Big brother %s already in roster\n Family: %s' \
|
'Big brother %s already in roster\n Family: %s' \
|
||||||
% (big_brother_jid, family)
|
% (big_brother_jid, family)
|
||||||
self._add_entity(big_brother_contact, big_brother_account)
|
self._add_entity(big_brother_contact, big_brother_account)
|
||||||
|
@ -549,8 +548,8 @@ class RosterWindow:
|
||||||
# or brother already added
|
# or brother already added
|
||||||
continue
|
continue
|
||||||
|
|
||||||
assert len(self._get_contact_iter(_jid, _account,
|
assert not self._get_contact_iter(_jid, _account,
|
||||||
_contact, self.model)) == 0, \
|
_contact, self.model), \
|
||||||
"%s already in roster.\n Family: %s" % (_jid, nearby_family)
|
"%s already in roster.\n Family: %s" % (_jid, nearby_family)
|
||||||
self._add_entity(_contact, _account,
|
self._add_entity(_contact, _account,
|
||||||
big_brother_contact = big_brother_contact,
|
big_brother_contact = big_brother_contact,
|
||||||
|
@ -600,8 +599,8 @@ class RosterWindow:
|
||||||
|
|
||||||
ok = self._remove_entity(_contact, _account)
|
ok = self._remove_entity(_contact, _account)
|
||||||
assert ok, '%s was not removed' % _jid
|
assert ok, '%s was not removed' % _jid
|
||||||
assert len(self._get_contact_iter(_jid, _account, _contact,
|
assert not self._get_contact_iter(_jid, _account, _contact,
|
||||||
self.model)) == 0, '%s is removed but still in roster' % _jid
|
self.model), '%s is removed but still in roster' % _jid
|
||||||
|
|
||||||
if not family_in_roster:
|
if not family_in_roster:
|
||||||
return False
|
return False
|
||||||
|
@ -610,15 +609,15 @@ class RosterWindow:
|
||||||
(nearby_family, family)
|
(nearby_family, family)
|
||||||
iters = self._get_contact_iter(old_big_jid, old_big_account,
|
iters = self._get_contact_iter(old_big_jid, old_big_account,
|
||||||
old_big_contact, self.model)
|
old_big_contact, self.model)
|
||||||
assert len(iters) > 0, 'Old Big Brother %s is not in roster anymore' % \
|
assert iters, 'Old Big Brother %s is not in roster anymore' % \
|
||||||
old_big_jid
|
old_big_jid
|
||||||
assert not self.model.iter_children(iters[0]), \
|
assert not self.model.iter_children(iters[0]), \
|
||||||
'Old Big Brother %s still has children' % old_big_jid
|
'Old Big Brother %s still has children' % old_big_jid
|
||||||
|
|
||||||
ok = self._remove_entity(old_big_contact, old_big_account)
|
ok = self._remove_entity(old_big_contact, old_big_account)
|
||||||
assert ok, "Old Big Brother %s not removed" % old_big_jid
|
assert ok, "Old Big Brother %s not removed" % old_big_jid
|
||||||
assert len(self._get_contact_iter(old_big_jid, old_big_account,
|
assert not self._get_contact_iter(old_big_jid, old_big_account,
|
||||||
old_big_contact, self.model)) == 0, \
|
old_big_contact, self.model), \
|
||||||
'Old Big Brother %s is removed but still in roster' % old_big_jid
|
'Old Big Brother %s is removed but still in roster' % old_big_jid
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@ -683,8 +682,8 @@ class RosterWindow:
|
||||||
jid = app.get_jid_from_account(account)
|
jid = app.get_jid_from_account(account)
|
||||||
contact = app.contacts.get_first_contact_from_jid(account, jid)
|
contact = app.contacts.get_first_contact_from_jid(account, jid)
|
||||||
|
|
||||||
assert len(self._get_contact_iter(jid, account, contact,
|
assert not self._get_contact_iter(jid, account, contact,
|
||||||
self.model)) == 0, 'Self contact %s already in roster' % jid
|
self.model), 'Self contact %s already in roster' % jid
|
||||||
|
|
||||||
child_iterA = self._get_account_iter(account, self.model)
|
child_iterA = self._get_account_iter(account, self.model)
|
||||||
self._iters[account]['contacts'][jid] = [self.model.append(child_iterA,
|
self._iters[account]['contacts'][jid] = [self.model.append(child_iterA,
|
||||||
|
@ -716,7 +715,7 @@ class RosterWindow:
|
||||||
account -- the corresponding account.
|
account -- the corresponding account.
|
||||||
"""
|
"""
|
||||||
contact = app.contacts.get_contact_with_highest_priority(account, jid)
|
contact = app.contacts.get_contact_with_highest_priority(account, jid)
|
||||||
if len(self._get_contact_iter(jid, account, contact, self.model)):
|
if self._get_contact_iter(jid, account, contact, self.model):
|
||||||
# If contact already in roster, do nothing
|
# If contact already in roster, do nothing
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -1152,8 +1151,8 @@ class RosterWindow:
|
||||||
to_hide = []
|
to_hide = []
|
||||||
while(iterG):
|
while(iterG):
|
||||||
parent = self.modelfilter.iter_parent(iterG)
|
parent = self.modelfilter.iter_parent(iterG)
|
||||||
if (not self.modelfilter.iter_has_child(iterG)) or (len(to_hide) > \
|
if (not self.modelfilter.iter_has_child(iterG)) or (to_hide \
|
||||||
0 and self.modelfilter.iter_n_children(iterG) == 1):
|
and self.modelfilter.iter_n_children(iterG) == 1):
|
||||||
to_hide.append(iterG)
|
to_hide.append(iterG)
|
||||||
if not parent or self.modelfilter[parent][Column.TYPE] != \
|
if not parent or self.modelfilter[parent][Column.TYPE] != \
|
||||||
'group':
|
'group':
|
||||||
|
@ -1300,7 +1299,7 @@ class RosterWindow:
|
||||||
# a child has awaiting messages?
|
# a child has awaiting messages?
|
||||||
jidC = self.model[iterC][Column.JID]
|
jidC = self.model[iterC][Column.JID]
|
||||||
accountC = self.model[iterC][Column.ACCOUNT]
|
accountC = self.model[iterC][Column.ACCOUNT]
|
||||||
if len(app.events.get_events(accountC, jidC)):
|
if app.events.get_events(accountC, jidC):
|
||||||
icon_name = 'event'
|
icon_name = 'event'
|
||||||
break
|
break
|
||||||
iterC = self.model.iter_next(iterC)
|
iterC = self.model.iter_next(iterC)
|
||||||
|
@ -2583,7 +2582,7 @@ class RosterWindow:
|
||||||
GLib.idle_add(ctrl.parent_win.set_active_tab, ctrl)
|
GLib.idle_add(ctrl.parent_win.set_active_tab, ctrl)
|
||||||
else:
|
else:
|
||||||
ctrl = app.interface.new_chat(obj.contact, account)
|
ctrl = app.interface.new_chat(obj.contact, account)
|
||||||
if len(app.events.get_events(account, obj.jid)):
|
if app.events.get_events(account, obj.jid):
|
||||||
ctrl.read_queue()
|
ctrl.read_queue()
|
||||||
|
|
||||||
def _nec_gc_presence_received(self, obj):
|
def _nec_gc_presence_received(self, obj):
|
||||||
|
@ -2718,7 +2717,7 @@ class RosterWindow:
|
||||||
contact = app.contacts.get_contact(obj.conn.name, obj.jid)
|
contact = app.contacts.get_contact(obj.conn.name, obj.jid)
|
||||||
obj.session.control = app.interface.new_chat(contact,
|
obj.session.control = app.interface.new_chat(contact,
|
||||||
obj.conn.name, session=obj.session)
|
obj.conn.name, session=obj.session)
|
||||||
if len(app.events.get_events(obj.conn.name, obj.fjid)):
|
if app.events.get_events(obj.conn.name, obj.fjid):
|
||||||
obj.session.control.read_queue()
|
obj.session.control.read_queue()
|
||||||
|
|
||||||
if obj.show_in_roster:
|
if obj.show_in_roster:
|
||||||
|
@ -3196,7 +3195,7 @@ class RosterWindow:
|
||||||
elif event.keyval == Gdk.KEY_Delete:
|
elif event.keyval == Gdk.KEY_Delete:
|
||||||
treeselection = self.tree.get_selection()
|
treeselection = self.tree.get_selection()
|
||||||
model, list_of_paths = treeselection.get_selected_rows()
|
model, list_of_paths = treeselection.get_selected_rows()
|
||||||
if not len(list_of_paths):
|
if not list_of_paths:
|
||||||
return
|
return
|
||||||
type_ = model[list_of_paths[0]][Column.TYPE]
|
type_ = model[list_of_paths[0]][Column.TYPE]
|
||||||
account = model[list_of_paths[0]][Column.ACCOUNT]
|
account = model[list_of_paths[0]][Column.ACCOUNT]
|
||||||
|
@ -3535,7 +3534,7 @@ class RosterWindow:
|
||||||
self.previous_status_combobox_active = active
|
self.previous_status_combobox_active = active
|
||||||
return
|
return
|
||||||
accounts = list(app.connections.keys())
|
accounts = list(app.connections.keys())
|
||||||
if len(accounts) == 0:
|
if not accounts:
|
||||||
ErrorDialog(_('No account available'),
|
ErrorDialog(_('No account available'),
|
||||||
_('You must create an account before you can chat with other '
|
_('You must create an account before you can chat with other '
|
||||||
'contacts.'))
|
'contacts.'))
|
||||||
|
@ -3697,7 +3696,7 @@ class RosterWindow:
|
||||||
# if a contact row is selected, update colors (eg. for status msg)
|
# if a contact row is selected, update colors (eg. for status msg)
|
||||||
# because gtk engines may differ in bg when window is selected
|
# because gtk engines may differ in bg when window is selected
|
||||||
# or not
|
# or not
|
||||||
if len(self._last_selected_contact):
|
if self._last_selected_contact:
|
||||||
for (jid, account) in self._last_selected_contact:
|
for (jid, account) in self._last_selected_contact:
|
||||||
self.draw_contact(jid, account, selected=True, focus=True)
|
self.draw_contact(jid, account, selected=True, focus=True)
|
||||||
|
|
||||||
|
@ -3705,7 +3704,7 @@ class RosterWindow:
|
||||||
# if a contact row is selected, update colors (eg. for status msg)
|
# if a contact row is selected, update colors (eg. for status msg)
|
||||||
# because gtk engines may differ in bg when window is selected
|
# because gtk engines may differ in bg when window is selected
|
||||||
# or not
|
# or not
|
||||||
if len(self._last_selected_contact):
|
if self._last_selected_contact:
|
||||||
for (jid, account) in self._last_selected_contact:
|
for (jid, account) in self._last_selected_contact:
|
||||||
self.draw_contact(jid, account, selected=True, focus=False)
|
self.draw_contact(jid, account, selected=True, focus=False)
|
||||||
|
|
||||||
|
@ -3720,7 +3719,7 @@ class RosterWindow:
|
||||||
# let message window close the tab
|
# let message window close the tab
|
||||||
return
|
return
|
||||||
list_of_paths = self.tree.get_selection().get_selected_rows()[1]
|
list_of_paths = self.tree.get_selection().get_selected_rows()[1]
|
||||||
if not len(list_of_paths) and not app.config.get(
|
if not list_of_paths and not app.config.get(
|
||||||
'quit_on_roster_x_button') and ((app.interface.systray_enabled and\
|
'quit_on_roster_x_button') and ((app.interface.systray_enabled and\
|
||||||
app.config.get('trayicon') == 'always') or app.config.get(
|
app.config.get('trayicon') == 'always') or app.config.get(
|
||||||
'allow_hide_roster')):
|
'allow_hide_roster')):
|
||||||
|
@ -4385,7 +4384,7 @@ class RosterWindow:
|
||||||
path = helpers.get_file_path_from_dnd_dropped_uri(a_uri)
|
path = helpers.get_file_path_from_dnd_dropped_uri(a_uri)
|
||||||
if not os.path.isfile(path):
|
if not os.path.isfile(path):
|
||||||
bad_uris.append(a_uri)
|
bad_uris.append(a_uri)
|
||||||
if len(bad_uris):
|
if bad_uris:
|
||||||
ErrorDialog(_('Invalid file URI:'), '\n'.join(bad_uris))
|
ErrorDialog(_('Invalid file URI:'), '\n'.join(bad_uris))
|
||||||
return
|
return
|
||||||
def _on_send_files(account, jid, uris):
|
def _on_send_files(account, jid, uris):
|
||||||
|
@ -5523,7 +5522,7 @@ class RosterWindow:
|
||||||
except TypeError:
|
except TypeError:
|
||||||
self.tree.get_selection().unselect_all()
|
self.tree.get_selection().unselect_all()
|
||||||
return
|
return
|
||||||
if not len(list_of_paths):
|
if not list_of_paths:
|
||||||
# no row is selected
|
# no row is selected
|
||||||
return
|
return
|
||||||
if len(list_of_paths) > 1:
|
if len(list_of_paths) > 1:
|
||||||
|
|
|
@ -209,7 +209,7 @@ class SearchWindow:
|
||||||
return
|
return
|
||||||
|
|
||||||
self.dataform = dataforms.extend_form(node=obj.data)
|
self.dataform = dataforms.extend_form(node=obj.data)
|
||||||
if len(self.dataform.items) == 0:
|
if not self.dataform.items:
|
||||||
# No result
|
# No result
|
||||||
self.label.set_text(_('No result'))
|
self.label.set_text(_('No result'))
|
||||||
self.label.show()
|
self.label.show()
|
||||||
|
|
|
@ -404,7 +404,7 @@ class ChatControlSession(object):
|
||||||
self.control = app.interface.new_chat(contact,
|
self.control = app.interface.new_chat(contact,
|
||||||
self.conn.name, session=self)
|
self.conn.name, session=self)
|
||||||
|
|
||||||
if len(app.events.get_events(self.conn.name, fjid)):
|
if app.events.get_events(self.conn.name, fjid):
|
||||||
self.control.read_queue()
|
self.control.read_queue()
|
||||||
else:
|
else:
|
||||||
if no_queue: # We didn't have a queue: we change icons
|
if no_queue: # We didn't have a queue: we change icons
|
||||||
|
|
|
@ -371,7 +371,7 @@ class StatusIcon:
|
||||||
|
|
||||||
def on_left_click(self):
|
def on_left_click(self):
|
||||||
win = app.interface.roster.window
|
win = app.interface.roster.window
|
||||||
if len(app.events.get_systray_events()) == 0:
|
if not app.events.get_systray_events():
|
||||||
# No pending events, so toggle visible/hidden for roster window
|
# No pending events, so toggle visible/hidden for roster window
|
||||||
if win.get_property('visible') and (win.get_property(
|
if win.get_property('visible') and (win.get_property(
|
||||||
'has-toplevel-focus') or os.name == 'nt'):
|
'has-toplevel-focus') or os.name == 'nt'):
|
||||||
|
|
Loading…
Reference in New Issue