Skip to content

Commit

Permalink
refactor: tree structure
Browse files Browse the repository at this point in the history
  • Loading branch information
sacklippe committed Jul 4, 2024
1 parent 5889dd5 commit 3aeeb29
Show file tree
Hide file tree
Showing 33 changed files with 40 additions and 31 deletions.
3 changes: 3 additions & 0 deletions musync/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from pathlib import Path

ROOT_DIR = Path(__file__).parent.parent.resolve()
2 changes: 2 additions & 0 deletions musync/common/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .session import Session
from .sync_manager import SyncManager
File renamed without changes.
2 changes: 1 addition & 1 deletion musync/entity/artist.py → musync/common/entity/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import tidalapi as tidal

from musync.entity.origin import Origin
from musync.common.entity.origin import Origin


@dataclass(frozen=True, slots=True)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import tidalapi as tidal

from musync.entity.origin import Origin
from musync.common.entity.origin import Origin


@dataclass(frozen=True, slots=True)
Expand Down
4 changes: 2 additions & 2 deletions musync/entity/track.py → musync/common/entity/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import pytz
import tidalapi

from musync.entity.origin import Origin
from musync.entity.utils import normalize_str
from musync.common.entity.origin import Origin
from musync.common.entity.utils import normalize_str


@dataclass(frozen=True, slots=True)
Expand Down
2 changes: 1 addition & 1 deletion musync/entity/user.py → musync/common/entity/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import tidalapi as tidal

from musync.entity.origin import Origin
from musync.common.entity.origin import Origin


@dataclass(frozen=True, slots=True)
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion musync/session.py → musync/common/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import spotipy
import tidalapi

from musync.entity import Playlist, Track, User
from musync.common.entity import Playlist, Track, User


class Session(ABC):
Expand Down
4 changes: 2 additions & 2 deletions musync/sync_manager.py → musync/common/sync_manager.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import warnings

from musync.entity import Playlist, Track
from musync.error import MissingPrivilegesError, TrackNotFoundWarning
from musync.common.entity import Playlist, Track
from musync.common.error import MissingPrivilegesError, TrackNotFoundWarning
from musync.spotify import SpotifySession
from musync.tidal import TidalSession

Expand Down
4 changes: 2 additions & 2 deletions musync/spotify/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import spotipy
from dotenv import load_dotenv

from musync.entity import Artist, Origin, Playlist, Track, User
from musync.session import Session
from musync.common.entity import Artist, Origin, Playlist, Track, User
from musync.common import Session

load_dotenv()

Expand Down
12 changes: 5 additions & 7 deletions musync/tidal/session.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
from pathlib import Path
from typing import Iterable

import tidalapi

from musync.entity import Artist, Origin, Playlist, Track, User
from musync.error import IncompatibleEntityError, MissingPrivilegesError
from musync.session import Session

TIDAL_DIR = Path(__file__).parent.parent.parent.resolve()
from musync import ROOT_DIR
from musync.common.entity import Artist, Origin, Playlist, Track, User
from musync.common.error import IncompatibleEntityError, MissingPrivilegesError
from musync.common.session import Session


class TidalSession(Session):
_client: tidalapi.Session

def __init__(self) -> None:
session_file = TIDAL_DIR / "tidal-session-oauth.json"
session_file = ROOT_DIR / "tidal-session-oauth.json"
self._client = tidalapi.Session()
self._client.login_session_file(session_file)

Expand Down
4 changes: 2 additions & 2 deletions tests/integrationtests/spotify/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import pytest

from musync.entity import Origin, Playlist, Track, User
from musync.common.entity import Origin, Playlist, Track, User
from musync.spotify import SpotifySession
from tests.unittests.entity import DATA_DIR
from tests.unittests.common.entity import DATA_DIR


@pytest.fixture
Expand Down
4 changes: 2 additions & 2 deletions tests/integrationtests/test_sync_manager.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest

from musync.entity import Playlist, Track
from musync.common import SyncManager
from musync.common.entity import Playlist, Track
from musync.spotify import SpotifySession
from musync.sync_manager import SyncManager
from musync.tidal import TidalSession


Expand Down
4 changes: 2 additions & 2 deletions tests/integrationtests/tidal/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import pytest

from musync.entity import Origin, Playlist, Track, User
from musync.common.entity import Origin, Playlist, Track, User
from musync.tidal import TidalSession
from tests.unittests.entity import DATA_DIR
from tests.unittests.common.entity import DATA_DIR


@pytest.fixture
Expand Down
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import pytest

from musync.entity import Artist, Origin
from tests.unittests.entity import DATA_DIR
from musync.common.entity import Artist, Origin
from tests.unittests.common.entity import DATA_DIR


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import pytest

from musync.entity import Origin, Playlist
from tests.unittests.entity import DATA_DIR
from musync.common.entity import Origin, Playlist
from tests.unittests.common.entity import DATA_DIR


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import pytest
import pytz

from musync.entity import Origin, Track
from tests.unittests.entity import DATA_DIR
from musync.common.entity import Origin, Track
from tests.unittests.common.entity import DATA_DIR


@pytest.fixture(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import pytest

from musync.entity import Origin, User
from tests.unittests.entity import DATA_DIR
from musync.common.entity import Origin, User
from tests.unittests.common.entity import DATA_DIR


@pytest.fixture
Expand Down
6 changes: 6 additions & 0 deletions tests/unittests/test_root_dir.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from musync import ROOT_DIR


def test_root_dir():
musync_dir = ROOT_DIR / "musync"
assert musync_dir.exists()

0 comments on commit 3aeeb29

Please sign in to comment.