1111TESTMODE = True
1212
1313
14- def get_things_to_delete () -> (
14+ def _get_things_to_delete () -> (
1515 Tuple [List [Tuple [str , float , str ]], List [Tuple [str , float , str ]]]
1616):
1717 (
@@ -36,33 +36,33 @@ def get_things_to_delete() -> (
3636
3737 if (
3838 os .path .isdir (item_path )
39- and get_days_since_creation (item_path ) > days_until_deletion
39+ and _get_days_since_creation (item_path ) > days_until_deletion
4040 ):
41- _folder_results .append ((item_path , get_size_bytes (item_path ), "age" ))
41+ _folder_results .append ((item_path , _get_size_bytes (item_path ), "age" ))
4242 if os .path .isfile (item_path ):
43- if re .match (pattern , item ) and has_extracted_folder (item_path ):
43+ if re .match (pattern , item ) and _has_extracted_folder (item_path ):
4444 _file_results .append (
4545 (
4646 item_path ,
47- get_size_bytes (item_path ),
47+ _get_size_bytes (item_path ),
4848 "unpacked" ,
4949 )
5050 )
5151 continue
52- if get_days_since_creation (item_path ) > days_until_deletion :
53- _file_results .append ((item_path , get_size_bytes (item_path ), "age" ))
52+ if _get_days_since_creation (item_path ) > days_until_deletion :
53+ _file_results .append ((item_path , _get_size_bytes (item_path ), "age" ))
5454
5555 return _file_results , _folder_results
5656
5757
58- def bytes_to_string (bytes_size : float ) -> str :
58+ def _bytes_to_string (bytes_size : float ) -> str :
5959 if bytes_size >= 1024 ** 3 :
6060 return f"{ bytes_size / 1024 ** 3 :.2f} GB"
6161 else :
6262 return f"{ bytes_size / 1024 ** 2 :.2f} MB"
6363
6464
65- def get_size_bytes (path : str ) -> float :
65+ def _get_size_bytes (path : str ) -> float :
6666 return_size_bytes = 0
6767 if os .path .isfile (path ):
6868 return_size_bytes = os .path .getsize (path )
@@ -75,7 +75,7 @@ def get_size_bytes(path: str) -> float:
7575 return return_size_bytes
7676
7777
78- def get_days_since_creation (path : str ) -> int :
78+ def _get_days_since_creation (path : str ) -> int :
7979 if os .path .isfile (path ):
8080 creation_time = os .path .getctime (path )
8181 elif os .path .isdir (path ):
@@ -88,12 +88,12 @@ def get_days_since_creation(path: str) -> int:
8888 return (current_date - creation_date ).days
8989
9090
91- def has_extracted_folder (file_path : str ) -> bool :
91+ def _has_extracted_folder (file_path : str ) -> bool :
9292 folder_path = os .path .splitext (file_path )[0 ]
9393 return os .path .isdir (folder_path )
9494
9595
96- def delete_file_or_folder (path : str , isfile : bool ):
96+ def _delete_file_or_folder (path : str , isfile : bool ):
9797 if TESTMODE :
9898 return
9999 with contextlib .suppress (FileNotFoundError ):
@@ -103,7 +103,7 @@ def delete_file_or_folder(path: str, isfile: bool):
103103 shutil .rmtree (path )
104104
105105
106- def handle_startup () -> None :
106+ def _handle_startup () -> None :
107107 (
108108 _ ,
109109 _ ,
@@ -114,6 +114,8 @@ def handle_startup() -> None:
114114
115115 if start_with_windows :
116116 registry .add_to_autostart ()
117+ else :
118+ registry .remove_from_autostart ()
117119
118120 max_log_size_bytes = max_log_size_mb * 1024 * 1024
119121 if (
@@ -125,9 +127,9 @@ def handle_startup() -> None:
125127
126128
127129def process_things ():
128- handle_startup ()
130+ _handle_startup ()
129131
130- things_to_delete = get_things_to_delete ()
132+ things_to_delete = _get_things_to_delete ()
131133 files_to_delete , folders_to_delete = things_to_delete
132134
133135 bytes_to_delete = 0
@@ -152,17 +154,17 @@ def process_things():
152154
153155 logger .log (
154156 logger .INFO ,
155- f"{ type_label } : { basename } SIZE: { bytes_to_string (size_bytes )} REASON: { reason } " ,
157+ f"{ type_label } : { basename } SIZE: { _bytes_to_string (size_bytes )} REASON: { reason } " ,
156158 )
157159
158160 bytes_to_delete += size_bytes
159- delete_file_or_folder (path , is_file )
161+ _delete_file_or_folder (path , is_file )
160162
161- if bytes_to_delete <= 0 :
163+ if bytes_to_delete == 0. 0 :
162164 logger .show_summary ()
163165 else :
164166 popup .show_notification (
165- f"Deleted { bytes_to_string (bytes_to_delete )} from your computer." ,
167+ f"Deleted { _bytes_to_string (bytes_to_delete )} from your computer." ,
166168 f"{ len (files_to_delete )} files and { len (folders_to_delete )} folders.\n "
167169 + f"{ amount_reason_unpacked } files already unpacked, { amount_reason_age } too old ({ config .data [2 ]} days)" ,
168170 )
0 commit comments