Skip to content

Remove some one line methods for formatting alerts #1176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 12 additions & 30 deletions src/stratis_cli/_actions/_list_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,19 +249,6 @@ def __init__(self, uuid_formatter, selection):
self.uuid_formatter = uuid_formatter
self.selection = selection

@staticmethod
def alert_summary(codes):
"""
Alert summary to display, if any

:param codes: list of error codes to display
:type codes: list of PoolErrorCode

:returns: string with alert summary
:rtype: str
"""
return [f"{code}: {code.summarize()}" for code in codes]

def _print_detail_view(self, mopool, size_change_codes):
"""
Print the detailed view for a single pool.
Expand All @@ -276,7 +263,10 @@ def _print_detail_view(self, mopool, size_change_codes):
print(f"UUID: {self.uuid_formatter(mopool.Uuid())}")
print(f"Name: {mopool.Name()}")

alert_summary = self.alert_summary(self.alert_codes(mopool) + size_change_codes)
alert_summary = [
f"{code}: {code.summarize()}"
for code in (self.alert_codes(mopool) + size_change_codes)
]
print(f"Alerts: {len(alert_summary)}")
for line in alert_summary: # pragma: no cover
print(f" {line}")
Expand Down Expand Up @@ -395,19 +385,6 @@ def __init__(self, uuid_formatter):
"""
self.uuid_formatter = uuid_formatter

@staticmethod
def alert_string(codes):
"""
Alert information to display, if any

:param codes: list of error codes to display
:type codes: list of PoolErrorCode

:returns: string w/ alert information, "" if no alert
:rtype: str
"""
return ", ".join(sorted(str(code) for code in codes))

def display(self):
"""
List pools in table view.
Expand Down Expand Up @@ -484,9 +461,14 @@ def gen_string(has_property, code):
physical_size_triple(mopool),
properties_string(mopool),
self.uuid_formatter(mopool.Uuid()),
self.alert_string(
self.alert_codes(mopool)
+ self._from_sets(pool_object_path, increased, decreased)
", ".join(
sorted(
str(code)
for code in (
self.alert_codes(mopool)
+ self._from_sets(pool_object_path, increased, decreased)
)
)
),
)
for (pool_object_path, mopool) in pools_with_props
Expand Down
Loading