9(Zc@s)ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z m Z ddlZddlmZmZddlmZmZddlmZddlmZmZmZmZmZddlmZddlmZmZeje Z!d Z"d Z#d Z$ej%d Z&d dgZ'ej(ej)fZ*dgZ+de,fdYZ-dZ.dZ/dZ0dZ1dZ2e3dZ4de5fdYZ6e7dZ8e9dZ:dZ;e$dZ<e$dZ=dZ>d Z?dd!ZAe7d"ZBd#ZCd$ZDd%e5fd&YZEd'e5fd(YZFd)ZGd*ZHd+d,ZIdd-ZJd.ZKd/ZLd0ZMd1ZNd2ZOe3d3ZPe3d4ZQd5ZRd6e5fd7YZSd8e5fd9YZTdS(:iN(ttzlocalttzutc(tInvalidExpressionErrortConfigNotFound(tInvalidDNSNameErrort ClientError(tMetadataRetrievalError(tjsontquotet zip_longestturlsplitt urlunsplit(trequests(t OrderedDicttsixisAhttp://169.254.169.254/latest/meta-data/iam/security-credentials/s-._~s-z0-9][a-z0-9\-]*[a-z0-9]s us-gov-west-1sfips-us-gov-west-1t dualstackt_RetriesExceededErrorcBseZdZRS(s@Internal exception used when the number of retries are exceeded.(t__name__t __module__t__doc__(((s0/tmp/pip-build-wDUJoH/botocore/botocore/utils.pyR4scCsIt|doH|jjdtoH|jjddkoH|jdkS(sDetermines if the provided shape is the special header type jsonvalue. :type shape: botocore.shape :param shape: Shape to be inspected for the jsonvalue trait. :return: True if this type is a jsonvalue, False otherwise :rtype: Bool t serializationt jsonvaluetlocationtheadertstring(thasattrRtgettFalset type_name(tshape((s0/tmp/pip-build-wDUJoH/botocore/botocore/utils.pytis_json_value_header9s cCsd|jjd|jjd|j}|jdd}|jdd}tjdd|}|S(svReturns the module name for a service This is the value used in both the documentation and client class name tserviceAbbreviationtserviceFullNametAmazonttAWSs\W+(tmetadataRt service_nametreplacetretsub(t service_modeltname((s0/tmp/pip-build-wDUJoH/botocore/botocore/utils.pytget_service_module_nameHs  cCs|s dSt|S(Nt/(tremove_dot_segments(tpath((s0/tmp/pip-build-wDUJoH/botocore/botocore/utils.pytnormalize_url_pathWscCs|s dS|jd}g}xR|D]J}|r&|dkr&|dkr`|rm|jqmqp|j|q&q&W|ddkrd}nd}|ddkr|rd}nd}|dj||S(NR"R,t.s..ii(tsplittpoptappendtjoin(turlt input_urlt output_listtxtfirsttlast((s0/tmp/pip-build-wDUJoH/botocore/botocore/utils.pyR-]s"    cCsa| s|dkr%td|nx5dddgD]$}||kr5td|q5q5WdS(NR0t expressiont[t]t*(R(R;tinvalid((s0/tmp/pip-build-wDUJoH/botocore/botocore/utils.pytvalidate_jmespath_for_setxs  cCs|rt|n|jdd}|dt|dkrH|dnd}}|sjtd|n|r||kri||t j d |nXi} x]t|D]O} i| d 6|| d d 6|| dd6|| dd6|| dd6} qRW| S(Nsutf-8s R,iiRNROt{sQMetadata service returned non 200 status code of %s for url: %s, content body: %ss\Max number of attempts exceeded (%s) when attempting to retrieve data from metadata service.t role_namet AccessKeyIdt access_keytSecretAccessKeyt secret_keytTokenttokent Expirationt expiry_time(RLRJRKR[tcontenttdecodeR1tendswithtretrieve_iam_role_credentialsRtloadsRTRURWRtsorted( RMtdataR5RNROtrtfieldstfieldtvalt final_dataR]((s0/tmp/pip-build-wDUJoH/botocore/botocore/utils.pyRisB     !     (RRt DEFAULT_METADATA_SERVICE_TIMEOUTt!METADATA_SECURITY_CREDENTIALS_URLRPR[Ri(((s0/tmp/pip-build-wDUJoH/botocore/botocore/utils.pyRIs cCsx|D]}t||tra||krP||krPt||||q||||sR"N(thashlibtsha256titertupdatet hexdigesttdigest(Rtas_hextchecksumtchunk((Rs0/tmp/pip-build-wDUJoH/botocore/botocore/utils.pytcalculate_sha256s   csg}dtj}x<tfddD]}|j||jq1W|sj|djSxxt|dkrg}xSt|D]E\}}|dk r|j|||jq|j|qW|}qmWt j |dj dS( s\Calculate a tree hash checksum. For more information see: http://docs.aws.amazon.com/amazonglacier/latest/dev/checksum-calculations.html :param body: Any file like object. This has the same constraints as the ``body`` param in calculate_sha256 :rtype: str :returns: The hex version of the calculated tree hash ics jS(N(R}((Rtrequired_chunk_size(s0/tmp/pip-build-wDUJoH/botocore/botocore/utils.pyRsR"iitasciiiN( RRRR3RRRBt _in_pairsRtbinasciithexlifyRg(RtchunksRRt new_chunksR9tsecond((RRs0/tmp/pip-build-wDUJoH/botocore/botocore/utils.pytcalculate_tree_hashs "   cCst|}t||S(N(RR (titerablet shared_iter((s0/tmp/pip-build-wDUJoH/botocore/botocore/utils.pyRs tCachedPropertycBs eZdZdZdZRS(sA read only property that caches the initially computed value. This descriptor will only call the provided ``fget`` function once. Subsequent access to this property will return the cached value. cCs ||_dS(N(t_fget(RMtfget((s0/tmp/pip-build-wDUJoH/botocore/botocore/utils.pyRPscCs:|dkr|S|j|}||j|jj<|SdS(N(RRt__dict__R(RMtobjtclstcomputed_value((s0/tmp/pip-build-wDUJoH/botocore/botocore/utils.pyt__get__s  (RRRRPR(((s0/tmp/pip-build-wDUJoH/botocore/botocore/utils.pyRs tArgumentGeneratorcBsJeZdZedZdZddZdZdZdZ RS(sGenerate sample input based on a shape model. This class contains a ``generate_skeleton`` method that will take an input/output shape (created from ``botocore.model``) and generate a sample dictionary corresponding to the input/output shape. The specific values used are place holder values. For strings either an empty string or the member name can be used, for numbers 0 or 0.0 is used. The intended usage of this class is to generate the *shape* of the input structure. This can be useful for operations that have complex input shapes. This allows a user to just fill in the necessary data instead of worrying about the specific structure of the input arguments. Example usage:: s = botocore.session.get_session() ddb = s.get_service_model('dynamodb') arg_gen = ArgumentGenerator() sample_input = arg_gen.generate_skeleton( ddb.operation_model('CreateTable').input_shape) print("Sample input for dynamodb.CreateTable: %s" % sample_input) cCs ||_dS(N(t_use_member_names(RMtuse_member_names((s0/tmp/pip-build-wDUJoH/botocore/botocore/utils.pyRP*scCsg}|j||S(sGenerate a sample input. :type shape: ``botocore.model.Shape`` :param shape: The input shape. :return: The generated skeleton input corresponding to the provided input shape. (t_generate_skeleton(RMRtstack((s0/tmp/pip-build-wDUJoH/botocore/botocore/utils.pytgenerate_skeleton-s R"cCs |j|jz|jdkr2|j||S|jdkrQ|j||S|jdkrp|j||S|jdkr|jr|S|jrtj |jSdS|jdkrdS|jd krd S|jd krt S|jd kr t j d dddddSWd|j XdS(Nt structureRwtmapRR"tintegertlongiRgtbooleant timestampii(sintegerslong( R3R*Rt_generate_type_structuret_generate_type_listt_generate_type_mapRtenumtrandomtchoiceRVRR2(RMRRR*((s0/tmp/pip-build-wDUJoH/botocore/botocore/utils.pyR:s.   cCse|j|jdkriSt}x9|jjD](\}}|j||d||| sz           (       !>   $   -   ! `    >       ~