fortrace.utility.console_applications.text_editor package

Submodules

fortrace.utility.console_applications.text_editor.nano module

class fortrace.utility.console_applications.text_editor.nano.Nano(pty: REPLWrapper)[source]

Bases: GenericConsoleTextEditor

Nano text editor.

close()[source]

Close a console application.

Call this method to return to the command line. Sometimes it might be necessary to clean the buffer by calling self._pty.run_command(“clear”).

Notes

After a call to close refrain from using the object again

delete_current_line()[source]
go_to_line(line_num: int)[source]

Place the cursor in the specified line

Parameters:

line_num – if line_num == -1 the cursor is placed at the end of the file

replace(old: str, new: str, count: int = -1)[source]

Replace occurrence of pattern in file.

Parameters:
  • old – pattern to be searched for

  • new – pattern to replace __old

  • count – maximum number of occurrences to replace. -1 (the default value) means to replace all occurrences.

save_file()[source]

Save currently active file.

fortrace.utility.console_applications.text_editor.text_editor module

class fortrace.utility.console_applications.text_editor.text_editor.GenericConsoleTextEditor(pty: REPLWrapper, name: str)[source]

Bases: GenericConsoleApplication

Representation of generic console-based text editor.

abstractmethod delete_current_line()[source]
get_editor_screen() list[str][source]
abstractmethod go_to_line(line_num: int)[source]

Place the cursor in the specified line

Parameters:

line_num – if line_num == -1 the cursor is placed at the end of the file

abstractmethod replace(old: str, new: str, count: int = -1)[source]

Replace occurrence of pattern in file.

Parameters:
  • old – pattern to be searched for

  • new – pattern to replace __old

  • count – maximum number of occurrences to replace. -1 (the default value) means to replace all occurrences.

abstractmethod save_file()[source]

Save currently active file.

send_file(path: PathLike)[source]

Send a whole file to the domain by typing it into the text editor.

The file has to be saved afterward.

Parameters:

path – path to the file to be sent (should be encoded in UTF-8)

fortrace.utility.console_applications.text_editor.text_editor_factory module

fortrace.utility.console_applications.text_editor.text_editor_factory.get_console_text_editor(name: str, pty: REPLWrapper) GenericConsoleTextEditor[source]

Factory for console text editors.

Parameters:
  • name – name of the text editor to be opened

  • pty – handle to terminal (NOT VirshConsole)

Returns:

handle to opened text editor

fortrace.utility.console_applications.text_editor.vim module

class fortrace.utility.console_applications.text_editor.vim.VIM(pty: REPLWrapper)[source]

Bases: GenericConsoleTextEditor

VIM text editor.

change_mode(mode: VIMMode)[source]

Change VIM to the specified mode.

Parameters:

mode – target mode

close()[source]

Close a console application.

Call this method to return to the command line. Sometimes it might be necessary to clean the buffer by calling self._pty.run_command(“clear”).

Notes

After a call to close refrain from using the object again

delete_current_line()[source]
go_to_line(line_num: int)[source]

Go to a specific line.

VIM’s line indices start at 1. Place the cursor at the first column.

Parameters:

line_num – line to set cursor to. If -1 set cursor at the end of the file. If line_num is larger than the real number of lines of a file, VIM will set the cursor to the last line as well.

property mode
replace(old: str, new: str, count: int = -1)[source]

Replace occurrence of pattern in file.

Parameters:
  • old – pattern to be searched for

  • new – pattern to replace __old

  • count – maximum number of occurrences to replace. -1 (the default value) means to replace all occurrences.

save_file()[source]

Save currently active file.

send_command(command: str)[source]

Enter a specified command in VIM’s normal mode.

Enters VIM’s normal mode and enters the specified command. If possible use change_mode, since some commands do

not work with a RET appended, and this will be done automatically.

Notes

VIM will stay in normal mode after this method.

Parameters:

command – command to be entered

send_file(path: PathLike)[source]

Send a whole file to the domain by typing it into the text editor.

The file has to be saved afterward.

Parameters:

path – path to the file to be sent (should be encoded in UTF-8)

class fortrace.utility.console_applications.text_editor.vim.VIMMode(*values)[source]

Bases: Enum

INSERT = 2
NORMAL = 1
VISUAL = 3
VISUAL_BLOCK = 5
VISUAL_LINE = 4

Module contents