platform agnosticity
This commit is contained in:
@@ -1,14 +1,42 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import platform
|
||||
from pathlib import Path
|
||||
from typing import Any, ClassVar
|
||||
|
||||
import platformdirs
|
||||
import yaml
|
||||
from pydantic import Field, field_validator
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
APP_NAME = "ocr-pipeline"
|
||||
APP_AUTHOR = "aman"
|
||||
|
||||
|
||||
def _get_platform_ignore_patterns() -> list[str]:
|
||||
"""Get platform-specific ignore patterns for file watching."""
|
||||
patterns = [
|
||||
"*.tmp",
|
||||
"*.partial",
|
||||
"*.crdownload",
|
||||
"*.part",
|
||||
"~$*", # MS Office temp files
|
||||
"*.swp",
|
||||
"*.swo", # Vim swap files
|
||||
]
|
||||
system = platform.system().lower()
|
||||
if system == "darwin":
|
||||
patterns.extend([".DS_Store", "._*", ".Spotlight-V100", ".Trashes", ".fseventsd"])
|
||||
elif system == "windows":
|
||||
patterns.extend(["Thumbs.db", "desktop.ini", "*.lnk", "$RECYCLE.BIN"])
|
||||
else:
|
||||
# Linux/Unix
|
||||
patterns.extend([".directory", "*.swp", "*.swo", ".git"])
|
||||
return patterns
|
||||
|
||||
|
||||
class InputConfig(BaseSettings):
|
||||
paths: list[str] = Field(default_factory=lambda: ["~/Pictures"])
|
||||
patterns: list[str] = Field(
|
||||
@@ -132,7 +160,9 @@ class FrontmatterConfig(BaseSettings):
|
||||
|
||||
|
||||
class OutputConfig(BaseSettings):
|
||||
base_directory: str = "./data/ocr_output"
|
||||
base_directory: str = Field(
|
||||
default_factory=lambda: str(platformdirs.user_data_dir(APP_NAME, APP_AUTHOR))
|
||||
)
|
||||
format: str = "markdown"
|
||||
organize_by: str = "date_run" # date_run | source_dir | flat
|
||||
frontmatter: FrontmatterConfig = Field(default_factory=FrontmatterConfig)
|
||||
@@ -141,15 +171,10 @@ class OutputConfig(BaseSettings):
|
||||
class WatchConfig(BaseSettings):
|
||||
enabled: bool = True
|
||||
debounce_seconds: int = 5
|
||||
ignore_patterns: list[str] = Field(
|
||||
default_factory=lambda: [
|
||||
".DS_Store",
|
||||
"*.tmp",
|
||||
"*.partial",
|
||||
"*.crdownload",
|
||||
]
|
||||
ignore_patterns: list[str] = Field(default_factory=_get_platform_ignore_patterns)
|
||||
db_path: str = Field(
|
||||
default_factory=lambda: str(Path(platformdirs.user_data_dir(APP_NAME, APP_AUTHOR)) / "processed_files.db")
|
||||
)
|
||||
db_path: str = "./data/processed_files.db"
|
||||
poll_interval: float = 1.0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user