Skip to content

Latest commit

 

History

History
120 lines (58 loc) · 2.89 KB

velocitas_lib.file_utils.md

File metadata and controls

120 lines (58 loc) · 2.89 KB

module velocitas_lib.file_utils


function replace_text_in_file

replace_text_in_file(file_path: str, text: str, replacement: str) → None

Replace all occurrences of text in a file with a replacement.

Args:

  • file_path (str): The path to the file.
  • text (str): The text to find.
  • replacement (str): The replacement for text.

function capture_area_in_file

capture_area_in_file(
    file: TextIOWrapper,
    start_line: str,
    end_line: str,
    map_fn: Optional[Callable[[str], str]] = None
) → List[str]

Capture an area of a textfile between a matching start line (exclusive) and the first line matching end_line (exclusive).

Args:

  • file (TextIOWrapper): The text file to read from.
  • start_line (str): The line which triggers the capture (will not be part of the output)
  • end_line (str): The line which terminates the capture (will not be bart of the output)
  • map_fn (Optional[Callable[[str], str]], optional): An optional mapping function to transform captured lines. Defaults to None.

Returns:

  • List[str]: A list of captured lines.

function read_file

read_file(file_path: str) → Optional[str]

Reads the file with the given file_path and returns it's content as a str.

Args:

  • file_path (str): the file_path of the file to read.

Returns:

  • str: the content of the specified file.

function write_file

write_file(file_path: str, content: str) → bool

Writes the content to the file_path and returns the success of the write operation.

Args:

  • file_path (str): the file_path of the file to write.
  • content (str): the content to be written to the file.

Returns:

  • bool: True if writing was successful, False otherwise.

This file was automatically generated via lazydocs.