Source code for fabex.operators.log_ops

"""Fabex 'log_ops.py' © 2012 Vilem Novak

Blender Operator definitions are in this file.
They mostly call the functions from 'utils.py'
"""

from os import listdir
from pathlib import Path

import bpy
from bpy.types import Operator

[docs] log_folder = str(Path(__file__).parent.parent / "logs")
[docs] class CamOpenLogFolder(Operator): """Open the CAM Log Folder"""
[docs] bl_idname = "scene.cam_open_log_folder"
[docs] bl_label = "Open Log Folder"
[docs] bl_options = {"REGISTER", "UNDO"}
@classmethod
[docs] def poll(cls, context): return context.scene is not None
[docs] def execute(self, context): """Opens the folder where CAM logs are stored. Args: context: The context in which the operation is executed. Returns: dict: A dictionary indicating the operation's completion status, specifically returning {'FINISHED'} upon successful execution. """ bpy.ops.file.external_operation(filepath=log_folder, operation="OPEN") return {"FINISHED"}
[docs] class CamPurgeLogs(Operator): """Delete CAM Logs"""
[docs] bl_idname = "scene.cam_purge_logs"
[docs] bl_label = "Purge CAM Logs"
[docs] bl_options = {"REGISTER", "UNDO"}
@classmethod
[docs] def poll(cls, context): return context.scene is not None
[docs] def execute(self, context): """Execute the CAM log removal process. This function removes the files from the CAM logs folder Args: context: The context in which the function is executed. Returns: dict: A dictionary indicating the status of the operation, specifically {'FINISHED'} upon successful execution. """ for file in listdir(log_folder): file_name = Path(log_folder) / file Path.unlink(file_name) return {"FINISHED"}