o
    ýÞhÚ,  ã                   @   s^   d dl 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G dd	„ d	ƒZdS )
é    N)Úimport_module)ÚImproperlyConfigured)Úcached_property)Úimport_stringÚmodule_has_submoduleÚappsÚmodelsc                   @   sp   e Zd ZdZdd„ Zdd„ Zedd„ ƒZedd	„ ƒZ	d
d„ Z
edd„ ƒZddd„Zddd„Zdd„ Zdd„ ZdS )Ú	AppConfigz>Class representing a Django application and its configuration.c                 C   s€   || _ || _d | _t| dƒs| d¡d | _| j ¡ s"td| j ƒ‚t| dƒs-| j ¡ | _	t| dƒs8|  
|¡| _d | _d | _d S )NÚlabelÚ.é   z4The app label '%s' is not a valid Python identifier.Úverbose_nameÚpath)ÚnameÚmoduler   ÚhasattrÚ
rpartitionr
   Úisidentifierr   Útitler   Ú_path_from_moduler   Úmodels_moduler   )ÚselfÚapp_nameÚ
app_module© r   úR/var/www/html/premium_crap/venv/lib/python3.10/site-packages/django/apps/config.pyÚ__init__   s   

ÿ


zAppConfig.__init__c                 C   s   d| j j| jf S )Nz<%s: %s>)Ú	__class__Ú__name__r
   ©r   r   r   r   Ú__repr__:   s   zAppConfig.__repr__c                 C   s   ddl m} |jS )Nr   )Úsettings)Údjango.confr!   ÚDEFAULT_AUTO_FIELD)r   r!   r   r   r   Údefault_auto_field=   s   zAppConfig.default_auto_fieldc                 C   s   | j jtjuS )N)r   r$   r	   r   r   r   r   Ú!_is_default_auto_field_overriddenC   s   z+AppConfig._is_default_auto_field_overriddenc                 C   s€   t t|dg ƒƒ}t|ƒdkr&t|ddƒ}|dur tj |¡g}nt t|ƒƒ}t|ƒdkr4td||f ƒ‚|s<td| ƒ‚|d S )z;Attempt to determine app's filesystem path from its module.Ú__path__é   Ú__file__Nz�The app module %r has multiple filesystem locations (%r); you must configure this app with an AppConfig subclass with a 'path' class attribute.zƒThe app module %r has no filesystem location, you must configure this app with an AppConfig subclass with a 'path' class attribute.r   )ÚlistÚgetattrÚlenÚosr   ÚdirnameÚsetr   )r   r   ÚpathsÚfilenamer   r   r   r   G   s&   þÿþÿzAppConfig._path_from_modulec                    s  d}d}d}zt |ƒ}W n	 ty   Y n^w t|tƒrkd|tf }t |ƒ}‡ fdd„t |tj¡D ƒ}t|ƒdkr@|d d }n+dd„ |D ƒ}t|ƒdkr_dd„ |D ƒ}td	|d
 	|¡f ƒ‚t|ƒdkrk|d d }|du rsˆ }|}|du r‡zt
|ƒ}W n	 ty†   Y nw |du rÊ|du rÊ| d¡\}}	}
|rÆ|
d  ¡ rÆt |ƒ}‡ fdd„t |tj¡D ƒ}d||
f }|rÂ|dd
 	|¡ 7 }t|ƒ‚t |ƒ t|tƒsÕtd| ƒ‚|du rìz|j}W n tyë   td| ƒ‚w zt |ƒ}W n t�y   td||j|jf ƒ‚w |||ƒS )zU
        Factory that creates an app config from an entry in INSTALLED_APPS.
        Nú%s.%sc                    s6   g | ]\}}t |ˆ ƒr|ˆ urt|d dƒr||f‘qS )ÚdefaultT)Ú
issubclassr*   ©Ú.0r   Ú	candidate©Úclsr   r   Ú
<listcomp>~   s    ü
ÿüz$AppConfig.create.<locals>.<listcomp>r'   r   c                 S   s$   g | ]\}}t |d dƒr||f‘qS )r2   F)r*   r4   r   r   r   r9   Œ   s    
ýÿc                 S   s   g | ]\}}t |ƒ‘qS r   )Úrepr)r5   r   Ú_r   r   r   r9   ’   s    z0%r declares more than one default AppConfig: %s.z, r   c                    s*   g | ]\}}t |ˆ ƒr|ˆ urt|ƒ‘qS r   )r3   r:   r4   r7   r   r   r9   ³   s    ýþz*Module '%s' does not contain a '%s' class.z Choices are: %s.z#'%s' isn't a subclass of AppConfig.z"'%s' must supply a name attribute.z7Cannot import '%s'. Check that '%s.%s.name' is correct.)r   Ú	Exceptionr   ÚAPPS_MODULE_NAMEÚinspectÚ
getmembersÚisclassr+   ÚRuntimeErrorÚjoinr   r   ÚisupperÚImportErrorr3   r	   r   r   ÚAttributeErrorÚ
__module__Ú__qualname__)r8   ÚentryÚapp_config_classr   r   Úmod_pathÚmodÚapp_configsÚ
candidatesr;   Úcls_nameÚmsgr   r7   r   Úcreatec   s’   ÿ
	
þ	þÿÿÿ
þþ

ÿýÿÿÿ
zAppConfig.createTc                 C   sL   |r| j  ¡  n| j  ¡  z| j| ¡  W S  ty%   td| j|f ƒ‚w )zŒ
        Return the model with the given case-insensitive model_name.

        Raise LookupError if no model exists with this name.
        z#App '%s' doesn't have a '%s' model.)r   Úcheck_models_readyÚcheck_apps_readyr   ÚlowerÚKeyErrorÚLookupErrorr
   )r   Ú
model_nameÚrequire_readyr   r   r   Ú	get_modelà   s   
ÿÿzAppConfig.get_modelFc                 c   sB   � | j  ¡  | j ¡ D ]}|jjr|sq|jjr|sq|V  qdS )a—  
        Return an iterable of models.

        By default, the following models aren't included:

        - auto-created models for many-to-many relations without
          an explicit intermediate table,
        - models that have been swapped out.

        Set the corresponding keyword argument to True to include such models.
        Keyword arguments aren't documented; they're a private API.
        N)r   rQ   r   ÚvaluesÚ_metaÚauto_createdÚswapped)r   Úinclude_auto_createdÚinclude_swappedÚmodelr   r   r   Ú
get_modelsñ   s   €
ûzAppConfig.get_modelsc                 C   s<   | j j| j | _t| jtƒrd| jtf }t|ƒ| _	d S d S )Nr1   )
r   Ú
all_modelsr
   r   r   r   ÚMODELS_MODULE_NAMEr   r   r   )r   Úmodels_module_namer   r   r   Úimport_models  s
   þzAppConfig.import_modelsc                 C   s   dS )zT
        Override this method in subclasses to run code when Django starts.
        Nr   r   r   r   r   Úready  s    zAppConfig.readyN)T)FF)r   rF   rG   Ú__doc__r   r    r   r$   Úpropertyr%   r   ÚclassmethodrP   rX   r`   rd   re   r   r   r   r   r	      s    *



|
	r	   )r>   r,   Ú	importlibr   Údjango.core.exceptionsr   Údjango.utils.functionalr   Údjango.utils.module_loadingr   r   r=   rb   r	   r   r   r   r   Ú<module>   s    