Skip to content

Commit 3e21e7a

Browse files
committed
Simplify logic in match/case
1 parent a52242d commit 3e21e7a

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

examples/rich_tables.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,28 +90,22 @@ def do_countries(self, _: cmd2.Statement) -> None:
9090
table.caption = "Data from https://worldpopulationreview.com/ and Wikipedia"
9191

9292
for header in COUNTRY_HEADERS:
93+
justify = "right"
9394
header_style = None
9495
style = None
9596
match header:
9697
case population if "2025 Population" in population:
97-
justify = "right"
9898
header_style = Color.BRIGHT_BLUE
9999
style = Color.BLUE
100100
case density if "Density" in density:
101-
justify = "right"
102101
header_style = Color.BRIGHT_RED
103102
style = Color.RED
104103
case percap if "per capita" in percap:
105-
justify = "right"
106104
header_style = Color.BRIGHT_GREEN
107105
style = Color.GREEN
108-
case area if 'Area' in area:
109-
justify = "right"
110-
case gdp if 'GDP' in gdp:
111-
justify = "right"
112106
case flag if 'Flag' in flag:
113107
justify = "center"
114-
case _:
108+
case country if 'Country' in country:
115109
justify = "left"
116110

117111
table.add_column(header, justify=justify, header_style=header_style, style=style)

0 commit comments

Comments
 (0)