1
- from typing import Callable
1
+ from typing import Any , Callable
2
2
3
3
import qbittorrentapi
4
4
from stdl import fs
5
5
from stdl .st import colored
6
6
7
7
8
- def is_windows_path (path : str ):
8
+ def is_windows_path (path : str ) -> bool :
9
9
return ":" in path and "\\ " in path
10
10
11
11
12
- def win_to_unix_path (path : str , drive_path : str = "/mnt" ):
12
+ def win_to_unix_path (path : str , drive_path : str = "/mnt" ) -> str :
13
13
"""
14
14
E:\\ files\\ -> /mnt/e/files/
15
15
/mnt/e/files/ -> /mnt/e/files/
@@ -23,7 +23,7 @@ def win_to_unix_path(path: str, drive_path: str = "/mnt"):
23
23
return path
24
24
25
25
26
- def unix_to_win_path (path : str , drive_path : str = "/mnt" ):
26
+ def unix_to_win_path (path : str , drive_path : str = "/mnt" ) -> str :
27
27
"""
28
28
/mnt/e/files/ -> E:\\ files\\
29
29
"""
@@ -34,7 +34,7 @@ def unix_to_win_path(path: str, drive_path: str = "/mnt"):
34
34
return path
35
35
36
36
37
- def same_path (path : str ):
37
+ def same_path (path : str ) -> str :
38
38
return path
39
39
40
40
@@ -56,7 +56,7 @@ def __init__(
56
56
self .client .auth_log_in ()
57
57
self .path_transoform_func = path_transform_func
58
58
59
- def get_torrents (self ):
59
+ def get_torrents (self ) -> list [ dict [ Any , Any ]] :
60
60
torrents = [dict (** i ) for i in self .client .torrents_info ()] # type: ignore
61
61
for i in torrents :
62
62
if i ["tags" ] == "" :
@@ -65,7 +65,7 @@ def get_torrents(self):
65
65
i ["tags" ] = [i .strip () for i in i ["tags" ].split ("," )]
66
66
return torrents
67
67
68
- def export_torrents (self , path : str ):
68
+ def export_torrents (self , path : str ) -> None :
69
69
torrents = self .get_torrents ()
70
70
data = []
71
71
for i in torrents :
@@ -81,7 +81,7 @@ def export_torrents(self, path: str):
81
81
fs .json_dump (data , path )
82
82
print (f"{ len (data )} torrents saved to { path } ." )
83
83
84
- def import_torrents (self , path : str ):
84
+ def import_torrents (self , path : str ) -> None :
85
85
current = [i ["magnet_uri" ] for i in self .get_torrents ()]
86
86
fs .ensure_paths_exist (path )
87
87
data = fs .json_load (path )
0 commit comments