Don't construct empty lists in tests

This commit is contained in:
desbma 2014-12-11 13:34:47 +01:00 committed by Alessio Sergi
parent 59fc36e334
commit 7cf0a31997
10 changed files with 10 additions and 10 deletions

View File

@ -664,7 +664,7 @@ class _GlancesCurses(object):
# Exit if:
# - the plugin_stats message is empty
# - the display tag = False
if plugin_stats['msgdict'] == [] or not plugin_stats['display']:
if not plugin_stats['msgdict'] or not plugin_stats['display']:
# Exit
return 0

View File

@ -67,7 +67,7 @@ class Plugin(GlancesPlugin):
# Build the string message
# Header
if self.stats == []:
if not self.stats:
msg = _("No warning or critical alert detected")
ret.append(self.curse_add_line(msg, "TITLE"))
else:

View File

@ -103,7 +103,7 @@ class GlancesGrabBat(object):
def getcapacitypercent(self):
"""Get batteries capacity percent."""
if not self.initok or self.bat.stat == []:
if not self.initok or not self.bat.stat:
return []
# Init the bsum (sum of percent)

View File

@ -122,7 +122,7 @@ class Plugin(GlancesPlugin):
ret = []
# Only process if stats exist and display plugin enable...
if self.stats == [] or args.disable_diskio:
if not self.stats or args.disable_diskio:
return ret
# Build the string message

View File

@ -158,7 +158,7 @@ class Plugin(GlancesPlugin):
ret = []
# Only process if stats exist and display plugin enable...
if self.stats == [] or args.disable_fs:
if not self.stats or args.disable_fs:
return ret
# Max size for the fsname name

View File

@ -88,7 +88,7 @@ class Plugin(GlancesPlugin):
ret = []
# Only process if stats exist and display plugin enable...
if self.stats == [] or args.disable_process:
if not self.stats or args.disable_process:
return ret
# Build the string message

View File

@ -185,7 +185,7 @@ class Plugin(GlancesPlugin):
ret = []
# Only process if stats exist and display plugin enable...
if self.stats == [] or args.disable_network:
if not self.stats or args.disable_network:
return ret
# Max size for the interface name

View File

@ -130,7 +130,7 @@ class Plugin(GlancesPlugin):
ret = []
# No per CPU stat ? Exit...
if self.stats == []:
if not self.stats:
msg = _("PER CPU not available")
ret.append(self.curse_add_line(msg, "TITLE"))
return ret

View File

@ -355,7 +355,7 @@ class Plugin(GlancesPlugin):
ret = []
# Only process if stats exist and display plugin enable...
if self.stats == [] or args.disable_process:
if not self.stats or args.disable_process:
return ret
# Compute the sort key

View File

@ -125,7 +125,7 @@ class Plugin(GlancesPlugin):
ret = []
# Only process if stats exist and display plugin enable...
if self.stats == [] or args.disable_sensors:
if not self.stats or args.disable_sensors:
return ret
# Build the string message