utils

This module provides utility functions for the PyRat library. It includes mainly a function to create a workspace, which is meant to be called just at the beginning of a PyRat project.

utils.init_workspace(target_directory='pyrat_workspace')[source]

Creates all the directories for a clean student workspace. Also creates a few default programs to start with. This function also takes care of adding the workspace to the Python path so that it can be used directly. If the workspace already exists, it is not modified but we setup the Python path anyway to use it.

Parameters:

target_directory (str) – The directory in which to create the workspace.

Return type:

None

utils.is_valid_directory(directory)[source]

Checks if a directory exists or can be created, without actually creating it.

Parameters:

directory (str) – The directory to check.

Return type:

bool

Returns:

True if the directory can be created, False otherwise.