forked from TagStudioDev/TagStudio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
073d517
commit 24df756
Showing
12 changed files
with
219 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from pathlib import Path | ||
|
||
import structlog | ||
from PySide6.QtCore import QSettings | ||
from src.core.constants import TS_FOLDER_NAME | ||
from src.core.enums import SettingItems | ||
from src.core.library.alchemy.library import LibraryStatus | ||
|
||
logger = structlog.get_logger(__name__) | ||
|
||
|
||
class DriverMixin: | ||
settings: QSettings | ||
|
||
def evaluate_path(self, open_path: str | None) -> LibraryStatus: | ||
"""Check if the path of library is valid.""" | ||
library_path: Path | None = None | ||
if open_path: | ||
library_path = Path(open_path) | ||
if not library_path.exists(): | ||
logger.error("Path does not exist.", open_path=open_path) | ||
return LibraryStatus(success=False, message="Path does not exist.") | ||
elif self.settings.value( | ||
SettingItems.START_LOAD_LAST, defaultValue=True, type=bool | ||
) and self.settings.value(SettingItems.LAST_LIBRARY): | ||
library_path = Path(self.settings.value(SettingItems.LAST_LIBRARY)) | ||
Check failure on line 26 in tagstudio/src/core/driver.py GitHub Actions / mypy[mypy] tagstudio/src/core/driver.py#L26
Raw output
|
||
if library_path and not (library_path / TS_FOLDER_NAME).exists(): | ||
logger.error( | ||
"TagStudio folder does not exist.", | ||
library_path=library_path, | ||
ts_folder=TS_FOLDER_NAME, | ||
) | ||
self.settings.setValue(SettingItems.LAST_LIBRARY, "") | ||
# dont consider this a fatal error, just skip opening the library | ||
return LibraryStatus(success=True) | ||
|
||
if library_path: | ||
return LibraryStatus( | ||
success=True, | ||
library_path=library_path, | ||
) | ||
|
||
logger.info("No Library to open") | ||
return LibraryStatus(success=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from . import constants | ||
from .enums import ItemType | ||
from .library import Library | ||
from .models import Entry, Tag | ||
|
||
__all__ = ["Entry", "Library", "Tag", "ItemType"] | ||
__all__ = ["Entry", "Library", "Tag", "ItemType", "constants"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
LIBRARY_FILENAME: str = "ts_library.sqlite" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
LIBRARY_FILENAME: str = "ts_library.json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.