ReFreSH.MobileSuit.UI package

Submodules

ReFreSH.MobileSuit.UI.CommandLineUI module

class ReFreSH.MobileSuit.UI.CommandLineUI.ConsoleInput(io: IIOHub)[source]

Bases: object

Useful input components for console UI.

SelectItemFrom(prompt: str, selectFrom: List[T], serializer: Callable[[T], str] | None = None, labeler: Callable[[int, T], str] | None = None) T[source]

A CUI that allows the user select ONE objective from Alternative objectives.

Args:

self prompt: Prompt to guide user selection selectFrom: Alternative objectives serializer: Method of Serializing Object as Text labeler: Label of objectives to guide user selection

Returns:

Selected item from selectFrom

static SelectItemsFrom(self, prompt: str, selectFrom: List[T], serializer: Callable[[T], str] | None = None, labeler: Callable[[int, T], str] | None = None, parser: Callable[[str | None, Dict[str, int]], List[int] | None] | None = None) Iterable[T][source]

A CUI that allows the user select ONE objective from Alternative objectives.

Args:

self prompt: Prompt to guide user selection selectFrom: Alternative objectives serializer: Method of Serializing Object as Text labeler: Label of objectives to guide user selection parser: Function to parse user input into several int index

Returns:

Selected items from selectFrom

static SelectYesNo(self, prompt: str, default: bool | None = None) bool[source]

A CUI that allows the user answer yes/no by inputting “y” or “n”.

Args:

self prompt: Prompt to guide user input default: NULL if only y/n is allowed; Otherwise, if user input is null or empty, such default value will be returned.

Returns:

True if user says “yes”.

classmethod SpaceHyphenParser(userInput: str | None, labelMapping: Dict[str, int]) List[int] | None[source]

Split user input using space and hyphen. E.g., “1-3 4” will be parsed to {1,2,3,4}.

Args:

userInput: String from user labelMapping: Dictionary maps label to index.

Returns:

Parsed indices or None if failed to parse.

exception SpaceHyphenParserException[source]

Bases: Exception

classmethod SpaceHyphenParserInternal(userInput: str | None, labelMapping: Dict[str, int]) Iterable[int][source]
static ToStringOrEmptySerializer(origin: T | None) str[source]

Serialize target with ToString()??””

Args:

origin: Origin value

Returns:

Serialized target used ToString()??””

Module contents