Use get_key instead of hardcoded names in sorted_stats

上级 3a68e85d
......@@ -180,7 +180,7 @@ class Plugin(GlancesPlugin):
msg = '{:>7}'.format('W/s')
ret.append(self.curse_add_line(msg))
# Disk list (sorted by name)
for i in self.sorted_stats('disk_name'):
for i in self.sorted_stats():
# Is there an alias for the disk name ?
disk_real_name = i['disk_name']
disk_name = self.has_alias(i['disk_name'])
......
......@@ -289,7 +289,7 @@ class Plugin(GlancesPlugin):
msg = '{:>7}'.format('Tx/s')
ret.append(self.curse_add_line(msg))
# Interface list (sorted by name)
for i in self.sorted_stats('interface_name'):
for i in self.sorted_stats():
# Do not display interface in down state (issue #765)
if ('is_up' in i) and (i['is_up'] is False):
continue
......
......@@ -286,8 +286,9 @@ class GlancesPlugin(object):
"""Get the short detected OS name (SNMP)."""
return self._short_system_name
def sorted_stats(self, key):
def sorted_stats(self):
"""Get the stats sorted by an alias (if present) or key."""
key = self.get_key()
return sorted(self.stats, key=lambda stat: tuple(map(
lambda part: int(part) if part.isdigit() else part.lower(),
re.split(r"(\d+|\D+)", self.has_alias(stat[key]) or stat[key])
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册