
    h"                     H    d dl Z d dlmZ d dlmZ d dlmZ dZ G d d      Zy)    N)import_module)ImproperlyConfigured)module_has_submodulemodelsc                   N    e Zd ZdZd Zd Zd Zed        ZddZ	ddZ
d Zd	 Zy
)	AppConfigz>Class representing a Django application and its configuration.c                 .   || _         || _        d | _        t        | d      s|j	                  d      d   | _        t        | d      s| j
                  j                         | _        t        | d      s| j                  |      | _	        d | _
        d | _        y )Nlabel.   verbose_namepath)namemoduleappshasattr
rpartitionr
   titler   _path_from_moduler   models_moduler   )selfapp_name
app_modules      U/var/www/html/ranktracker/api/venv/lib/python3.12/site-packages/django/apps/config.py__init__zAppConfig.__init__   s    	 ! 	 tW%!,,S1!4DJ t^, $

 0 0 2D tV$..z:DI
 "     c                 P    d| j                   j                  d| j                  dS )N<z: >)	__class____name__r
   r   s    r   __repr__zAppConfig.__repr__3   s    !^^44djjAAr   c                 <   t        t        |dg             }t        |      dk7  rDt        |dd      }|!t        j                  j                  |      g}nt        t        |            }t        |      dkD  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_module6   s     WVZ45u:?vz48H#23 SZ(u:>& 5;ECD D &139:; ; Qxr   c                    	 t        |      }	 |j                  }|j                  d      \  }}}t        |      }	 t        ||      } t        | t              st        d|z        	 | j                  }	 t        |      }	 | ||	      S # t        $ r  | ||      cY S w xY w# t        $ r d}|j                  d      \  }}}|s Y w xY w# t        $ rb |\t        d |j                  j                         D              }|r$t        d|d|ddj                  |      d      t        |       n Y w xY w# t        $ r t        d	|z        w xY w# t        $ r t        d
|d|d|d      w xY w)zU
        Factory that creates an app config from an entry in INSTALLED_APPS.
        r   Nc              3      K   | ]:  \  }}t        |t              r%t        |t              r|t        urt	        |       < y w)N)
isinstancetype
issubclassr   repr).0r   	candidates      r   	<genexpr>z#AppConfig.create.<locals>.<genexpr>}   s<      $#24!)T2y)4Y. J$s   A A'z' does not contain a class 'z'. Choices are: z, 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   default_app_configr   AttributeErrorImportErrorr)   sorted__dict__itemsr   joinr4   r   r   )
clsentryr   mod_path_cls_namemod
candidatesr   r   s
             r   createzAppConfig.createQ   s   
	> #5)F>11
 ).(8(8(=%!X H%	#x(C0 #y)&5=? ?
	>xxH	&x0J 8Z((s " *5&))*!  
	 F$)$4$4S$9!Ha  
	6  	~
 $ $69ll6H6H6J$ 
 .#Xtyy/DF  e$ %#	>  	>&4u<> >	>  	&h 	sL   B B C &D6 3E BB#CCA(D32D36EE0c                     |r| j                   j                          n| j                   j                          	 | 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   sq     II((*II&&(	R;;z//122 	R9=ZPR R	Rs   A &A<c              #      K   | j                   j                          | j                  j                         D ]8  }|j                  j
                  r|s|j                  j                  r|s5| : yw)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   rJ   r   values_metaauto_createdswapped)r   include_auto_createdinclude_swappedmodels       r   
get_modelszAppConfig.get_models   s^      			$$&[['') 	E{{''0D{{""?K	s   A1A3c                     | j                   j                  | j                     | _        t	        | j
                  t              r&| j                  dt        }t        |      | _	        y y )Nr   )
r   
all_modelsr
   r   r   r   MODELS_MODULE_NAMEr   r   r   )r   models_module_names     r   import_modelszAppConfig.import_models   sQ     ii**4::6-?@,0II7I!J!./A!BD Ar   c                      y)zT
        Override this method in subclasses to run code when Django starts.
        N r"   s    r   readyzAppConfig.ready   s    r   N)T)FF)r!   
__module____qualname____doc__r   r#   r   classmethodrH   rQ   rZ   r_   rb   ra   r   r   r   r   
   sC    H$LB6 S) S)jR *Cr   r   )	r+   	importlibr   django.core.exceptionsr   django.utils.module_loadingr   r]   r   ra   r   r   <module>rj      s#    	 # 7 < N Nr   