11"""RED-Python application main module."""
2+
23import os
34import csv
4- import copy
55import tkinter as tk
66from tkinter import ttk , filedialog , messagebox
77from datetime import datetime
88
99from config import (
1010 Settings ,
1111 DEFAULT_FILTER_RULES ,
12- DEFAULT_PROTECTED_DIRS ,
13- DEFAULT_SETTINGS ,
1412)
1513from core import Scanner , Cleaner , ScanResult
1614from filters import METHODS , TYPES , METHOD_LABELS , TYPE_LABELS
@@ -100,7 +98,6 @@ def _ok(self):
10098
10199
102100class SettingsDialog (tk .Toplevel ):
103-
104101 def __init__ (self , parent , settings : Settings ):
105102 super ().__init__ (parent )
106103 self .title ("Settings - RED-Python" )
@@ -169,9 +166,7 @@ def _build(self):
169166 # Buttons row
170167 bf = ttk .Frame (t1 )
171168 bf .pack (fill = tk .X , padx = 6 , pady = 4 )
172- ttk .Button (bf , text = "+ Add" , command = self ._rule_add ).pack (
173- side = tk .LEFT , padx = 2
174- )
169+ ttk .Button (bf , text = "+ Add" , command = self ._rule_add ).pack (side = tk .LEFT , padx = 2 )
175170 ttk .Button (bf , text = "✎ Edit" , command = self ._rule_edit ).pack (
176171 side = tk .LEFT , padx = 2
177172 )
@@ -194,9 +189,9 @@ def _build(self):
194189 # ── Tab 2: Protection ─────────────────────────────────────────
195190 t2 = ttk .Frame (nb )
196191 nb .add (t2 , text = "Protection" )
197- ttk .Label (
198- t2 , text = "Protected folders (one per line - never deleted):"
199- ). pack ( anchor = tk . W , padx = 6 , pady = ( 6 , 0 ))
192+ ttk .Label (t2 , text = "Protected folders (one per line - never deleted):" ). pack (
193+ anchor = tk . W , padx = 6 , pady = ( 6 , 0 )
194+ )
200195 self ._protected = tk .Text (t2 , font = ("Consolas" , 9 ))
201196 sb2 = ttk .Scrollbar (t2 , command = self ._protected .yview )
202197 self ._protected .config (yscrollcommand = sb2 .set )
@@ -312,9 +307,7 @@ def _unreg_shell(self):
312307 # ── Bottom buttons ────────────────────────────────────────────
313308 bb = ttk .Frame (self )
314309 bb .pack (fill = tk .X , padx = 6 , pady = 6 )
315- ttk .Button (bb , text = "Cancel" , command = self .destroy ).pack (
316- side = tk .RIGHT , padx = 4
317- )
310+ ttk .Button (bb , text = "Cancel" , command = self .destroy ).pack (side = tk .RIGHT , padx = 4 )
318311 ttk .Button (bb , text = "Save" , command = self ._save ).pack (side = tk .RIGHT )
319312
320313 # ------------------------------------------------------------------
@@ -473,7 +466,10 @@ def _apply_style(self):
473466 s .theme_use (theme )
474467 break
475468 except Exception as _e :
476- import sys ; print (f'[DEBUG] Ignored Exception: { _e } ' , file = sys .stderr ); continue
469+ import sys
470+
471+ print (f"[DEBUG] Ignored Exception: { _e } " , file = sys .stderr )
472+ continue
477473
478474 # ------------------------------------------------------------------
479475 def _build (self ):
@@ -487,9 +483,7 @@ def _build(self):
487483 self ._path_entry .bind ("<Return>" , lambda e : self ._add_path ())
488484
489485 ttk .Button (tb , text = "Browse" , command = self ._browse ).pack (side = tk .LEFT , padx = 2 )
490- ttk .Button (tb , text = "+ Add" , command = self ._add_path ).pack (
491- side = tk .LEFT , padx = 2
492- )
486+ ttk .Button (tb , text = "+ Add" , command = self ._add_path ).pack (side = tk .LEFT , padx = 2 )
493487 ttk .Button (tb , text = "− Remove" , command = self ._remove_path ).pack (
494488 side = tk .LEFT , padx = 2
495489 )
@@ -599,17 +593,17 @@ def _build(self):
599593 side = tk .LEFT , fill = tk .X , expand = True , padx = (0 , 6 )
600594 )
601595
602- self ._btn_stop = ttk .Button (bf , text = "Stop" , command = self ._stop , state = tk .DISABLED )
596+ self ._btn_stop = ttk .Button (
597+ bf , text = "Stop" , command = self ._stop , state = tk .DISABLED
598+ )
603599 self ._btn_stop .pack (side = tk .RIGHT , padx = 2 )
604600 self ._btn_delete = ttk .Button (
605601 bf , text = "Delete selected" , command = self ._delete , state = tk .DISABLED
606602 )
607603 self ._btn_delete .pack (side = tk .RIGHT , padx = 2 )
608604 self ._btn_scan = ttk .Button (bf , text = "Scan" , command = self ._scan )
609605 self ._btn_scan .pack (side = tk .RIGHT , padx = 2 )
610- ttk .Button (bf , text = "Export…" , command = self ._export ).pack (
611- side = tk .RIGHT , padx = 2
612- )
606+ ttk .Button (bf , text = "Export…" , command = self ._export ).pack (side = tk .RIGHT , padx = 2 )
613607 ttk .Button (bf , text = "Deselect" , command = self ._desel_all ).pack (
614608 side = tk .RIGHT , padx = 2
615609 )
@@ -706,17 +700,21 @@ def _do():
706700 try :
707701 total_bytes += os .path .getsize (long_path (fpath ))
708702 except Exception as _e :
709- import sys ; print (f'[DEBUG] Ignored Exception: { _e } ' , file = sys .stderr )
703+ import sys
704+
705+ print (f"[DEBUG] Ignored Exception: { _e } " , file = sys .stderr )
710706
711707 if total_bytes > 0 :
712708 if total_bytes < 1024 :
713709 size_str = f"{ total_bytes } B"
714710 elif total_bytes < 1024 * 1024 :
715- size_str = f"{ total_bytes / 1024 :.1f} KB"
711+ size_str = f"{ total_bytes / 1024 :.1f} KB"
716712 else :
717- size_str = f"{ total_bytes / (1024 * 1024 ):.1f} MB"
713+ size_str = f"{ total_bytes / (1024 * 1024 ):.1f} MB"
718714 except Exception as _e :
719- import sys ; print (f'[DEBUG] Ignored Exception: { _e } ' , file = sys .stderr )
715+ import sys
716+
717+ print (f"[DEBUG] Ignored Exception: { _e } " , file = sys .stderr )
720718
721719 self ._tree .insert (
722720 "" ,
@@ -766,9 +764,7 @@ def _delete(self):
766764 to_process = [r for r in self .results if r .status == "empty" ]
767765
768766 if not to_process :
769- messagebox .showinfo (
770- "No selection" , "There are no empty folders to delete."
771- )
767+ messagebox .showinfo ("No selection" , "There are no empty folders to delete." )
772768 return
773769
774770 mode = self ._mode .get ()
@@ -811,7 +807,9 @@ def _do():
811807 values = ("Deleted" , vals [1 ] if vals else "" ),
812808 )
813809 except Exception as _e :
814- import sys ; print (f'[DEBUG] Ignored Exception: { _e } ' , file = sys .stderr )
810+ import sys
811+
812+ print (f"[DEBUG] Ignored Exception: { _e } " , file = sys .stderr )
815813
816814 self .after (0 , _do )
817815
@@ -820,7 +818,9 @@ def _do():
820818 try :
821819 self ._tree .item (result .path , tags = ("error" ,))
822820 except Exception as _e :
823- import sys ; print (f'[DEBUG] Ignored Exception: { _e } ' , file = sys .stderr )
821+ import sys
822+
823+ print (f"[DEBUG] Ignored Exception: { _e } " , file = sys .stderr )
824824
825825 self .after (0 , _do )
826826
0 commit comments