
    ؄_                     b    d Z ddlmZ ddlmZ  G d de          ZddZ G d	 d
e          ZdS )zeLegacy routines to resolve circular module imports at runtime.

These routines are replaced in 1.4.

    )update_wrapper   )compatc                        e Zd ZdZddZd ZdS )_memoized_propertyzivendored version of langhelpers.memoized_property.

    not needed in the 1.4 version of preloaded.

    Nc                 H    || _         |p|j        | _        |j        | _        d S N)fget__doc____name__)selfr
   docs      _/var/www/book.euthymeo.com/html/venv/lib/python3.11/site-packages/sqlalchemy/util/_preloaded.py__init__z_memoized_property.__init__   s$    	*dl    c                 V    || S |                      |          x|j        | j        <   }|S r	   )r
   __dict__r   )r   objclsresults       r   __get__z_memoized_property.__get__   s.    ;K/3yy~~=T]#fr   r	   )r   
__module____qualname__r   r   r    r   r   r   r      sA         & & & &
    r   r   Tc                    t          j        |           rt          j        |           }n| }t          j        | }|d         r|d         d         }n|d         rd|d         z  }nd}t          j        |d         |d         |d         d|d                   }d}|d         r|t	          |d                   z  }|d         r|t	          |d                   z  }|d         |d         z   }|r|d|z
  d         }nd}t          j        ||d         |d         |d	 
          }	|rt          ||||	          S t          |dd         ||dd         |	dd                   S )zlvendored version of langhelpers._format_argspec_plus.

    not needed in the 1.4 version of preloaded.

    r   r   z%s[0]N         r   c                     d| z   S )N=r   )xs    r   <lambda>z&_format_argspec_plus.<locals>.<lambda>M   s
    cAg r   )formatvalue)argsself_arg	apply_posapply_kw)r   callableinspect_getfullargspecinspect_formatargspeclendict)
fngroupedspecr$   r%   r&   num_defaults	name_argsdefaulted_valsr'   s
             r   _format_argspec_plusr4   &   s    r ,R00'.DAw 71:	a T!W$,Qa$q'4a I LAw %DG$Aw %DG$Q$q'!I "1|#3#5#56+QQ%%  H  
	
 
 
 	
 ad"oad^	
 
 
 	
r   c                   h    e Zd ZdZd Zd Zed             Z e            Z	i Z
 G d de          ZdS )dependenciesa  Apply imported dependencies as arguments to a function.

    E.g.::

        @util.dependencies(
            "sqlalchemy.sql.widget",
            "sqlalchemy.engine.default"
        );
        def some_func(self, widget, default, arg1, arg2, **kw):
            # ...

    Rationale is so that the impact of a dependency cycle can be
    associated directly with the few functions that cause the cycle,
    and not pollute the module-level namespace.

    c           
          g | _         |D ]k}|                    d          }| j                             t                              d                    |dd                   |d                              ld S )N.r   r(   )import_depssplitappendr6   _importlaterjoin)r   depsdeptokenss       r   r   zdependencies.__init__q   s}     	 	CYYs^^F##))#((6!B$<*@*@&*MM   	 	r   c                 
   | j         }t          j        |          }t          |d                   }|d         dv }t	          t          |                    D ]}d|z  |d         ||rdndz   <   t          |d          }|D ]	}||rdnd= 
||d         d d <   t          |d          }	d|	d         |d	         d
z  }
t          |
t                                }t          |d|          j
        |_
        t          ||          S )Nr   )r   r   zimport_deps[%r]r   F)r/   z!lambda %(args)s: fn(%(apply_kw)s)r$   r'   )r$   r'   im_func)r9   r   r*   listranger,   r4   evallocalsgetattr__defaults__r   )r   r.   r9   r0   	spec_zerohasselfi
inner_specimpname
outer_speccode	decorateds               r   __call__zdependencies.__call__y   s4   &,R00aMM	A,/1s;''(( 	G 	GA1BQ1FDGAg,1-..)$>>>
" 	/ 	/Gw-!!A..Q
)$>>>
2v&":.6
 6
 

 vxx((	!(Y!;!;!H	i,,,r   c                     t          t          j                  D ]0}|j                            |          r|                                 1d S r	   )rC   r6   _unresolved
_full_path
startswith_resolve)r   pathms      r   resolve_allzdependencies.resolve_all   sL    l.// 	 	A|&&t,, 

	 	r   c                   j    e Zd Z e            Zi Zd Zd Zed             Z	e
d             Zd Zd ZdS )dependencies._importlaterc                     |dz   |z   }|t           j        v rt           j        |         S t                              |           xt           j        |<   }|S Nr8   )r6   _by_keyobject__new__)r   rW   addtlkeyimps        r   r`   z!dependencies._importlater.__new__   sO    *u$Cl***#+C0028..2E2EE$S)C
r   c                 `    || _         || _        t          j                            |            d S r	   )_il_path	_il_addtlr6   rS   add)r   rW   ra   s      r   r   z"dependencies._importlater.__init__   s-     DM"DN$((.....r   c                 &    | j         dz   | j        z   S r]   )re   rf   r   s    r   rT   z$dependencies._importlater._full_path   s    =3&77r   c                     | t           j        v r t          d| j        d| j        d          t          | j        | j                  S )Nz6importlater.resolve_all() hasn't been called (this is  ))r6   rS   ImportErrorre   rf   rG   _initial_importri   s    r   modulez dependencies._importlater.module   sS    |///!k }}}dnnn6   4/@@@r   c                     t           j                            |            t          j        | j        t                      t                      | j        g          | _	        d S r	   )
r6   rS   discardr   import_re   globalsrF   rf   rn   ri   s    r   rV   z"dependencies._importlater._resolve   sK    $,,T222#)>wyy&((T^4D$ $D   r   c                     |dk    rt          d| j        z            	 t          | j        |          }n)# t          $ r t	          d| j        d|d          w xY w|| j        |<   |S )Nro   zCould not resolve module %szModule z has no attribute '')rm   rT   rG   ro   AttributeErrorr   )r   rb   attrs      r   __getattr__z%dependencies._importlater.__getattr__   s    h!1DOC  t{C00!   $n9=###N   "&DM#Ks	   5 &AN)r   r   r   setrS   r^   r`   r   propertyrT   r   ro   rV   rx   r   r   r   r<   r[      s        cee	 	 		/ 	/ 	/
 
	8 	8 
	8 
	A 	A 
		A	 	 		 	 	 	 	r   r<   N)r   r   r   r   r   rQ   classmethodrY   ry   rS   r^   r_   r<   r   r   r   r6   r6   _   s         "  - - -6   [
 #%%KG3 3 3 3 3v 3 3 3 3 3r   r6   N)T)	r   	functoolsr    r   r_   r   r4   r6   r   r   r   <module>r~      s     % $ $ $ $ $             &6
 6
 6
 6
rq q q q q6 q q q q qr   