Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/mypy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
run: |
python -m pip install --upgrade uv
uv pip install --system -r requirements.txt
uv pip install --system mypy==1.11.2
uv pip install --system mypy==1.13.0
mkdir tagstudio/.mypy_cache

- uses: tsuyoshicho/action-mypy@v4
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ruff==0.6.4
pre-commit==3.7.0
pytest==8.2.0
Pyinstaller==6.6.0
mypy==1.11.2
mypy==1.13.0
syrupy==4.7.1
pytest-qt==4.4.0
pytest-cov==5.0.0
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ PySide6_Addons==6.7.1
PySide6_Essentials==6.7.1
PySide6==6.7.1
rawpy==0.21.0
SQLAlchemy==2.0.34
SQLAlchemy==2.0.36
structlog==24.4.0
typing_extensions>=3.10.0.0,<=4.11.0
ujson>=5.8.0,<=5.9.0
vtf2img==0.1.0
vtf2img==0.1.0
2 changes: 1 addition & 1 deletion tagstudio/src/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
VERSION_BRANCH: str = "EXPERIMENTAL" # Usually "" or "Pre-Release"

# The folder & file names where TagStudio keeps its data relative to a library.
TS_FOLDER_NAME: str = ".TagStudio"
BACKUP_FOLDER_NAME: str = "backups"
COLLAGE_FOLDER_NAME: str = "collages"
TS_FOLDER_NOINDEX: str = ".ts_noindex"

FONT_SAMPLE_TEXT: str = (
"""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!?@$%(){}[]"""
Expand Down
18 changes: 8 additions & 10 deletions tagstudio/src/core/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

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

Expand All @@ -14,27 +13,26 @@ class DriverMixin:

def evaluate_path(self, open_path: str | None) -> LibraryStatus:
"""Check if the path of library is valid."""
library_path: Path | None = None
storage_path: Path | None = None
if open_path:
library_path = Path(open_path)
if not library_path.exists():
storage_path = Path(open_path)
if not storage_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():
storage_path = Path(str(self.settings.value(SettingItems.LAST_LIBRARY)))
if not storage_path.exists():
logger.error(
"TagStudio folder does not exist.",
library_path=library_path,
ts_folder=TS_FOLDER_NAME,
storage_path=storage_path,
)
self.settings.setValue(SettingItems.LAST_LIBRARY, "")
# dont consider this a fatal error, just skip opening the library
library_path = None
storage_path = None

return LibraryStatus(
success=True,
library_path=library_path,
storage_path=storage_path,
)
13 changes: 4 additions & 9 deletions tagstudio/src/core/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
from uuid import uuid4


class SettingItems(str, enum.Enum):
class SettingItems(enum.StrEnum):
"""List of setting item names."""

START_LOAD_LAST = "start_load_last"
LAST_LIBRARY = "last_library"
LAST_LIBRARY = "last_storage"
LIBS_LIST = "libs_list"
WINDOW_SHOW_LIBS = "window_show_libs"
WINDOW_SHOW_DIRS = "window_show_dirs"
AUTOPLAY = "autoplay_videos"


Expand All @@ -25,12 +26,6 @@ class Theme(str, enum.Enum):
COLOR_DISABLED_BG = "#65440D12"


class OpenStatus(enum.IntEnum):
NOT_FOUND = 0
SUCCESS = 1
CORRUPTED = 2


class MacroID(enum.Enum):
AUTOFILL = "autofill"
SIDECAR = "sidecar"
Expand Down Expand Up @@ -64,4 +59,4 @@ class LibraryPrefs(DefaultEnum):
IS_EXCLUDE_LIST = True
EXTENSION_LIST: list[str] = [".json", ".xmp", ".aae"]
PAGE_SIZE: int = 500
DB_VERSION: int = 2
LIBRARY_NAME: str = "TS Library"
23 changes: 18 additions & 5 deletions tagstudio/src/core/library/alchemy/enums.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import enum
from dataclasses import dataclass
from dataclasses import dataclass, field
from pathlib import Path


Expand Down Expand Up @@ -50,17 +50,20 @@ class SearchMode(enum.IntEnum):
OR = 1


class ItemType(enum.Enum):
ENTRY = 0
COLLATION = 1
TAG_GROUP = 2
class ItemType(enum.IntEnum):
NONE = 0
ENTRY = 1
COLLATION = 2
TAG_GROUP = 3


@dataclass
class FilterState:
"""Represent a state of the Library grid view."""

# these should remain
include_folders: set[int] = field(default_factory=set)
exclude_folders: set[int] = field(default_factory=set)
page_index: int | None = None
page_size: int | None = None
search_mode: SearchMode = SearchMode.AND # TODO - actually implement this
Expand All @@ -81,6 +84,13 @@ class FilterState:
# a generic query to be parsed
query: str | None = None

def toggle_folder(self, folder_id: int):
# check if any filter is active and adjust that one, as they are disjunctive
if self.include_folders:
self.include_folders ^= {folder_id}
else:
self.exclude_folders ^= {folder_id}

def __post_init__(self):
# strip values automatically
if query := (self.query and self.query.strip()):
Expand Down Expand Up @@ -109,6 +119,9 @@ def __post_init__(self):
self.name = self.name and self.name.strip()
self.id = int(self.id) if str(self.id).isnumeric() else self.id

if self.include_folders and self.exclude_folders:
raise ValueError("Can't combine include_folders and exclude_folders.")

if self.page_index is None:
self.page_index = 0
if self.page_size is None:
Expand Down
Loading