From a8895850d8863b16f3d59064bc9a37f6320892a5 Mon Sep 17 00:00:00 2001 From: kyleknap Date: Thu, 22 Oct 2015 10:48:20 -0700 Subject: [PATCH] Remove unused logic --- awscli/customizations/s3/subcommands.py | 30 ------------------- .../customizations/s3/test_subcommands.py | 23 -------------- 2 files changed, 53 deletions(-) diff --git a/awscli/customizations/s3/subcommands.py b/awscli/customizations/s3/subcommands.py index 773b0a98c9fb..ff5394a68504 100644 --- a/awscli/customizations/s3/subcommands.py +++ b/awscli/customizations/s3/subcommands.py @@ -749,7 +749,6 @@ def run(self): 'rb': 'remove_bucket' } result_queue = queue.Queue() - operation_name = cmd_translation[paths_type][self.cmd] file_generator = FileGenerator(self._source_client, operation_name, @@ -969,35 +968,6 @@ def check_path_type(self, paths): else: raise TypeError("%s\nError: Invalid argument type" % usage) - def check_src_path(self, paths): - """ - This checks the source paths to deem if they are valid. The check - performed in S3 is first it lists the objects using the source path. - If there is an error like the bucket does not exist, the error will be - caught with ``check_error()`` function. If the operation is on a - single object in s3, it checks that a list of object was returned and - that the first object listed is the name of the specified in the - command line. If the operation is on objects under a common prefix, - it will check that there are common prefixes and objects under - the specified prefix. - For local files, it first checks that the path exists. Then it checks - that the path is a directory if it is a directory operation or that - the path is a file if the operation is on a single file. - """ - src_path = paths[0] - dir_op = self.parameters['dir_op'] - if not src_path.startswith('s3://'): - src_path = os.path.abspath(src_path) - if os.path.exists(src_path): - if os.path.isdir(src_path) and not dir_op: - raise Exception("Error: Requires a local file") - elif os.path.isfile(src_path) and dir_op: - raise Exception("Error: Requires a local directory") - else: - pass - else: - raise Exception("Error: Local path does not exist") - def add_region(self, parsed_globals): self.parameters['region'] = parsed_globals.region diff --git a/tests/unit/customizations/s3/test_subcommands.py b/tests/unit/customizations/s3/test_subcommands.py index db3a6126e176..168834472071 100644 --- a/tests/unit/customizations/s3/test_subcommands.py +++ b/tests/unit/customizations/s3/test_subcommands.py @@ -596,29 +596,6 @@ def test_check_path_type_fail(self): with self.assertRaises(TypeError): cmd_param.check_path_type(combos[path_args]) - def test_check_src_path_pass(self): - # This tests to see if all of the checks on the source path works. It - # does so by testing if s3 objects and and prefixes exist as well as - # local files and directories. All of these should not throw an - # exception. - s3_file = 's3://' + self.bucket + '/' + 'text1.txt' - local_file = self.loc_files[0] - s3_prefix = 's3://' + self.bucket - local_dir = self.loc_files[3] - - # :var files: a list of tuples where the first element is a single - # element list of file paths. The second element is a boolean - # representing if the operation is a directory operation. - files = [([s3_file], False), ([local_file], False), - ([s3_prefix], True), ([local_dir], True)] - - parameters = {} - for filename in files: - parameters['dir_op'] = filename[1] - cmd_parameter = CommandParameters('put', parameters, '') - cmd_parameter.add_region(mock.Mock()) - cmd_parameter.check_src_path(filename[0]) - def test_validate_streaming_paths_upload(self): paths = ['-', 's3://bucket'] cmd_params = CommandParameters('cp', {}, '')