Skip to content

Commit a290f54

Browse files
refactor base module to resolve circular import
1 parent 6e7ae4c commit a290f54

File tree

18 files changed

+30
-32
lines changed

18 files changed

+30
-32
lines changed

sonicbit/handlers/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from .token_file import TokenFileHandler, TokenHandler
1+
from .token_file_handler import TokenFileHandler
2+
from .token_handler import TokenHandler
23

34
__all__ = [
45
"TokenHandler",
Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
11
import json
22
import os
33

4+
from sonicbit.handlers.token_handler import TokenHandler
45
from sonicbit.types.auth_response import AuthResponse
56

67

7-
class TokenHandler:
8-
def __init__(self):
9-
pass
10-
11-
def write(self, email: str, auth: AuthResponse) -> None:
12-
print(f"{email}'s token is {auth.token}")
13-
14-
def read(self, email: str) -> str | None:
15-
return input(f"Enter {email}'s token: ")
16-
17-
188
class TokenFileHandler(TokenHandler):
199
def __init__(self, path: str = ".sonicbit.cache"):
2010
self.path = os.path.abspath(path)

sonicbit/handlers/token_handler.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from sonicbit.types.auth_response import AuthResponse
2+
3+
4+
class TokenHandler:
5+
def __init__(self):
6+
pass
7+
8+
def write(self, email: str, auth: AuthResponse) -> None:
9+
print(f"{email}'s token is {auth.token}")
10+
11+
def read(self, email: str) -> str | None:
12+
return input(f"Enter {email}'s token: ")

sonicbit/modules/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
from .auth import Auth
2-
from .base import SonicBitBase
32
from .file import File
43
from .remote_download import RemoteDownload
54
from .torrent import Torrent
65
from .user import User
76

87
__all__ = [
9-
"SonicBitBase",
108
"Auth",
119
"File",
1210
"RemoteDownload",

sonicbit/modules/auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
from requests import Session, request
44

5+
from sonicbit.base import SonicBitBase
56
from sonicbit.constants import Constants
6-
from sonicbit.handlers.token_file import TokenHandler
7-
from sonicbit.modules.base import SonicBitBase
7+
from sonicbit.handlers.token_handler import TokenHandler
88
from sonicbit.types import AuthResponse
99

1010
logger = logging.getLogger(__name__)

sonicbit/modules/file.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import json
22
import logging
33

4-
4+
from sonicbit.base import SonicBitBase
55
from sonicbit.enums import FileCommand
6-
from sonicbit.modules.base import SonicBitBase
76
from sonicbit.types import File as FileType
87
from sonicbit.types import FileList, PathInfo
98

sonicbit/modules/remote_download.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import logging
22

3-
3+
from sonicbit.base import SonicBitBase
44
from sonicbit.enums import RemoteDownloadCommand
55
from sonicbit.error.error import SonicbitError
6-
from sonicbit.modules.base import SonicBitBase
76
from sonicbit.types import RemoteTaskList
87
from sonicbit.types.path_info import PathInfo
98

sonicbit/modules/torrent.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import logging
22
from typing import List
33

4-
4+
from sonicbit.base import SonicBitBase
55
from sonicbit.enums import TorrentCommand
66
from sonicbit.error import SonicbitError
7-
from sonicbit.modules.base import SonicBitBase
87
from sonicbit.types import PathInfo, TorrentDetails, TorrentList
98

109
logger = logging.getLogger(__name__)

sonicbit/modules/user.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import logging
22

3-
3+
from sonicbit.base import SonicBitBase
44
from sonicbit.error.error import SonicbitError
5-
from sonicbit.modules.base import SonicBitBase
65
from sonicbit.types import UserDetails
76
from sonicbit.types.storage_details import StorageDetails
87

0 commit comments

Comments
 (0)