Base
provide.foundation.archive.base
¶
TODO: Add module docstring.
Classes¶
ArchiveError
¶
ArchiveError(
message: str,
*,
code: str | None = None,
context: dict[str, Any] | None = None,
cause: Exception | None = None,
**extra_context: Any
)
Bases: FoundationError
Base exception for archive-related errors.
Source code in provide/foundation/errors/base.py
ArchiveFormatError
¶
ArchiveFormatError(
message: str,
*,
code: str | None = None,
context: dict[str, Any] | None = None,
cause: Exception | None = None,
**extra_context: Any
)
Bases: ArchiveError
Archive format is invalid or corrupted.
Source code in provide/foundation/errors/base.py
ArchiveIOError
¶
ArchiveIOError(
message: str,
*,
code: str | None = None,
context: dict[str, Any] | None = None,
cause: Exception | None = None,
**extra_context: Any
)
Bases: ArchiveError
I/O operation failed during archive processing.
Source code in provide/foundation/errors/base.py
ArchiveValidationError
¶
ArchiveValidationError(
message: str,
*,
code: str | None = None,
context: dict[str, Any] | None = None,
cause: Exception | None = None,
**extra_context: Any
)
Bases: ArchiveError
Archive validation failed (security checks, malformed paths, etc).
Source code in provide/foundation/errors/base.py
BaseArchive
¶
Bases: ABC
Abstract base class for all archive implementations.
This defines the common interface that all archive implementations must follow, ensuring consistency across different archive formats.
Functions¶
create
abstractmethod
¶
Create an archive from source path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Path
|
Source file or directory to archive |
required |
output
|
Path
|
Output archive file path |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Path to the created archive file |
Raises:
| Type | Description |
|---|---|
ArchiveError
|
If archive creation fails |
Source code in provide/foundation/archive/base.py
extract
abstractmethod
¶
Extract an archive to output path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
archive
|
Path
|
Archive file to extract |
required |
output
|
Path
|
Output directory for extracted contents |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Path to the extraction directory |
Raises:
| Type | Description |
|---|---|
ArchiveError
|
If extraction fails |
Source code in provide/foundation/archive/base.py
validate
abstractmethod
¶
Validate that an archive is properly formed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
archive
|
Path
|
Archive file to validate |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if archive is valid, False otherwise |
Raises:
| Type | Description |
|---|---|
ArchiveError
|
If validation cannot be performed |
Source code in provide/foundation/archive/base.py
BaseCompressor
¶
Bases: ABC
Abstract base class for compression implementations.
Provides common compression/decompression interface for stream, file, and bytes operations. Subclasses must implement the library-specific compression/decompression methods.
Attributes¶
format_name
abstractmethod
property
¶
Return the name of the compression format (e.g., 'GZIP', 'BZIP2').
Functions¶
compress
¶
Compress data from input stream to output stream.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_stream
|
BinaryIO
|
Input binary stream |
required |
output_stream
|
BinaryIO
|
Output binary stream |
required |
Raises:
| Type | Description |
|---|---|
ArchiveError
|
If compression fails |
Source code in provide/foundation/archive/base.py
compress_bytes
¶
Compress bytes data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
bytes
|
Input bytes |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
Compressed bytes |
Raises:
| Type | Description |
|---|---|
ArchiveError
|
If compression fails |
Source code in provide/foundation/archive/base.py
compress_file
¶
Compress a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_path
|
Path
|
Input file path |
required |
output_path
|
Path
|
Output file path |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Path to compressed file |
Raises:
| Type | Description |
|---|---|
ArchiveError
|
If compression fails |
Source code in provide/foundation/archive/base.py
decompress
¶
Decompress data from input stream to output stream.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_stream
|
BinaryIO
|
Input binary stream (compressed) |
required |
output_stream
|
BinaryIO
|
Output binary stream |
required |
Raises:
| Type | Description |
|---|---|
ArchiveError
|
If decompression fails |
Source code in provide/foundation/archive/base.py
decompress_bytes
¶
Decompress bytes data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
bytes
|
Compressed bytes |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
Decompressed bytes |
Raises:
| Type | Description |
|---|---|
ArchiveError
|
If decompression fails |
Source code in provide/foundation/archive/base.py
decompress_file
¶
Decompress a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_path
|
Path
|
Input file path (compressed) |
required |
output_path
|
Path
|
Output file path |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Path to decompressed file |
Raises:
| Type | Description |
|---|---|
ArchiveError
|
If decompression fails |