brain_pipe.parser.file.FileLoadMixin

class FileLoadMixin

Bases: object

Mixin class for a TextParser to load a file before parsing.

Attributes

READ_MODE

__init__()

Methods

__init__()

get_additional_kwargs(input_, info)

Find the additional arguments that should be passed to the parser.

load_file(path)

Load a file into a text that can be parsed.

get_additional_kwargs(input_: Any, info: Dict[str, Any]) Dict[str, Any]

Find the additional arguments that should be passed to the parser.

This function identifies additional arguments that should be passed to the parser by e.g. a CLI.

Parameters:
  • input (str) – The input string that should be parsed when the parser is called.

  • info (Dict[str, Any]) – A dictionary containing available info, such as e.g. parsed CLI arguments. This information can be used to determine the additional arguments.

Returns:

A dictionary containing the names of the arguments as keys and the options (kwargs) for a (CLI) argument parser as values.

Return type:

Dict[str, Any]

load_file(path: str) str

Load a file into a text that can be parsed.

Parameters:

path (str) – The path to the file to load.

Returns:

The text that was loaded from the file.

Return type:

str