U
    7h                     @   sT   d dl mZ d dlZd dlZd dlZd dlmZ dd Zd
ddZG dd	 d	Z	dS )    )BytesION)settingsc              	   C   sT   ddl m} ddlm} z| |  }t|j}|W S  |tfk
rN   Y dS X dS )zp
    Load a templatetag library on multiple Django versions.

    Returns None if the library isn't loaded.
    r   )get_installed_libraries)InvalidTemplateLibraryN)Zdjango.template.backends.djangor   Zdjango.template.libraryr   	importlibimport_moduleregisterKeyError)libnamer   r   lib r   R/var/www/formularioweb/env/lib/python3.8/site-packages/django_extensions/compat.pyload_tag_library   s    
r   c                 C   s2   t tdd}|r.|D ]}| |kr||    S q|S )z Read template settings Z	TEMPLATESN)getattrr   )Ztemplate_keydefaultZtemplates_varZtdictr   r   r   get_template_setting   s    r   c                   @   s0   e Zd ZdZejdfddZdd Zdd Zd	S )
UnicodeWriterz
    CSV writer which will write rows to CSV file "f",
    which is encoded in the given encoding.
    We are using this custom UnicodeWriter for python versions 2.x
    utf-8c                 K   s:   t  | _tj| jfd|i|| _|| _t| | _d S )Ndialect)r   queuecsvwriterstreamcodecsgetincrementalencoderencoder)selffr   encodingkwdsr   r   r   __init__/   s    zUnicodeWriter.__init__c                 C   sR   | j dd |D  | j }|d}| j|}| j| | j	d d S )Nc                 S   s   g | ]}| d qS )r   )encode).0sr   r   r   
<listcomp>6   s     z*UnicodeWriter.writerow.<locals>.<listcomp>r   r   )
r   writerowr   getvaluedecoder   r!   r   writetruncate)r   rowdatar   r   r   r%   5   s    

zUnicodeWriter.writerowc                 C   s   |D ]}|  | qd S )N)r%   )r   rowsr*   r   r   r   	writerowsA   s    zUnicodeWriter.writerowsN)	__name__
__module____qualname____doc__r   excelr    r%   r-   r   r   r   r   r   (   s   r   )N)
ior   r   r   r   Zdjango.confr   r   r   r   r   r   r   r   <module>   s   

