Refactor code formatting for improved readability in flavor and math filter utilities
All checks were successful
CI / ci (push) Successful in 17s
CI / ci (pull_request) Successful in 17s

- Standardized code formatting in `flavor.py` and `mathfilters.py` for better visual clarity and consistency.
- Ensured proper indentation and spacing to enhance maintainability and readability of the utility functions.
This commit is contained in:
2026-02-12 20:19:30 +03:00
parent 656a6bfac4
commit d4fc2e920f
2 changed files with 81 additions and 81 deletions

View File

@@ -1,21 +1,21 @@
from collections import Counter
from openstack.connection import Connection
def get_flavor_list(connection: Connection) -> dict:
servers = list(connection.compute.servers(all_projects=True))
flavor_ids = [s.flavor["id"] for s in servers if "id" in s.flavor]
flavor_count = Counter(flavor_ids).most_common()
flavors = list(flavor_count)
result = {}
placeholder = {"name": "", "count": 0}
for idx, prefix in [(0, "first"), (1, "second"), (2, "third")]:
if len(flavors) > idx:
result[f"{prefix}_common_flavor"] = {"name": flavors[idx][0], "count": flavors[idx][1]}
else:
result[f"{prefix}_common_flavor"] = placeholder
return result
from collections import Counter
from openstack.connection import Connection
def get_flavor_list(connection: Connection) -> dict:
servers = list(connection.compute.servers(all_projects=True))
flavor_ids = [s.flavor["id"] for s in servers if "id" in s.flavor]
flavor_count = Counter(flavor_ids).most_common()
flavors = list(flavor_count)
result = {}
placeholder = {"name": "", "count": 0}
for idx, prefix in [(0, "first"), (1, "second"), (2, "third")]:
if len(flavors) > idx:
result[f"{prefix}_common_flavor"] = {"name": flavors[idx][0], "count": flavors[idx][1]}
else:
result[f"{prefix}_common_flavor"] = placeholder
return result