handlers
flavor.psp.format_2025.handlers
¶
TODO: Add module docstring.
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
321 322 323 324 325 326 327 328 329 330 331 332 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 | |
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 |
Source code in flavor/psp/format_2025/handlers.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |