Skip to content

Commit

Permalink
Remove unused logic
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleknap committed Oct 22, 2015
1 parent 5c31ead commit 5e28883
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 52 deletions.
29 changes: 0 additions & 29 deletions awscli/customizations/s3/subcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,35 +969,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

Expand Down
23 changes: 0 additions & 23 deletions tests/unit/customizations/s3/test_subcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', {}, '')
Expand Down

0 comments on commit 5e28883

Please sign in to comment.