
    Vh              	          U d Z ddlmZmZ ddlmZmZmZmZm	Z	 ddl
mZmZ  e	d      Z e	d      Z e	d      Zded	ee   d
efdZdeegef   dee   d
ee   fdZdee   dee   d
efdZdeeegef   d
eeegef   fdZdeegef   deegef   d
eegef   fdZ eej,                   e ee       ed                  Zeee   ged   f   ed<   deegef   deg ee   f   d
efdZdeegef   d
eg ef   fdZy)z1
General functional-style helpers for disttrial.
    )partialwraps)	AwaitableCallableIterableOptionalTypeVar)Deferredsucceed_A_B_Cdefaultoptionalreturnc                     || S |S )z
    Get a definite value from an optional value.

    @param default: The value to return if the optional value is missing.

    @param optional: The optional value to return if it exists.
     )r   r   s     N/home/dcms/DCMS/lib/python3.12/site-packages/twisted/trial/_dist/functional.pyfromOptionalr      s     O    	conditionxsc              #   6   K   |D ]  } | |      r|  y yw)z
    @return: An iterable over C{xs} that stops when C{condition} returns
        ``False`` based on the value of iterated C{xs}.
    Nr   )r   r   xs      r   	takeWhiler      s&     
  Q<G	s   abc                 :   K   |  d{    | d{   S 7 7 w)z
    Wait for one action to complete and then another.

    If either action fails, failure is propagated.  If the first action fails,
    the second action is not waited on.
    Nr   )r   r   s     r   sequencer   +   s      GG7N s   	fc                 .     t                fd       }|S )zc
    Create a function like another but with the order of the first two
    arguments flipped.
    c                      ||       S Nr   )r   r   r    s     r   gzflip.<locals>.g<   s    Awr   r   )r    r$   s   ` r   flipr&   6   s"     1X  Hr   fxfyc                 N     t               t               fd              }|S )z
    Create a function that calls one function with an argument and then
    another function with the result of the first function.
    c                        |             S r#   r   )r   r'   r(   s    r   r$   zcompose.<locals>.gI   s     "Q%yr   r%   )r'   r(   r$   s   `` r   composer+   C   s.     2Y
2Y   Hr   NdiscardResult	predicateactionc                 D   K   	  |        d{   } | |      s|S 7 w)z
    Call a function repeatedly until its result fails to satisfy a predicate.

    @param predicate: The check to apply.

    @param action: The function to call.

    @return: The result of C{action} which did not satisfy C{predicate}.
    Nr   )r-   r.   results      r   iterateWhiler1   X   s)      x M s     c                 (     ddt         f fd}|S )z
    Wrap a function with another that automatically passes an integer counter
    of the number of calls that have gone through the wrapper.
    r   r   c                  8    	        } dz  | S # dz  w xY w)N   r   )r0   counterr    s    r   r$   zcountingCalls.<locals>.gr   s,    	wZFqLG qLGs    )r   )r    r$   r5   s   ` @r   countingCallsr6   k   s    
 Gr  Hr   )__doc__	functoolsr   r   typingr   r   r   r   r	   twisted.internet.deferr
   r   r   r   r   r   boolr   r   r&   r+   fromCoroutiner,   __annotations__r1   intr6   r   r   r   <module>r?      s   % C C 4T]T]T]
" 
 
 
	2$*- 	8B< 	HRL 	im 	" " 
Hb"Xr\" 
xR"'= 
"r" "r(: xb?Q  <CDNGDM*<x2$78 d
#R2&' &XseRi( Xb"f-= r   