Skip to content

Commit 5e94d79

Browse files
authored
Update sorty.py
Pep 8 reformating
1 parent 170c5f7 commit 5e94d79

File tree

1 file changed

+12
-25
lines changed

1 file changed

+12
-25
lines changed

sorty.py

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
1-
2-
3-
4-
5-
import pystray, PIL.Image, PIL.ImageTk
6-
71
import json
82
import tkinter as tk
93
from tkinter import filedialog
10-
from notifypy import Notify
11-
12-
import os
13-
import shutil
14-
import mimetypes
15-
164

5+
import PIL.Image
6+
import PIL.ImageTk
7+
import pystray
8+
from notifypy import Notify
179

1810
image = PIL.Image.open("ico.png")
1911

2012
enable_notifications = True
2113

2214
destination = ""
2315

16+
2417
def create_settings():
2518
root = tk.Tk()
2619
root.withdraw()
@@ -41,10 +34,12 @@ def create_settings():
4134
json.dump(settings, settings_file)
4235

4336

37+
import os
38+
import shutil
39+
import mimetypes
4440

4541

4642
def sort_files(directory):
47-
4843
folders = {
4944
"Images": os.path.join(directory, "Images"),
5045
"Audio": os.path.join(directory, "Audio"),
@@ -55,7 +50,6 @@ def sort_files(directory):
5550
"Other": os.path.join(directory, "Other")
5651
}
5752

58-
5953
for folder in folders.values():
6054
os.makedirs(folder, exist_ok=True)
6155

@@ -64,11 +58,9 @@ def sort_files(directory):
6458
for filename in os.listdir(directory):
6559
file_path = os.path.join(directory, filename)
6660

67-
6861
if os.path.isdir(file_path):
6962
continue
7063

71-
7264
if filename.lower().endswith('.exe'):
7365
target_folder = folders["Other"]
7466
else:
@@ -93,7 +85,6 @@ def sort_files(directory):
9385
else:
9486
target_folder = folders["Other"]
9587

96-
9788
shutil.move(file_path, os.path.join(target_folder, filename))
9889
print(f"Перемещен: {filename} в {target_folder}")
9990
moved_files_count += 1
@@ -104,7 +95,6 @@ def sort_files(directory):
10495

10596

10697
def sort(icon, item):
107-
10898
if enable_notifications:
10999
notification = Notify()
110100
notification.application_name = "Sorty!"
@@ -120,8 +110,7 @@ def sort(icon, item):
120110
print("sorted!")
121111

122112

123-
def exit_action(icon:pystray.Icon):
124-
113+
def exit_action(icon: pystray.Icon):
125114
icon.stop()
126115
exit(0)
127116

@@ -132,20 +121,19 @@ def change_settings():
132121
with open("settings.sorty", "r") as settings_file:
133122
settings = json.load(settings_file)
134123

135-
136124
enable_notifications = settings.get("notificationsenabled", enable_notifications)
137125
destination = settings.get("download_folder", destination)
138126

139127
print(destination)
140128
print(enable_notifications)
141129

142-
icon = pystray.Icon("Sorty", image, menu = pystray.Menu(
130+
131+
icon = pystray.Icon("Sorty", image, menu=pystray.Menu(
143132
pystray.MenuItem("Sort!", sort),
144133
pystray.MenuItem("Сhange Directory", change_settings),
145-
pystray.MenuItem("Exit", lambda : exit_action(icon))
134+
pystray.MenuItem("Exit", lambda: exit_action(icon))
146135
))
147136

148-
149137
if os.path.exists("settings.sorty"):
150138
with open("settings.sorty", "r") as settings_file:
151139
settings = json.load(settings_file)
@@ -161,4 +149,3 @@ def change_settings():
161149
print(enable_notifications)
162150

163151
icon.run()
164-

0 commit comments

Comments
 (0)