From 9ceb42af2f4f43ae0e4f8783594a45c32cc51762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 14 Mar 2018 14:36:33 +0100 Subject: [PATCH] Moved some code into its own function --- blender_asset_tracer/cli/pack.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/blender_asset_tracer/cli/pack.py b/blender_asset_tracer/cli/pack.py index dd36314..eb7abf0 100644 --- a/blender_asset_tracer/cli/pack.py +++ b/blender_asset_tracer/cli/pack.py @@ -49,15 +49,7 @@ def create_packer(args, bpath: pathlib.Path, ppath: pathlib.Path, if args.noop: raise ValueError('S3 uploader does not support no-op.') - from blender_asset_tracer.pack import s3 - - # Split the target path into 's3:/', hostname, and actual target path - parts = tpath.parts - endpoint = parts[1] - tpath = pathlib.Path(*tpath.parts[2:]) - log.info('Uploading to S3-compatible storage %s at %s', endpoint, tpath) - - packer = s3.S3Packer(bpath, ppath, tpath, endpoint=endpoint) # type: pack.Packer + packer = create_s3packer(bpath, ppath, tpath) else: packer = pack.Packer(bpath, ppath, tpath, args.noop) @@ -71,6 +63,18 @@ def create_packer(args, bpath: pathlib.Path, ppath: pathlib.Path, return packer +def create_s3packer(bpath, ppath, tpath) -> pack.Packer: + from blender_asset_tracer.pack import s3 + + # Split the target path into 's3:/', hostname, and actual target path + parts = tpath.parts + endpoint = parts[1] + tpath = pathlib.Path(*tpath.parts[2:]) + log.info('Uploading to S3-compatible storage %s at %s', endpoint, tpath) + + return s3.S3Packer(bpath, ppath, tpath, endpoint=endpoint) + + def paths_from_cli(args) -> typing.Tuple[pathlib.Path, pathlib.Path, pathlib.Path]: """Return paths to blendfile, project, and pack target.