
    0j&#                     t   d Z ddlZddlmZ ddlmZmZmZmZ ddl	m
Z
mZ eeef         Zeeef         Z G d d          Zd	ed
eeej        f         fdZded
eej                 fdZded
eeej                          fdZded
eeej                          fdZded
ee         fdZ G d de          ZdS )zSchema module.    N)import_module)DictAnyTypeOptional   )
containers	providersc                       e Zd ZdeddfdZd Zd Z	 ddedee	j
                 ddfd	Z	 ddedee	j
                 ddfd
Zdedeej                 fdZdS )SchemaProcessorV1schemareturnNc                 D    || _         t          j                    | _        d S N)_schemar	   DynamicContainer
_container)selfr   s     b/home/rurouni/.hermes/hermes-agent/venv/lib/python3.11/site-packages/dependency_injector/schema.py__init__zSchemaProcessorV1.__init__   s    $577    c                     |                      | j        d                    |                     | j        d                    dS )zProcess schema.	containerN)_create_providersr   _setup_injectionsr   s    r   processzSchemaProcessorV1.process   s>    t|K8999t|K899999r   c                     | j         j        S )zReturn providers.)r   r
   r   s    r   get_providerszSchemaProcessorV1.get_providers   s    ((r   provider_schemar   c                 ^   || j         }|                                D ]\  }}d }d|v rt          |d                   }g } || }|t          j        t
          j                  }|                    ||           t          |t          j                  r| 	                    ||           d S )Nproviderr    r   )
r   items_get_provider_clsr
   	Containerr	   r   set_provider
isinstancer   )r   r    r   provider_namedatar"   provider_typeargss           r   r   z#SchemaProcessorV1._create_providers   s    
 I#2#8#8#:#: 	Q 	QM4HT!! 1$z2B C C )=$/$.z/JKK""=(;;;(I$788 Q&&tx&PPP+	Q 	Qr   c                 	   || j         }|                                D ]\  }}t          ||          }g }i }|                    d          }|ryt	          |t
                    r@|                    d          r+|                     |t          d          d                    }nt          |          }|
                    |           |                    d          }	|	r|	D ]}
d }t	          |
t
                    r?|
                    d          r*|                     |
t          d          d                    }t	          |
t                    r9g }t          |
                    d                    }|
                    d          }|ryt	          |t
                    r@|                    d          r+|                     |t          d          d                    }nt          |          }|                    |           |
                    dg           D ]i}t	          |t
                    rR|                    d          r=|                    |                     |t          d          d                               j || }|s|
}|                    |           |r
 |j        |  |                    d          }|r|                                D ]\  }}
d }t	          |
t
                    r?|
                    d          r*|                     |
t          d          d                    }t	          |
t                    r9g }t          |
                    d                    }|
                    d          }|ryt	          |t
                    r@|                    d          r+|                     |t          d          d                    }nt          |          }|                    |           |
                    dg           D ]i}t	          |t
                    rR|                    d          r=|                    |                     |t          d          d                               j || }|s|
}|||<   |r |j        di | t	          |t           j                  r|                     ||           d S )Nprovidesz
container.r,   r"   kwargsr#    )r   r$   getattrgetr(   str
startswith_resolve_providerlen_import_stringset_providesdictr%   appendadd_args
add_kwargsr
   r&   r   )r   r    r   r)   r*   r"   r,   r/   r.   arg_injectionsarg	injectionprovider_argsr+   provider_argkwarg_injectionsnames                    r   r   z#SchemaProcessorV1._setup_injections;   s^   
 I#2#8#8#:#: `	Q `	QM4y-88HDFxx
