Verified Commit cd4e0eae authored by Sebastian Endres's avatar Sebastian Endres
Browse files

Solve PlotModeAll problem with argparse...

parent 86cfd19f
......@@ -22,23 +22,6 @@ class Side(Enum):
RIGHT = "right"
class PlotModeAll(Enum):
OFFSET_NUMBER = "offset-number"
PACKET_NUMBER = "packet-number"
FILE_SIZE = "file-size"
ALL = "all"
def get_plot_modes(self) -> list[PlotMode]:
"""Get PlotModes (resolve 'all')."""
return {
PlotModeAll.OFFSET_NUMBER: [PlotMode.OFFSET_NUMBER],
PlotModeAll.PACKET_NUMBER: [PlotMode.PACKET_NUMBER],
PlotModeAll.FILE_SIZE: [PlotMode.FILE_SIZE],
PlotModeAll.ALL: [mode for mode in PlotMode],
}[self]
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
......@@ -96,9 +79,10 @@ def parse_args():
parser.add_argument(
"--mode",
action="store",
choices=PlotModeAll,
type=PlotModeAll,
default=PlotModeAll.OFFSET_NUMBER,
choices=PlotMode,
nargs="+",
type=PlotMode,
default=[mode for mode in PlotMode],
help="The mode of plotting (time vs. packet-number or time vs. file-size or both)",
)
parser.add_argument(
......@@ -122,7 +106,7 @@ class PlotAllCli:
force=False,
only_sat=False,
include_failed=False,
mode: PlotModeAll = PlotModeAll.OFFSET_NUMBER,
modes: list[PlotMode] = [mode for mode in PlotMode],
debug=False,
):
# self.log_dirs = log_dirs
......@@ -134,7 +118,7 @@ class PlotAllCli:
self.format = format
self.force = force
self.include_failed = include_failed
self.modes = mode.get_plot_modes()
self.modes = modes
self._current_log_dir: Optional[Path] = None
self.debug = debug
......@@ -317,7 +301,7 @@ def main():
format=args.format,
force=args.force,
include_failed=args.include_failed,
mode=args.mode,
modes=args.mode,
debug=args.debug,
)
try:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment