Skip to content

Commit

Permalink
fileobjects support
Browse files Browse the repository at this point in the history
  • Loading branch information
maxme1 committed Apr 7, 2024
1 parent 8abcf97 commit 23648d6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bev/cli/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import typer
from rich.progress import track
from tarn.utils import value_to_buffer
from typing_extensions import Annotated

from ..exceptions import HashError
Expand Down Expand Up @@ -130,7 +131,12 @@ def save_hash(value, file, repo, fetch):
f.write(value)


def copy_value(value, file):
with value_to_buffer(value) as f, open(file, 'wb') as file:
shutil.copyfileobj(f, file)


PULL_MODES = {
PullMode.copy: lambda h, dst, repo, fetch: repo.storage.read(shutil.copyfile, h, dst, fetch=fetch),
PullMode.copy: lambda h, dst, repo, fetch: repo.storage.read(copy_value, h, dst, fetch=fetch),
PullMode.hash: save_hash,
}

0 comments on commit 23648d6

Please sign in to comment.