o @&a`@s8ddlZddlZddlZddlmZddlmZddlmZddl m Z ddl m Z ddl m Z ddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZmZmZm Z m!Z!m"Z"m#Z#ddl$m%Z%ddl&m'Z'm(Z(m)Z)ddl*m+Z+e,e-Z.dddddZ/ddddZ0ddddZ1ddddZ2ddd dZ3d!dd"dZ4d#dd$d%d&d'Z5d(d)d%d$d%d*Z6d+d)d,d$d-d.Z7d/d0d1Z8d2ed3d4d5d6Z9d7ed3d4d8d6Z:d9gd:d;d<Z;d=d>d?d@ZdIdJdKdLZ?dMdNd1Z@dOdBdCdCgdPdFZAdQdJdRdLZBdSgdTdUd<ZCdVdWd1ZDdXdYd1ZEdZd[d1ZFd\d]d1ZGd^d_d1ZHd`dad1ZIdbdcd1ZJdddededfdgidfdgidhdidjZKdkdldmgdnd<ZLdodpd1ZMdqdrd1ZNdsddtdZOdud)dvdwdZPdxdyd1ZQdzd{d|dLZRd}dd~dZSddddZTddgdBdddZUe2e3e:e9e;e5e6e7e=e>e?e@eAeBeCeUse of Exclude and Include Filters for details.acl)privatez public-readzpublic-read-writezauthenticated-readz aws-exec-readzbucket-owner-readzbucket-owner-full-controlzlog-delivery-writeaSets the ACL for the object when the command is performed. If you use this parameter you must have the "s3:PutObjectAcl" permission included in the list of actions for your IAM policy. Only accepts values of ``private``, ``public-read``, ``public-read-write``, ``authenticated-read``, ``aws-exec-read``, ``bucket-owner-read``, ``bucket-owner-full-control`` and ``log-delivery-write``. See Canned ACL for details)rchoicesr!grants+a

Grant specific permissions to individual users or groups. You can supply a list of grants of the form

