plugins: containers: Refactor update()

Commit 445d20dc ("plugins: containers: Refactor") changed update() so
that, stats are added if any of is_key_in_container_and_not_hidden()
or is_key_absent_in_container() is true.

This could be replaced by the negation of is_key_in_container_and_hidden()

Part-of: #2801
Suggested-by: Jasmin Blackshaw <105jassen@gmail.com>
Signed-off-by: Ariel Otilibili <otilibil@eurecom.fr>
This commit is contained in:
Ariel Otilibili 2025-05-31 11:21:33 +02:00
parent c5acae327b
commit d6802b77d7
No known key found for this signature in database
GPG Key ID: 0A69BD35A1DA4DE6
1 changed files with 3 additions and 6 deletions

View File

@ -227,11 +227,8 @@ class ContainersPlugin(GlancesPluginModel):
if self.input_method != 'local':
return self.get_init_value()
def is_key_in_container_and_not_hidden(container):
return (key := container.get('key')) in container and not self.is_hide(nativestr(container.get(key)))
def is_key_absent_in_container(container):
return 'key' not in container or container.get('key') not in container
def is_key_in_container_and_hidden(container):
return (key := container.get('key')) in container and self.is_hide(nativestr(container.get(key)))
def add_engine_into_container(engine, container):
return container | {"engine": engine}
@ -246,7 +243,7 @@ class ContainersPlugin(GlancesPluginModel):
(
add_engine_into_container(engine, container)
for container in get_containers_from_updated_watcher(watcher)
if is_key_in_container_and_not_hidden(container) or is_key_absent_in_container(container)
if not is_key_in_container_and_hidden(container)
)
for engine, watcher in self.watchers.items()
)