
    NwgQ                     j    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y)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y)ViewInspectorz[
    Descriptor class on APIView.

    Provide subclass for per-view schema generation
    z^[a-zA-Z][0-9A-Za-z_]*:c                 "    t               | _        y N)r   instance_schemasselfs    X/var/www/horilla/myenv/lib/python3.12/site-packages/rest_framework/schemas/inspectors.py__init__zViewInspector.__init__   s     1 3    c                 N    || 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                 6    || j                   |<   |||_        y y r
   r   )r   r   others      r   __set__zViewInspector.__set__2   s$    */h'!EJ r   c                 @    | j                   J d       | j                   S )zView property.zvSchema 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-     zz% 	
E	
% zzr   c                     || _         y r
   r   )r   values     r   r   zViewInspector.view@   s	    
r   c                     d | _         y r
   r   r   s    r   r   zViewInspector.viewD   s	    
r   c           	      p   | j                   }t        |d|j                               }t        ||d      j                  }|r=| j	                  ||j                         t        j                  t        |                  S | j	                  |t        |d|j                               |j                               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     yydHflln="4d;CC00v||~zGXGXYbcsYtGuvv00wtXv||~7^151J1J1LN Nr   c                    |j                         }d}ddi}|D ]V  }| j                  j                  |      r)|j                  d      \  }}}	|	j	                         ||<   G||xx   d|z   z  cc<   X t
        j                  }
||v r||   j	                         S ||
v r|
|   |v r||
|      j	                         S |d   j	                         S )N :
)
splitlinesheader_regexmatch	partitionstripr   SCHEMA_COERCE_METHOD_NAMES)r   r   headerdescriptionlinescurrent_sectionsectionsline	separatorleadcoerce_method_namess              r   r%   z&ViewInspector._get_description_sectionZ   s    &&(8 	9D  &&t,37>>#3F0D,0JJL))TD[8)	9 +EEXF#))++(("6*h6 3F ;<BBDD|!!##r   N)__name__
__module____qualname__r$   recompiler2   r   r   r   propertyr   setterdeleterr,   r%    r   r   r   r      sx     2::78L4,"
   
[[  
\\ 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   
isinstancerJ   r   DEFAULT_SCHEMA_CLASS
issubclassr   r   )r   r   r   resultinspector_class	inspector	__class__s         r   r   zDefaultSchema.__get__r   s^    51&-0M&;;/=9 	
b	
9 $%	!	r   )r@   rA   rB   r$   r   __classcell__)rS   s   @r   rJ   rJ   p   s    I r   rJ   )r$   rC   weakrefr   django.utils.encodingr   rest_framework.settingsr   rest_framework.utilsr   r   rJ   rH   r   r   <module>rY      s4   
 
 % + 0 +^$ ^$BM r   