beamerpkg 1.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
beamerpkg/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ """Portable Beamer presentation bundles."""
2
+
3
+ from __future__ import annotations
4
+
5
+ __version__ = "1.0.1"
beamerpkg/cli.py ADDED
@@ -0,0 +1,170 @@
1
+ """Command-line interface for beamerpkg."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import json
7
+ import shutil
8
+ import subprocess
9
+ import sys
10
+ import tempfile
11
+ from importlib.resources import files
12
+ from pathlib import Path
13
+
14
+ from .package import PackageError, extract_package, inspect_package, pack_package
15
+
16
+
17
+ def _build_parser() -> argparse.ArgumentParser:
18
+ parser = argparse.ArgumentParser(
19
+ prog="beamerpkg",
20
+ description="Bundle Beamer PDFs and external media into relocatable packages.",
21
+ )
22
+ subparsers = parser.add_subparsers(dest="command", required=True)
23
+
24
+ pack = subparsers.add_parser("pack", help="create a .beamerpkg container")
25
+ pack.add_argument("pdf", type=Path)
26
+ pack.add_argument("--root", type=Path, default=None, help="root for media paths")
27
+ pack.add_argument("--assets", type=Path, default=None, help="asset-list sidecar")
28
+ pack.add_argument("--output", "-o", type=Path, default=None)
29
+ pack.add_argument("--notes", type=Path, default=None, help="optional .pdfpc file")
30
+ pack.add_argument(
31
+ "--source-root",
32
+ type=Path,
33
+ default=None,
34
+ help="root used to preserve editable source paths (defaults to --root)",
35
+ )
36
+ pack.add_argument(
37
+ "--source",
38
+ type=Path,
39
+ action="append",
40
+ default=[],
41
+ help="editable source file or directory relative to --source-root; repeatable",
42
+ )
43
+
44
+ inspect = subparsers.add_parser("inspect", help="validate and describe a package")
45
+ inspect.add_argument("package", type=Path)
46
+ inspect.add_argument("--json", action="store_true", help="emit the manifest as JSON")
47
+
48
+ present = subparsers.add_parser("present", help="extract and launch with pdfpc")
49
+ present.add_argument("package", type=Path)
50
+ present.add_argument(
51
+ "--presenter",
52
+ default="pdfpc",
53
+ help="presenter executable (default: pdfpc)",
54
+ )
55
+
56
+ subparsers.add_parser(
57
+ "texdir",
58
+ help="print the directory containing beamerpkg.sty (for TEXINPUTS)",
59
+ )
60
+
61
+ return parser
62
+
63
+
64
+ def _cmd_pack(args: argparse.Namespace) -> int:
65
+ output = pack_package(
66
+ args.pdf,
67
+ root=args.root,
68
+ asset_list=args.assets,
69
+ output=args.output,
70
+ notes=args.notes,
71
+ source_root=args.source_root,
72
+ sources=tuple(args.source),
73
+ )
74
+ print(output)
75
+ return 0
76
+
77
+
78
+ def _cmd_inspect(args: argparse.Namespace) -> int:
79
+ report = inspect_package(args.package)
80
+ manifest = report["manifest"]
81
+ if args.json:
82
+ print(json.dumps(manifest, indent=2, sort_keys=True))
83
+ return 0
84
+
85
+ presentation = manifest["presentation"]
86
+ assets = manifest["assets"]
87
+ print(f"schema: {manifest['schema_version']}")
88
+ print(f"presentation: {presentation['path']} ({presentation['size']} bytes)")
89
+ print(f"assets: {len(assets)}")
90
+ if manifest.get("notes") is not None:
91
+ print(f"notes: {manifest['notes']['path']}")
92
+ source = manifest.get("source")
93
+ if source is not None:
94
+ print(f"source files: {len(source['files'])}")
95
+ for asset in assets:
96
+ print(f" OK {asset['path']} {asset['size']} bytes")
97
+ return 0
98
+
99
+
100
+ def _cmd_texdir(args: argparse.Namespace) -> int:
101
+ print(Path(str(files("beamerpkg") / "tex")).resolve())
102
+ return 0
103
+
104
+
105
+ def _cmd_present(args: argparse.Namespace) -> int:
106
+ package = args.package.resolve()
107
+ presenter = shutil.which(args.presenter)
108
+ if presenter is None:
109
+ raise PackageError(f"presenter executable not found: {args.presenter}")
110
+
111
+ with tempfile.TemporaryDirectory(prefix="beamerpkg-") as tmp:
112
+ destination = Path(tmp)
113
+ report = extract_package(package, destination)
114
+ presentation = report["manifest"]["presentation"]["path"]
115
+ completed = subprocess.run(
116
+ [presenter, *args.presenter_args, presentation],
117
+ cwd=destination,
118
+ check=False,
119
+ )
120
+ return completed.returncode
121
+
122
+
123
+ def _split_presenter_args(argv: list[str]) -> tuple[list[str], list[str]]:
124
+ """Split arguments after -- for transparent presenter passthrough."""
125
+
126
+ if "--" not in argv:
127
+ return argv, []
128
+
129
+ separator = argv.index("--")
130
+ cli_args = argv[:separator]
131
+ presenter_args = argv[separator + 1 :]
132
+ return cli_args, presenter_args
133
+
134
+
135
+ def main(argv: list[str] | None = None) -> int:
136
+ parser = _build_parser()
137
+ raw_argv = list(sys.argv[1:] if argv is None else argv)
138
+ cli_argv, explicit_presenter_args = _split_presenter_args(raw_argv)
139
+ args, unknown = parser.parse_known_args(cli_argv)
140
+
141
+ if args.command == "present":
142
+ if explicit_presenter_args and unknown:
143
+ parser.error(
144
+ "presenter arguments must be either after -- or passed directly, not both"
145
+ )
146
+ args.presenter_args = explicit_presenter_args or unknown
147
+ else:
148
+ if explicit_presenter_args:
149
+ parser.error("arguments after -- are only supported by the present command")
150
+ if unknown:
151
+ parser.error("unrecognized arguments: " + " ".join(unknown))
152
+ args.presenter_args = []
153
+ try:
154
+ if args.command == "pack":
155
+ return _cmd_pack(args)
156
+ if args.command == "inspect":
157
+ return _cmd_inspect(args)
158
+ if args.command == "present":
159
+ return _cmd_present(args)
160
+ if args.command == "texdir":
161
+ return _cmd_texdir(args)
162
+ except PackageError as exc:
163
+ print(f"beamerpkg: {exc}", file=sys.stderr)
164
+ return 2
165
+ parser.error(f"unknown command: {args.command}")
166
+ return 2
167
+
168
+
169
+ if __name__ == "__main__":
170
+ raise SystemExit(main())
beamerpkg/package.py ADDED
@@ -0,0 +1,418 @@
1
+ """Create, validate, and extract beamerpkg containers."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import hashlib
6
+ import json
7
+ import shutil
8
+ import stat
9
+ import tempfile
10
+ import zipfile
11
+ from pathlib import Path, PurePosixPath
12
+ from typing import Any
13
+
14
+ from .pdf_media import PdfMediaError, discover_pdf_media_references
15
+
16
+ SCHEMA_VERSION = 1
17
+ MANIFEST_NAME = "manifest.json"
18
+ ASSET_LIST_SUFFIX = ".beamerpkg-assets"
19
+ PACKAGE_SUFFIX = ".beamerpkg"
20
+ SOURCE_PREFIX = PurePosixPath("source")
21
+
22
+
23
+ class PackageError(ValueError):
24
+ """Raised when a package or requested asset is invalid."""
25
+
26
+
27
+ def _sha256(path: Path) -> str:
28
+ digest = hashlib.sha256()
29
+ with path.open("rb") as handle:
30
+ for chunk in iter(lambda: handle.read(1024 * 1024), b""):
31
+ digest.update(chunk)
32
+ return digest.hexdigest()
33
+
34
+
35
+ def _file_record(path: Path, archive_path: str) -> dict[str, Any]:
36
+ return {
37
+ "path": archive_path,
38
+ "size": path.stat().st_size,
39
+ "sha256": _sha256(path),
40
+ }
41
+
42
+
43
+ def _safe_relative_path(raw: str) -> PurePosixPath:
44
+ normalized = raw.strip().replace("\\", "/")
45
+ if not normalized:
46
+ raise PackageError("asset path is empty")
47
+ if "://" in normalized or normalized.lower().startswith("file:"):
48
+ raise PackageError(f"remote or URI media references are unsupported: {raw!r}")
49
+ path = PurePosixPath(normalized)
50
+ if path.is_absolute() or ".." in path.parts or "." in path.parts:
51
+ raise PackageError(f"asset path must be a clean relative path: {raw!r}")
52
+ if path.parts[0].endswith(":"):
53
+ raise PackageError(f"asset path must not use a drive prefix: {raw!r}")
54
+ return path
55
+
56
+
57
+ def read_asset_list(path: Path) -> tuple[PurePosixPath, ...]:
58
+ """Read one media path per line, ignoring blank lines and comments."""
59
+
60
+ if not path.is_file():
61
+ raise PackageError(f"asset list not found: {path}")
62
+
63
+ assets: list[PurePosixPath] = []
64
+ seen: set[str] = set()
65
+ for line_number, raw_line in enumerate(
66
+ path.read_text(encoding="utf-8").splitlines(), start=1
67
+ ):
68
+ stripped = raw_line.strip()
69
+ if not stripped or stripped.startswith("#"):
70
+ continue
71
+ try:
72
+ asset = _safe_relative_path(stripped)
73
+ except PackageError as exc:
74
+ raise PackageError(f"{path}:{line_number}: {exc}") from exc
75
+ key = asset.as_posix()
76
+ if key not in seen:
77
+ seen.add(key)
78
+ assets.append(asset)
79
+ return tuple(assets)
80
+
81
+
82
+ def _select_asset_paths(
83
+ pdf: Path,
84
+ asset_list: Path | None,
85
+ ) -> tuple[PurePosixPath, ...]:
86
+ """Choose explicit sidecar assets or discover them from PDF annotations."""
87
+
88
+ if asset_list is not None:
89
+ resolved_asset_list = asset_list.resolve()
90
+ asset_paths = read_asset_list(resolved_asset_list)
91
+ if not asset_paths:
92
+ raise PackageError(
93
+ f"asset list contains no media paths: {resolved_asset_list}"
94
+ )
95
+ return asset_paths
96
+
97
+ try:
98
+ discovered = tuple(
99
+ _safe_relative_path(reference)
100
+ for reference in discover_pdf_media_references(pdf)
101
+ )
102
+ except PdfMediaError as exc:
103
+ raise PackageError(str(exc)) from exc
104
+
105
+ if discovered:
106
+ return discovered
107
+
108
+ legacy_sidecar = pdf.with_suffix(ASSET_LIST_SUFFIX)
109
+ if legacy_sidecar.is_file():
110
+ asset_paths = read_asset_list(legacy_sidecar)
111
+ if asset_paths:
112
+ return asset_paths
113
+
114
+ raise PackageError(
115
+ "no supported external media references found in PDF and no "
116
+ f"legacy asset list found at {legacy_sidecar}"
117
+ )
118
+
119
+
120
+ def _collect_source_files(
121
+ source_root: Path,
122
+ source_inputs: tuple[Path, ...],
123
+ output: Path,
124
+ ) -> tuple[tuple[PurePosixPath, Path], ...]:
125
+ """Collect an explicit editable-source snapshot under the source/ prefix."""
126
+
127
+ if not source_inputs:
128
+ return ()
129
+
130
+ source_root = source_root.resolve()
131
+ if not source_root.is_dir():
132
+ raise PackageError(f"source root is not a directory: {source_root}")
133
+
134
+ output = output.resolve()
135
+ collected: dict[str, tuple[PurePosixPath, Path]] = {}
136
+
137
+ def add_file(candidate: Path) -> None:
138
+ if candidate.is_symlink():
139
+ raise PackageError(f"source symlinks are not supported: {candidate}")
140
+
141
+ resolved = candidate.resolve()
142
+ try:
143
+ relative = resolved.relative_to(source_root)
144
+ except ValueError as exc:
145
+ raise PackageError(f"source escapes source root: {candidate}") from exc
146
+
147
+ if resolved == output:
148
+ raise PackageError(
149
+ "source selection includes the output package; choose narrower "
150
+ f"--source inputs: {candidate}"
151
+ )
152
+
153
+ archive_path = SOURCE_PREFIX.joinpath(*relative.parts)
154
+ archive_name = archive_path.as_posix()
155
+ collected[archive_name] = (archive_path, resolved)
156
+
157
+ for raw_input in source_inputs:
158
+ if raw_input.is_absolute():
159
+ raise PackageError(f"source input must be relative: {raw_input}")
160
+
161
+ relative_input = _safe_relative_path(raw_input.as_posix())
162
+ candidate = source_root.joinpath(*relative_input.parts)
163
+
164
+ if not candidate.exists():
165
+ raise PackageError(f"source input not found: {raw_input}")
166
+ if candidate.is_symlink():
167
+ raise PackageError(f"source symlinks are not supported: {raw_input}")
168
+
169
+ if candidate.is_file():
170
+ add_file(candidate)
171
+ continue
172
+ if not candidate.is_dir():
173
+ raise PackageError(f"source input is not a file or directory: {raw_input}")
174
+
175
+ for child in sorted(candidate.rglob("*")):
176
+ if child.is_symlink():
177
+ raise PackageError(f"source symlinks are not supported: {child}")
178
+ if child.is_file():
179
+ add_file(child)
180
+
181
+ return tuple(collected[key] for key in sorted(collected))
182
+
183
+
184
+ def pack_package(
185
+ pdf: Path,
186
+ *,
187
+ root: Path | None = None,
188
+ asset_list: Path | None = None,
189
+ output: Path | None = None,
190
+ notes: Path | None = None,
191
+ source_root: Path | None = None,
192
+ sources: tuple[Path, ...] = (),
193
+ ) -> Path:
194
+ """Bundle a PDF and its declared media files into one relocatable ZIP container."""
195
+
196
+ pdf = pdf.resolve()
197
+ if not pdf.is_file():
198
+ raise PackageError(f"presentation PDF not found: {pdf}")
199
+ if pdf.suffix.lower() != ".pdf":
200
+ raise PackageError(f"presentation must be a PDF: {pdf}")
201
+
202
+ root = (root or pdf.parent).resolve()
203
+ if not root.is_dir():
204
+ raise PackageError(f"asset root is not a directory: {root}")
205
+
206
+ output = (output or pdf.with_suffix(PACKAGE_SUFFIX)).resolve()
207
+ asset_paths = _select_asset_paths(pdf, asset_list)
208
+ resolved_source_root = (source_root or root).resolve()
209
+ source_files = _collect_source_files(resolved_source_root, sources, output)
210
+
211
+ reserved = {MANIFEST_NAME, pdf.name}
212
+ resolved_assets: list[tuple[PurePosixPath, Path]] = []
213
+ for archive_path in asset_paths:
214
+ archive_name = archive_path.as_posix()
215
+ if archive_name in reserved:
216
+ raise PackageError(f"asset path collides with package metadata: {archive_name}")
217
+ source = root.joinpath(*archive_path.parts).resolve()
218
+ try:
219
+ source.relative_to(root)
220
+ except ValueError as exc:
221
+ raise PackageError(f"asset escapes root: {archive_name}") from exc
222
+ if not source.is_file():
223
+ raise PackageError(f"asset not found: {archive_name} (resolved to {source})")
224
+ resolved_assets.append((archive_path, source))
225
+
226
+ if notes is None:
227
+ candidate = pdf.with_suffix(".pdfpc")
228
+ notes = candidate if candidate.is_file() else None
229
+ elif not notes.is_file():
230
+ raise PackageError(f"notes file not found: {notes}")
231
+
232
+ presentation_record = _file_record(pdf, pdf.name)
233
+ asset_records = [
234
+ _file_record(source, archive_path.as_posix())
235
+ for archive_path, source in resolved_assets
236
+ ]
237
+ notes_record = _file_record(notes, notes.name) if notes is not None else None
238
+ source_records = [
239
+ _file_record(source, archive_path.as_posix())
240
+ for archive_path, source in source_files
241
+ ]
242
+ source_record = (
243
+ {"root": SOURCE_PREFIX.as_posix(), "files": source_records}
244
+ if source_records
245
+ else None
246
+ )
247
+
248
+ manifest = {
249
+ "schema_version": SCHEMA_VERSION,
250
+ "presentation": presentation_record,
251
+ "notes": notes_record,
252
+ "assets": asset_records,
253
+ "source": source_record,
254
+ }
255
+
256
+ output.parent.mkdir(parents=True, exist_ok=True)
257
+ with tempfile.NamedTemporaryFile(
258
+ prefix=f".{output.name}.", suffix=".tmp", dir=output.parent, delete=False
259
+ ) as handle:
260
+ temporary_output = Path(handle.name)
261
+
262
+ try:
263
+ # Media and PDFs are already compressed. ZIP_STORED keeps packaging fast and
264
+ # preserves media bytes exactly rather than spending CPU for negligible gain.
265
+ with zipfile.ZipFile(temporary_output, "w", compression=zipfile.ZIP_STORED) as zf:
266
+ zf.writestr(
267
+ MANIFEST_NAME,
268
+ json.dumps(manifest, indent=2, sort_keys=True) + "\n",
269
+ )
270
+ zf.write(pdf, arcname=pdf.name)
271
+ if notes is not None:
272
+ zf.write(notes, arcname=notes.name)
273
+ for archive_path, source in resolved_assets:
274
+ zf.write(source, arcname=archive_path.as_posix())
275
+ for archive_path, source in source_files:
276
+ zf.write(source, arcname=archive_path.as_posix())
277
+ temporary_output.replace(output)
278
+ except Exception:
279
+ temporary_output.unlink(missing_ok=True)
280
+ raise
281
+
282
+ return output
283
+
284
+
285
+ def _load_manifest(zf: zipfile.ZipFile) -> dict[str, Any]:
286
+ try:
287
+ raw = zf.read(MANIFEST_NAME)
288
+ except KeyError as exc:
289
+ raise PackageError(f"package is missing {MANIFEST_NAME}") from exc
290
+ try:
291
+ manifest = json.loads(raw.decode("utf-8"))
292
+ except (UnicodeDecodeError, json.JSONDecodeError) as exc:
293
+ raise PackageError("manifest.json is not valid UTF-8 JSON") from exc
294
+ if not isinstance(manifest, dict):
295
+ raise PackageError("manifest.json must contain a JSON object")
296
+ if manifest.get("schema_version") != SCHEMA_VERSION:
297
+ raise PackageError(
298
+ "unsupported schema_version: " f"{manifest.get('schema_version')!r}"
299
+ )
300
+ return manifest
301
+
302
+
303
+ def _manifest_records(manifest: dict[str, Any]) -> tuple[dict[str, Any], ...]:
304
+ presentation = manifest.get("presentation")
305
+ if not isinstance(presentation, dict):
306
+ raise PackageError("manifest.presentation must be an object")
307
+ assets = manifest.get("assets")
308
+ if not isinstance(assets, list):
309
+ raise PackageError("manifest.assets must be a list")
310
+ notes = manifest.get("notes")
311
+ source = manifest.get("source")
312
+
313
+ records: list[dict[str, Any]] = [presentation]
314
+ if notes is not None:
315
+ if not isinstance(notes, dict):
316
+ raise PackageError("manifest.notes must be an object or null")
317
+ records.append(notes)
318
+ for asset in assets:
319
+ if not isinstance(asset, dict):
320
+ raise PackageError("manifest asset entries must be objects")
321
+ records.append(asset)
322
+
323
+ if source is not None:
324
+ if not isinstance(source, dict):
325
+ raise PackageError("manifest.source must be an object or null")
326
+ if source.get("root") != SOURCE_PREFIX.as_posix():
327
+ raise PackageError("manifest.source.root must be 'source'")
328
+ source_files = source.get("files")
329
+ if not isinstance(source_files, list):
330
+ raise PackageError("manifest.source.files must be a list")
331
+ for source_file in source_files:
332
+ if not isinstance(source_file, dict):
333
+ raise PackageError("manifest source entries must be objects")
334
+ source_path = source_file.get("path")
335
+ if not isinstance(source_path, str):
336
+ raise PackageError("manifest source entry is missing string path")
337
+ safe_source_path = _safe_relative_path(source_path)
338
+ if not safe_source_path.parts or safe_source_path.parts[0] != "source":
339
+ raise PackageError("manifest source paths must be under source/")
340
+ records.append(source_file)
341
+
342
+ return tuple(records)
343
+
344
+
345
+ def inspect_package(package: Path) -> dict[str, Any]:
346
+ """Validate a package and return its manifest plus an ``ok`` marker."""
347
+
348
+ package = package.resolve()
349
+ if not package.is_file():
350
+ raise PackageError(f"package not found: {package}")
351
+
352
+ try:
353
+ with zipfile.ZipFile(package, "r") as zf:
354
+ manifest = _load_manifest(zf)
355
+ names = zf.namelist()
356
+ if len(names) != len(set(names)):
357
+ raise PackageError("package contains duplicate ZIP member names")
358
+
359
+ records = _manifest_records(manifest)
360
+ expected = {MANIFEST_NAME}
361
+ for record in records:
362
+ archive_path = record.get("path")
363
+ if not isinstance(archive_path, str):
364
+ raise PackageError("manifest file record is missing string path")
365
+ safe_path = _safe_relative_path(archive_path).as_posix()
366
+ expected.add(safe_path)
367
+ try:
368
+ payload = zf.read(safe_path)
369
+ except KeyError as exc:
370
+ raise PackageError(f"package is missing declared file: {safe_path}") from exc
371
+ if record.get("size") != len(payload):
372
+ raise PackageError(f"size mismatch for {safe_path}")
373
+ digest = hashlib.sha256(payload).hexdigest()
374
+ if record.get("sha256") != digest:
375
+ raise PackageError(f"SHA-256 mismatch for {safe_path}")
376
+
377
+ unexpected = set(names) - expected
378
+ if unexpected:
379
+ raise PackageError(
380
+ "package contains undeclared files: " + ", ".join(sorted(unexpected))
381
+ )
382
+
383
+ presentation_path = manifest["presentation"]["path"]
384
+ if not zf.read(presentation_path).startswith(b"%PDF-"):
385
+ raise PackageError("declared presentation does not look like a PDF")
386
+ except zipfile.BadZipFile as exc:
387
+ raise PackageError(f"not a valid ZIP package: {package}") from exc
388
+
389
+ return {"ok": True, "manifest": manifest}
390
+
391
+
392
+ def _is_zip_symlink(info: zipfile.ZipInfo) -> bool:
393
+ mode = info.external_attr >> 16
394
+ return stat.S_ISLNK(mode)
395
+
396
+
397
+ def extract_package(package: Path, destination: Path) -> dict[str, Any]:
398
+ """Validate and safely extract a package into an existing directory."""
399
+
400
+ report = inspect_package(package)
401
+ destination = destination.resolve()
402
+ destination.mkdir(parents=True, exist_ok=True)
403
+
404
+ with zipfile.ZipFile(package, "r") as zf:
405
+ for info in zf.infolist():
406
+ if _is_zip_symlink(info):
407
+ raise PackageError(f"ZIP symlink entries are not allowed: {info.filename}")
408
+ archive_path = _safe_relative_path(info.filename)
409
+ target = destination.joinpath(*archive_path.parts).resolve()
410
+ try:
411
+ target.relative_to(destination)
412
+ except ValueError as exc:
413
+ raise PackageError(f"ZIP member escapes destination: {info.filename}") from exc
414
+ target.parent.mkdir(parents=True, exist_ok=True)
415
+ with zf.open(info, "r") as source, target.open("wb") as sink:
416
+ shutil.copyfileobj(source, sink)
417
+
418
+ return report
beamerpkg/pdf_media.py ADDED
@@ -0,0 +1,94 @@
1
+ """Discover external media references from PDF annotations."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+ from typing import Any
7
+
8
+ from pypdf import PdfReader
9
+
10
+
11
+ class PdfMediaError(ValueError):
12
+ """Raised when PDF media annotations cannot be inspected."""
13
+
14
+
15
+ def _resolve(value: Any) -> Any:
16
+ get_object = getattr(value, "get_object", None)
17
+ return get_object() if callable(get_object) else value
18
+
19
+
20
+ def _file_spec_text(value: Any) -> str | None:
21
+ value = _resolve(value)
22
+ if isinstance(value, str):
23
+ return value
24
+ if isinstance(value, dict):
25
+ for key in ("/UF", "/F"):
26
+ candidate = _resolve(value.get(key))
27
+ if isinstance(candidate, str):
28
+ return candidate
29
+ return None
30
+
31
+
32
+ def _pdfpc_launch_media_reference(raw: str) -> str | None:
33
+ """Return a media path from a recognized pdfpc launch-link target."""
34
+
35
+ reference, separator, query = raw.strip().partition("?")
36
+ if not separator:
37
+ return None
38
+
39
+ option_names = {
40
+ part.split("=", 1)[0].strip().lower()
41
+ for part in query.split("&")
42
+ if part.strip()
43
+ }
44
+ if not option_names.intersection({"autostart", "loop", "start", "stop"}):
45
+ return None
46
+ return reference
47
+
48
+
49
+ def discover_pdf_media_references(pdf: Path) -> tuple[str, ...]:
50
+ """Return external media paths referenced by supported PDF annotations.
51
+
52
+ Supports standard /Movie annotations emitted by Beamer's multimedia package
53
+ and pdfpc-style /Launch links carrying recognized media options such as
54
+ autostart or loop.
55
+ """
56
+
57
+ try:
58
+ reader = PdfReader(str(pdf), strict=False)
59
+ except Exception as exc:
60
+ raise PdfMediaError(f"failed to read PDF annotations from {pdf}: {exc}") from exc
61
+
62
+ references: list[str] = []
63
+ seen: set[str] = set()
64
+
65
+ for page in reader.pages:
66
+ annotations = _resolve(page.get("/Annots")) or []
67
+ for annotation_ref in annotations:
68
+ annotation = _resolve(annotation_ref)
69
+ if not isinstance(annotation, dict):
70
+ continue
71
+
72
+ reference: str | None = None
73
+ subtype = annotation.get("/Subtype")
74
+
75
+ if subtype == "/Movie":
76
+ movie = _resolve(annotation.get("/Movie"))
77
+ if isinstance(movie, dict):
78
+ reference = _file_spec_text(movie.get("/F"))
79
+ elif subtype == "/Link":
80
+ action = _resolve(annotation.get("/A"))
81
+ if isinstance(action, dict) and action.get("/S") == "/Launch":
82
+ raw = _file_spec_text(action.get("/F"))
83
+ if raw is not None:
84
+ reference = _pdfpc_launch_media_reference(raw)
85
+
86
+ if reference is None:
87
+ continue
88
+
89
+ key = reference.strip()
90
+ if key and key not in seen:
91
+ seen.add(key)
92
+ references.append(key)
93
+
94
+ return tuple(references)
@@ -0,0 +1,29 @@
1
+ \NeedsTeXFormat{LaTeX2e}
2
+ \ProvidesPackage{beamerpkg}[2026/09/30 v0.2 Record Beamer movie assets]
3
+
4
+ \RequirePackage{multimedia}
5
+ \RequirePackage{hyperref}
6
+
7
+ \newwrite\beamerpkgassetfile
8
+ \immediate\openout\beamerpkgassetfile=\jobname.beamerpkg-assets
9
+ \AtEndDocument{\immediate\closeout\beamerpkgassetfile}
10
+
11
+ \newcommand{\beamerpkgrecordasset}[1]{%
12
+ \begingroup
13
+ \edef\beamerpkgassetpath{\detokenize{#1}}%
14
+ \immediate\write\beamerpkgassetfile{\beamerpkgassetpath}%
15
+ \endgroup
16
+ }
17
+
18
+ % Portable standard Beamer movie annotation. In pdfpc this is click-to-play.
19
+ \newcommand{\pkgmovie}[3][]{%
20
+ \beamerpkgrecordasset{#3}%
21
+ \movie[#1]{#2}{#3}%
22
+ }
23
+
24
+ % pdfpc-specific launch-link movie. Options follow pdfpc's run: URL syntax,
25
+ % e.g. [autostart&loop]. Keep this separate from the portable \movie path.
26
+ \newcommand{\pkgpdfpcmovie}[3][autostart]{%
27
+ \beamerpkgrecordasset{#3}%
28
+ \href{run:#3?#1}{#2}%
29
+ }
@@ -0,0 +1,281 @@
1
+ Metadata-Version: 2.4
2
+ Name: beamerpkg
3
+ Version: 1.0.1
4
+ Summary: Portable Beamer/PDF presentation bundles with external media assets
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Author: Uli Kerzel
8
+ Requires-Python: >=3.11,<4.0
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Classifier: Programming Language :: Python :: 3.15
15
+ Requires-Dist: pypdf (>=5.0,<7.0)
16
+ Project-URL: Homepage, https://github.com/ukerzel/beamerpkg
17
+ Project-URL: Issues, https://github.com/ukerzel/beamerpkg/issues
18
+ Project-URL: Repository, https://github.com/ukerzel/beamerpkg
19
+ Description-Content-Type: text/markdown
20
+
21
+ # beamerpkg
22
+
23
+ `beamerpkg` makes multimedia Beamer presentations portable without replacing
24
+ Beamer's rendering model.
25
+
26
+ ```text
27
+ Beamer -> ordinary PDF + external MP4 files -> one relocatable .beamerpkg
28
+ |
29
+ v
30
+ unpack temporarily + pdfpc
31
+ ```
32
+
33
+ Equations, TikZ, columns, backgrounds, arrows, Beamer overlays, fonts, and all
34
+ other slide layout remain PDF. The package layer only restores external media at
35
+ the relative paths already referenced by the PDF.
36
+
37
+ ## Status
38
+
39
+ The container/path MVP was validated on **2026-09-30** with pdfpc under WSL/WSLg:
40
+ the packaged PDF rendered normally and the packaged H.264 video played in the
41
+ TeX-defined rectangle. The full-resolution autoplay demo also works.
42
+
43
+ Version 0.2 adds **wrapperless media discovery**: for standard Beamer
44
+ `multimedia/\movie` documents, `beamerpkg pack` reads the PDF annotation and
45
+ collects the referenced local media automatically. A `.beamerpkg-assets`
46
+ sidecar is no longer required for normal use.
47
+
48
+ ## Package format
49
+
50
+ A `.beamerpkg` is an ordinary ZIP archive:
51
+
52
+ ```text
53
+ talk.beamerpkg
54
+ ├── manifest.json
55
+ ├── talk.pdf
56
+ ├── talk.pdfpc # optional
57
+ ├── media/
58
+ │ └── simulation.mp4
59
+ └── source/ # optional editable source snapshot
60
+ ├── talk.tex
61
+ ├── figures/
62
+ └── references.bib
63
+ ```
64
+
65
+ The manifest contains SHA-256 hashes and byte sizes. Runtime media are stored at
66
+ exactly the same relative paths used by Beamer. Optional editable sources live
67
+ under `source/` and are recorded separately in the manifest.
68
+
69
+ ## Install for development
70
+
71
+ Requires Python 3.11+ and Poetry.
72
+
73
+ ```bash
74
+ poetry install
75
+ ```
76
+
77
+ The only runtime Python dependency is `pypdf`, used to inspect PDF annotations.
78
+
79
+ ## Optional editable source payload
80
+
81
+ A presentation package can also carry the LaTeX source and authoring assets so
82
+ the recipient can modify and rebuild the presentation without editing the PDF.
83
+
84
+ Source inclusion is explicit. Pass a source root and repeat `--source` for the
85
+ files or directories to preserve:
86
+
87
+ ```bash
88
+ poetry run beamerpkg pack build/talk.pdf \
89
+ --root build \
90
+ --source-root . \
91
+ --source talk.tex \
92
+ --source figures \
93
+ --source references.bib
94
+ ```
95
+
96
+ Those files are stored with their relative structure under `source/`:
97
+
98
+ ```text
99
+ source/
100
+ ├── talk.tex
101
+ ├── figures/
102
+ │ └── plot.png
103
+ └── references.bib
104
+ ```
105
+
106
+ Because `.beamerpkg` is an ordinary ZIP archive, a recipient can unpack it,
107
+ edit the source tree, and rebuild with their normal LaTeX toolchain. Runtime
108
+ presentation files remain separate, so including sources never changes pdfpc
109
+ playback.
110
+
111
+ The source snapshot is deliberately opt-in and explicit: beamerpkg does not
112
+ guess which files constitute a reproducible authoring project. Directories are
113
+ included recursively; source paths must remain within `--source-root`, and
114
+ symlinks are rejected.
115
+
116
+ An asset needed both by the runtime presentation and by the editable source tree
117
+ may be stored twice. This keeps both trees self-contained and avoids symlink or
118
+ viewer-specific deduplication behavior in the package format.
119
+
120
+ ## Standard Beamer: no Beamerpkg LaTeX helper required
121
+
122
+ The wrapperless standard-Beamer route is **click-to-start in pdfpc**. This is
123
+ the expected behavior of the normal `\movie` annotation path; autoplay is a
124
+ separate pdfpc-specific feature described below.
125
+
126
+ Write an ordinary Beamer movie:
127
+
128
+ ```latex
129
+ \usepackage{multimedia}
130
+
131
+ \movie[loop,showcontrols]
132
+ {\includegraphics[width=\linewidth]{media/poster.png}}
133
+ {media/video.mp4}
134
+ ```
135
+
136
+ Compile it normally, then package it:
137
+
138
+ ```bash
139
+ poetry run beamerpkg pack talk.pdf --root .
140
+ ```
141
+
142
+ The packer discovers the external `/Movie` file reference from the PDF,
143
+ validates that it is a safe local relative path, and includes it at the same path
144
+ inside the container.
145
+
146
+ An explicit sidecar remains available as a compatibility/fallback route:
147
+
148
+ ```bash
149
+ poetry run beamerpkg pack talk.pdf --root . --assets talk.beamerpkg-assets
150
+ ```
151
+
152
+ ## pdfpc autoplay
153
+
154
+ Autoplay is viewer-specific rather than part of the container format. For pdfpc,
155
+ the bundled LaTeX helper `beamerpkg.sty` provides:
156
+
157
+ ```latex
158
+ \pkgpdfpcmovie[autostart&loop]
159
+ {\includegraphics[width=\linewidth]{media/poster.png}}
160
+ {media/video.mp4}
161
+ ```
162
+
163
+ The helper ships with the Python package. `beamerpkg texdir` prints its
164
+ directory, so LaTeX can find it without copying files:
165
+
166
+ ```bash
167
+ TEXINPUTS="$(beamerpkg texdir)//:" pdflatex talk.tex
168
+ ```
169
+
170
+ In a repository checkout it lives at `src/beamerpkg/tex/beamerpkg.sty`.
171
+
172
+ This emits pdfpc's `run:` launch-link mechanism. The packer also recognizes
173
+ these pdfpc media launch links and strips their query options when collecting
174
+ the underlying media file.
175
+
176
+ ## pdfpc speaker notes and settings
177
+
178
+ If a same-name pdfpc sidecar exists beside the PDF, it is included automatically:
179
+
180
+ ```text
181
+ talk.pdf
182
+ talk.pdfpc
183
+ ```
184
+
185
+ ```bash
186
+ poetry run beamerpkg pack talk.pdf --root .
187
+ ```
188
+
189
+ The resulting package records `talk.pdfpc` separately as `notes` in the
190
+ manifest and restores it beside `talk.pdf` before launching pdfpc. This keeps
191
+ speaker notes and other pdfpc presentation metadata portable without putting
192
+ them into the PDF itself.
193
+
194
+ The repository demo contains `examples/demo.pdfpc` with a visible speaker note
195
+ on the first page so this behavior can be checked in presenter view.
196
+
197
+ ## Inspect and present
198
+
199
+ ```bash
200
+ poetry run beamerpkg inspect talk.beamerpkg
201
+ poetry run beamerpkg present talk.beamerpkg
202
+ ```
203
+
204
+ `beamerpkg present` validates the archive, extracts it to a temporary directory
205
+ while preserving all relative paths, launches `pdfpc` from that directory, and
206
+ keeps the directory alive until the presenter exits. Arguments after `--` are
207
+ forwarded verbatim to the presenter before the PDF filename.
208
+
209
+ For a single physical monitor, keep both pdfpc windows available and switch
210
+ between presenter and audience views with the desktop window switcher.
211
+
212
+ When invoking through Poetry, pass pdfpc options directly after the package:
213
+
214
+ ```bash
215
+ poetry run beamerpkg present talk.beamerpkg -w both
216
+ ```
217
+
218
+ Poetry may consume a literal `--` separator before the Beamerpkg CLI sees it.
219
+ When invoking an installed `beamerpkg` executable directly, the explicit
220
+ separator form is also supported:
221
+
222
+ ```bash
223
+ beamerpkg present talk.beamerpkg -- -w both
224
+ ```
225
+
226
+ This is intentionally transparent passthrough rather than a Beamerpkg-specific
227
+ single-monitor mode. Other pdfpc options work the same way.
228
+
229
+ ## Demo
230
+
231
+ The demo uses the full repository assets, a pdfpc metadata sidecar, and an
232
+ editable source snapshot:
233
+
234
+ - `examples/media/gemini_generated_video_b2693757.mp4`
235
+ - `examples/media/video-poster_big.png`
236
+ - `examples/demo.pdfpc` (speaker notes / pdfpc metadata)
237
+ - `source/examples/demo.tex`
238
+ - `source/examples/media/...`
239
+ - `source/src/beamerpkg/tex/beamerpkg.sty`
240
+
241
+ The mixed demo also contains two lightweight Beamer/PDF motion examples before
242
+ the video slides:
243
+
244
+ - a short `\transfade[duration=0.2]` page transition;
245
+ - a three-state manual overlay sequence that progressively builds
246
+ `Input -> Model -> Result` and remains fully reversible with the arrow keys.
247
+
248
+ Both are encoded in the PDF itself; `beamerpkg` does not need to discover or
249
+ package anything special for them. The overlay example deliberately avoids
250
+ `\transduration`: timed PDF pages restart their timer when revisited, which
251
+ makes backward navigation jump forward again.
252
+
253
+ Build both the mixed autoplay demo and a pure stock-Beamer wrapperless example:
254
+
255
+ ```bash
256
+ git pull --rebase
257
+ poetry install
258
+ ./examples/build_demo.sh
259
+
260
+ poetry run beamerpkg present examples/demo.beamerpkg
261
+ poetry run beamerpkg present examples/wrapperless.beamerpkg
262
+ ```
263
+
264
+ `examples/demo.tex` also embeds speaker notes and a 10-minute countdown via
265
+ the standard `pdfpc` LaTeX package, so they travel inside the PDF itself. The
266
+ title page deliberately has no embedded note: pdfpc lets an embedded note
267
+ replace the sidecar note for the same page, so page 1 keeps showing the
268
+ `examples/demo.pdfpc` note and both routes can be checked in presenter view.
269
+
270
+ `examples/wrapperless.tex` imports only Beamer's `multimedia` package. It is
271
+ the integration proof that packaging no longer depends on a Beamerpkg-specific
272
+ LaTeX command. In pdfpc this wrapperless example is click-to-start.
273
+
274
+ The mixed `examples/demo.tex` intentionally contains two video slides: one
275
+ standard wrapperless `\movie` slide that is click-to-start, followed by one
276
+ pdfpc-specific `\pkgpdfpcmovie[autostart&loop]` slide that starts
277
+ automatically.
278
+
279
+ See [`docs/MVP.md`](https://github.com/ukerzel/beamerpkg/blob/main/docs/MVP.md) for the original acceptance test and
280
+ [`docs/NEXT_STEPS.md`](https://github.com/ukerzel/beamerpkg/blob/main/docs/NEXT_STEPS.md) for the remaining work.
281
+
@@ -0,0 +1,10 @@
1
+ beamerpkg/__init__.py,sha256=b6_q-0y4c9sS_OZcc_gi0pBgQ30BRSWEmBmM6BkyXKU,103
2
+ beamerpkg/cli.py,sha256=xNcjI5BGlvHdiUQFfjU9pL-9EvWHasrDmKIJ7xdPDK0,5638
3
+ beamerpkg/package.py,sha256=0NbpPhyAMWU1Lbezkvuzkmr7efTZQWscyfLkiND6ezg,15574
4
+ beamerpkg/pdf_media.py,sha256=KmsLBWDBuI_Nyy3DSq1kWxk358xnFG_nyQYlgMjdXxw,2953
5
+ beamerpkg/tex/beamerpkg.sty,sha256=UyLBia8xMhPhVL6FbJAJOQprUz9juSUnPnzDmsDlCJo,887
6
+ beamerpkg-1.0.1.dist-info/METADATA,sha256=LRQba46dNzX-GHbuNR3RkOhuq4TcPYtHjt0fFthllZw,9585
7
+ beamerpkg-1.0.1.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
8
+ beamerpkg-1.0.1.dist-info/entry_points.txt,sha256=pD-TX3Jbw0KzyYom8F4ZCe3htHt1jixxL9XQ1kvUjXM,48
9
+ beamerpkg-1.0.1.dist-info/licenses/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
10
+ beamerpkg-1.0.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 2.5.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ beamerpkg=beamerpkg.cli:main
3
+
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS