class documentation
class ProgramsFileManager(object):
Constructor: ProgramsFileManager(programs_dir, extension)
A manager for handling program files.
This class provides methods to create, read, update, and delete program files.
Parameters | |
programs | The directory where program files are stored. |
extension | The file extension for program files. |
Method | __init__ |
Initialize the ProgramsFileManager. |
Method | exists |
Check if a file with a certain name exists. |
Method | get |
Get a list of all file names available in the storage. |
Method | get |
Undocumented |
Method | read |
Read the content of the specified file. |
Method | remove |
Remove the specified file. |
Method | temporary |
Undocumented |
Method | write |
Write the content of code inside a file named name |
Method | _path |
Get the full file path from the given file name. |
Instance Variable | __extension |
Undocumented |
Instance Variable | __programs |
Undocumented |
Initialize the ProgramsFileManager.
Parameters | |
programs | The directory where program files are stored. |
extension:str | The file extension for program files. |
Check if a file with a certain name exists.
Parameters | |
name:str | The name of the file to check. |
Returns | |
bool | True if the file exists, else False. |
Get a list of all file names available in the storage.
Parameters | |
with | If True, include file extensions in the names. |
Returns | |
list[str] | A list of file names. |
Raises | |
Unknown exception | ProgramFileException: If the list of files cannot be retrieved. |
Read the content of the specified file.
Parameters | |
name:str | The name of the file to read. |
Returns | |
str | The content of the file. |
Raises | |
Unknown exception | ProgramFileException: If the file does not exist or cannot be read. |
Remove the specified file.
Parameters | |
name:str | The name of the file to remove. |
Raises | |
Unknown exception | ProgramFileException: If the file cannot be removed. |
Write the content of code
inside a file named name
Parameters | |
name:str | The name of the file to write to. |
code:str | The content of the file. |
overwrite | If True and a file already exist with this name, it will be overwritten |
Raises | |
Unknown exception | ProgramFileException: If the file cannot be created or written. |