wasp_general.cli package¶
Submodules¶
wasp_general.cli.cli module¶
-
class
wasp_general.cli.cli.WConsoleBase(command_set=None)[source]¶ Bases:
wasp_general.cli.cli.WConsoleProto-
fin_session()[source]¶ WConsoleProto.fin_session()implementation. Commits current input rowReturns: None
-
prompt()[source]¶ WConsoleProto.prompt()implementation
-
start_session()[source]¶ WConsoleProto.start_session()implementation. Sets cursor to 0 position before sessionReturns: None
-
truncate(length)[source]¶ Shortcut for self.window().truncate_feedback(result) call
Parameters: length – same as length in WConsoleWindowProto.truncate_feedback()Returns: None
-
write(result, cr=True)[source]¶ Shortcut for self.window().write_feedback(result) call
Parameters: - result – same as feedback in
WConsoleWindowProto.write_feedback() - cr – same as cr in
WConsoleWindowProto.write_feedback()
Returns: None
- result – same as feedback in
-
-
class
wasp_general.cli.cli.WConsoleDrawerProto[source]¶ Bases:
objectBasic class that helps displaying console content
-
draw(window, prompt_show=True)[source]¶ Display console content on console window
Parameters: - window – windows to draw
- prompt_show – same as ‘prompt_show’ in
WConsoleWindowProto.refresh()method
Returns: None
-
suitable(window, prompt_show=True)[source]¶ Check if this class can display console content
Parameters: - window – window that should be drawn
- prompt_show – same as ‘prompt_show’ in
WConsoleWindowProto.refresh()method
Returns: bool (True if this class can draw console content, False - if it can not)
-
-
class
wasp_general.cli.cli.WConsoleHistory[source]¶ Bases:
objectSimple console history implementation
-
add(value)[source]¶ Add new record to history. Record will be added to the end
Parameters: value – new record Returns: int record position in history
-
entry(position)[source]¶ Get record from history by record position
Parameters: position – record position Returns: str
-
-
class
wasp_general.cli.cli.WConsoleProto[source]¶ Bases:
objectBasic class for console implementation. It has non-changeable and changeable history (
WConsoleHistory). One stores previous entered rows, other one helps to entered new row by editing previous one.-
history_mode(mode_value=None)[source]¶ Get and/or set current history mode.
History mode defines what row will be changed with
WConsoleProto.update_row()or can be got byWConsoleProto.row()call. If history mode disabled, thenWConsoleProto.update_row()andWConsoleProto.row()affects current row prompt. If history mode is enabled, thenWConsoleProto.update_row()andWConsoleProto.row()affects current entry in historyWConsoleHistory(entry atWConsoleHistory.position())History mode is turned off by default.
Parameters: mode_value – True value enables history mode. False - disables. None - do nothing Returns: bool
-
prompt()[source]¶ Return prompt, that would be printed before row. Prompt length must be the same within every session
Returns: str
-
prompt_show()[source]¶ Return flag, that shows, whether to display prompt and current command at the window end, or not
Returns: bool
-
-
class
wasp_general.cli.cli.WConsoleWindowBase(console, *drawers)[source]¶ Bases:
wasp_general.cli.cli.WConsoleWindowProtoBasic class for console window implementation
-
class
wasp_general.cli.cli.WConsoleWindowProto(console)[source]¶ Bases:
objectBasic class for console window implementation
-
cursor(pos=None)[source]¶ Set and/or get relative cursor position. Defines cursor position in current input row.
Parameters: pos – if value is not None, then current cursor position is set to this value and the same value is returned Returns: int
-
data(previous_data=False, prompt=False, console_row=False, console_row_to_cursor=False, console_row_from_cursor=False)[source]¶ Return output data. Flags specifies what data to append. If no flags was specified nul-length string returned
Parameters: - previous_data – If True, then previous output appends
- prompt – If True, then console prompt appends. If console_row or console_row_to_cursor is True, then this value is omitted
- console_row – If True, then console prompt and current input appends.
- console_row_to_cursor – If True, then console prompt and current input till cursor appends. If console_row is True, then this value is omitted
- console_row_from_cursor – If True, then current input from cursor appends. If console_row is True, then this value is omitted
Returns: str
-
height()[source]¶ Get window height. If windows height was changed - window must be refreshed via
WConsoleWindowProto.refresh()Returns: int
-
list_data(previous_data=False, prompt=False, console_row=False, console_row_to_cursor=False, console_row_from_cursor=False)[source]¶ Return list of strings. Where each string is fitted to windows width. Parameters are the same as they are in
WConsoleWindow.data()methodReturns: list of str
-
refresh(prompt_show=True)[source]¶ Refresh current window. Clear current window and redraw it with one of drawers
Parameters: prompt_show – flag, that specifies, whether to show prompt and current row at the windows end, or not
Returns: None
-
set_cursor(y, x)[source]¶ Set input cursor in window to specified coordinates. 0, 0 - is top left coordinates
Parameters: - y – vertical coordinates, 0 - top, bottom - positive value
- x – horizontal coordinates, 0 - left, right - positive value
Returns:
-
split(data)[source]¶ Split data into list of string, each (self.width() - 1) length or less. If nul-length string specified then empty list is returned
Parameters: data – data to split Returns: list of str
-
truncate_feedback(length)[source]¶ Remove data from feedback (removes text from previous output)
Parameters: length – string length to remove (including required cr-characters) Returns: None
-
width()[source]¶ Get window width. If windows width was changed - window must be refreshed via
WConsoleWindowProto.refresh()Returns: int
-
write_data(data, start_position=0)[source]¶ Write data from the specified line
Parameters: - data – string to write, each one on new line
- start_position – starting line
Returns:
-
wasp_general.cli.curses module¶
-
class
wasp_general.cli.curses.WCursesWindow(console)[source]¶ Bases:
wasp_general.cli.cli.WConsoleWindowBase-
class
BigWindowDrawer[source]¶ Bases:
wasp_general.cli.cli.WConsoleDrawerProtoWConsoleWindowProto.DrawerProto implementation. Suites if content and even current row doesn’t fit window width and height
-
class
EmptyWindowDrawer[source]¶ Bases:
wasp_general.cli.cli.WConsoleDrawerProtoWConsoleWindowProto.DrawerProto implementation. Suites if there is nothing to display
-
class
ScrolledWindowDrawer[source]¶ Bases:
wasp_general.cli.cli.WConsoleDrawerProtoWConsoleWindowProto.DrawerProto implementation. Suites if content doesn’t fit window width and height but current row fits
-
class
SmallWindowDrawer[source]¶ Bases:
wasp_general.cli.cli.WConsoleDrawerProtoWConsoleWindowProto.DrawerProto implementation. Suites if there is content and content fits window width and height
-
class