Skip to content

botcity.plugins.files.plugin.BotFilesPlugin

get_all_file_paths(self, directory_path=None)

Get the path of all files present in the given directory.

Parameters:

Name Type Description Default
directory_path str

The directory to list the content. Defaults to current directory.

None

Returns:

Type Description
List[str]

The list containing the path of all files present in the folder.

get_last_created_file(self, directory_path=None, file_extension='')

Returns the last created file in a specific folder.

Parameters:

Name Type Description Default
directory_path str

The path of the folder where the file is expected. Defaults to current directory.

None
file_extension str

The extension of the file to be searched for (e.g., .pdf, .txt). Defaults to any file.

''

Returns:

Type Description
str

The path of the last created file.

unzip_all(self, zip_file, destination_folder=None)

Extract all content from a zip file.

Parameters:

Name Type Description Default
zip_file str

The path of the zip file to be extracted.

required
destination_folder str

The folder where the zip file content will be saved. Defaults to current directory.

None

unzip_file(self, zip_file, file_to_extract, destination_folder=None)

Extract a specified file from a zip file.

Parameters:

Name Type Description Default
zip_file str

The path of the zip file that contains the file to extract.

required
file_to_extract str

The name/path of the file that is in the zip file.

required
destination_folder str

The folder where the extracted file will be saved. Defaults to current directory.

None

wait_for_file(self, directory_path=None, file_extension='', timeout=60000)

Wait for a new file to be available at the specified path until a timeout.

Parameters:

Name Type Description Default
directory_path(str, optional

The path of the folder where the file is expected. Defaults to the current working directory.

required
file_extension str

The extension of the file to be searched for (e.g., .pdf, .txt). Defaults to any file.

''
timeout int

Maximum wait time (ms) to wait for the file. Defaults to 60000ms (60s).

60000

Note

This method should be used as a context manager.

zip_directory(self, directory_path, zip_filename)

Zip the given folder with all files and subfolders.

Parameters:

Name Type Description Default
directory_path str

The directory to be zipped.

required
zip_filename str

The path where the zip file will be saved.

required

zip_files(self, files_path, zip_filename)

Create a zip file containing all the given files.

Parameters:

Name Type Description Default
files_path List[str]

The list of files to be zipped.

required
zip_filename str

The path where the zip file will be saved.

required