§
    ¥”j‘  ã                   ó  — d dl Z d dlmZ d dlmZ d dlm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 G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        ZdS )é    N)Úgettext_lazy)Ú
exceptions)Úunicode_http_header©Ú_reverse)Úapi_settings)Úreplace_query_param)Ú
_MediaTypec                   óL   — e Zd Zej        Zej        Zej        Z	d„ Z
dd„Zd„ ZdS )ÚBaseVersioningc                 ó`   — d}t          |                     | j        j        ¬¦  «        ¦  «        ‚)Nz.{cls}.determine_version() must be implemented.)Úcls)ÚNotImplementedErrorÚformatÚ	__class__Ú__name__)ÚselfÚrequestÚargsÚkwargsÚmsgs        úh/var/www/finuniver-perm.ru/html/portfolio/venv/lib/python3.11/site-packages/rest_framework/versioning.pyÚdetermine_versionz BaseVersioning.determine_version   s6   € Ø>ˆÝ! #§*¢*Ø”Ô'ð #-ñ #
ô #
ñ ô ð 	ó    Nc                 ó$   — t          |||||fi |¤ŽS ©Nr   )r   Úviewnamer   r   r   r   Úextras          r   ÚreversezBaseVersioning.reverse   s    € Ý˜ $¨°¸ÐIÐIÀ5ÐIÐIÐIr   c                 óD   — | j         sdS |d ur|| j        k    p|| j         v S )NT)Úallowed_versionsÚdefault_version)r   Úversions     r   Úis_allowed_versionz!BaseVersioning.is_allowed_version   s<   € ØÔ$ð 	Ø�4Ø Ð$ÐH¨°DÔ4HÒ)Hð 3Ø˜DÔ1Ð1ð	4r   ©NNNN)r   Ú
__module__Ú__qualname__r   ÚDEFAULT_VERSIONr"   ÚALLOWED_VERSIONSr!   ÚVERSION_PARAMÚversion_paramr   r   r$   © r   r   r   r      sc   € € € € € Ø"Ô2€OØ#Ô4ÐØ Ô.€Mðð ð ðJð Jð Jð Jð4ð 4ð 4ð 4ð 4r   r   c                   ó.   — e Zd ZdZ ed¦  «        Zd„ ZdS )ÚAcceptHeaderVersioningzb
    GET /something/ HTTP/1.1
    Host: example.com
    Accept: application/json; version=1.0
    z#Invalid version in "Accept" header.c                 óò   — t          |j        ¦  «        }|j                             | j        | j        ¦  «        }t          |¦  «        }|                      |¦  «        st          j	        | j
        ¦  «        ‚|S r   )r
   Úaccepted_media_typeÚparamsÚgetr+   r"   r   r$   r   ÚNotAcceptableÚinvalid_version_message)r   r   r   r   Ú
media_typer#   s         r   r   z(AcceptHeaderVersioning.determine_version*   sm   € Ý Ô ;Ñ<Ô<ˆ
ØÔ#×'Ò'¨Ô(:¸DÔ<PÑQÔQˆÝ% gÑ.Ô.ˆØ×&Ò& wÑ/Ô/ð 	IÝÔ*¨4Ô+GÑHÔHÐHØˆr   N)r   r&   r'   Ú__doc__Ú_r4   r   r,   r   r   r.   r.   "   s@   € € € € € ðð ð
  ˜aÐ EÑFÔFÐðð ð ð ð r   r.   c                   ó@   ‡ — e Zd ZdZ ed¦  «        Zd„ Zdˆ fd„	Zˆ xZS )ÚURLPathVersioninga8  
    To the client this is the same style as `NamespaceVersioning`.
    The difference is in the backend - this implementation uses
    Django's URL keyword arguments to determine the version.

    An example URL conf for two views that accept two different versions.

    urlpatterns = [
        re_path(r'^(?P<version>[v1|v2]+)/users/$', users_list, name='users-list'),
        re_path(r'^(?P<version>[v1|v2]+)/users/(?P<pk>[0-9]+)/$', users_detail, name='users-detail')
    ]

    GET /1.0/something/ HTTP/1.1
    Host: example.com
    Accept: application/json
    zInvalid version in URL path.c                 ó´   — |                      | j        | j        ¦  «        }|€| j        }|                      |¦  «        st	          j        | j        ¦  «        ‚|S r   )r2   r+   r"   r$   r   ÚNotFoundr4   ©r   r   r   r   r#   s        r   r   z#URLPathVersioning.determine_versionI   sX   € Ø—*’*˜TÔ/°Ô1EÑFÔFˆØˆ?ØÔ*ˆGà×&Ò& wÑ/Ô/ð 	DÝÔ% dÔ&BÑCÔCÐCØˆr   Nc                 ór   •— |j         �| j        |j         i|pi ¥} t          ¦   «         j        |||||fi |¤ŽS r   )r#   r+   Úsuperr   ©r   r   r   r   r   r   r   r   s          €r   r   zURLPathVersioning.reverseR   s\   ø€ ØŒ?Ð&àÔ" G¤Oðà�<˜RðˆFð
 �u‰wŒwŒØ�d˜F G¨Vð
ð 
Ø7<ð
ð 
ð 	
r   r%   ©	r   r&   r'   r6   r7   r4   r   r   Ú__classcell__©r   s   @r   r9   r9   6   si   ø€ € € € € ðð ð   ˜aÐ >Ñ?Ô?Ððð ð ð	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
r   r9   c                   óF   ‡ — e Zd ZdZ ed¦  «        Zd„ Zdˆ fd„	Zd„ Zˆ xZ	S )ÚNamespaceVersioninga£  
    To the client this is the same style as `URLPathVersioning`.
    The difference is in the backend - this implementation uses
    Django's URL namespaces to determine the version.

    An example URL conf that is namespaced into two separate versions

    # users/urls.py
    urlpatterns = [
        path('/users/', users_list, name='users-list'),
        path('/users/<int:pk>/', users_detail, name='users-detail')
    ]

    # urls.py
    urlpatterns = [
        path('v1/', include('users.urls', namespace='v1')),
        path('v2/', include('users.urls', namespace='v2'))
    ]

    GET /1.0/something/ HTTP/1.1
    Host: example.com
    Accept: application/json
    zBInvalid version in URL path. Does not match any version namespace.c                 óæ   — t          |dd ¦  «        }|�|j        s| j        S |j                             d¦  «        }|D ]}|                      |¦  «        r|c S Œt          j        | j        ¦  «        ‚)NÚresolver_matchú:)ÚgetattrÚ	namespacer"   Úsplitr$   r   r;   r4   )r   r   r   r   rF   Úpossible_versionsr#   s          r   r   z%NamespaceVersioning.determine_versionx   s‹   € Ý  Ð*:¸DÑAÔAˆØÐ!¨Ô)AÐ!ØÔ'Ð'ð +Ô4×:Ò:¸3Ñ?Ô?ÐØ(ð 	ð 	ˆGØ×&Ò& wÑ/Ô/ð Ø���ðåÔ! $Ô">Ñ?Ô?Ð?r   Nc                 óz   •— |j         �|                      ||¦  «        } t          ¦   «         j        |||||fi |¤ŽS r   )r#   Úget_versioned_viewnamer>   r   r?   s          €r   r   zNamespaceVersioning.reverse„   sR   ø€ ØŒ?Ð&Ø×2Ò2°8¸WÑEÔEˆHØ�u‰wŒwŒØ�d˜F G¨Vð
ð 
Ø7<ð
ð 
ð 	
r   c                 ó   — |j         dz   |z   S )NrG   )r#   )r   r   r   s      r   rM   z*NamespaceVersioning.get_versioned_viewname‹   s   € ØŒ Ñ$ xÑ/Ð/r   r%   )
r   r&   r'   r6   r7   r4   r   r   rM   rA   rB   s   @r   rD   rD   ^   s{   ø€ € € € € ðð ð.  ˜aÐ dÑeÔeÐð
@ð 
@ð 
@ð
ð 
ð 
ð 
ð 
ð 
ð0ð 0ð 0ð 0ð 0ð 0ð 0r   rD   c                   óN   — e Zd ZdZ ej        d¦  «        Z ed¦  «        Zd„ Z	dS )ÚHostNameVersioningzX
    GET /something/ HTTP/1.1
    Host: v1.example.com
    Accept: application/json
    z,^([a-zA-Z0-9]+)\.[a-zA-Z0-9]+\.[a-zA-Z0-9]+$zInvalid version in hostname.c                 ó(  — |                      ¦   «                              d¦  «        \  }}}| j                             |¦  «        }|s| j        S |                     d¦  «        }|                      |¦  «        st          j        | j	        ¦  «        ‚|S )NrG   é   )
Úget_hostÚ	partitionÚhostname_regexÚmatchr"   Úgroupr$   r   r;   r4   )	r   r   r   r   ÚhostnameÚ	separatorÚportrV   r#   s	            r   r   z$HostNameVersioning.determine_version˜   sŽ   € Ø$+×$4Ò$4Ñ$6Ô$6×$@Ò$@ÀÑ$EÔ$EÑ!ˆ�)˜TØÔ#×)Ò)¨(Ñ3Ô3ˆØð 	(ØÔ'Ð'Ø—+’+˜a‘.”.ˆØ×&Ò& wÑ/Ô/ð 	DÝÔ% dÔ&BÑCÔCÐCØˆr   N)
r   r&   r'   r6   ÚreÚcompilerU   r7   r4   r   r,   r   r   rP   rP   �   sR   € € € € € ðð ð
  �R”ZÐ OÑPÔP€NØ˜aÐ >Ñ?Ô?Ððð ð ð ð r   rP   c                   ó@   ‡ — e Zd ZdZ ed¦  «        Zd„ Zdˆ fd„	Zˆ xZS )ÚQueryParameterVersioningza
    GET /something/?version=0.1 HTTP/1.1
    Host: example.com
    Accept: application/json
    z#Invalid version in query parameter.c                 ó¬   — |j                              | j        | j        ¦  «        }|                      |¦  «        st          j        | j        ¦  «        ‚|S r   )Úquery_paramsr2   r+   r"   r$   r   r;   r4   r<   s        r   r   z*QueryParameterVersioning.determine_version®   sP   € ØÔ&×*Ò*¨4Ô+=¸tÔ?SÑTÔTˆØ×&Ò& wÑ/Ô/ð 	DÝÔ% dÔ&BÑCÔCÐCØˆr   Nc                 óˆ   •—  t          ¦   «         j        |||||fi |¤Ž}|j        �t          || j        |j        ¦  «        S |S r   )r>   r   r#   r	   r+   )	r   r   r   r   r   r   r   Úurlr   s	           €r   r   z QueryParameterVersioning.reverse´   sX   ø€ Ø�e‰gŒgŒoØ�d˜F G¨Vð
ð 
Ø7<ð
ð 
ˆð Œ?Ð&Ý& s¨DÔ,>ÀÄÑPÔPÐPØˆ
r   r%   r@   rB   s   @r   r^   r^   ¦   si   ø€ € € € € ðð ð
  ˜aÐ EÑFÔFÐðð ð ðð ð ð ð ð ð ð ð ð r   r^   )r[   Údjango.utils.translationr   r7   Úrest_frameworkr   Úrest_framework.compatr   Úrest_framework.reverser   Úrest_framework.settingsr   Ú*rest_framework.templatetags.rest_frameworkr	   Úrest_framework.utils.mediatypesr
   r   r.   r9   rD   rP   r^   r,   r   r   ú<module>rj      s’  ðØ 	€	€	€	à 6Ð 6Ð 6Ð 6Ð 6Ð 6à %Ð %Ð %Ð %Ð %Ð %Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø +Ð +Ð +Ð +Ð +Ð +Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø JÐ JÐ JÐ JÐ JÐ JØ 6Ð 6Ð 6Ð 6Ð 6Ð 6ð4ð 4ð 4ð 4ð 4ñ 4ô 4ð 4ð*ð ð ð ð ˜^ñ ô ð ð(%
ð %
ð %
ð %
ð %
˜ñ %
ô %
ð %
ðP.0ð .0ð .0ð .0ð .0˜.ñ .0ô .0ð .0ðbð ð ð ð ˜ñ ô ð ð.ð ð ð ð ˜~ñ ô ð ð ð r   