
    7h|                         S SK r S SKrS SKJr  S SKJrJr  S SKJr  SSK	J
r
  S r\ R                  " S5      rS	 r " S
 S\5      r " S S\5      r " S S\\\5      r " S S\5      rg)    N)inspect)DeclarativeMetadeclared_attr)_get_table_key   to_strc                    U R                   R                  SS5      (       d$  [        S U R                  SS  5       5      (       d  gU R                   H  nSUR                   ;  a  M  [	        UR                   S   [
        5      (       a    gXL =(       d8    UR                   R                  SS5      =(       d    [	        U[        5      (       + (       + s  $    g)a  Determine whether ``__tablename__`` should be automatically generated
for a model.

* If no class in the MRO sets a name, one should be generated.
* If a declared attr is found, it should be used instead.
* If a name is found, it should be used if the class is a mixin, otherwise
  one should be generated.
* Abstract models should not have one generated.

Later, :meth:`._BoundDeclarativeMeta.__table_cls__` will determine if the
model looks like single or joined-table inheritance. If no primary key is
found, the name will be unset.
__abstract__Fc              3   B   #    U  H  n[        U[        5      v   M     g 7fN)
isinstancer   ).0bs     kC:\Users\ROHAN GUPTA\OneDrive\Desktop\mathbuddy-assessment\venv\Lib\site-packages\flask_sqlalchemy/model.py	<genexpr>'should_set_tablename.<locals>.<genexpr>   s     K?a:a11?s   r   N__tablename__T)__dict__getany__mro__r   r   r   )clsbases     r   should_set_tablenamer      s     	//K3;;qr?KKK$--/dmmO4mDD K 5}}  75dO44
 	
      z([A-Z]+)(?=[a-z0-9])c                 P    S n[         R                  X5      R                  S5      $ )Nc                     U R                  5       n[        U5      S:  a  SUS S < SUS   < 3R                  5       $ SUR                  5       -   $ )Nr   _)grouplenlower)matchwords     r   _join"camel_to_snake_case.<locals>._join3   sG    {{}t9q= $Sb	484;;==TZZ\!!r   r   )camelcase_resublstrip)namer&   s     r   camel_to_snake_caser,   2   s%    " E(//44r   c                   .   ^  \ rS rSrU 4S jrS rSrU =r$ )NameMetaMixin>   c                    > [        U 5      (       a  [        U R                  5      U l        [        [
        U ]  XU5        SU R                  ;  a%  SU R                  ;   a  U R                  S   c  U ?g g g g )Nr   	__table__)	r   r,   __name__r   superr.   __init__r   r1   )r   r+   basesd	__class__s       r   r4   NameMetaMixin.__init__?   sm    $$ 3CLL ACmS*4:
 3<</s||+[)1 2 , 0r   c                     [        US   UR                  S5      5      nX0R                  R                  ;   a  [        R
                  " U0 UD6$ U Hj  n[        U[        R                  5      (       a  UR                  (       d!  [        U[        R                  5      (       d  MT  [        R
                  " U0 UD6s  $    U R                  SS  H  nSUR                  ;   d  M    O   [        R
                  " U0 UD6$ SU R                  ;   a  U ?gg)zThis is called by SQLAlchemy during mapper setup. It determines the
final table object that the model will use.

If no primary key is found, that indicates single-table inheritance,
so no table will be created and ``__tablename__`` will be unset.
r   schemar   r    r1   r   N)r   r   metadatatablessaTabler   Columnprimary_keyPrimaryKeyConstraintr   r   r   )r   argskwargskeyargr   s         r   __table_cls__NameMetaMixin.__table_cls__N   s     T!Wfjj&:;,,%%%88T,V,, CC++c2#:#:;;xx000  KK"%Ddmm+ & 88T,V,, cll*! +r    )r2   
__module____qualname____firstlineno__r4   rF   __static_attributes____classcell__r7   s   @r   r.   r.   >   s    !" !"r   r.   c                   (   ^  \ rS rSrU 4S jrSrU =r$ )BindMetaMixinr   c                    > UR                  SS 5      =(       d    [        U SS 5      n[        [        U ]  XU5        Ub(  [        U SS 5      b  X@R
                  R                  S'   g g g )N__bind_key__r1   bind_key)popgetattrr3   rP   r4   r1   info)r   r+   r5   r6   rT   r7   s        r   r4   BindMetaMixin.__init__s   si    EE.$' 2sND1 	
 	mS*4:GCd$C$O-5MMz* %Pr   rH   )r2   rI   rJ   rK   r4   rL   rM   rN   s   @r   rP   rP   r   s    	6 	6r   rP   c                       \ rS rSrSrg)DefaultMeta   rH   N)r2   rI   rJ   rK   rL   rH   r   r   rZ   rZ      s    r   rZ   c                   &    \ rS rSrSrSrSrS rSrg)Model   zBase class for SQLAlchemy declarative base model.

To define models, subclass :attr:`db.Model <SQLAlchemy.Model>`, not this
class. To customize ``db.Model``, subclass this and pass it as
``model_class`` to :class:`SQLAlchemy`.
Nc                     [        U 5      R                  nUc  SR                  [        U 5      5      nOSR	                  S U 5       5      nSR                  [        U 5      R                  U5      $ )Nz(transient {0})z, c              3   8   #    U  H  n[        U5      v   M     g 7fr   r   )r   values     r   r   !Model.__repr__.<locals>.<genexpr>   s     ?hU6%==hs   z	<{0} {1}>)r   identityformatidjointyper2   )selfrc   pks      r   __repr__Model.__repr__   s\    4=))"))"T(3B?h??B!!$t*"5"5r::r   rH   )	r2   rI   rJ   rK   __doc__query_classqueryrj   rL   rH   r   r   r]   r]      s     K
 E;r   r]   )re
sqlalchemyr=   r   sqlalchemy.ext.declarativer   r   sqlalchemy.schemar   _compatr	   r   compiler(   r,   rg   r.   rP   rZ   objectr]   rH   r   r   <module>rv      sh    	   E , !H zz12	51"D 1"h
6D 
6	- 	;F ;r   