o
    ^"<f)                     @   s   d Z ddlZddlZddlZddlZddlZddlmZ ddlZddl	m
Z
 ddlmZ ddlmZ ddlmZmZ dZd	Zd
ZG dd deZG dd deZG dd dZG dd dZe ZdS )z
Settings and configuration for Django.

Read values from the module specified by the DJANGO_SETTINGS_MODULE environment
variable, and then from django.conf.global_settings; see the global_settings.py
for a list of all possible variables.
    N)Path)global_settings)ImproperlyConfigured)RemovedInDjango40Warning)
LazyObjectemptyDJANGO_SETTINGS_MODULEzZThe PASSWORD_RESET_TIMEOUT_DAYS setting is deprecated. Use PASSWORD_RESET_TIMEOUT instead.zThe DEFAULT_HASHING_ALGORITHM transitional setting is deprecated. Support for it and tokens, cookies, sessions, and signatures that use SHA-1 hashing algorithm will be removed in Django 4.0.c                   @   s    e Zd ZdZdd Zdd ZdS )SettingsReferencez
    String subclass which references a current settings value. It's treated as
    the value in memory but serializes to a settings.NAME attribute reference.
    c                 C   s   t | |S N)str__new__selfvaluesetting_name r   K/var/www/html/kck/venv/lib/python3.10/site-packages/django/conf/__init__.pyr   )   s   zSettingsReference.__new__c                 C   s
   || _ d S r
   )r   r   r   r   r   __init__,      
zSettingsReference.__init__N)__name__
__module____qualname____doc__r   r   r   r   r   r   r	   $   s    r	   c                       sv   e Zd ZdZdddZdd Zdd Z fd	d
Z fddZe	fddZ
edd Zedd Zedd Z  ZS )LazySettingsz
    A lazy proxy for either global Django settings or a custom settings object.
    The user can manually configure settings prior to using them. Otherwise,
    Django uses the settings module pointed to by DJANGO_SETTINGS_MODULE.
    Nc                 C   s>   t jt}|s|rd| nd}td|tf t|| _dS )z
        Load the settings module pointed to by the environment variable. This
        is used the first time settings are needed, if the user hasn't
        configured settings manually.
        z
setting %ssettingszRequested %s, but settings are not configured. You must either define the environment variable %s or call settings.configure() before accessing settings.N)osenvirongetENVIRONMENT_VARIABLEr   Settings_wrapped)r   namesettings_moduledescr   r   r   _setup6   s   zLazySettings._setupc                 C   s   | j tu rdS dd| j ji S )Nz<LazySettings [Unevaluated]>z$<LazySettings "%(settings_module)s">r"   )r    r   SETTINGS_MODULEr   r   r   r   __repr__G   s
   
zLazySettings.__repr__c                 C   s^   | j tu r
| | t| j |}|dv r|dur| |}n
|dkr(|s(td|| j|< |S )z<Return the value of a setting and cache it in self.__dict__.>   	MEDIA_URL
STATIC_URLN
SECRET_KEYz)The SECRET_KEY setting must not be empty.)r    r   r$   getattr_add_script_prefixr   __dict__)r   r!   valr   r   r   __getattr__O   s   


zLazySettings.__getattr__c                    s4   |dkr
| j   n| j |d t || dS )z
        Set the value of setting. Clear all cached values if _wrapped changes
        (@override_settings does this) or clear single values when set.
        r    N)r-   clearpopsuper__setattr__r   r!   r   	__class__r   r   r3   _   s   zLazySettings.__setattr__c                    s   t  | | j|d dS )z3Delete a setting and clear it from cache if needed.N)r2   __delattr__r-   r1   r   r!   r5   r   r   r7   j   s   zLazySettings.__delattr__c                 K   sV   | j tur	tdt|}| D ]\}}| std| t||| q|| _ dS )z
        Called to manually configure the settings. The 'default_settings'
        parameter sets where to retrieve any unspecified values from (its
        argument must support attribute access (__getattr__)).
        zSettings already configured.zSetting %r must be uppercase.N)r    r   RuntimeErrorUserSettingsHolderitemsisupper	TypeErrorsetattr)r   default_settingsoptionsholderr!   r   r   r   r   	configureo   s   

zLazySettings.configurec                 C   s(   |  dr| S ddlm} d| | f S )z
        Add SCRIPT_NAME prefix to relative paths.

        Useful when the app is being served at a subpath and manually prefixing
        subpath to STATIC_URL and MEDIA_URL in settings is inconvenient.
        )zhttp://zhttps:///r   )get_script_prefixz%s%s)
startswithdjango.urlsrD   )r   rD   r   r   r   r,   ~   s   
	zLazySettings._add_script_prefixc                 C   s
   | j tuS )z9Return True if the settings have already been configured.)r    r   r&   r   r   r   
