Skip to content

Commit f595dd0

Browse files
committed
Fail on misconfigured list of documents
1 parent d8b824b commit f595dd0

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/pdfbaker/baker.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from . import errors
1010
from .document import PDFBakerDocument
11+
from .errors import PDFBakeError
1112

1213
__all__ = ["PDFBaker"]
1314

@@ -99,11 +100,21 @@ def _load_config(self, config_file: Path) -> dict[str, Any]:
99100
raise errors.PDFBakeError(f"Failed to load config file: {exc}") from exc
100101

101102
def _get_document_paths(
102-
self, documents: list[dict[str, str] | str]
103+
self, documents: list[dict[str, str] | str] | None
103104
) -> dict[str, Path]:
104-
"""Resolve document paths to absolute paths."""
105-
document_paths: dict[str, Path] = {}
105+
"""Resolve document paths to absolute paths.
106+
107+
Args:
108+
documents: List of document names or dicts with name/path,
109+
or None if no documents specified
106110
111+
Returns:
112+
Dictionary mapping document names to their paths
113+
"""
114+
if not documents:
115+
return {}
116+
117+
document_paths: dict[str, Path] = {}
107118
for doc_name in documents:
108119
if isinstance(doc_name, dict):
109120
# Format: {"name": "doc_name", "path": "/absolute/path/to/doc"}
@@ -113,6 +124,8 @@ def _get_document_paths(
113124
# Default: document in subdirectory with same name as doc_name
114125
doc_path = self.base_dir / doc_name
115126

127+
if not doc_path.exists():
128+
raise PDFBakeError(f"Document directory not found: {doc_path}")
116129
document_paths[doc_name] = doc_path.resolve()
117130

118131
return document_paths

0 commit comments

Comments
 (0)