o
    b)                     @   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emptyZ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   S/var/www/secure340b-portal/env/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_URLNZ
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   r1   _   s   zLazySettings.__setattr__c                    s   t  | | j|d dS )z3Delete a setting and clear it from cache if needed.N)r0   __delattr__r+   r/   r   r    r3   r   r   r5   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optionsZ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)
startswithZdjango.urlsrA   )r   rA   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_stackrB   r   pathdirnamedjango__file__warningswarn*PASSWORD_RESET_TIMEOUT_DAYS_DEPRECATED_MSGr   r-   )r   stackfilename_r   r   r   rG      s   
z(LazySettings.PASSWORD_RESET_TIMEOUT_DAYSr	   )r   r   r   r   r#   r&   r-   r1   r5   r   r?   staticmethodr*   propertyrC   rG   __classcell__r   r   r3   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)ZINSTALLED_APPSZTEMPLATE_DIRSZLOCALE_PATHSz*The %s setting must be a list or a tuple. rG   PASSWORD_RESET_TIMEOUTzJPASSWORD_RESET_TIMEOUT_DAYS/PASSWORD_RESET_TIMEOUT are mutually exclusive.<      DEFAULT_HASHING_ALGORITHMtzsetz/usr/share/zoneinfor@   zIncorrect timezone setting: %sZTZ)!dirr   r:   r<   r)   r$   	importlibimport_moduleset_explicit_settings
isinstancelisttupler   addis_overriddenrG   rN   rO   rP   r   (DEFAULT_HASHING_ALGORITHM_DEPRECATED_MSGhasattrtimeZ	TIME_ZONEr   joinpathsplitexists
ValueErrorr   r   r[   )r   r!   settingmodZtuple_settingsZsetting_valueZzoneinfo_rootZzone_info_filer   r   r   r      sF   



zSettings.__init__c                 C   s
   || j v S r	   )r`   )r   rm   r   r   r   re      r   zSettings.is_overriddenc                 C   s   d| j j| jd S )Nz<%(cls)s "%(settings_module)s">)clsr!   )r4   r   r$   r%   r   r   r   r&      s   zSettings.__repr__N)r   r   r   r   re   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 )r8   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)r_   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:   rp   AttributeErrorr)   r=   r6   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 )NrG   rW   rX   rY   rZ   )
rp   discardr<   rN   rO   rP   r   rf   r0   r1   r2   r3   r   r   r1      s   zUserSettingsHolder.__setattr__c                    s*   | j | t| |rt | d S d S r	   )rp   rd   rg   r0   r5   r6   r3   r   r   r5      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	   )rp   ).0sr%   r   r   	<genexpr>   s    
z-UserSettingsHolder.__dir__.<locals>.<genexpr>)sortedr+   r\   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 )Nre   c                 S   s   dS )NFr   )rt   r   r   r   <lambda>  s    z2UserSettingsHolder.is_overridden.<locals>.<lambda>)rp   r+   r)   r=   )r   rm   ZdeletedZset_locallyZset_on_defaultr   r   r   re     s   

z UserSettingsHolder.is_overriddenc                 C   s   dd| j ji S )Nz	<%(cls)s>ro   )r4   r   r%   r   r   r   r&     s   zUserSettingsHolder.__repr__)r   r   r   r   r$   r   r-   r1   r5   rw   re   r&   rV   r   r   r3   r   r8      s    	r8   )r   r]   r   rh   rH   rN   pathlibr   rL   Zdjango.confr   Zdjango.core.exceptionsr   Zdjango.utils.deprecationr   Zdjango.utils.functionalr   r   r   rP   rf   r
   r   r   r   r8   r   r   r   r   r   <module>   s,    p>
3