o
    h#                     @   s  d Z ddlmZ ddlmZ dd Zdd ZzddlmZ	 W n e
y)   d	Z	Y nw zdd	lZW n e
y;   d	ZY nw zdd	lZW n e
yM   d	ZY nw zdd	lZW n e
y_   d	ZY nw zdd	lZW n e
yq   d	ZY nw zdd	lZW n e
y   d	ZY nw d
ejvrejd
g e_zdd	lZdZdZdd ZW n e
y   d	Zd	ZY nw zdd	lZddlmZ ddlmZmZ dd Zdd ZW n e
y   d	Zdd Zdd ZY nw ed	ured	urdd	lZddlmZ G dd deZ dd Z!ndd Z!dZ"dZ#dZ$d	S ) z
The `compat` module provides support for backwards compatibility with older
versions of Django/Python, and compatibility wrappers around optional packages.
    )settings)Viewc                 C   s   t | tr
| dS | S )Nz
iso-8859-1)
isinstancebytesdecode)value r   ]/var/www/html/magazine_api/magazine_env/lib/python3.10/site-packages/rest_framework/compat.pyunicode_http_header	   s   

r
   c                 C   s6   t j| j d dkr|jt| jddddS |  S )NZENGINEzdjango.db.backends.oraclepkT)Zflat)Zpk__in)r   Z	DATABASESdbfiltersetZvalues_listdistinct)Zquerysetbaser   r   r	   r      s   r   )fieldsNpatchzmarkdown.extensions.tocZ	baselevelc                 C   s2   t g}t tdii}tj||d}t| || S )z}
        Simple wrapper around :func:`markdown.markdown` to set the base level
        of '#' style headers to <h2>.
        2)
extensionsextension_configs)HEADERID_EXT_PATHLEVEL_PARAMmarkdownMarkdownmd_filter_add_syntax_highlightconvert)textr   r   mdr   r   r	   apply_markdownL   s   
r   )HtmlFormatter)	TextLexerget_lexer_by_namec                 C   s&   t |dd}td|d}t| ||S )NF)stripallT)Znowrapstyle)r!   r   pygments	highlight)r   langr#   lexer	formatterr   r   r	   pygments_highlightf   s   r)   c                 C   s   t | d}|dS )Nr#   z
.highlight)r   Zget_style_defs)r#   r(   r   r   r	   pygments_cssk   s   

r+   c                 C   s   | S Nr   )r   r&   r#   r   r   r	   r)   r      c                 C   s   d S r,   r   r*   r   r   r	   r+   u   r-   )Preprocessorc                   @   s.   e Zd ZedejejB Ze Z	dd Z
dS )CodeBlockPreprocessorz^\s*``` *([^\n]+)\n(.+?)^\s*```c                    s*    fdd} j |d|}|dS )Nc              	      sv   z	t | d}W n ttfy   t }Y nw | ddd}t|| j}|ddddd	d
}d| S )N      	z    z

z
&nbsp;

z<br />z\@@z

%s

)	r!   group
ValueError	NameErrorr    replacer$   r%   r(   )mr'   codeselfr   r	   repl   s   
z'CodeBlockPreprocessor.run.<locals>.replr3   )patternsubjoinsplit)r<   linesr=   retr   r;   r	   run   s   	
zCodeBlockPreprocessor.runN)__name__
__module____qualname__recompileMSr>   r   r(   rD   r   r   r   r	   r/      s    r/   c                 C   s   | j t dd dS )Nr%   (   T)Zpreprocessorsregisterr/   r   r   r   r	   r      s   r   c                 C   s   dS )NFr   rN   r   r   r	   r      r-   ),:)z, : )rO   rQ   )%__doc__Zdjango.confr   Zdjango.views.genericr   r
   r   Zdjango.contrib.postgresr   Zpostgres_fieldsImportErrorZcoreapiZuritemplateZ
coreschemayamlrequestsZhttp_method_namesr   r   r   r   r$   Zpygments.formattersr   Zpygments.lexersr    r!   r)   r+   rH   Zmarkdown.preprocessorsr.   r/   r   ZSHORT_SEPARATORSZLONG_SEPARATORSZINDENT_SEPARATORSr   r   r   r	   <module>   s    
	
