File: //opt/alt/python37/lib/python3.7/site-packages/boto3/resources/__pycache__/factory.cpython-37.pyc
B
�P�e�X � @ s� d dl Z d dlmZ ddlmZ ddlmZ ddlmZm Z ddl
mZmZ dd l
mZ dd
lmZ ddlmZmZ e �e�ZG dd
� d
�ZdS )� N)�partial� )� docstring)�ResourceLoadException� )�
ServiceAction�WaiterAction)�ResourceMeta�ServiceResource)�CollectionFactory)�
ResourceModel)�ResourceHandler�build_identifiersc @ s� e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z dd� Z
dd� Zdd� Zdd� Z
dd� Zdd� Zdd� Zdd� Zdd� Zd d!� Zd&d#d$�Zd%S )'�ResourceFactoryaW
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).
c C s t � | _|| _d S )N)r �_collection_factory�_emitter)�selfZemitter� r �H/opt/alt/python37/lib/python3.7/site-packages/boto3/resources/factory.py�__init__% s zResourceFactory.__init__c
C s" t �d|j|� t|||j�}d}|jr6|j�|j�}|�|� t |j|d�}d|i}| j
||||d� | j||||d� | j|||||d� | j
|||d� | j||||d� | j||||d� |}|j|kr�d }|jd
| }tg} | jdk �r| jjd|� �|| |d� tt|�t| �|�S )
a{
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.
z
Loading %s:%sN)�resource_model�meta)�attrsr �
resource_namer )r r r �service_context)r r r r r )r r r r
�.zcreating-resource-class.)Zclass_attributes�base_classesr )�logger�debug�service_namer �resource_json_definitions�shape�
service_model� shape_forZload_rename_mapr �_load_identifiers�
_load_actions�_load_attributes�_load_collections�_load_has_relations�
_load_waitersr
r �emit�type�str�tuple)
r r �single_resource_json_definitionr r r! r r �cls_namer r r r �load_from_definition) sp
z$ResourceFactory.load_from_definitionc C s4 x.|j D ]$}|j �|j� | �||�||j<