ó
pÁìVc           @  s  d  Z  d d l m Z d d l Z d d l m Z d d l m Z m Z d d l	 m
 Z
 m Z m Z d d l m Z d d l m Z y d d l Z Wn! e k
 r· d d	 l m Z n Xd
 „  Z d „  Z d „  Z d „  Z d „  Z y d d l m Z Wn e k
 rd Z n Xy d d l m Z Wn e k
 r@d Z n Xy d d l Z Wn e k
 rjd Z n Xy d d l Z Wn e k
 r”d Z n Xe j  d7 k r°d „  Z! n	 d „  Z! d Z" y. d e j# k rìd d l" Z" d d l$ Z" n  Wn e k
 r n Xe j  d8 k r?d d l% m& Z& m' Z' d d l% m( Z( m) Z) n˜ d d l% m& Z* d d l% m' Z+ d d l% m( Z, d d l% m) Z- d e* f d „  ƒ  YZ& d e+ f d  „  ƒ  YZ' d! e, f d" „  ƒ  YZ( d# e- f d$ „  ƒ  YZ) d% e j. k rüe j. d% g e _. n  y d d l/ Z/ d& „  Z0 Wn e k
 r.d Z0 n Xe j1 rMd9 Z2 d: Z3 d; Z4 n d< Z2 d= Z3 d> Z4 e j  d? k r¡d d/ l5 m6 Z6 d d0 l7 m8 Z8 d d1 l9 m: Z: n d Z6 Z: Z8 y d d2 l% m; Z; Wn e k
 rÜd Z; n Xd3 „  Z< d d d4 „ Z= d5 „  Z> d6 „  Z? d S(@   u   
The `compat` module provides support for backwards compatibility with older
versions of Django/Python, and compatibility wrappers around optional packages.
iÿÿÿÿ(   t   unicode_literalsN(   t   settings(   t
   connectiont   transaction(   t   Contextt   RequestContextt   Template(   t   six(   t   View(   t	   importlibc         C  s&   t  j r t |  ƒ j d ƒ St |  ƒ S(   Nu   utf-8(   R   t   PY2t   reprt   decode(   t   instance(    (    so   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/compat.pyt   unicode_repr   s    	c         C  s   t  j r |  j d ƒ S|  S(   Nu   utf-8(   R   R
   t   encode(   t   value(    (    so   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/compat.pyt   unicode_to_repr   s    	c         C  s#   t  |  t j ƒ r |  j d ƒ S|  S(   Nu
   iso-8859-1(   t
   isinstanceR   t   binary_typeR   (   R   (    (    so   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/compat.pyt   unicode_http_header'   s    c         C  s@   t  |  d ƒ r |  j ƒ  S|  j d t |  j ƒ |  j d Sd  S(   Nu   total_secondsg     õ@g    €„.A(   t   hasattrt   total_secondst   dayst   floatt   secondst   microseconds(   t	   timedelta(    (    so   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/compat.pyR   .   s    
c         C  sI   t  j |  j d d k r? | j d t |  j d d t ƒƒ ƒ S|  j ƒ  S(   Nu   ENGINEu   django.db.backends.oraclet   pk__inu   pkt   flat(   R   t	   DATABASESt   dbt   filtert   sett   values_listt   Truet   distinct(   t   querysett   base(    (    so   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/compat.pyR$   6   s    %(   t   fields(   t	   JSONFieldi   i   c         C  s   |  S(   N(    (   t   text(    (    so   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/compat.pyt   clean_manytomany_helptextZ   s    c         C  s    |  j  d ƒ r |  d  }  n  |  S(   NuE    Hold down "Control", or "Command" on a Mac, to select more than one.i»ÿÿÿ(   t   endswith(   R)   (    (    so   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/compat.pyR*   _   s    u   guardiani   (   t   MinValueValidatort   MaxValueValidator(   t   MinLengthValidatort   MaxLengthValidator(   R,   (   R-   (   R.   (   R/   R,   c           B  s   e  Z d  „  Z RS(   c         O  s5   | j  d |  j ƒ |  _ t t |  ƒ j | | Ž  d  S(   Nu   message(   t   popt   messaget   superR,   t   __init__(   t   selft   argst   kwargs(    (    so   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/compat.pyR3   |   s    (   t   __name__t
   __module__R3   (    (    (    so   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/compat.pyR,   {   s   R-   c           B  s   e  Z d  „  Z RS(   c         O  s5   | j  d |  j ƒ |  _ t t |  ƒ j | | Ž  d  S(   Nu   message(   R0   R1   R2   R-   R3   (   R4   R5   R6   (    (    so   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/compat.pyR3   ‚   s    (   R7   R8   R3   (    (    (    so   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/compat.pyR-      s   R.   c           B  s   e  Z d  „  Z RS(   c         O  s5   | j  d |  j ƒ |  _ t t |  ƒ j | | Ž  d  S(   Nu   message(   R0   R1   R2   R.   R3   (   R4   R5   R6   (    (    so   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/compat.pyR3   ˆ   s    (   R7   R8   R3   (    (    (    so   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/compat.pyR.   ‡   s   R/   c           B  s   e  Z d  „  Z RS(   c         O  s5   | j  d |  j ƒ |  _ t t |  ƒ j | | Ž  d  S(   Nu   message(   R0   R1   R2   R/   R3   (   R4   R5   R6   (    (    so   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/compat.pyR3   Ž   s    (   R7   R8   R3   (    (    (    so   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/compat.pyR/      s   u   patchc         C  s4   d g } t  } t j d | d | ƒ } | j |  ƒ S(   u}   
        Simple wrapper around :func:`markdown.markdown` to set the base level
        of '#' style headers to <h2>.
        u   headerid(level=2)t
   extensionst	   safe_mode(   t   Falset   markdownt   Markdownt   convert(   R)   R9   R:   t   md(    (    so   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/compat.pyt   apply_markdown   s    	u   ,u   :u   , u   : t   ,t   :s   , s   : (   t   DurationField(   t   parse_duration(   t   duration_string(   t   DecimalValidatorc           C  sy   t  t d ƒ rC t j j d t ƒ ru t j r@ t j t ƒ q@ qu n2 t j	 ƒ  ru t j
 ƒ  rh t j ƒ  n  t j ƒ  n  d  S(   Nu   set_rollbacku   ATOMIC_REQUESTS(   R   R   R   t   settings_dictt   getR;   t   in_atomic_blockt   set_rollbackR#   t
   is_managedt   is_dirtyt   rollbackt   leave_transaction_management(    (    (    so   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/compat.pyRJ   Ä   s    	c         C  sf   t  j d k  s t |  t ƒ rO | r6 t | | ƒ } n t | ƒ } |  j | ƒ S|  j | d | ƒSd S(   u‚  
    Passing Context or RequestContext to Template.render is deprecated in 1.9+,
    see https://github.com/django/django/pull/3883 and
    https://github.com/django/django/blob/1.9rc1/django/template/backends/django.py#L82-L84

    :param template: Template instance
    :param context: dict
    :param request: Request instance
    :return: rendered template as SafeText instance
    i   i   t   requestN(   i   i   (   t   djangot   VERSIONR   R   R   R   t   render(   t   templatet   contextRO   (    (    so   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/compat.pyt   template_renderÕ   s    c         C  sC   t  j d k  r |  j ƒ  Sg  |  j D] } | j j s# | ^ q# Sd S(   u6  
    Django 1.8 changed meta api, see
    https://docs.djangoproject.com/en/1.8/ref/models/meta/#migrating-old-meta-api
    https://code.djangoproject.com/ticket/12663
    https://github.com/django/django/pull/3848

    :param opts: Options instance
    :return: list of relations except many-to-many ones
    i   i	   N(   i   i	   (   RP   RQ   t   get_all_related_objectst   related_objectst   fieldt   many_to_many(   t   optst   r(    (    so   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/compat.pyRV   ë   s    

c         C  sC   t  j d k  r |  j ƒ  Sg  |  j D] } | j j r# | ^ q# Sd S(   u¤   
    Django 1.8 changed meta api, see docstr in compat.get_all_related_objects()

    :param opts: Options instance
    :return: list of many-to-many relations
    i   i	   N(   i   i	   (   RP   RQ   t$   get_all_related_many_to_many_objectsRW   RX   RY   (   RZ   R[   (    (    so   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/compat.pyR\   û   s    
(   i   i   (   i   i   (   u   ,u   :(   u   , u   : (   u   ,u   : (   RA   RB   (   s   , s   : (   RA   s   : (   i   i   (@   t   __doc__t
   __future__R    RP   t   django.confR   t	   django.dbR   R   t   django.templateR   R   R   t   django.utilsR   t   django.views.genericR   R	   t   ImportErrorR   R   R   R   R$   t   django.contrib.postgresR'   t   postgres_fieldst   Nonet   django.contrib.postgres.fieldsR(   t   django_filterst   crispy_formsRQ   R*   t   guardiant   INSTALLED_APPSt   guardian.shortcutst   django.core.validatorsR,   R-   R.   R/   t   DjangoMinValueValidatort   DjangoMaxValueValidatort   DjangoMinLengthValidatort   DjangoMaxLengthValidatort   http_method_namesR<   R@   t   PY3t   SHORT_SEPARATORSt   LONG_SEPARATORSt   INDENT_SEPARATORSt   django.db.modelsRC   t   django.utils.dateparseRD   t   django.utils.durationRE   RF   RJ   RU   RV   R\   (    (    (    so   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/compat.pyt   <module>   s    						



	

		
		