mirror of
https://github.com/borgbackup/borg.git
synced 2026-06-11 01:41:57 -04:00
Move get_chunker to __init__.py and update Chunker signature
Relocated `get_chunker` function from `chunker` module to `chunkers.__init__.py` for improved organization. Updated `Chunker` class signature to include a `sparse` parameter with a default value. Adjusted imports and type hints accordingly.
This commit is contained in:
parent
a78c310b72
commit
322e2018ec
3 changed files with 21 additions and 16 deletions
|
|
@ -1,2 +1,15 @@
|
|||
from .chunker import * # noqa
|
||||
from .reader import * # noqa
|
||||
|
||||
|
||||
def get_chunker(algo, *params, **kw):
|
||||
if algo == "buzhash":
|
||||
seed = kw["seed"]
|
||||
sparse = kw["sparse"]
|
||||
return Chunker(seed, *params, sparse=sparse)
|
||||
if algo == "fixed":
|
||||
sparse = kw["sparse"]
|
||||
return ChunkerFixed(*params, sparse=sparse)
|
||||
if algo == "fail":
|
||||
return ChunkerFailing(*params)
|
||||
raise TypeError("unsupported chunker algo %r" % algo)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from typing import List, Any, Iterator, BinaryIO
|
||||
from typing import List, Iterator, BinaryIO
|
||||
|
||||
from .reader import fmap_entry
|
||||
|
||||
|
|
@ -6,7 +6,6 @@ API_VERSION: str
|
|||
|
||||
def buzhash(data: bytes, seed: int) -> int: ...
|
||||
def buzhash_update(sum: int, remove: int, add: int, len: int, seed: int) -> int: ...
|
||||
def get_chunker(algo: str, *params, **kw) -> Any: ...
|
||||
|
||||
class ChunkerFailing:
|
||||
def __init__(self, block_size: int, map: str) -> None: ...
|
||||
|
|
@ -18,6 +17,12 @@ class ChunkerFixed:
|
|||
|
||||
class Chunker:
|
||||
def __init__(
|
||||
self, seed: int, chunk_min_exp: int, chunk_max_exp: int, hash_mask_bits: int, hash_window_size: int
|
||||
self,
|
||||
seed: int,
|
||||
chunk_min_exp: int,
|
||||
chunk_max_exp: int,
|
||||
hash_mask_bits: int,
|
||||
hash_window_size: int,
|
||||
sparse: bool = False,
|
||||
) -> None: ...
|
||||
def chunkify(self, fd: BinaryIO = None, fh: int = -1, fmap: List[fmap_entry] = None) -> Iterator: ...
|
||||
|
|
|
|||
|
|
@ -444,16 +444,3 @@ def buzhash_update(uint32_t sum, unsigned char remove, unsigned char add, size_t
|
|||
sum = _buzhash_update(sum, remove, add, len, table)
|
||||
free(table)
|
||||
return sum
|
||||
|
||||
|
||||
def get_chunker(algo, *params, **kw):
|
||||
if algo == 'buzhash':
|
||||
seed = kw['seed']
|
||||
sparse = kw['sparse']
|
||||
return Chunker(seed, *params, sparse=sparse)
|
||||
if algo == 'fixed':
|
||||
sparse = kw['sparse']
|
||||
return ChunkerFixed(*params, sparse=sparse)
|
||||
if algo == 'fail':
|
||||
return ChunkerFailing(*params)
|
||||
raise TypeError('unsupported chunker algo %r' % algo)
|
||||
|
|
|
|||
Loading…
Reference in a new issue