Skip to content

Commit 87fb3e3

Browse files
fixed importing of packages
1 parent 7d31fa0 commit 87fb3e3

File tree

10 files changed

+29
-22
lines changed

10 files changed

+29
-22
lines changed

sonicbit/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from sonicbit.handlers.token_file import TokenFileHandler
44
from sonicbit.sonicbit import SonicBit
55

6-
__version__ = "0.1.0"
6+
__version__ = "0.1.1"
77
__all__ = ["SonicBit", "TokenFileHandler"]
88

99
logging.basicConfig(

sonicbit/handlers/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from .token_file import TokenHandler, TokenFileHandler
2+
3+
__all__ = [
4+
"TokenHandler",
5+
"TokenFileHandler",
6+
]

sonicbit/handlers/token_file.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from sonicbit.types import AuthResponse
55

66

7-
class BaseTokenHandler:
7+
class TokenHandler:
88
def __init__(self):
99
pass
1010

@@ -15,7 +15,7 @@ def read(self, email: str) -> str | None:
1515
return input(f"Enter {email} sesion: ")
1616

1717

18-
class TokenFileHandler(BaseTokenHandler):
18+
class TokenFileHandler(TokenHandler):
1919
def __init__(self, path: str = ".sonicbit.cache"):
2020
self.path = os.path.abspath(path)
2121
super().__init__()

sonicbit/modules/auth.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,20 @@
33
from requests import Session, request
44

55
from sonicbit.constants import Constants
6-
from sonicbit.handlers.token_file import BaseTokenHandler, TokenFileHandler
6+
from sonicbit.handlers.token_file import TokenHandler, TokenFileHandler
7+
from sonicbit.modules.base import SonicBitBase
78
from sonicbit.types import AuthResponse
89

910
logger = logging.getLogger(__name__)
1011

1112

12-
class Auth:
13+
class Auth(SonicBitBase):
1314
def __init__(
1415
self,
1516
email: str,
1617
password: str,
1718
token: str = None,
18-
token_handler: BaseTokenHandler = TokenFileHandler(),
19+
token_handler: TokenHandler = TokenFileHandler(),
1920
):
2021
logger.debug("Initializing Auth")
2122
self.session = Session()
@@ -27,7 +28,7 @@ def __init__(
2728
self.session.headers.update({"Authorization": f"Bearer {token}"})
2829

2930
def get_token(
30-
self, email: str, password: str, token_handler: BaseTokenHandler
31+
self, email: str, password: str, token_handler: TokenHandler
3132
) -> str:
3233
logger.debug("Getting token")
3334
token = token_handler.read(email)

sonicbit/modules/base.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1+
from requests import Session
2+
3+
14
class SonicBitBase:
2-
pass
5+
"""Base class for all SonicBit modules."""
6+
7+
session = Session

sonicbit/modules/file.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44
from requests import Session
55

66
from sonicbit.enums import FileCommand
7+
from sonicbit.modules.base import SonicBitBase
78
from sonicbit.types import File as FileType
89
from sonicbit.types import FileList, PathInfo
910

1011
logger = logging.getLogger(__name__)
1112

1213

13-
class File:
14-
session: Session
15-
14+
class File(SonicBitBase):
1615
def list_files(self, path: PathInfo = PathInfo.root()) -> FileList:
1716
logger.debug(f"Listing files in {path.path}")
1817
params = {

sonicbit/modules/remote_download.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44

55
from sonicbit.enums import RemoteDownloadCommand
66
from sonicbit.error.error import SonicbitError
7+
from sonicbit.modules.base import SonicBitBase
78
from sonicbit.types import RemoteTaskList
89
from sonicbit.types.path_info import PathInfo
910

1011
logger = logging.getLogger(__name__)
1112

1213

13-
class RemoteDownload:
14-
session: Session
15-
14+
class RemoteDownload(SonicBitBase):
1615
def add_remote_download(self, url: str, path: PathInfo) -> bool:
1716
logger.debug(f"Adding remote download {url} to {path.path}")
1817

sonicbit/modules/torrent.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55

66
from sonicbit.enums import TorrentCommand
77
from sonicbit.error import SonicbitError
8+
from sonicbit.modules.base import SonicBitBase
89
from sonicbit.types import PathInfo, TorrentDetails, TorrentList
910

1011
logger = logging.getLogger(__name__)
1112

1213

13-
class Torrent:
14-
session: Session
15-
14+
class Torrent(SonicBitBase):
1615
def add_torrent(
1716
self,
1817
uri: str | List[str],

sonicbit/modules/user.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
from requests import Session
44

55
from sonicbit.error.error import SonicbitError
6+
from sonicbit.modules.base import SonicBitBase
67
from sonicbit.types import UserDetails
78
from sonicbit.types.storage_details import StorageDetails
89

910
logger = logging.getLogger(__name__)
1011

1112

12-
class User:
13-
session: Session
14-
13+
class User(SonicBitBase):
1514
def get_user_details(self) -> UserDetails:
1615
logger.debug("Getting user details")
1716
response = self.session.post(self.url("/get/user/details"))

sonicbit/sonicbit.py

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

87

9-
class SonicBit(SonicBitBase, Auth, User, File, Torrent, RemoteDownload):
8+
class SonicBit(Auth, User, File, Torrent, RemoteDownload):
109
def __init__(self, email: str, password: str, token: str = None):
1110
super().__init__(email, password, token)

0 commit comments

Comments
 (0)