Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove extensions submodule #964

Merged
merged 2 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed cozy/extensions/__init__.py
Empty file.
2 changes: 0 additions & 2 deletions cozy/extensions/is_same_book.py

This file was deleted.

5 changes: 0 additions & 5 deletions cozy/extensions/set.py

This file was deleted.

5 changes: 4 additions & 1 deletion cozy/model/database_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
from cozy.db.file import File
from cozy.db.track import Track
from cozy.db.track_to_file import TrackToFile
from cozy.extensions.is_same_book import is_same_book
from cozy.media.media_file import MediaFile
from cozy.model.book import Book, BookIsEmpty

log = logging.getLogger("db_importer")


def is_same_book(book_a: str, book_b: str) -> bool:
return book_a.casefold() == book_b.casefold()


class TrackInsertRequest:
track_data: object
file: File
Expand Down
6 changes: 5 additions & 1 deletion cozy/model/library.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import re
from typing import Optional

import inject
Expand All @@ -8,14 +9,17 @@
from cozy.architecture.profiler import timing
from cozy.db.book import Book as BookModel
from cozy.db.file import File
from cozy.extensions.set import split_strings_to_set
from cozy.model.book import Book, BookIsEmpty
from cozy.model.chapter import Chapter
from cozy.model.settings import Settings

log = logging.getLogger("ui")


def split_strings_to_set(set_to_split: set[str]) -> set[str]:
return {entry.strip() for item in set_to_split for entry in re.split(",|;|/|&", item)}


class Library(EventSender):
_db = cache = inject.attr(SqliteDatabase)
_settings: Settings = inject.attr(Settings)
Expand Down
3 changes: 1 addition & 2 deletions cozy/view_model/library_view_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
from cozy.architecture.event_sender import EventSender
from cozy.architecture.observable import Observable
from cozy.control.filesystem_monitor import FilesystemMonitor
from cozy.extensions.set import split_strings_to_set
from cozy.media.importer import Importer, ScanStatus
from cozy.media.player import Player
from cozy.model.book import Book
from cozy.model.library import Library
from cozy.model.library import Library, split_strings_to_set
from cozy.open_view import OpenView
from cozy.report import reporter
from cozy.ui.import_failed_dialog import ImportFailedDialog
Expand Down
3 changes: 1 addition & 2 deletions cozy/view_model/search_view_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
from cozy.architecture.event_sender import EventSender
from cozy.architecture.observable import Observable
from cozy.control.filesystem_monitor import FilesystemMonitor
from cozy.extensions.set import split_strings_to_set
from cozy.model.book import Book
from cozy.model.library import Library
from cozy.model.library import Library, split_strings_to_set
from cozy.open_view import OpenView


Expand Down
Empty file removed test/cozy/extensions/__init__.py
Empty file.
33 changes: 0 additions & 33 deletions test/cozy/extensions/test_is_same_book.py

This file was deleted.

5 changes: 2 additions & 3 deletions test/cozy/model/test_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from peewee import SqliteDatabase

from cozy.application_settings import ApplicationSettings
from cozy.extensions.set import split_strings_to_set
from cozy.model.settings import Settings


Expand All @@ -28,7 +27,7 @@ def test_library_contains_books():


def test_authors_contains_every_author_from_db():
from cozy.model.library import Library
from cozy.model.library import Library, split_strings_to_set
from cozy.db.book import Book

library = Library()
Expand All @@ -42,7 +41,7 @@ def test_authors_contains_every_author_from_db():


def test_readers_contains_every_reader_from_db():
from cozy.model.library import Library
from cozy.model.library import Library, split_strings_to_set
from cozy.db.book import Book

library = Library()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from cozy.extensions.set import split_strings_to_set
from cozy.model.library import split_strings_to_set


def test_split_strings_does_nothing_for_non_seperated_element():
Expand Down