--grants Permission=Grantee_Type=Grantee_ID [Permission=Grantee_Type=Grantee_ID ...]To specify the same permission type for multiple grantees, specify the permission as such as --grants Permission=Grantee_Type=Grantee_ID,Grantee_Type=Grantee_ID,...Each value contains the following elements:For more information on Amazon S3 access control, see Access Control)rr.r!sse?AES256aws:kmszSpecifies server-side encryption of the object in S3. Valid values are ``AES256`` and ``aws:kms``. If the parameter is specified but no value is provided, ``AES256`` is used.)rr.constr2r!zsse-ca Specifies server-side encryption using customer provided keys of the the object in S3. ``AES256`` is the only valid value. If the parameter is specified but no value is provided, ``AES256`` is used. If you provide this value, ``--sse-c-key`` must be specified as well.z sse-c-keyblobzThe customer-provided encryption key to use to server-side encrypt the object in S3. If you provide this value, ``--sse-c`` must be specified as well. The key provided should **not** be base64 encoded.)r cli_type_namer!zsse-kms-key-idzThe customer-managed AWS Key Management Service (KMS) key ID that should be used to server-side encrypt the object in S3. You should only provide this parameter if you are using a customer managed customer master key (CMK) and not the AWS managed KMS CMK.zsse-c-copy-sourceaThis parameter should only be specified when copying an S3 object that was encrypted server-side with a customer-provided key. It specifies the algorithm to use when decrypting the source object. ``AES256`` is the only valid value. If the parameter is specified but no value is provided, ``AES256`` is used. If you provide this value, ``--sse-c-copy-source-key`` must be specified as well. zsse-c-copy-source-keyaThis parameter should only be specified when copying an S3 object that was encrypted server-side with a customer-provided key. Specifies the customer-provided encryption key for Amazon S3 to use to decrypt the source object. The encryption key provided must be one that was used when the source object was created. If you provide this value, ``--sse-c-copy-source`` be specified as well. The key provided should **not** be base64 encoded.z storage-class)STANDARDREDUCED_REDUNDANCY STANDARD_IA ONEZONE_IAINTELLIGENT_TIERINGGLACIER DEEP_ARCHIVE GLACIER_IRzThe type of storage to use for the object. Valid choices are: STANDARD | REDUCED_REDUNDANCY | STANDARD_IA | ONEZONE_IA | INTELLIGENT_TIERING | GLACIER | DEEP_ARCHIVE | GLACIER_IR. Defaults to 'STANDARD'zwebsite-redirectzIf the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. Amazon S3 stores the value of this header in the object metadata.z cache-controlz9Specifies caching behavior along the request/reply chain.zcontent-dispositionz4Specifies presentational information for the object.zcontent-encodingzSpecifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field.zcontent-languagezThe language the content is in.z source-regionafWhen transferring objects from an s3 bucket to an s3 bucket, this specifies the region of the source bucket. Note the region specified by ``--region`` or through configuration of the CLI refers to the region of the destination bucket. If ``--source-region`` is not specified the region of the source will be the same as the region of the destination bucket.expiresz=The date and time at which the object is no longer cacheable.metadatamaptypestring)rGkeyvalueaJA map of metadata to store with the objects in S3. This will be applied to every object which is part of this request. In a sync, this means that files which haven't changed won't receive the new metadata. When copying between two s3 locations, the metadata-directive argument will default to 'REPLACE' unless otherwise specified.)rr;schemar!zmetadata-directiveCOPYREPLACEaSpecifies whether the metadata is copied from the source object or replaced with metadata provided when copying S3 objects. Note that if the object is copied over in parts, the source object's metadata will not be copied over, no matter the value for ``--metadata-directive``, and instead the desired metadata values must be specified as parameters on the command line. Valid values are ``COPY`` and ``REPLACE``. If this parameter is not specified, ``COPY`` will be used by default. If ``REPLACE`` is used, the copied object will only have the metadata values that were specified by the CLI command. Note that if you are using any of the following parameters: ``--content-type``, ``content-language``, ``--content-encoding``, ``--content-disposition``, ``--cache-control``, or ``--expires``, you will need to specify ``--metadata-directive REPLACE`` for non-multipart copies if you want the copied objects to have the specified metadata values.zindex-documentaBA suffix that is appended to a request that is for a directory on the website endpoint (e.g. if the suffix is index.html and you make a request to samplebucket/images/ the data that is returned will be for the object with the key name images/index.html) The suffix must not be empty and must not include a slash character.zerror-documentz9The object key name to use when a 4XX class error occurs.zonly-show-errorszGOnly errors and warnings are displayed. All other output is suppressed.z no-progressprogressz~File transfer progress is not displayed. This flag is only applied when the quiet and only-show-errors flags are not provided.z expected-sizea/This argument specifies the expected size of a stream in terms of bytes. Note that this argument is needed only when a stream is being uploaded to s3 and the size is larger than 50GB. Failure to include this argument under these conditions may result in a failed upload due to too many parts in upload.z page-sizeintegerzThe number of results to return in each response to a list operation. The default value is 1000 (the maximum allowed). Using a lower value may help if an operation times out.zignore-glacier-warningsaTurns off glacier warnings. Warnings about an operation that cannot be performed because it involves copying, downloading, or moving a glacier object will no longer be printed to standard error and will no longer cause the return code of the command to be ``2``.zforce-glacier-transferzMForces a transfer request on all Glacier objects in a sync or recursive copy.z request-payer requestera0Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. Documentation on downloading objects from requester pays buckets can be found at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html)rr2r.r9r!cCs|jd||||dS)Ns3) region_name endpoint_urlverifyconfig) create_client)sessionregionrSrTrUrYF/usr/lib/python3/dist-packages/awscli/customizations/s3/subcommands.py get_clientsr[c@seZdZddZdS) S3CommandcCst|j|j|j|j|_dSN)r[_sessionrXrS verify_sslclient)self parsed_argsparsed_globalsrYrYrZ _run_mains  zS3Command._run_mainN)__name__ __module__ __qualname__rdrYrYrYrZr\s r\cseZdZdZdZdZddddedeeee e gZ fd d Z dd d Z dddZddZ dddZddZddZddZddZZS) ListCommandlszList S3 objects and common prefixes under a prefix or all S3 buckets. Note that the --output and --no-paginate arguments are ignored for this command.z or NONEpathsr6s3://T)rr.r'positional_argsynopsiscstt|||d|_d|_d|_d|_|j|_|j }| dr'|dd}t |\}}|s4| n|j rB||||j|jn ||||j|j|jrS||rY|SdS)NFTrrk)superrhrd _empty_result_at_first_page_size_accumulator_total_objectshuman_readable_human_readablerj startswithr_list_all_bucketsr_list_all_objects_recursive page_size request_payer_list_all_objectsr"_print_summary_check_no_objects)rarbrcpathbucketrI __class__rYrZrds0      zListCommand._run_mainNc CsV|jd}||dd|id}|dur||d<|jdi|}|D]}||q!dS)Nlist_objects_v2/PageSize)BucketPrefix DelimiterPaginationConfig RequestPayerrYr` get_paginatorpaginate _display_page rarrIryrz paginator paging_argsiterator response_datarYrYrZr{s  zListCommand._list_all_objectscCs|dg}|dg}|s|sd|_dS|D]}|dd}|d}ddd }|d |d } t| q|D]D} || d } |jt| d 7_|jd 7_| | d } |ri| dd} | d}n| d}| d | d |d} t| q9d|_ dS)NCommonPrefixesContentsTrrPRE z/ LastModifiedSizer,Key F) getrpsplitrjustr_make_last_mod_strrrintrs_make_size_strrq)rar use_basenamecommon_prefixescontents common_prefixprefix_componentsprefix pre_string print_strcontent last_mod_strsize_strfilename_componentsfilenamerYrYrZrs6       zListCommand._display_pagecCsJ|j}|d}|D]}||d}|d|dd}t|q dS)NBuckets CreationDaterNamer)r` list_bucketsrr)rarbucketsrrrrYrYrZrws  zListCommand._list_all_bucketsc CsX|jd}||d|id}|dur||d<|jdi|}|D] }|j|ddq dS)Nrr)rrrrF)rrYrrrYrYrZrx&s z'ListCommand._list_all_objects_recursivecCs|jr|jrdSdS)Nr,r)rprqrarYrYrZr}3s zListCommand._check_no_objectscCszt|}|t}t|jt|jdt|jdt|jdt|j dt|j df}d|}| ddS)zz This function creates the last modified time string whenever objects or buckets are being listed z%s-%s-%s %s:%s:%sr) r astimezonerstryearmonthzfilldayhourminutesecondljust)ralast_mod last_mod_tuprrYrYrZr:s  zListCommand._make_last_mod_strcCs$|jrt|}nt|}|ddS)zV This function creates the size string when objects are being listed. r)rurrr)rasizerrYrYrZrIs  zListCommand._make_size_strcCsZt|j}tddd|d|jrt|j}nt|j}tddd|ddS)zQ This function prints a summary of total objects and total bytes z Total Objects: rrz Total Size: N)rrsrrrurrr)rarrYrYrZr|Ss   zListCommand._print_summary)NN)T)rerfrgNAME DESCRIPTIONUSAGE RECURSIVE PAGE_SIZEHUMAN_READABLE SUMMARIZE REQUEST_PAYER ARG_TABLErdr{rrwrxr}rrr| __classcell__rYrYrrZrhs. $    rhcsLeZdZdZdZdZdddedeegZfdd Z d d Z d d Z Z S)WebsiteCommandwebsitez+Set the website configuration for a bucket.rjr,Trr.rlrmcs@tt|||||jd}||}|jj||ddS)Nr)rWebsiteConfiguration)rorrd_get_bucket_namerj_build_website_configurationr`put_bucket_website)rarbrcrwebsite_configurationrrYrZrdgs zWebsiteCommand._run_maincCs8i}|jdurd|ji|d<|jdurd|ji|d<|S)NSuffix IndexDocumentr ErrorDocument)index_documenterror_document)rarbwebsite_configrYrYrZros  z+WebsiteCommand._build_website_configurationcCs8|dr |dd}|dr|dd}t||S)Nrkrnrr)rvendswithr)rar~rYrYrZrys    zWebsiteCommand._get_bucket_name) rerfrgrrrINDEX_DOCUMENTERROR_DOCUMENTrrdrrrrYrYrrZr`s  rcsBeZdZdZdZdZddedddd d d gZfd d ZZS)PresignCommandpresignzGenerate a pre-signed URL for an Amazon S3 object. This allows anyone who receives the pre-signed URL to retrieve the S3 object with an HTTP GET request. For sigv4 requests the region needs to be configured explicitly.rr~Trrlrmz expires-inirOzMNumber of seconds until the pre-signed URL expires. Default is 3600 seconds.)rr'r;r!cshtt||||j}|dr|dd}t|\}}|jjd||d|jd}t |t ddS)Nrkrn get_object)rr) ExpiresInrr) rorrdr~rvrr`generate_presigned_url expires_inr)rarbrcr~rrIurlrrYrZrds   zPresignCommand._run_main rerfrgrrrrrdrrYrYrrZrsrcs,eZdZfddZddZddZZS)S3TransferCommandcstt|||||||i}t|j||j}||| || || || |j tjdi|jdi}t|j|j|j|}|||S)NrQrY)rorrd_convert_path_args_build_call_parametersCommandParametersrr add_regionadd_endpoint_urladd_verify_ssl add_page_size add_pathsrjr RuntimeConfig build_configr^get_scoped_configrCommandArchitecture parameters set_clientscreate_instructionsrun)rarbrcparams cmd_paramsruntime_configcmdrrYrZrds*         zS3TransferCommand._run_maincCs"t|D]\}}|||<q|S)zj This takes all of the commands in the name space and puts them into a dictionary )varsitems)raargscommand_paramsrrJrYrYrZrs z(S3TransferCommand._build_call_parameterscCspt|jts |jg|_tt|jD]#}|j|}t|tjr5|t }| d}|d}||j|<qdS)Nzutf-8) isinstancerjlistrangelenr binary_typedecodesysgetfilesystemencodingencode)rarbir~dec_pathenc_pathnew_pathrYrYrZrs       z$S3TransferCommand._convert_path_args)rerfrgrdrrrrYrYrrZrs  rc@s8eZdZdZdZdZdddedgeeee e gZ dS) CpCommandcpzFCopies a local file or S3 object to another location locally or in S3.= or or rjrTrN) rerfrgrrr TRANSFER_ARGSMETADATAMETADATA_DIRECTIVE EXPECTED_SIZErrrYrYrYrZrs rc@s6eZdZdZdZdZdddedgeeee gZ dS) MvCommandmvzEMoves a local file or S3 object to another location locally or in S3.rrjrTrN) rerfrgrrrrrrrrrYrYrYrZrsrc @s8eZdZdZdZdZdddedeeee e e e e g ZdS) RmCommandrmzDeletes an S3 object.rrjr,TrN)rerfrgrrrDRYRUNQUIETrrINCLUDEEXCLUDEONLY_SHOW_ERRORSrrrYrYrYrZrsrc@s4eZdZdZdZdZdddedgeeegZ dS) SyncCommandsynczSyncs directories and S3 prefixes. Recursively copies new and updated files from the source directory to the destination. Only creates folders in the destination if they contain one or more files.rrjrTrN) rerfrgrrrrrrrrYrYrYrZr#sr#cs6eZdZdZdZdZddedgZfddZZS) MbCommandmbzCreates an S3 bucket.rr~Trc stt||||jdstd|jt|j\}}d|jj j i}d|i}|jj j dkr3||d<z|jj d i|t d|WdSt yc}zt d |j|ftjWYd}~d Sd}~ww) Nrk%s Error: Invalid argument typeLocationConstraintrz us-east-1CreateBucketConfigurationzmake_bucket: %s rzmake_bucket failed: %s %s r,rY)ror%rdr~rv TypeErrorrrr`metarR create_bucketr Exceptionr stderr)rarbrcr_ bucket_configrerrYrZrds(   zMbCommand._run_mainrrYrYrrZr%s r%cs@eZdZdZdZdZddedegZfddZd d Z Z S) RbCommandrbzDeletes an empty S3 bucket. A bucket must be completely empty of objects and versioned objects before it can be deleted. However, the ``--force`` parameter can be used to delete the non-versioned objects in the bucket before the bucket is deleted.rr~Trc stt||||jdstd|jt|j\}}|r%td||j r/| |j|z|j j |dt d|WdSty]}zt d|j|ftjWYd}~dSd}~ww) Nrkr'z5Please specify a valid bucket name only. E.g. s3://%s)rzremove_bucket: %s rzremove_bucket failed: %s %s r,)ror2rdr~rvr*rr ValueErrorr%_forcer` delete_bucketrr-r r.)rarbrcrrIr1rrYrZrd+s,   zRbCommand._run_maincCs,t|j}||dg|}|dkrtddS)z'Calls rm --recursive on the given path.z --recursiverz]remove_bucket failed: Unable to delete all objects in the bucket, bucket will not be deleted.N)rr^ RuntimeError)rar~rcrrcrYrYrZr5Ds zRbCommand._force) rerfrgrrrFORCErrdr5rrYrYrrZr2s r2c@sZeZdZdZdddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ dS)ra This class drives the actual command. A command is performed in two steps. First a list of instructions is generated. This list of instructions identifies which type of components are required based on the name of the command and the parameters passed to the command line. After the instructions are generated the second step involves using the list of instructions to wire together an assortment of generators to perform the command. NcCs:||_||_||_g|_||_d|_d|_d|_d|_dSr]) rWrr instructions_runtime_config _endpoint_source_endpoint_client_source_client)rarWrrrrYrYrZ__init__Xs zCommandArchitecture.__init__cCsd}|jddkrtdd}t|j|jd|jd|jd|d|_t|j|jd|jd|jd|d|_|jd rV|jd d krXt|j|jd d|jd|d|_dSdSdS) Nr5r8s3v4)signature_versionrXrSr_)rXrSrTrU source_region paths_types3s3)rrrr[rWr>r?)ra client_configrYrYrZrcs8   zCommandArchitecture.set_clientscCs^|r'|jd|jdr|jd|jdkr!|jd|jd|jddS)aG This function creates the instructions based on the command name and extra parameters. Note that all commands must have an s3_handler instruction in the instructions and must be at the end of the instruction list because it sends the request to S3 and does not yield anything. file_generatorr-r$ comparatorfile_info_builder s3_handlerN)needs_filegeneratorr:appendrrrrrYrYrZrs      z'CommandArchitecture.create_instructionscCs |jd S)N is_stream)rrrYrYrZrKs z'CommandArchitecture.needs_filegeneratorcCspi}t|d<t|d<t|d<|jjd|jd}|dur6|D]}|d}|dur5|j}|d7}|||<q |S) zDetermines the sync strategy for the command. It defaults to the default sync strategies but a customizable sync strategy can override the default strategy if it returns the instance of its self when the event is emitted. "file_at_src_and_dest_sync_strategyfile_not_at_dest_sync_strategyfile_not_at_src_sync_strategyzchoosing-s3-sync-strategy)rNr,_sync_strategy)rrrrWemitr sync_type)rasync_strategies responsesresponseoverride_sync_strategyrSrYrYrZchoose_sync_strategiess"  z*CommandArchitecture.choose_sync_strategiesc Cs|jd}|jd}|jd}t|||j}t|||j}ddddd}t}||}|j||jd |jd |d } |jd |jd |jd |d } |} || | | || | d <|} || | | d <t di| } t di| }t |\}}t |dd|||dd|dd||jddg}t |j|j|j}t|j|j|j|}|}i}|jdkr||g| |gt|jt|jgtdi|g|g|gd}nV|jdkr|jdr|g|gd}nD|jdkr|g| gt|jg|g|gd}n-|jdkr|g| gt|jg|g|gd}n|jdkr/|g| gt|jg|g|gd}|d}|jrt|jd}g}||}tt|D]$}t|t|kr`|||j|qI|||||qI|}|js7d}|djdkrd}|S|djdkrd}|S) a This function wires together all of the generators and completes the command. First a dictionary is created that is indexed first by the command name. Then using the instruction, another dictionary can be indexed to obtain the objects corresponding to the particular instruction for that command. To begin the wiring, either a ``FileFormat`` or ``TaskInfo`` object, depending on the command, is put into a list. Then the function enters a while loop that pops off an instruction. It then determines the object needed and calls the call function of the object using the list as the input. Depending on the number of objects in the input list and the number of components in the list corresponding to the instruction, the call method of the component can be called two different ways. If the number of inputs is equal to the number of components a 1:1 mapping of inputs to components is used when calling the call function. If the there are more inputs than components, then a 2:1 mapping of inputs to components is used where the component call method takes two inputs instead of one. Whatever files are yielded from the call function is appended to a list and used as the input for the next repetition of the while loop until there are no more instructions. srcr rDuploadcopydownloaddelete)locals3rEs3localrQr&ry)r`operation_namer&ry result_queuerequest_parametersr~rGT)rYr compare_keysrc_type dest_typer`r`rMr$)setuprGr-rHrIrJrrM)rgrJ)rgrGr-rIrJrrrgrr,rNrY)rr formatrQueuer?r>/_get_file_generator_request_parameters_skeleton_map_request_payer_params_map_sse_c_paramsr rr r rr;rXrr rr:poprr rLcallnum_tasks_failednum_tasks_warned)rarYr rDfiles rev_filescmd_translationrar` fgen_kwargs rgen_kwargsfgen_request_parametersrgen_request_parametersrG rev_generatorstream_dest_pathstream_compare_keystream_file_inforIs3_transfer_handlerrT command_dict instruction file_list componentsrr8rYrYrZrs                   zCommandArchitecture.runcCs iiidS)N) HeadObject ListObjects ListObjectsV2rYrrYrYrZrj;szCCommandArchitecture._get_file_generator_request_parameters_skeletoncCs<t|dd|jdit|dd|jdidS)Nrrzr)rmap_head_object_paramsrrmap_list_objects_v2_params)rarcrYrYrZrkBs  z-CommandArchitecture._map_request_payer_paramscCsHt|d|j|dkr"t|d|jd|jdddSdS)NrrEsse_c_copy_sourcesse_c_copy_source_key)sse_c sse_c_key)rrrr)rarcrDrYrYrZrlNs   z%CommandArchitecture._map_sse_c_paramsr]) rerfrg__doc__r@rrrKrXrrjrkrlrYrYrYrZrNs   rc@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZd ddZddZdS)!rz{ This class is used to do some initial error based on the parameters and arguments passed to the command line. cCs||_||_||_d|vrd|jd<d|vrd|jd<d|vr$d|jd<|jdvr.d|jd<|jdkr:d|jd <dSd|jd <dS) a! Stores command name and parameters. Ensures that the ``dir_op`` flag is true if a certain command is being used. :param cmd: The name of the command, e.g. "rm". :param parameters: A dictionary of parameters. :param usage: A usage string rFr&TrCN)r$r&r3ris_move)rrusage)rarrrrYrYrZr@es       zCommandParameters.__init__cCsx|||||d}||jd<t|dkr!|d|jd<n t|dkr.|d|jd<|||dS)a Reformats the parameters dictionary by including a key and value for the source and the destination. If a destination is not used the destination is the same as the source to ensure the destination always have some value. rrYrr,r N)check_path_type_normalize_s3_trailing_slashrr _validate_streaming_paths_validate_path_args_validate_sse_c_args)rarjsrc_pathrYrYrZrs      zCommandParameters.add_pathscCsjd|jd<|jddks|jddkr3|jdks|jdr"tdd |jd<d|jd<d |jd <dSdS) NFrMrY-r rrzEStreaming currently is only compatible with non-recursive cp commandsTonly_show_errors)rrrr4rrYrYrZrs   z+CommandParameters._validate_streaming_pathscCs|j}|jdkr||d|drtd|d|dfd|dkr:|ds:tj|ds8td|ddSd |dkrU|d rWtj|dsYt|ddSdSdSdS) NrrYr z)Cannot mv a file onto itself: '%s' - '%s'r^rDrMz)The user-provided path %s does not exist.r_r) rr _same_pathr4osr~existsr7makedirs)rarrYrYrZrs$ z%CommandParameters._validate_path_argscCsJ|jddks dS||krdS|dr#tj|}|tj||kSdS)NrDrEFTr)rrrr~basenamejoin)rarYr src_baserYrYrZrs  zCommandParameters._same_pathcCsRt|D]"\}}|dr&t|dd\}}|s&|ds&|d7}|||<qdS)Nrkrnr) enumeratervrr)rarjrr~rrIrYrYrZrs z.CommandParameters._normalize_s3_trailing_slashcCsgdgdgdgdggd}d}d|j|jf}tt|D]}||dr/|d}q!|d}q!|j||vrB||jd <d Std |) zn This initial check ensures that the path types for the specified command is correct. )rr$r)r&r3r)rEr_r^rQlocal locallocalrbzusage: aws s3 %s %srkrQrrDr'N)rrrr rvrr*)rarj template_typerDrrrYrYrZrs"   z!CommandParameters.check_path_typecC|j|jd<dS)NrX)rXrrarcrYrYrZrzCommandParameters.add_regioncCs*d|vrt|d|jd<dSd|jd<dS)z6 Adds endpoint_url to the parameters. rSNgetattrrrrYrYrZrs z"CommandParameters.add_endpoint_urlcCr)Nr_)r_rrrYrYrZrrz CommandParameters.add_verify_sslcCst|dd|jd<dS)Nryr)rarbrYrYrZrszCommandParameters.add_page_sizecCs||d|dS)Nr)_validate_sse_c_arg%_validate_sse_c_copy_source_for_pathsrrYrYrZrs  z&CommandParameters._validate_sse_c_argsrcCs|d}d|dd}d|dd}|j|r(|j|s(td||f|j|r<|j|s>td||fdSdS)N_keyz--r/rz1It %s is specified, %s must be specified as well.)replacerrr4)ra sse_c_typesse_c_key_typesse_c_type_paramsse_c_key_type_paramrYrYrZrs&    z%CommandParameters._validate_sse_c_argcCs*|jdr|jddkrtddSdS)NrrDrEz:--sse-c-copy-source is only supported for copy operations.)rrr4rrYrYrZrs z7CommandParameters._validate_sse_c_copy_source_for_pathsN)r)rerfrgrr@rrrrrrrrrrrrrrYrYrYrZr`s       rr])frloggingr botocore.clientrdateutil.parserr dateutil.tzr awscli.compatrrawscli.customizations.commandsr#awscli.customizations.s3.comparatorr(awscli.customizations.s3.fileinfobuilderr #awscli.customizations.s3.fileformatr &awscli.customizations.s3.filegeneratorr !awscli.customizations.s3.fileinfor awscli.customizations.s3.filtersr "awscli.customizations.s3.s3handlerrawscli.customizations.s3.utilsrrrrrrrawscli.customizations.utilsr*awscli.customizations.s3.syncstrategy.baserrrawscli.customizations.s3r getLoggerreLOGGERrrrrrr9FOLLOW_SYMLINKSNO_FOLLOW_SYMLINKSNO_GUESS_MIME_TYPE CONTENT_TYPEr!r ACLGRANTSSSESSE_C SSE_C_KEYSSE_KMS_KEY_IDSSE_C_COPY_SOURCESSE_C_COPY_SOURCE_KEY STORAGE_CLASSWEBSITE_REDIRECT CACHE_CONTROLCONTENT_DISPOSITIONCONTENT_ENCODINGCONTENT_LANGUAGE SOURCE_REGIONEXPIRESrrrrr" NO_PROGRESSrrIGNORE_GLACIER_WARNINGSFORCE_GLACIER_TRANSFERrrr[r\rhrrrrrrr#r%r2objectrrrYrYrYrZsj              $                     (!+    0