ichor.cli package

Subpackages

Submodules

ichor.cli.console_menu module

class ConsoleMenu(this_menu_options: MenuOptions | None = None, title=None, subtitle=None, formatter=None, prologue_text=None, epilogue_text=None, clear_screen=True, show_exit_option=True, exit_option_text='Exit', exit_menu_char='q')

Bases: ConsoleMenu

Subclasses from consolemenu.ConsoleMenu, which is the base menu class. This subclass adds the this_menu_options attribute, which contains options for the menus, see the MenuOptions class. These options can be changed.

Also, the get_prologue_text method is overwritten here to be able print out extra info in the prologue before the menu items. The information printed is stored variables (that the user has selected) as well as any warnings. Since menus can open submenus, the submenus get the options of the parent menus, and the submenus can also add their own options.

For example the pointsdirectory menu can be used to select a folder which is in the structure of a PointsDirectory. Then a submenu can be used and it will remember the chosen folder in the parent directory. Also, this submenu can put in its own options (which will be displayed in the prolog along with the parent options and any warnings).

Parameters:
  • this_menu_options – A MenuOptions instance (a dataclass) containing options which can be changed by the user.

  • kwargs – Key word arguments to be passed to the original ConsoleMenu class.

get_prologue_text() str

Gets the prologue text, containing information for saved variables that are needed for jobs. First, if the ConsoleMenu instance has a default self.prologue_text, this gets printed out (this should not really be needed, can put this info in the subtitle anyway). After that, the information of options from parent classes is printed out (the oldest parent options are at the top). Finally, any options that the current menu adds are printed.

property parent_menu_options: List[MenuOptions]

Returns a list of MenuOption instances which contain information about options from parent classes. The list is reverse sorted, meaning that the earliest class is displayed first.

class Screen

Bases: Screen

Screen size of menu, overwrites some methods from library class.

input(prompt: str = '')

Prompt the end user for input. Without overwriting this, pressing Tab makes a tab. However, PathCompleter changes this, so after using a function with PathCompleter, the Tab button no longer makes a tab. With this fix, pressing Tab in any selection menu does not do anything (i.e. does not insert a tab like it did before). Menus requiring PathCompleter still work as intended and paths are auto-completed.

Parameters:

prompt – The message to display as the prompt.

Returns:

The input provided by the user.

add_items_to_menu(menu: ConsoleMenu, items: Iterable[MenuItem])

Adds a list of MenuItem instances to a ConsoleMenu instance.

ichor.cli.global_menu_variables module

These are global variables that are used and modified in the menus as needed. This is made so that submenus can easily access specific values that have been modified by parent menus.

ichor.cli.main_menu module

class MainMenuMenuOptions(selected_ichor_config_file: pathlib.Path)

Bases: MenuOptions

check_selected_points_directory_path() str | None

Checks whether the ichor_config.yaml is present in the user home directory.

selected_ichor_config_file: Path
class MainMenuOptions

Bases: MenuOptions

run_main_menu()

Runs main ichor menu.

ichor.cli.menu_description module

class MenuDescription(title: str, subtitle: str = '', prologue_description_text: str = '', epilogue_description_text: str = '', show_exit_option: bool = True)

Bases: object

Dataclass for menu descriptions. Each menu has its own description, which remains CONSTANT. Each menu has its own title/subtitle/etc, so make instance of this for each menu and fill in details.

epilogue_description_text: str = ''
prologue_description_text: str = ''
show_exit_option: bool = True
subtitle: str = ''
title: str

ichor.cli.menu_options module

class MenuOptions

Bases: object

Base class for Menu options. Each menu can implements its own options. Formats and prints out the options, as well as displays warnings to prologue when there are warnings for the given options. These options can be changed by the user.

static formatter_check_function(s)

Formats the string output of the check function, so that the user knows something is wrong.

static formatter_menu_options(s: str)

Formats the names of the dataclass variables, so they are printed nicely in the terminal.

run_check_functions()

Runs all methods that start with check. These are methods that make sure the current selected values make sense. If they do not, warnings are displayed (when warnings are implemented).

Module contents