Skip to content

Commit

Permalink
Handle 'None' cell value when trying to sort
Browse files Browse the repository at this point in the history
  • Loading branch information
OCopping committed May 28, 2024
1 parent a9010c1 commit 009a127
Showing 1 changed file with 45 additions and 15 deletions.
60 changes: 45 additions & 15 deletions src/edge_containers_cli/cmds/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,47 @@ def __init__(
def __lt__(self, other: Any) -> bool:
if type(other) != SortableText:
return NotImplemented
return cast(bool, self.value < other.value)

# Handle None as values
match self.value, other.value:
case (None, None):
return False
case (None, _):
return False
case (_, None):
return True
case _:
return cast(bool, self.value < other.value)

def __gt__(self, other: Any) -> bool:
if type(other) != SortableText:
return NotImplemented
return cast(bool, self.value > other.value)

# Handle None as values
match self.value, other.value:
case (None, None):
return False
case (None, _):
return True
case (_, None):
return False
case _:
return cast(bool, self.value > other.value)

def __eq__(self, other: Any) -> bool:
if type(other) != SortableText:
return NotImplemented
return cast(bool, self.value == other.value)

# Handle None as values
match self.value, other.value:
case (None, None):
return True
case (None, _):
return False
case (_, None):
return False
case _:
return cast(bool, self.value == other.value)


class IocTable(Widget):
Expand Down Expand Up @@ -354,18 +384,6 @@ async def populate_table(self) -> None:


class MonitorApp(App):
def __init__(
self,
beamline: str,
commands: Commands,
running_only: bool,
) -> None:
super().__init__()

self.commands = commands
self.running_only = running_only
self.beamline = beamline

CSS_PATH = "monitor.tcss"

BINDINGS = [
Expand All @@ -378,6 +396,18 @@ def __init__(
# Binding("d", "toggle_dark", "Toggle dark mode"),
]

def __init__(
self,
beamline: str,
commands: Commands,
running_only: bool,
) -> None:
super().__init__()

self.commands = commands
self.running_only = running_only
self.beamline = beamline

def compose(self) -> ComposeResult:
"""Create child widgets for the app."""
yield Header(show_clock=True)
Expand Down

0 comments on commit 009a127

Please sign in to comment.