configured   s   
zLazySettings.configuredc                 C   sF   t  }|d \}}}}|tjtjstj	t
tdd | dS )N   )
stacklevelPASSWORD_RESET_TIMEOUT_DAYS)	tracebackextract_stackrE   r   pathdirnamedjango__file__warningswarn*PASSWORD_RESET_TIMEOUT_DAYS_DEPRECATED_MSGr   r/   )r   stackfilename_r   r   r   rK      s   
z(LazySettings.PASSWORD_RESET_TIMEOUT_DAYSr
   )r   r   r   r   r$   r'   r/   r3   r7   r   rB   staticmethodr,   propertyrG   rK   __classcell__r   r   r5   r   r   0   s    


r   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )r   c                 C   s`  t tD ]}| rt| |tt| q|| _t| j}d}t | _	t |D ](}| rOt||}||v rCt
|ttfsCtd| t| || | j	| q'| drq| dr^tdt| d| jd d d  ttt | dr|ttt ttd	r| jrtd
}|j| jd }| r| std| j | jtjd< t   d S d S d S )N)INSTALLED_APPSTEMPLATE_DIRSLOCALE_PATHSz*The %s setting must be a list or a tuple. rK   PASSWORD_RESET_TIMEOUTzJPASSWORD_RESET_TIMEOUT_DAYS/PASSWORD_RESET_TIMEOUT are mutually exclusive.<      DEFAULT_HASHING_ALGORITHMtzsetz/usr/share/zoneinforC   zIncorrect timezone setting: %sTZ)!dirr   r<   r>   r+   r%   	importlibimport_moduleset_explicit_settings
isinstancelisttupler   addis_overriddenrK   rR   rS   rT   r   (DEFAULT_HASHING_ALGORITHM_DEPRECATED_MSGhasattrtime	TIME_ZONEr   joinpathsplitexists
ValueErrorr   r   rb   )r   r"   settingmodtuple_settingssetting_valuezoneinfo_rootzone_info_filer   r   r   r      sF   



zSettings.__init__c                 C   s
   || j v S r
   )rh   )r   rv   r   r   r   rm      r   zSettings.is_overriddenc                 C   s   d| j j| jd S )Nz<%(cls)s "%(settings_module)s">)clsr"   )r6   r   r%   r&   r   r   r   r'      s   zSettings.__repr__N)r   r   r   r   rm   r'   r   r   r   r   r      s    3r   c                       sX   e Zd ZdZdZdd Zdd Z fddZ fd	d
Zdd Z	dd Z
dd Z  ZS )r:   z$Holder for user configured settings.Nc                 C   s   t  | jd< || _dS )z
        Requests for configuration variables not in this class are satisfied
        from the module specified in default_settings (if possible).
        _deletedN)rg   r-   r?   )r   r?   r   r   r   r      s   
zUserSettingsHolder.__init__c                 C   s"   |  r	|| jv rtt| j|S r
   )r<   r}   AttributeErrorr+   r?   r8   r   r   r   r/      s   zUserSettingsHolder.__getattr__c                    s^   | j | |dkrt| d|d d d  ttt |dkr&ttt t 	|| d S )NrK   r^   r_   r`   ra   )
r}   discardr>   rR   rS   rT   r   rn   r2   r3   r4   r5   r   r   r3      s   zUserSettingsHolder.__setattr__c                    s*   | j | t| |rt | d S d S r
   )r}   rl   ro   r2   r7   r8   r5   r   r   r7      s   
zUserSettingsHolder.__delattr__c                    s&   t  fddg  jt jD S )Nc                 3   s    | ]
}| j vr|V  qd S r
   )r}   ).0sr&   r   r   	<genexpr>   s    
z-UserSettingsHolder.__dir__.<locals>.<genexpr>)sortedr-   rd   r?   r&   r   r&   r   __dir__   s   zUserSettingsHolder.__dir__c                 C   s6   || j v }|| jv }t| jddd |}|p|p|S )Nrm   c                 S   s   dS )NFr   )r   r   r   r   <lambda>  s    z2UserSettingsHolder.is_overridden.<locals>.<lambda>)r}   r-   r+   r?   )r   rv   deletedset_locallyset_on_defaultr   r   r   rm     s   

z UserSettingsHolder.is_overriddenc                 C   s   dd| j ji S )Nz	<%(cls)s>r|   )r6   r   r&   r   r   r   r'     s   zUserSettingsHolder.__repr__)r   r   r   r   r%   r   r/   r3   r7   r   rm   r'   rZ   r   r   r5   r   r:      s    	r:   )r   re   r   rp   rL   rR   pathlibr   rP   django.confr   django.core.exceptionsr   django.utils.deprecationr   django.utils.functionalr   r   r   rT   rn   r   r	   r   r   r:   r   r   r   r   r   <module>   s,    p>
3