o  iT @sXddlmZddlmZddgZddlmZddlmZGdddZ GdddZ d S) ) annotations)wrapsRestartGeneratorMethodReplacer) Generator)Callablec@s$eZdZdZd ddZd d d Zd S)rz Wraps a generator callable which will be called whenever this class is iterated and its result returned. This is used to create an iterator which can start iteration over the given generator multiple times. create_genCallable[[], Generator]returnNonecC ||_dSNr)selfrrX/home/dell461/cl/sdc2/last_ska_mid/HISourceFinder-master-l/src/monai/utils/decorators.py__init__ zRestartGenerator.__init__rcCs|Sr r)rrrr__iter__szRestartGenerator.__iter__N)rr r r )r r)__name__ __module__ __qualname____doc__rrrrrrrs c@s.eZdZdZdZdddZd d Zd d Zd S)rz Base class for method decorators which can be used to replace methods pass to replace_method() with wrapped versions. Z__replacemethods__methrr r cCr r )rrrrrrr*rzMethodReplacer.__init__cCs|S)zl Return a new method to replace `meth` in the instantiated object, or `meth` to do nothing. rrrrrreplace_method-szMethodReplacer.replace_methodcs|jf}t|js&|jtfdd}||_t|j|gnt|j}tfdd|Ds<||t|j dS)a Add the (name,self.replace_method) pair to the list named by replace_list_name in `owner`, creating the list and replacing the constructor of `owner` if necessary. The replaced constructor will call the old one then do the replacing operation of substituting, for each (name,self.replace_method) pair, the named method with the returned value from self.replace_method. csZ|g|Ri|t|jD]\}}}t||r*t||}||}t|||qdSr )getattrreplace_list_name isinstancesetattr)_selfargskwargsmownerZreplacerrZnewmeth)oldinitrrrnewinit@s   z,MethodReplacer.__set_name__..newinitc3s|] }|dkVqdS)rNr).0nl)namerr Psz.MethodReplacer.__set_name__..N) rhasattrrrrrranyappendr)rr$r)entryr&namelistr)r)r%rr __set_name__3s     zMethodReplacer.__set_name__N)rrr r )rrrrrrrr0rrrrr#s   N) __future__r functoolsr__all__collections.abcrtypingrrrrrrrs