U!\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?d6dwd6Z4dZ5dZ6dZ7dZ8dZ9dZ:e;dZ<de=fdYZ>de?fdYZ@de@fdYZAeBdZCdZDeEdZFdZGe/dZHe/dZIdZJdZKddZMeBdZNdZOdZPde?fdYZQde?fdYZRdZSdZTddZUddZVdZWdZXdZYdZZe;dZ[e;dZ\dZ]dZ^de?fdYZ_de?fdYZ`dZadZbddZcdS(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.dynamodbttaggingcCs't|tr|S|jdkSdS(s~Ensures a boolean value if a string or boolean is provided For strings, the value for True/False is case insensitive ttrueN(t isinstancetbooltlower(tval((s2/tmp/pip-install-usGedi/botocore/botocore/utils.pytensure_booleanscCsIt|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(thasattrRWtgettFalset type_name(tshape((s2/tmp/pip-install-usGedi/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+(tmetadataR]t service_nametreplacetretsub(t service_modeltname((s2/tmp/pip-install-usGedi/botocore/botocore/utils.pytget_service_module_names  cCs|s dSt|S(Nt/(tremove_dot_segments(tpath((s2/tmp/pip-install-usGedi/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(NReRot.s..ii(tsplittpoptappendtjoin(turlt input_urlt output_listtxtfirsttlast((s2/tmp/pip-install-usGedi/botocore/botocore/utils.pyRps"    cCsa| s|dkr%td|nx5dddgD]$}||kr5td|q5q5WdS(NRst expressiont[t]t*(R (R~tinvalid((s2/tmp/pip-install-usGedi/botocore/botocore/utils.pytvalidate_jmespath_for_sets  cCs|rt|n|jdd}|dt|dkrH|dnd}}|sjtd|n|r||kri||scCs'|js#|j|ddttStS(Nsno bodyR(tcontentRRR^(RR((s2/tmp/pip-install-usGedi/botocore/botocore/utils.pyRDs cCsRd}||j|jg}|r>|d7}|j|jntj||dS(NsHMetadata service returned %s response with status code of %s for url: %ss, content body: %s(RRxRvRRR(RRt reason_to_logRt statementt logger_args((s2/tmp/pip-install-usGedi/botocore/botocore/utils.pyRJs  N(RRRRt DEFAULT_METADATA_SERVICE_TIMEOUTtMETADATA_BASE_URLRRRRRRR^R(((s2/tmp/pip-install-usGedi/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((s2/tmp/pip-install-usGedi/botocore/botocore/utils.pytretrieve_iam_role_credentials^s$        cCs|jd|jd|jjS(NRR(Rt _URL_PATHt_needs_retry_for_role_namettext(R((s2/tmp/pip-install-usGedi/botocore/botocore/utils.pyR}s  cCs2|jd|j|d|j}tj|jS(NRR(RRt_needs_retry_for_credentialsRtloadsR(RRtr((s2/tmp/pip-install-usGedi/botocore/botocore/utils.pyRs   cCsAytj|jtSWn"tk r<|j|dtSXdS(Ns invalid json(RRRR^t ValueErrorRR(RR((s2/tmp/pip-install-usGedi/botocore/botocore/utils.pyt_is_invalid_jsons  cCs|j|p|j|S(N(RR(RR((s2/tmp/pip-install-usGedi/botocore/botocore/utils.pyRscCs+|j|p*|j|p*|j|S(N(RRR(RR((s2/tmp/pip-install-usGedi/botocore/botocore/utils.pyRscCs8x1|jD]&}||kr tjd|tSq WtS(Ns3Retrieved credentials is missing required field: %s(t_REQUIRED_CREDENTIAL_FIELDSRRR^R(RRtfield((s2/tmp/pip-install-usGedi/botocore/botocore/utils.pyRs ( RRRRRRRRRRR(((s2/tmp/pip-install-usGedi/botocore/botocore/utils.pyRXs      cCsx|D]}t||tra||krP||krPt||||q||||sReN(thashlibtsha256titertupdatet hexdigesttdigest(R"tas_hextchecksumtchunk((R"s2/tmp/pip-install-usGedi/botocore/botocore/utils.pytcalculate_sha256~s   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(s2/tmp/pip-install-usGedi/botocore/botocore/utils.pyR#sReiitasciiiN( R$R%R&RvR)R(Rt _in_pairsRtbinasciithexlifytdecode(R"tchunksR%R,t new_chunksR|tsecond((R"R.s2/tmp/pip-install-usGedi/botocore/botocore/utils.pytcalculate_tree_hashs "   cCst|}t||S(N(R&R(titerablet shared_iter((s2/tmp/pip-install-usGedi/botocore/botocore/utils.pyR0s 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((s2/tmp/pip-install-usGedi/botocore/botocore/utils.pyRscCs:|dkr|S|j|}||j|jj<|SdS(N(RR;t__dict__R(Rtobjtclstcomputed_value((s2/tmp/pip-install-usGedi/botocore/botocore/utils.pyt__get__s  (RRRRRA(((s2/tmp/pip-install-usGedi/botocore/botocore/utils.pyR:s 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((s2/tmp/pip-install-usGedi/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(RR`tstack((s2/tmp/pip-install-usGedi/botocore/botocore/utils.pytgenerate_skeletons RecCs |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 structureRtmapR[RetintegertlongiR gtbooleant timestampii(sintegerslong( RvRmR_t_generate_type_structuret_generate_type_listt_generate_type_mapRCtenumtrandomtchoiceRR Ru(RR`RFRm((s2/tmp/pip-install-usGedi/botocore/botocore/utils.pyRE s.   cCse|j|jdkriSt}x9|jjD](\}}|j||d|||ytt|jrtSWnttjfk r9nXtS(s: Returns whether we should bypass proxies or not. (R R RvRRtsockettgaierrorR^(Rx((s2/tmp/pip-install-usGedi/botocore/botocore/utils.pyR6s 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(R]Rtcgit parse_headerR(Rtdefaultt content_typeR((s2/tmp/pip-install-usGedi/botocore/botocore/utils.pytget_encoding_from_headersKs  (dRjRtloggingR R$R1RRRRRRRtdateutil.parserRt dateutil.tzRRRtbotocore.awsrequesttbotocore.httpsessiontbotocore.compatRRRRRRRR t*botocore.vendored.six.moves.urllib.requestR R tbotocore.exceptionsR R RRRRRRRt getLoggerRRRRt SAFE_CHARSR_RgRRt EVENT_ALIASESRVRaRnRrRpRRRt ExceptionRtobjectRRR^RRtopenRRRRRRRR!R-R7R0R:RBReRkRsRnRuRRRRRRRRRRRR(((s2/tmp/pip-install-usGedi/botocore/botocore/utils.pyt s                (@         !XQ    $   -   ! `    >       b