-
-
Notifications
You must be signed in to change notification settings - Fork 388
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 c0427d7
Showing
13 changed files
with
233 additions
and
93 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,40 @@ | ||
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(str(self.settings.value(SettingItems.LAST_LIBRARY))) | ||
if 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 | ||
library_path = None | ||
|
||
return LibraryStatus( | ||
success=True, | ||
library_path=library_path, | ||
) |
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
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.