Fix simplifiable-if-statement pylint errors
This commit is contained in:
parent
defe74cc06
commit
acb0bacc09
|
@ -424,10 +424,8 @@ def account_supports_private_storage(account):
|
||||||
def account_is_connected(account):
|
def account_is_connected(account):
|
||||||
if account not in connections:
|
if account not in connections:
|
||||||
return False
|
return False
|
||||||
if connections[account].connected > 1: # 0 is offline, 1 is connecting
|
# 0 is offline, 1 is connecting
|
||||||
return True
|
return connections[account].connected > 1
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def is_invisible(account):
|
def is_invisible(account):
|
||||||
return SHOW_LIST[connections[account].connected] == 'invisible'
|
return SHOW_LIST[connections[account].connected] == 'invisible'
|
||||||
|
@ -455,11 +453,9 @@ def get_number_of_securely_connected_accounts():
|
||||||
return num_of_secured
|
return num_of_secured
|
||||||
|
|
||||||
def account_is_securely_connected(account):
|
def account_is_securely_connected(account):
|
||||||
if account_is_connected(account) and \
|
if not account_is_connected(account):
|
||||||
account in con_types and con_types[account] in ('tls', 'ssl'):
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
return False
|
||||||
|
return con_types.get(account) in ('tls', 'ssl')
|
||||||
|
|
||||||
def get_transport_name_from_jid(jid, use_config_setting = True):
|
def get_transport_name_from_jid(jid, use_config_setting = True):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -145,16 +145,14 @@ def get_interface(interface, path, start_service=True):
|
||||||
started = True
|
started = True
|
||||||
if interface not in running_services:
|
if interface not in running_services:
|
||||||
# try to start the service
|
# try to start the service
|
||||||
if start_service and dbus_iface.StartServiceByName(interface, dbus.UInt32(0)) == 1:
|
started = start_service and dbus_iface.StartServiceByName(
|
||||||
started = True
|
interface, dbus.UInt32(0)) == 1
|
||||||
else:
|
|
||||||
started = False
|
|
||||||
if not started:
|
if not started:
|
||||||
return None
|
return None
|
||||||
obj = bus.get_object(interface, path)
|
obj = bus.get_object(interface, path)
|
||||||
return dbus.Interface(obj, interface)
|
return dbus.Interface(obj, interface)
|
||||||
except Exception as e:
|
except Exception as error:
|
||||||
log.debug(str(e))
|
log.debug(error)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -598,10 +598,7 @@ class P2PConnection(IdleObject, PlugIn):
|
||||||
|
|
||||||
def _plug_idle(self):
|
def _plug_idle(self):
|
||||||
readable = self.state != 0
|
readable = self.state != 0
|
||||||
if self.sendqueue or self.sendbuff:
|
writable = self.sendqueue or self.sendbuff
|
||||||
writable = True
|
|
||||||
else:
|
|
||||||
writable = False
|
|
||||||
if self.writable != writable or self.readable != readable:
|
if self.writable != writable or self.readable != readable:
|
||||||
app.idlequeue.plug_idle(self, writable, readable)
|
app.idlequeue.plug_idle(self, writable, readable)
|
||||||
|
|
||||||
|
|
|
@ -60,10 +60,7 @@ log = logging.getLogger('gajim.conversation_textview')
|
||||||
|
|
||||||
def is_selection_modified(mark):
|
def is_selection_modified(mark):
|
||||||
name = mark.get_name()
|
name = mark.get_name()
|
||||||
if name and name in ('selection_bound', 'insert'):
|
return name in ('selection_bound', 'insert')
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def has_focus(widget):
|
def has_focus(widget):
|
||||||
return widget.get_state_flags() & Gtk.StateFlags.FOCUSED == \
|
return widget.get_state_flags() & Gtk.StateFlags.FOCUSED == \
|
||||||
|
@ -82,14 +79,12 @@ class TextViewImage(Gtk.Image):
|
||||||
|
|
||||||
def _get_selected(self):
|
def _get_selected(self):
|
||||||
parent = self.get_parent()
|
parent = self.get_parent()
|
||||||
if not parent or not self.anchor: return False
|
if not parent or not self.anchor:
|
||||||
|
return False
|
||||||
buffer_ = parent.get_buffer()
|
buffer_ = parent.get_buffer()
|
||||||
position = buffer_.get_iter_at_child_anchor(self.anchor)
|
position = buffer_.get_iter_at_child_anchor(self.anchor)
|
||||||
bounds = buffer_.get_selection_bounds()
|
bounds = buffer_.get_selection_bounds()
|
||||||
if bounds and position.in_range(*bounds):
|
return bounds and position.in_range(*bounds)
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def get_state(self):
|
def get_state(self):
|
||||||
parent = self.get_parent()
|
parent = self.get_parent()
|
||||||
|
|
|
@ -266,10 +266,7 @@ def set_unset_urgency_hint(window, unread_messages_no):
|
||||||
messages or not
|
messages or not
|
||||||
"""
|
"""
|
||||||
if app.config.get('use_urgency_hint'):
|
if app.config.get('use_urgency_hint'):
|
||||||
if unread_messages_no > 0:
|
window.props.urgency_hint = unread_messages_no > 0
|
||||||
window.props.urgency_hint = True
|
|
||||||
else:
|
|
||||||
window.props.urgency_hint = False
|
|
||||||
|
|
||||||
def get_pixbuf_from_data(file_data):
|
def get_pixbuf_from_data(file_data):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -139,11 +139,9 @@ class NotificationAreaTooltip(StatusTable):
|
||||||
message = acct['message']
|
message = acct['message']
|
||||||
message = helpers.reduce_chars_newlines(message, 100, 1)
|
message = helpers.reduce_chars_newlines(message, 100, 1)
|
||||||
message = GLib.markup_escape_text(message)
|
message = GLib.markup_escape_text(message)
|
||||||
if acct['name'] in app.con_types and \
|
con_type = app.con_types.get(acct['name'])
|
||||||
app.con_types[acct['name']] in ('tls', 'ssl'):
|
show_lock = con_type in ('tls', 'ssl')
|
||||||
show_lock = True
|
|
||||||
else:
|
|
||||||
show_lock = False
|
|
||||||
if message:
|
if message:
|
||||||
self.add_status_row(file_path, acct['show'],
|
self.add_status_row(file_path, acct['show'],
|
||||||
GLib.markup_escape_text(acct['account_label']) + ' - ' + \
|
GLib.markup_escape_text(acct['account_label']) + ' - ' + \
|
||||||
|
@ -322,11 +320,9 @@ class RosterTooltip(Gtk.Window, StatusTable):
|
||||||
message = acct['message']
|
message = acct['message']
|
||||||
message = helpers.reduce_chars_newlines(message, 100, 1)
|
message = helpers.reduce_chars_newlines(message, 100, 1)
|
||||||
message = GLib.markup_escape_text(message)
|
message = GLib.markup_escape_text(message)
|
||||||
if acct['name'] in app.con_types and \
|
con_type = app.con_types.get(acct['name'])
|
||||||
app.con_types[acct['name']] in ('tls', 'ssl'):
|
show_lock = con_type in ('tls', 'ssl')
|
||||||
show_lock = True
|
|
||||||
else:
|
|
||||||
show_lock = False
|
|
||||||
if message:
|
if message:
|
||||||
self.add_status_row(file_path, acct['show'],
|
self.add_status_row(file_path, acct['show'],
|
||||||
GLib.markup_escape_text(acct['account_label']) + ' - ' + \
|
GLib.markup_escape_text(acct['account_label']) + ' - ' + \
|
||||||
|
|
Loading…
Reference in New Issue