mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-22 08:41:32 +03:00
Move alias aware sorting to glances_plugin
This commit is contained in:
parent
56229d238a
commit
7a47c32341
@ -180,10 +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 sorted(self.stats, key=lambda stat: tuple(map(
|
||||
lambda part: int(part) if part.isdigit() else part.lower(),
|
||||
re.split(r"(\d+|\D+)", stat.get('alias') or stat['disk_name'])
|
||||
))):
|
||||
for i in self.sorted_stats('disk_name'):
|
||||
# Is there an alias for the disk name ?
|
||||
disk_real_name = i['disk_name']
|
||||
disk_name = self.has_alias(i['disk_name'])
|
||||
|
@ -286,6 +286,13 @@ class GlancesPlugin(object):
|
||||
"""Get the short detected OS name (SNMP)."""
|
||||
return self._short_system_name
|
||||
|
||||
def sorted_stats(self, key):
|
||||
"""Get the stats sorted by an alias (if present) or 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])
|
||||
)))
|
||||
|
||||
@short_system_name.setter
|
||||
def short_system_name(self, short_name):
|
||||
"""Set the short detected OS name (SNMP)."""
|
||||
|
Loading…
Reference in New Issue
Block a user