handlers
๐ค AI-Generated Content
This documentation was generated with AI assistance and is still being audited. Some, or potentially a lot, of this information may be inaccurate. Learn more.
flavor.psp.format_2025.handlers
¶
PSPF operation handlers bridging PSPF ops and Foundation archive tooling.
This module maps PSPF/2025 operation chains to provide.foundation.archive implementations, ensuring secure, tested, and consistent archive operations across the ecosystem.
Functions¶
apply_operations
¶
apply_operations(
data: bytes,
packed_ops: int,
compression_level: int = 6,
deterministic: bool = True,
) -> bytes
Apply PSPF operation chain using Foundation archive tools.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
bytes
|
Raw data to process |
required |
packed_ops
|
int
|
Packed PSPF operations as 64-bit integer |
required |
compression_level
|
int
|
Compression level (1-9) |
6
|
deterministic
|
bool
|
Create deterministic/reproducible output |
True
|
Returns:
| Type | Description |
|---|---|
bytes
|
Processed data after applying operation chain |
Raises:
| Type | Description |
|---|---|
ValueError
|
If operations are invalid or compression_level out of range |
ArchiveError
|
If operation execution fails |
Source code in flavor/psp/format_2025/handlers.py
create_tar_archive
¶
Create TAR archive from directory using Foundation's TarArchive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Path
|
Source directory or file |
required |
deterministic
|
bool
|
Create reproducible archive |
True
|
Returns:
| Type | Description |
|---|---|
bytes
|
TAR archive as bytes |
Raises:
| Type | Description |
|---|---|
ArchiveError
|
If archive creation fails |
FileNotFoundError
|
If source does not exist |
Source code in flavor/psp/format_2025/handlers.py
extract_archive
¶
extract_archive(
data: bytes,
dest: Path,
packed_ops: int,
limits: ArchiveLimits | None = None,
) -> Path
Extract archive data using Foundation's extractors with security limits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
bytes
|
Archive data (potentially compressed) |
required |
dest
|
Path
|
Destination directory |
required |
packed_ops
|
int
|
Packed PSPF operations to determine format |
required |
limits
|
ArchiveLimits | None
|
Optional extraction limits (uses DEFAULT_LIMITS if None) |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to extracted content |
Raises:
| Type | Description |
|---|---|
ArchiveError
|
If extraction fails or violates security limits |
ValueError
|
If operations are invalid |
Source code in flavor/psp/format_2025/handlers.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | |
map_operations
¶
Map PSPF operation codes to Foundation operations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pspf_ops
|
list[int]
|
List of PSPF operation codes |
required |
Returns:
| Type | Description |
|---|---|
list[ArchiveOperation]
|
List of Foundation ArchiveOperation enum values |
Raises:
| Type | Description |
|---|---|
ValueError
|
If operation code is unsupported |
Source code in flavor/psp/format_2025/handlers.py
reverse_operations
¶
Reverse PSPF operation chain for extraction using Foundation tools.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
bytes
|
Compressed/processed data |
required |
packed_ops
|
int
|
Packed PSPF operations as 64-bit integer |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
Decompressed/unprocessed data |
Raises:
| Type | Description |
|---|---|
ValueError
|
If operations are invalid |
ArchiveError
|
If operation reversal fails |