ó T!¶\c@sÑddlZddlmZddlmZddlmZddlmZmZddl m Z ddl m Z dd l mZmZd d lmZd d lmZejeƒZd efd„ƒYZdS(iÿÿÿÿN(tpartiali(t ServiceAction(t WaiterAction(t ResourceMetatServiceResource(tCollectionFactory(t ResourceModel(tbuild_identifierstResourceHandleri(tResourceLoadException(t docstringtResourceFactorycBsªeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„Zd„Zed„ZRS(sW A factory to create new :py:class:`~boto3.resources.base.ServiceResource` classes from a :py:class:`~boto3.resources.model.ResourceModel`. There are two types of lookups that can be done: one on the service itself (e.g. an SQS resource) and another on models contained within the service (e.g. an SQS Queue resource). cCstƒ|_||_dS(N(Rt_collection_factoryt_emitter(tselftemitter((s8/tmp/pip-install-usGedi/boto3/boto3/resources/factory.pyt__init__&s c CsÙtjd|j|ƒt|||jƒ}d }|jrR|jj|jƒ}n|j |ƒt |jd|ƒ}i|d6}|j d|d|d|d|ƒ|j d|d|d|d|ƒ|j d|d|d|d|d|ƒ|jd|d|d|ƒ|jd|d|d|d|ƒ|jd|d|d|d|ƒ|}|j|krkd}n|jd|}tg} |jd k r½|jjd |d |d | d|ƒntt|ƒt| ƒ|ƒS( s{ Loads a resource from a model, creating a new :py:class:`~boto3.resources.base.ServiceResource` subclass with the correct properties and methods, named based on the service and resource name, e.g. EC2.Instance. :type resource_name: string :param resource_name: Name of the resource to look up. For services, this should match the ``service_name``. :type single_resource_json_definition: dict :param single_resource_json_definition: The loaded json of a single service resource or resource definition. :type service_context: :py:class:`~boto3.utils.ServiceContext` :param service_context: Context about the AWS service :rtype: Subclass of :py:class:`~boto3.resources.base.ServiceResource` :return: The service or resource class. s Loading %s:%stresource_modeltmetatattrst resource_nametservice_contextRt.screating-resource-class.%stclass_attributest base_classesN(tloggertdebugt service_nameRtresource_json_definitionstNonetshapet service_modelt shape_fortload_rename_mapRt_load_identifierst _load_actionst_load_attributest_load_collectionst_load_has_relationst _load_waitersRR temitttypetstrttuple( RRtsingle_resource_json_definitionRRRRRtcls_nameR((s8/tmp/pip-install-usGedi/boto3/boto3/resources/factory.pytload_from_definition*sX                        cCsDx=|jD]2}|jj|jƒ|j||ƒ||j¹sRR3t member_modelRR1t snake_cased( RRR tdictR/tget_attributestitemst_create_identifier_aliast_create_autoload_property( RRRRRRRR/t attributesR1t orig_nametmembertprop((s8/tmp/pip-install-usGedi/boto3/boto3/resources/factory.pyR$ªs*          cCs@x9|jD].}|jd|jd|d|ƒ||j((s8/tmp/pip-install-usGedi/boto3/boto3/resources/factory.pys £scsJˆr4|jjdkr4t|dƒr4|jƒnˆ|i|jjƒS(NR6(RRlRRmR6(R(thandlert needs_data(s8/tmp/pip-install-usGedi/boto3/boto3/resources/factory.pyt get_reference¦s' RMRb( RtresourcetpathtanyR/R*R1RcR tReferenceDocstringReRfRg(RVRMRRR((RR€s8/tmp/pip-install-usGedi/boto3/boto3/resources/factory.pyRP’s      c saˆjj‰‡‡‡‡fd†}tˆƒ|_tjd|dˆdˆjdtƒ|_|S(s± Creates a new method which acts as a functools.partial, passing along the instance's low-level `client` to the new resource class' constructor. c s£g}ˆjjˆiƒ}ˆjdˆd|dˆƒ}ˆjj}|dk rx-t||ƒD]\}}|j|ƒqaWnt|d|j j |Œ||ŽS(NRR,Rtclient( RRpR.R‚R/RRR0RRR†( RRsRttpositional_argstjson_deft resource_clsR/R3tvalue(RVR1RRN(s8/tmp/pip-install-usGedi/boto3/boto3/resources/factory.pytcreate_resourceÂs     Rtsub_resource_modelRRb( R‚R)R*RcR tSubResourceDocstringRReRf(RVRNRRR‹((RVR1RRNs8/tmp/pip-install-usGedi/boto3/boto3/resources/factory.pyRR¹s    c sÇt|d|d|ƒ‰|ri‡fd†}tjd|jd|d|jd|d|jd tƒ}n?‡fd †}tjd|d|jd |d|jd tƒ}t|jƒ|_ ||_ |S( sc Creates a new method which makes a request to the underlying AWS service. RyRcs"ˆ|||Ž}||j_dS(N(RRl(RRsRttresponse(R;(s8/tmp/pip-install-usGedi/boto3/boto3/resources/factory.pyt do_actionøst action_nameRRit load_modelRRbcs4ˆ|||Ž}t|dƒr0d|j_n|S(NR6(RmRRRl(RRsRtRŽ(R;(s8/tmp/pip-install-usGedi/boto3/boto3/resources/factory.pyRsR4( RR tLoadReloadDocstringR1R RRetActionDocstringR*RcRf(RVR4RRR5Rtlazy_docstring((R;s8/tmp/pip-install-usGedi/boto3/boto3/resources/factory.pyR8ås,             (Rct __module__RfRR.R"R#R$R%R&RSR'R2RDRER\RLRPRRReR8(((s8/tmp/pip-install-usGedi/boto3/boto3/resources/factory.pyR s$  c  #  "     !   ' -(tloggingt functoolsRR;RRtbaseRRt collectionRtmodelRRŽRRt exceptionsR tdocsR t getLoggerRcRtobjectR (((s8/tmp/pip-install-usGedi/boto3/boto3/resources/factory.pyts