Skip to content

Commit

Permalink
refactor base DownloadCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
mjurbanski-reef committed Nov 13, 2023
1 parent a1c4a0e commit ec668b3
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions b2/console_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1417,16 +1417,6 @@ def _represent_legal_hold(cls, legal_hold: LegalHold):
def _print_file_attribute(self, label, value):
self._print((label + ':').ljust(20) + ' ' + value)


class DownloadFileMixin(
ThreadsMixin,
ProgressMixin,
SourceSseMixin,
WriteBufferSizeMixin,
SkipHashVerificationMixin,
MaxDownloadStreamsMixin,
DownloadCommand,
):
def get_local_output_filename(self, filename: str) -> str:
if filename == '-':
return STDOUT_FILE_PATH
Expand All @@ -1435,7 +1425,13 @@ def get_local_output_filename(self, filename: str) -> str:

@B2.register_subcommand
class DownloadFileById(
DownloadFileMixin,
ThreadsMixin,
ProgressMixin,
SourceSseMixin,
WriteBufferSizeMixin,
SkipHashVerificationMixin,
MaxDownloadStreamsMixin,
DownloadCommand,
):
"""
Downloads the given file, and stores it in the given local file.
Expand Down Expand Up @@ -1477,7 +1473,13 @@ def run(self, args):

@B2.register_subcommand
class DownloadFileByName(
DownloadFileMixin,
ThreadsMixin,
ProgressMixin,
SourceSseMixin,
WriteBufferSizeMixin,
SkipHashVerificationMixin,
MaxDownloadStreamsMixin,
DownloadCommand,
):
"""
Downloads the given file, and stores it in the given local file.
Expand Down Expand Up @@ -1521,7 +1523,11 @@ def run(self, args):

@B2.register_subcommand
class Cat(
DownloadFileMixin,
ProgressMixin,
SourceSseMixin,
WriteBufferSizeMixin,
SkipHashVerificationMixin,
DownloadCommand,
):
"""
Download content of a file identified by B2 URI directly to stdout.
Expand Down

0 comments on commit ec668b3

Please sign in to comment.