-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This refactoring removes the necessity of passing arguments through the ``FileGenerator`` class in order for the ``FileInfo`` class to obtain the arguments it requires to perform an operation.
- Loading branch information
Showing
10 changed files
with
257 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You | ||
# may not use this file except in compliance with the License. A copy of | ||
# the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "license" file accompanying this file. This file is | ||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF | ||
# ANY KIND, either express or implied. See the License for the specific | ||
# language governing permissions and limitations under the License. | ||
from awscli.customizations.s3.fileinfo import FileInfo | ||
|
||
|
||
class InfoSetter(object): | ||
""" | ||
This class takes a ``FileBase`` object's attributes and generates | ||
a ``FileInfo`` object so that the operation can be performed. | ||
""" | ||
def __init__(self, service, endpoint, source_endpoint=None, | ||
parameters = None): | ||
self._service = service | ||
self._endpoint = endpoint | ||
self._source_endpoint = endpoint | ||
if source_endpoint: | ||
self._source_endpoint = source_endpoint | ||
self._parameters = parameters | ||
|
||
def call(self, files): | ||
for file_base in files: | ||
file_info = self.inject_info(file_base) | ||
yield file_info | ||
|
||
def inject_info(self, file_base): | ||
file_info_attr = {} | ||
file_info_attr['src'] = file_base.src | ||
file_info_attr['dest'] = file_base.dest | ||
file_info_attr['compare_key'] = file_base.compare_key | ||
file_info_attr['size'] = file_base.size | ||
file_info_attr['last_update'] = file_base.last_update | ||
file_info_attr['src_type'] = file_base.src_type | ||
file_info_attr['dest_type'] = file_base.dest_type | ||
file_info_attr['operation_name'] = file_base.operation_name | ||
file_info_attr['service'] = self._service | ||
file_info_attr['endpoint'] = self._endpoint | ||
file_info_attr['source_endpoint'] = self._source_endpoint | ||
file_info_attr['parameters'] = self._parameters | ||
return FileInfo(**file_info_attr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.