Fix simplifiable-if-statement pylint errors

This commit is contained in:
Philipp Hörist 2018-09-17 23:21:38 +02:00 committed by Philipp Hörist
parent defe74cc06
commit acb0bacc09
6 changed files with 20 additions and 41 deletions

View File

@ -424,10 +424,8 @@ def account_supports_private_storage(account):
def account_is_connected(account):
if account not in connections:
return False
if connections[account].connected > 1: # 0 is offline, 1 is connecting
return True
else:
return False
# 0 is offline, 1 is connecting
return connections[account].connected > 1
def is_invisible(account):
return SHOW_LIST[connections[account].connected] == 'invisible'
@ -455,11 +453,9 @@ def get_number_of_securely_connected_accounts():
return num_of_secured
def account_is_securely_connected(account):
if account_is_connected(account) and \
account in con_types and con_types[account] in ('tls', 'ssl'):
return True
else:
if not account_is_connected(account):
return False
return con_types.get(account) in ('tls', 'ssl')
def get_transport_name_from_jid(jid, use_config_setting = True):
"""

View File

@ -145,16 +145,14 @@ def get_interface(interface, path, start_service=True):
started = True
if interface not in running_services:
# try to start the service
if start_service and dbus_iface.StartServiceByName(interface, dbus.UInt32(0)) == 1:
started = True
else:
started = False
started = start_service and dbus_iface.StartServiceByName(
interface, dbus.UInt32(0)) == 1
if not started:
return None
obj = bus.get_object(interface, path)
return dbus.Interface(obj, interface)
except Exception as e:
log.debug(str(e))
except Exception as error:
log.debug(error)
return None

View File

@ -598,10 +598,7 @@ class P2PConnection(IdleObject, PlugIn):
def _plug_idle(self):
readable = self.state != 0
if self.sendqueue or self.sendbuff:
writable = True
else:
writable = False
writable = self.sendqueue or self.sendbuff
if self.writable != writable or self.readable != readable:
app.idlequeue.plug_idle(self, writable, readable)

View File

@ -60,10 +60,7 @@ log = logging.getLogger('gajim.conversation_textview')
def is_selection_modified(mark):
name = mark.get_name()
if name and name in ('selection_bound', 'insert'):
return True
else:
return False
return name in ('selection_bound', 'insert')
def has_focus(widget):
return widget.get_state_flags() & Gtk.StateFlags.FOCUSED == \
@ -82,14 +79,12 @@ class TextViewImage(Gtk.Image):
def _get_selected(self):
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()
position = buffer_.get_iter_at_child_anchor(self.anchor)
bounds = buffer_.get_selection_bounds()
if bounds and position.in_range(*bounds):
return True
else:
return False
return bounds and position.in_range(*bounds)
def get_state(self):
parent = self.get_parent()

View File

@ -266,10 +266,7 @@ def set_unset_urgency_hint(window, unread_messages_no):
messages or not
"""
if app.config.get('use_urgency_hint'):
if unread_messages_no > 0:
window.props.urgency_hint = True
else:
window.props.urgency_hint = False
window.props.urgency_hint = unread_messages_no > 0
def get_pixbuf_from_data(file_data):
"""

View File

@ -139,11 +139,9 @@ class NotificationAreaTooltip(StatusTable):
message = acct['message']
message = helpers.reduce_chars_newlines(message, 100, 1)
message = GLib.markup_escape_text(message)
if acct['name'] in app.con_types and \
app.con_types[acct['name']] in ('tls', 'ssl'):
show_lock = True
else:
show_lock = False
con_type = app.con_types.get(acct['name'])
show_lock = con_type in ('tls', 'ssl')
if message:
self.add_status_row(file_path, acct['show'],
GLib.markup_escape_text(acct['account_label']) + ' - ' + \
@ -322,11 +320,9 @@ class RosterTooltip(Gtk.Window, StatusTable):
message = acct['message']
message = helpers.reduce_chars_newlines(message, 100, 1)
message = GLib.markup_escape_text(message)
if acct['name'] in app.con_types and \
app.con_types[acct['name']] in ('tls', 'ssl'):
show_lock = True
else:
show_lock = False
con_type = app.con_types.get(acct['name'])
show_lock = con_type in ('tls', 'ssl')
if message:
self.add_status_row(file_path, acct['show'],
GLib.markup_escape_text(acct['account_label']) + ' - ' + \