Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/openstack/__pycache__/resource.cpython-39.pyc
Ðазад
a t�h8O � @ sV d Z ddlZddlZddlZddlZddlZddlZddlm Z ddlm Z ddlZddlm Z ddlmZ ddlmZ ddlmZ dd lmZ d Zd(dd�ZG d d� d�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� dej�ZG dd� d�ZG dd� d�ZG dd� de�ZG dd � d �Z d!d"� Z!d)d$d%�Z"d&d'� Z#dS )*a� The :class:`~openstack.resource.Resource` class is a base class that represent a remote resource. The attributes that comprise a request or response for this resource are specified as class members on the Resource subclass where their values are of a component type, including :class:`~openstack.resource.Body`, :class:`~openstack.resource.Header`, and :class:`~openstack.resource.URI`. For update management, :class:`~openstack.resource.Resource` employs a series of :class:`~openstack.resource._ComponentManager` instances to look after the attributes of that particular component type. This is particularly useful for Body and Header types, so that only the values necessary are sent in requests to the server. When making requests, each of the managers are looked at to gather the necessary URI, body, and header data to build a request to be sent via keystoneauth's sessions. Responses from keystoneauth are then converted into this Resource class' appropriate components and types and then returned to the caller. � N)�adapter)�discover)� structures)�_log)� exceptions)�format)�utilsz{name}_seenc C s� |s| S t |t�rbt| tttf�rL|s*| S g }| D ]}|�t||�� q2|S |r\t| |�gS | gS t| |�rp| S t| |�s�t |tj�r�|� | �S t| t �r�|f i | ��S || �S d S �N)� issubclass�list� isinstance�tuple�set�append� _convert_typer � FormatterZdeserialize�dict)�valueZ data_type� list_type�ret�raw� r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/openstack/resource.pyr 6 s* r c @ s6 e Zd ZdZeZddd�Zdd� Zdd� Zd d � Z dS )�_BaseComponentNFc K sN || _ || _|dur&|r&|s&|� | _n|| _|| _|| _|| _|| _|| _dS )aT A typed descriptor for a component that makes up a Resource :param name: The name this component exists as on the server :param type: The type this component is expected to be by the server. By default this is None, meaning any value you specify will work. If you specify type=dict and then set a component to a string, __set__ will fail, for example. :param default: Typically None, but any other default can be set. :param alias: If set, alternative attribute on object to return. :param aka: If set, additional name attribute would be available under. :param alternate_id: When `True`, this property is known internally as a value that can be sent with requests that require an ID but when `id` is not a name the Resource has. This is a relatively uncommon case, and this setting should only be used once per Resource. :param list_type: If type is `list`, list_type designates what the type of the elements of the list should be. :param coerce_to_default: If the Component is None or not present, force the given default to be used. If a default is not given but a type is given, construct an empty version of the type in question. N)�name�type�default�alias�aka�alternate_idr �coerce_to_default) �selfr r r r r r r r �kwargsr r r �__init__\ s z_BaseComponent.__init__c C s� |d u r| S t || j�}z|| j }W np ty� | jr�tj| jd�}t ||d�s�tj| jd�}t||d� t || j�}t||� | Y S | j Y S 0 |d u r�d S t || j| j�S )N)r FT) �getattr�keyr �KeyErrorr �_SEEN_FORMATr �setattr�delattrr r r r )r! �instance�owner� attributesr Z alias_flagZ seen_flagr r r �__get__� s$ z_BaseComponent.__get__c C sH | j r|d u r| j}|| jkr.t|| j| j�}t|| j�}||| j<