
    >wgD                     r    d dl mZ d dlmZ d dlmZ d dlmZ i Zd Z	d Z
d Zdd	Zd
 ZddZd Zd Zd Zy)    )apps)settings)ImproperlyConfigured)swappable_dependencyc                     t         j                  | |       }dj                  |j                         |j                               }t	        t
        |      st        t
        |t        | |             |S )zReturns the setting name to use for the given model

    Returns the setting name to use for the given model (i.e.
    AUTH_USER_MODEL)
    z{prefix}_{model}_MODEL)prefixmodel)	_prefixesgetformatupperhasattrr   setattrjoin)	app_labelr	   r   settings       G/var/www/horilla/myenv/lib/python3.12/site-packages/swapper/__init__.pyswappable_settingr   	   s^     ]]9i0F&--||~U[[] . G
 8W%'4	5#9:N    c                 d    t        | |      }t        | |      }t        t        ||      }||k7  r|S y)zReturns the value of the swapped setting.

    Returns the value of the swapped setting, or False if the model hasn't
    been swapped.
    F)r   r   getattrr   )r   r	   default_modelr   values        r   
is_swappedr      s:     E*M	51GHg}5Er   c                 6    t        | |      xs t        | |      S )zReturns [app_label.model].

    Returns [app_label.model] unless the model has been swapped, in which
    case returns the swappable setting value.
    )r   r   r   r	   s     r   get_model_namer   *   s     i'A4	5+AAr   Nc                 B    t        t        | |            }|s|S |d   |fS )zReturns a Django 1.7+ style dependency tuple

    Returns a Django 1.7+ style dependency tuple for inclusion in
    migration.dependencies[]
    r   )r   r   )r   r	   versiondependenciess       r   
dependencyr!   3   s-     (y%(HIL?G##r   c                 ,     t         fd|D              S )z>Map model names to their swapped equivalents for the given appc              3   :   K   | ]  }|t        |      f  y wN)r   ).0r	   r   s     r   	<genexpr>z"get_model_names.<locals>.<genexpr>A   s     Ney%89Ns   )dict)r   modelss   ` r   get_model_namesr)   ?   s    NvNNNr   c                     t        | |      }|rt        |      \  } }	 t        j                  | ||      }|'|r%t        dj                  t        | |                  |S # t        $ r d}Y 8w xY w)zDLoad the specified model class, or the class it was swapped out for.)require_readyNzCould not find {name}!)name)r   splitr   	get_modelLookupErrorr   r   r   )r   r	   requiredr+   swappedclss         r   
load_modelr3   D   s    E*G >	5nnY]K {x"$++i1G+H
 	
 J  s   A! !A/.A/c                     |t         | <   y)z6Set a custom prefix to use for the given app (e.g. WQ)N)r
   )r   r   s     r   set_app_prefixr5   V   s    !Iir   c                 (    dj                  | |      S )Nz{app_label}.{model}r   )r   r   s     r   r   r   [   s      '' (  r   c                 4    | j                  d      \  }}} || fS )N.)
rpartition)r	   r   _s      r   r-   r-   b   s$    **3/Iq%er   r$   )TT)django.appsr   django.confr   django.core.exceptionsr   django.db.migrationsr   r
   r   r   r   r!   r)   r3   r5   r   r-    r   r   <module>r@      sE       7 5	$B	$O
$"
r   