݁[c@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddlmZmZddlZddlZddlZddlmZmZmZmZmZddlmZmZmZddlmZmZddl m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)ej*e+Z,dZ-dZ.d Z/ej0d Z1e'e&e(e)fZ2d gZ3iHd d 6d d6dd6dd6dd6dd6dd6dd6dd6dd6dd 6d!d"6d#d$6d%d&6d'd(6d)d*6d+d,6d-d.6d/d06d1d26d3d46d5d66d7d86d9d:6d;d<6d=d>6d?d@6dAdB6dCdD6dEdF6dGdH6dIdJ6dEdK6dLdM6dNdO6dPdQ6dRdS6dTdU6d+dV6d-dW6d5dX6dYdZ6d[d\6d]d^6d_d`6dadb6dcdd6dedf6dPdg6dhdi6djdk6djdl6dmdn6d_do6dpdq6drds6dtdu6dYdv6dwdx6dydz6d{d|6dad}6d~d6dd6dd6dd6dd6dd6dd6dd6d?d6dwd6Z4dZ5dZ6dZ7dZ8dZ9e:dZ;de<fdYZ=de>fdYZ?de?fdYZ@eAdZBdZCeDdZEdZFe/dZGe/dZHdZIdZJddZLeAdZMdZNdZOde>fdYZPde>fdYZQdZRdZSddZTddZUdZVdZWdZXdZYe:dZZe:dZ[dZ\dZ]de>fdYZ^de>fdYZ_dZ`dZaddZbdS(iN(ttzlocalttzutc(tjsontquotet zip_longestturlsplitt urlunsplit(t OrderedDicttsixturlparse(t getproxiest proxy_bypass( tInvalidExpressionErrortConfigNotFoundtInvalidDNSNameErrort ClientErrortMetadataRetrievalErrortEndpointConnectionErrortReadTimeoutErrortConnectionClosedErrortConnectTimeoutErrorishttp://169.254.169.254/s-._~s-z0-9][a-z0-9\-]*[a-z0-9]t dualstacksalexa-for-businessta4btalexaforbusinesst mediatailorsapi.mediatailortpricings api.pricingt sagemakers api.sagemakers api-gatewayt apigatewaysapplication-auto-scalingsapplication-autoscalingt appstreamt appstream2s auto-scalingt autoscalingsauto-scaling-planssautoscaling-planss cost-explorertces cloudhsm-v2t cloudhsmv2scloudsearch-domaintcloudsearchdomainscognito-identity-providers cognito-idpsconfig-servicetconfigscost-and-usage-report-servicetcursiot-data-planesdata.iotsiot-jobs-data-planes data.jobs.iotsmediastore-datasdata.mediastores data-pipelinet datapipelines device-farmt devicefarmsiot-1click-devices-servicesdevices.iot1clicksdirect-connectt directconnectsapplication-discovery-servicet discoverysdatabase-migration-servicetdmssdirectory-servicetdssdynamodb-streamstdynamodbstreamsselastic-beanstalktelasticbeanstalktefstelasticfilesystemselastic-load-balancingtelasticloadbalancingtemrtelasticmapreduceselastic-transcodertelastictranscodertelbselastic-load-balancing-v2telbv2tsestemailsmarketplace-entitlement-servicesentitlement.marketplaceselasticsearch-servicetesscloudwatch-eventsteventssiot-datas iot-jobs-datasiot1click-devicessiot-1click-projectssiot1click-projectsskinesis-analyticstkinesisanalyticss kinesis-videot kinesisvideoslex-model-building-services lex-modelsslex-runtime-services lex-runtimescloudwatch-logstlogssmachine-learningtmachinelearningsmarketplace-entitlementsmarketplace-commerce-analyticstmarketplacecommerceanalyticssmarketplace-meteringsmetering.marketplacetmeteringmarketplaces migration-hubtmghs models.lext cloudwatcht monitoringtmturksmturk-requestert opsworkscms opsworks-cmsprojects.iot1clicksresource-groups-tagging-apitresourcegroupstaggingapisroute-53troute53sroute-53-domainstroute53domainss runtime.lexssagemaker-runtimesruntime.sagemakertsimpledbtsdbssecrets-managertsecretsmanagertserverlessapplicationrepositorytserverlessreposservice-catalogtservicecatalogtsfntstatest stepfunctionssstorage-gatewaytstoragegatewaysstreams.dynamodbttaggingcCsIt|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(thasattrRQtgettFalset type_name(tshape((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pytis_json_value_headers 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+(tmetadataRWt service_nametreplacetretsub(t service_modeltname((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pytget_service_module_names  cCs|s dSt|S(Nt/(tremove_dot_segments(tpath((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pytnormalize_url_pathscCs|s dS|jd}g}xR|D]J}|r&|dkr&|dkr`|rm|jqmqp|j|q&q&W|ddkrd}nd}|ddkr|rd}nd}|dj||S(NR_Rit.s..ii(tsplittpoptappendtjoin(turlt input_urlt output_listtxtfirsttlast((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pyRjs"    cCsa| s|dkr%td|nx5dddgD]$}||kr5td|q5q5WdS(NRmt expressiont[t]t*(R (Rxtinvalid((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pytvalidate_jmespath_for_sets  cCs|rt|n|jdd}|dt|dkrH|dnd}}|sjtd|n|r||kri|||d7}|j|jntj||dS(NsHMetadata service returned %s response with status code of %s for url: %ss, content body: %s(RRrRpRRR(RRt reason_to_logRt statementt logger_args((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pyR?s  N(RRRRt DEFAULT_METADATA_SERVICE_TIMEOUTtMETADATA_BASE_URLRRRRRRRXR(((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pyRs $   tInstanceMetadataFetchercBs_eZdZddddgZdZdZdZdZd Zd Z d Z RS( s*latest/meta-data/iam/security-credentials/t AccessKeyIdtSecretAccessKeytTokent ExpirationcCsy|j}|j|}|j|rdi|d6|dd6|dd6|dd6|dd 6Sd |krd |krtjd |niSWn'|jk rtjd |jnXiS(Nt role_nameRt access_keyRt secret_keyRttokenRt expiry_timetCodetMessages7Error response received when retrievingcredentials: %s.s\Max number of attempts exceeded (%s) when attempting to retrieve data from metadata service.(t _get_iam_rolet_get_credentialst_contains_all_credential_fieldsRRRR(RRt credentials((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pytretrieve_iam_role_credentialsSs$        cCs|jd|jd|jjS(NRR(Rt _URL_PATHt_needs_retry_for_role_namettext(R((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pyRrs  cCs2|jd|j|d|j}tj|jS(NRR(RRt_needs_retry_for_credentialsRtloadsR(RRtr((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pyRxs   cCsAytj|jtSWn"tk r<|j|dtSXdS(Ns invalid json(RRRRXt ValueErrorRR(RR((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pyt_is_invalid_jsons  cCs|j|p|j|S(N(RR(RR((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pyRscCs+|j|p*|j|p*|j|S(N(RRR(RR((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pyRscCs8x1|jD]&}||kr tjd|tSq WtS(Ns3Retrieved credentials is missing required field: %s(t_REQUIRED_CREDENTIAL_FIELDSRRRXR(RRtfield((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pyRs ( RRRRRRRRRRR(((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pyRMs      cCsx|D]}t||tra||krP||krPt||||q||||sR_N(thashlibtsha256titertupdatet hexdigesttdigest(R tas_hextchecksumtchunk((R sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pytcalculate_sha256ss   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((R trequired_chunk_size(sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pyR!sR_iitasciiiN( R"R#R$RpR'R&Rt _in_pairsRtbinasciithexlifytdecode(R tchunksR#R*t new_chunksRvtsecond((R R,sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pytcalculate_tree_hashs "   cCst|}t||S(N(R$R(titerablet shared_iter((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pyR.s 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(Rtfget((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pyRscCs:|dkr|S|j|}||j|jj<|SdS(N(RR9t__dict__R(Rtobjtclstcomputed_value((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pyt__get__s  (RRRRR?(((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pyR8s 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(Rtuse_member_names((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pyRscCsg}|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(RRZtstack((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pytgenerate_skeletons 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 structureRtmapRUR_tintegertlongiR gtbooleant timestampii(sintegerslong( RpRgRYt_generate_type_structuret_generate_type_listt_generate_type_mapRAtenumtrandomtchoiceRR Ro(RRZRDRg((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pyRCs.   cCse|j|jdkriSt}x9|jjD](\}}|j||d|||ytt|jrtSWnttjfk r9nXtS(s: Returns whether we should bypass proxies or not. (R R RtRR tsockettgaierrorRX(Rr((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pyR+s s ISO-8859-1cCs_|jd}|sdStj|\}}d|krK|djdSd|kr[|SdS(sReturns encodings from given HTTP Header Dict. :param headers: dictionary to extract encoding from. :param default: default encoding if the content-type is text s content-typetcharsets'"RN(RWRtcgit parse_headerR(Rtdefaultt content_typeR((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pytget_encoding_from_headers@s  (cRdRtloggingR R"R/RRRPRRRtdateutil.parserRt dateutil.tzRRRtbotocore.awsrequesttbotocore.httpsessiontbotocore.compatRRRRRRRR t*botocore.vendored.six.moves.urllib.requestR R tbotocore.exceptionsR R RRRRRRRt getLoggerRRRRt SAFE_CHARSR]ReRRt EVENT_ALIASESR[RhRlRjR}RRt ExceptionRtobjectRRRXRRtopenRRRRRRRRR+R5R.R8R@RcRiRqRlRsRRRRRRRRRRRR(((sf/private/var/folders/71/gccz42bs2nl23mxwq3vp1qmhw5xjlw/T/pip-install-k836tR/botocore/botocore/utils.pyt s                (@         !XQ    $   -   ! `    >       b