everypixel-cli 0.1.0__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.
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
@@ -0,0 +1,5 @@
1
+ from .cli import app
2
+
3
+
4
+ if __name__ == "__main__":
5
+ app()
@@ -0,0 +1,10 @@
1
+ """CLI-independent application services for Everypixel operations."""
2
+
3
+ from .models import ExecutionOptions, OperationResult
4
+ from .services import ApplicationServices
5
+
6
+ __all__ = [
7
+ "ApplicationServices",
8
+ "ExecutionOptions",
9
+ "OperationResult",
10
+ ]
@@ -0,0 +1,59 @@
1
+ """Typed request and result models used independently from the CLI."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass, field
6
+ from pathlib import Path
7
+ from threading import Event
8
+ from typing import Any, Mapping
9
+
10
+
11
+ class OperationCancelled(Exception):
12
+ """Internal control flow raised when a caller abandons an operation."""
13
+
14
+
15
+ @dataclass(frozen=True)
16
+ class ExecutionOptions:
17
+ """Execution concerns shared by synchronous and asynchronous operations."""
18
+
19
+ wait: bool = False
20
+ download_directory: Path | None = None
21
+ timeout: float = 300.0
22
+ poll_interval: float = 2.0
23
+ cancel_event: Event | None = field(
24
+ default=None,
25
+ repr=False,
26
+ compare=False,
27
+ )
28
+
29
+ @property
30
+ def wait_for_result(self) -> bool:
31
+ """Downloads always require a completed task."""
32
+
33
+ return self.wait or self.download_directory is not None
34
+
35
+ def check_cancelled(self) -> None:
36
+ """Raise when the caller no longer wants this operation to continue."""
37
+
38
+ if self.cancel_event is not None and self.cancel_event.is_set():
39
+ raise OperationCancelled
40
+
41
+
42
+ @dataclass(frozen=True)
43
+ class OperationRequest:
44
+ """Transport-independent API operation request."""
45
+
46
+ endpoint: str
47
+ payload: Mapping[str, Any]
48
+ method: str = "POST"
49
+ execution: ExecutionOptions = ExecutionOptions()
50
+ fallback_extension: str = ".bin"
51
+
52
+
53
+ @dataclass(frozen=True)
54
+ class OperationResult:
55
+ """Application result that contains no presentation or HTTP objects."""
56
+
57
+ value: Any
58
+ task: Mapping[str, Any] | None = None
59
+ saved_files: tuple[Path, ...] = ()
@@ -0,0 +1,20 @@
1
+ """Convert application results into the public CLI/MCP-safe data contract."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Mapping
6
+ from typing import Any
7
+
8
+ from .models import OperationResult
9
+
10
+
11
+ def serialize_operation_result(result: OperationResult) -> Any:
12
+ """Preserve the existing CLI success payload shape."""
13
+
14
+ value = result.value
15
+ if isinstance(value, Mapping):
16
+ payload = dict(value)
17
+ if result.saved_files:
18
+ payload["downloaded"] = [str(path) for path in result.saved_files]
19
+ return payload
20
+ return value