
    Dvg,                     l    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	          ZdS )
    N)import_module)ImproperlyConfigured)cached_property)import_stringmodule_has_submoduleappsmodelsc                       e Zd ZdZd Zd Zed             Zed             Z	d Z
ed             Zdd	ZddZd Zd ZdS )	AppConfigz>Class representing a Django application and its configuration.c                    || _         || _        d | _        t          | d          s |                    d          d         | _        | j                                        st          d| j        z            t          | d          s| j                                        | _	        t          | d          s| 
                    |          | _        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_modules      O/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/django/apps/config.py__init__zAppConfig.__init__   s    	 ! 	 tW%% 	5!,,S11!4DJz&&(( 	&FS  
 t^,, 	3 $
 0 0 2 2D tV$$ 	;..z::DI
 "     c                 2    d| j         j        d| j        dS )N<z: >)	__class____name__r   r   s    r   __repr__zAppConfig.__repr__:   s      !^444djjjAAr   c                     ddl m} |j        S )Nr   )settings)django.confr(   DEFAULT_AUTO_FIELD)r   r(   s     r   default_auto_fieldzAppConfig.default_auto_field=   s    ((((((**r   c                 2    | j         j        t          j        uS )N)r#   r+   r   r%   s    r   !_is_default_auto_field_overriddenz+AppConfig._is_default_auto_field_overriddenC   s    ~0	8TTTr   c                    t          t          |dg                     }t          |          dk    rPt          |dd          }|!t          j                            |          g}nt          t          |                    }t          |          dk    rt          d|d|d          |st          d|z            |d	         S )
z;Attempt to determine app's filesystem path from its module.__path__   __file__NzThe app module z$ has multiple filesystem locations (zX); you must configure this app with an AppConfig subclass with a 'path' class attribute.zThe 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filenames       r   r   zAppConfig._path_from_moduleG   s    
 WVZ4455u::??vz488H#223 SZZ((u::>>&& 5;FFEEEC  
  	&139:  
 Qxr   c           
      4    d}d}d}	 t          |          }t          |t                    r|dt          }t          |          } fdt          j        |t          j                  D             }t          |          dk    r|d         d         }ntd |D             }t          |          dk    r4d |D             }t          |dd	                    |          d          t          |          dk    r|d         d         }| }|}n# t          $ r Y nw xY w|!	 t          |          }n# t          $ r Y nw xY w|||                    d          \  }}	}
|r|
d                                         rot          |          } fd
t          j        |t          j                  D             }d|d|
d}|r|dd	                    |          z  z  }t          |          t          |           t          |t                    st!          d|z            |)	 |j        }n # t$          $ r t!          d|z            w xY w	 t          |          }n1# t          $ r$ t!          d|d|j        d|j        d          w xY w |||          S )zU
        Factory that creates an app config from an entry in INSTALLED_APPS.
        Nr   c                 h    g | ].\  }}t          |          r|ut          |d d          *||f/S )defaultT)
issubclassr3   .0r   	candidateclss      r   
<listcomp>z$AppConfig.create.<locals>.<listcomp>~   sa       'i"9c22	
 &S00#Iy$?? 1	 9% 100r   r0   r   c                 >    g | ]\  }}t          |d d          ||fS )r<   F)r3   )r?   r   r@   s      r   rB   z$AppConfig.create.<locals>.<listcomp>   sC     # # #+D)"9i??#y)# # #r   c                 2    g | ]\  }}t          |          S  )repr)r?   r   _s      r   rB   z$AppConfig.create.<locals>.<listcomp>   s"    %L%L%LWT1d4jj%L%L%Lr   z+ declares more than one default AppConfig: z, c                 \    g | ](\  }}t          |          r|ut          |          )S rE   )r=   rF   r>   s      r   rB   z$AppConfig.create.<locals>.<listcomp>   sM       'i!)S11 7@s6J6J JJ6J6J6Jr   zModule 'z' does not contain a 'z' class.z Choices are: %s.z#'%s' isn't a subclass of AppConfig.z"'%s' must supply a name attribute.zCannot import 'z'. Check that 'z.name' is correct.)r   r   APPS_MODULE_NAMEinspect
getmembersisclassr4   RuntimeErrorjoin	Exceptionr   r   isupperImportErrorr=   r   r   r   AttributeError
__module____qualname__)rA   entryapp_config_classr   r   mod_pathmodapp_configs
candidatesrG   cls_namemsgs   `           r   createzAppConfig.createc   s     
/	!&u--J $J0@AA =&+ee-=-=>#H--   +2+=c7?+S+S   {##q(('21~a'8$$# #/:# # #K
 ;''!++%L%L%L%L%L
*%-XXtyy/D/D/D/DF   [))Q..+6q>!+<(  '#&  [  	 	 	D	` ##0#7#7      "2": %*$4$4S$9$9!Ha %HQK//11 % $H--   +2+=c7?+S+S  

 HHHH  G.:1F1FFFC!#&&& e$$$ *I66 	V&'Lu'TUUU Y+0! Y Y Y*+ORW+WXXXY
	&x00JJ 	 	 	&& HH$///$111	  	  *555s;   D 
DD#D3 3
E ?E $H, ,I	I .JTc                     |r| j                                          n| j                                          	 | j        |                                         S # t
          $ r t          d| j        d|d          w xY w)z
        Return the model with the given case-insensitive model_name.

        Raise LookupError if no model exists with this name.
        zApp 'z' doesn't have a 'z' model.)r   check_models_readycheck_apps_readyr	   lowerKeyErrorLookupErrorr   )r   
model_namerequire_readys      r   	get_modelzAppConfig.get_model   s      	)I((****I&&(((	;z//1122 	 	 	+9=ZZZP  	s   A &A<Fc              #      K   | j                                          | j                                        D ]$}|j        j        r|s|j        j        r|s |V  %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   r_   r	   values_metaauto_createdswapped)r   include_auto_createdinclude_swappedmodels       r   
get_modelszAppConfig.get_models   s}       		$$&&&['')) 	 	E{' 0D {" ? KKKK	 	r   c                     | j         j        | j                 | _        t	          | j        t                    r'| j        dt          }t          |          | _	        d S d S )Nr   )
r   
all_modelsr   r	   r   r   MODELS_MODULE_NAMEr   r   r   )r   models_module_names     r   import_modelszAppConfig.import_models  se     i*4:6-?@@ 	C,0III7I7I!J!./A!B!BD	C 	Cr   c                     dS )zT
        Override this method in subclasses to run code when Django starts.
        NrE   r%   s    r   readyzAppConfig.ready  s      r   N)T)FF)r$   rS   rT   __doc__r   r&   r   r+   propertyr-   r   classmethodr]   rf   ro   rt   rv   rE   r   r   r   r      s        HH( ( (TB B B + + _+
 U U XU  8 z6 z6 [z6x   "   *C C C    r   r   )rJ   r5   	importlibr   django.core.exceptionsr   django.utils.functionalr   django.utils.module_loadingr   r   rI   rr   r   rE   r   r   <module>r~      s     				 # # # # # # 7 7 7 7 7 7 3 3 3 3 3 3 K K K K K K K K  E E E E E E E E E Er   