notice

This is documentation for Rasa Documentation v2.x, which is no longer actively maintained.
For up-to-date documentation, see the latest version (3.x).

Version: 2.x

rasa.utils.io

pickle_dump

pickle_dump(filename: Union[Text, Path], obj: Any) -> None

Saves object to file.

Arguments:

  • filename - the filename to save the object to
  • obj - the object to store

pickle_load

pickle_load(filename: Union[Text, Path]) -> Any

Loads an object from a file.

Arguments:

  • filename - the filename to load the object from
  • Returns - the loaded object

unarchive

unarchive(byte_array: bytes, directory: Text) -> Text

Tries to unpack a byte array interpreting it as an archive.

Tries to use tar first to unpack, if that fails, zip will be used.

create_temporary_file

create_temporary_file(data: Any, suffix: Text = "", mode: Text = "w+") -> Text

Creates a tempfile.NamedTemporaryFile object for data.

mode defines NamedTemporaryFile's mode parameter in py3.

create_temporary_directory

create_temporary_directory() -> Text

Creates a tempfile.TemporaryDirectory.

create_path

create_path(file_path: Text) -> None

Makes sure all directories in the 'file_path' exists.

file_type_validator

file_type_validator(valid_file_types: List[Text], error_message: Text) -> Type["Validator"]

Creates a Validator class which can be used with questionary to validate file paths.

not_empty_validator

not_empty_validator(error_message: Text) -> Type["Validator"]

Creates a Validator class which can be used with questionary to validate that the user entered something other than whitespace.

create_validator

create_validator(function: Callable[[Text], bool], error_message: Text) -> Type["Validator"]

Helper method to create Validator classes from callable functions. Should be removed when questionary supports Validator objects.

json_unpickle

json_unpickle(file_name: Union[Text, Path]) -> Any

Unpickle an object from file using json.

Arguments:

  • file_name - the file to load the object from
  • Returns - the object

json_pickle

json_pickle(file_name: Union[Text, Path], obj: Any) -> None

Pickle an object to a file using json.

Arguments:

  • file_name - the file to store the object to
  • obj - the object to store

get_emoji_regex

get_emoji_regex() -> Pattern

Returns regex to identify emojis.