You are a Python programmer tasked with refactoring code. You are proficient in…
- User
SYSTEM: You are a Python programmer tasked with refactoring code. You are proficient in Python 3.12 and use modern features where appropriate. Your code is clear, easy to read, and free of unnecessary verbosity. For documentation, you use single-line docstrings and occasional comments. USER: # --- Configuration ---
class Config: """Configuration class for the image processing application.""" SCRIPT_DIR = Path(file).parent.resolve() INPUT_FOLDER = Path(os.getenv('INPUT_FOLDER', SCRIPT_DIR / '1. Input')) OUTPUT_FOLDER = Path(os.getenv('OUTPUT_FOLDER', SCRIPT_DIR / '2. Output')) DEFAULT_INPUT_FOLDER = INPUT_FOLDER DEFAULT_OUTPUT_FOLDER = OUTPUT_FOLDER IMAGEMAGICK = Path(os.getenv('IMAGEMAGICK', 'D:/Bilder/Python/0. Code/Requirements/ImageMagick.exe')) FFMPEG = Path(os.getenv('FFMPEG', 'D:/Bilder/Python/0. Code/Requirements/ffmpeg.exe'))
codeAUDIO_EXTENSIONS: Set[str] = {'.mka', '.mpga', '.mp3', '.aac', '.flac', '.opus'} IMAGE_EXTENSIONS: Set[str] = {'.png', '.jpg', '.jpeg', '.webp'} VIDEO_EXTENSIONS: Set[str] = {'.mkv', '.mp4'} # Constants for formatting and display SEPARATOR_LENGTH = 310 PADDING_LENGTH = 82 PROGRESS_BAR_LENGTH = 100 # Constants for resize options DEFAULT_RESIZE_MODE = "Shortest Side" DEFAULT_RESIZE_WIDTH = 0 DEFAULT_RESIZE_HEIGHT = 0 DEFAULT_RESIZE_SIDE = 1600 DEFAULT_RESIZE_FORMAT = "png" # Thresholds for color detection COLORDIFF_THRESHOLD: int = 5 # Threshold for color difference between channels FRACTION_COLORED_PIXELS_THRESHOLD: float = 0.03 # Fraction threshold to consider an image as color @classmethod def setup(cls): """Set up the output folder and configure logging.""" cls.OUTPUT_FOLDER.mkdir(parents=True, exist_ok=True) logging.getLogger("PIL").setLevel(logging.WARNING) @classmethod def initialize(cls): """Initialize the configuration and return a SharedState instance.""" cls.setup() return SharedState()@dataclass class SharedState: processed_files_lock: threading.Lock = field(default_factory=threading.Lock) processed_files_count: int = 0 total_files_count: int = 0 log_message_queue: Queue = field(default_factory=Queue) tab_messages: Dict[str, List[str]] = field(default_factory=lambda: { "Log": [], "Black": [], "White": [], "Color": [] }) stop_event: threading.Event = field(default_factory=threading.Event)
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.