
    ^fd                     x    d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	  G d d          Z
 G d	 d
e
          ZdS )zb
inspectors.py   # Per-endpoint view introspection

See schemas.__init__.py for package overview.
    N)WeakKeyDictionary)	smart_str)api_settings)
formattingc                       e Zd ZdZ ej        d          Zd Zd Zd Z	e
d             Zej        d             Zej        d             Zd	 Zd
 ZdS )ViewInspectorz[
    Descriptor class on APIView.

    Provide subclass for per-view schema generation
    z^[a-zA-Z][0-9A-Za-z_]*:c                 ,    t                      | _        d S N)r   instance_schemasselfs    S/var/www/html/env/lib/python3.11/site-packages/rest_framework/schemas/inspectors.py__init__zViewInspector.__init__   s     1 3 3    c                 @    || j         v r| j         |         S || _        | S )a%  
        Enables `ViewInspector` as a Python _Descriptor_.

        This is how `view.schema` knows about `view`.

        `__get__` is called when the descriptor is accessed on the owner.
        (That will be when view.schema is called in our case.)

        `owner` is always the owner class. (An APIView, or subclass for us.)
        `instance` is the view instance or `None` if accessed from the class,
        rather than an instance.

        See: https://docs.python.org/3/howto/descriptor.html for info on
        descriptor usage.
        r   view)r   instanceowners      r   __get__zViewInspector.__get__   s,      t,,,(22	r   c                 0    || j         |<   |	||_        d S d S r
   r   )r   r   others      r   __set__zViewInspector.__set__2   s(    */h'!EJJJ r   c                 2    | j         
J d            | j         S )zView property.NzvSchema generation REQUIRES a view instance. (Hint: you accessed `schema` from the view class rather than an instance.)_viewr   s    r   r   zViewInspector.view7   s*     z%%E &%% zr   c                     || _         d S r
   r   )r   values     r   r   zViewInspector.view@   s    


r   c                     d | _         d S r
   r   r   s    r   r   zViewInspector.viewD   s    


r   c           	         | j         }t          |d|                                          }t          ||d          j        }|rH|                     ||                                t          j        t          |                              S |                     |t          |d|                                          |                                          S )z
        Determine a path description.

        This will be based on the method docstring if one exists,
        or else the class docstring.
        actionN)	r   getattrlower__doc___get_description_sectionr   dedentr   get_view_description)r   pathmethodr   method_namemethod_docstrings         r   get_descriptionzViewInspector.get_descriptionH   s     ydHfllnn=="4d;;C 	N00v||~~zGXYbcsYtYtGuGuvvv00wtXv||~~7^7^151J1J1L1LN N Nr   c                    d |                                 D             }d}ddi}|D ]`}| j                            |          r1|                    d          \  }}}	|	                                ||<   M||xx         d|z   z  cc<   at
          j        }
||v r||                                         S ||
v r*|
|         |v r ||
|                                                  S |d                                         S )Nc                     g | ]}|S  r/   ).0lines     r   
<listcomp>z:ViewInspector._get_description_section.<locals>.<listcomp>[   s    ;;;$;;;r    :
)
splitlinesheader_regexmatch	partitionstripr   SCHEMA_COERCE_METHOD_NAMES)r   r   headerdescriptionlinescurrent_sectionsectionsr1   	separatorleadcoerce_method_namess              r   r%   z&ViewInspector._get_description_sectionZ   s#   ;;+"8"8":":;;;8 	9 	9D &&t,, 937>>#3F3F0D,0JJLL)))))TD[8)))) +EXF#))+++((("6*h66 3F ;<BBDDD|!!###r   N)__name__
__module____qualname__r$   recompiler7   r   r   r   propertyr   setterdeleterr,   r%   r/   r   r   r   r      s          2:788L4 4 4  ," " "
   X 
[  [ 
\  \N N N$$ $ $ $ $r   r   c                   "     e Zd ZdZ fdZ xZS )DefaultSchemaz?Allows overriding AutoSchema using DEFAULT_SCHEMA_CLASS settingc                     t                                          ||          }t          |t                    s|S t          j        }t          |t                    s
J d             |            }||_        |S )NzTDEFAULT_SCHEMA_CLASS must be set to a ViewInspector (usually an AutoSchema) subclass)	superr   
isinstancerM   r   DEFAULT_SCHEMA_CLASS
issubclassr   r   )r   r   r   resultinspector_class	inspector	__class__s         r   r   zDefaultSchema.__get__r   s|    511&-00 	M&;/=99 	
 	
b	
 	
9 $O%%	!	r   )rD   rE   rF   r$   r   __classcell__)rV   s   @r   rM   rM   p   s>        II        r   rM   )r$   rG   weakrefr   django.utils.encodingr   rest_framework.settingsr   rest_framework.utilsr   r   rM   r/   r   r   <module>r\      s    
 
			 % % % % % % + + + + + + 0 0 0 0 0 0 + + + + + +^$ ^$ ^$ ^$ ^$ ^$ ^$ ^$B    M     r   