++H 0h,, 81D1D\1R1R 8#55hs<?P?P?R?R6STTHH-h77H%%h///!XXf--N $+) #+ #+C $I!#s++ U|0L0L U$($:$:3s<?P?P?R?R;S$T$T	 "#t,, B(*(9#''*:M:M(N(N#&77:#6#6# 	;)(C88 DX=P=P ,> > D ,0+A+A$,S->->-@-@$A," ," ,:(+C+C)00:::,/GGFB,?,? " "L) ,c    ""."9"9,"G"G" !. 4 4$($:$:(4S5F5F5H5H(I%& %&!" !" !"
 %2M=$A	$ ($'	KK	**** )!!4((#xx11 $-!1!7!7!9!9 #- #-ID# $I!#s++ U|0L0L U$($:$:3s<?P?P?R?R;S$T$T	 "#t,, B(*(9#''*:M:M(N(N#&77:#6#6# 	;)(C88 DX=P=P ,> > D ,0+A+A$,S->->-@-@$A," ," ,:(+C+C)00:::,/GGFB,?,? " "L) ,c    ""."9"9,"G"G" !. 4 4$($:$:(4S5F5F5H5H(I%& %&!" !" !"
 %2M=$A	$ ($'	#,F4LL .##--f---(I$788 Q&&tx&PPPA`	Q `	Qr   rC   c                    |                     d          }	 t          | j        |d                   }n# t          $ r Y d S w xY w|dd          D ]}d}d|v rMd|v rI||                    d          |                    d          dz            }|                    |d          }	 t          ||          }n# t          $ r Y  d S w xY w|r
 |            }|S )N.r   r    ())splitr1   r   AttributeErrorfindrfindreplace)r   rC   segmentsr"   segmentparenthesess         r   r5   z#SchemaProcessorV1._resolve_provider   s   ::c??	t<<HH 	 	 	44	  | 	& 	&GKg~~#..%gll3&7&7'--:L:Lq:P&PQ!//+r::"8W55!   ttt  &#8::s!   3 
A A$B55
CCr   )__name__
__module____qualname__ContainerSchemar   r   r   ProviderSchemar   r	   r&   r   r   r3   r
   Providerr5   r0   r   r   r   r      s       8 84 8 8 8 8: : :
) ) ) 59Q Q'Q J01Q 
	Q Q Q QB 59hQ hQ'hQ J01hQ 
	hQ hQ hQ hQTc hy7I.J      r   r   r   r   c                 p    t          |           }|                                 |                                S )zBuild provider schema.)r   r   r   )r   schema_processors     r   build_schemarY      s4    (00))+++r   provider_cls_namec                 t    t          |           }|r|S t          |           }|r|S t          d|  d          )NzUndefined provider class "")_fetch_provider_cls_from_std_import_provider_clsSchemaError)rZ   std_provider_typecustom_provider_types      r   r%   r%      sW    45FGG !  /0ABB $##
G3DGGG
H
HHr   c                 .    t          t          | d           S r   )r1   r
   )rZ   s    r   r]   r]      s     9/666r   c                    	 t          |           }t          |t                    r-t          |t          j                  st          d| d          |S # t          t          f$ r}t          d|  d          |d }~wt          $ r Y d S w xY w)NzProvider class "z+" is not a subclass of providers base classzCan not import provider "r\   )
r7   r(   type
issubclassr
   rV   r_   ImportError
ValueErrorrJ   )rZ   cls	exceptions      r   r^   r^      s    .// c4   	C9K)L)L 	S3SSS   
 $   <(9<<<
 
	    tts   A B&A::B
Bstring_namec                 $   |                      d          }t          |          dk    r t          t          |d         d           }|r|S d                    |d d                   }|sd S |d         }t          |          }t          ||d           S )NrE   r   r   )rI   r6   r1   builtinsjoinr   )rj   rN   membermodule_namemodules        r   r7   r7      s      %%H
8}}8A;55 	M((8CRC=))K tb\F;''F664(((r   c                       e Zd ZdZdS )r_   zSchema-related error.N)rQ   rR   rS   __doc__r0   r   r   r_   r_      s        r   r_   )rs   rm   	importlibr   typingr   r   r   r   rF   r	   r
   rT   rU   r   r3   rV   rY   r%   r]   r^   objectr7   	Exceptionr_   r0   r   r   <module>rx      s      # # # # # # , , , , , , , , , , , , # # # # # # # # sCx.c3hn n n n n n n nb, ,T#y7I2I-J , , , ,	I 	Ii6H1I 	I 	I 	I 	I77d9%&'7 7 7 7C HT)BT=U4V    ") )(8 ) ) ) )"         )          r   