
    ?De                         d Z ddlmZ g dZddlZddlZddlZddlZddlZddlm	Z	 ddlm
Z
 ddlmZmZ ddlmZ 	 ddlZd
 Zdej        dddfdZd Zd Zd Zd Zd ZdS )z_
functions.py - wraps functions of module _ldap

See https://www.python-ldap.org/ for details.
    )__version__)
open
initializeinit
explode_dnexplode_rdn
get_option
set_option
escape_str	strf_secs	strp_secsN)timegm)	LDAPError)r   r   
LDAPObjectTc           
      
   | r|                                   	 t          j        dk    rt          j                            d                    d|j        t          j        ||f                               t          j        dk    r*t          j
        t          j        t          j                   	 	  ||i |}| r|                                  n# | r|                                  w w xY wnR# t          $ rE}t          j        dk    r/t          j                            dt          |          z              d	}~ww xY wt          j        dk    r4t          j                            d
t          j        |          z             |S )z
  Wrapper function which locks and logs calls to function

  lock
      Instance of threading.Lock or compatible
  func
      Function to call with arguments passed in via *args and **kwargs
  T   z*** {}.{} {}
_ldap	   )limitfile   z=> LDAPError: %s
Nz=> result:
%s
)acquireldap_trace_level_trace_filewriteformat__name__pprintpformat	tracebackprint_stack_trace_stack_limitreleaser   str)lockfuncargskwargsresultes         /./ldap/functions.py_ldap_function_callr.      s    
 LLNNNS!
-44V}%%  	 	 	 
	A		D$;AQRRRR	
tT#F##f	  
 	 
 
 
&))
1SVV<===	
 $a''-1G1GHIII	-s+   1C 9C- C))C- -
D<7A D77D<c                 (    t          | ||||fd|i|S )a  
  Return LDAPObject instance by opening LDAP connection to
  LDAP host specified by LDAP URL

  Parameters:
  uri
        LDAP URL containing at least connection scheme and hostport,
        e.g. ldap://localhost:389
  trace_level
        If non-zero a trace output of LDAP calls is generated.
  trace_file
        File object where to write the trace output to.
        Default is to use stdout.
  bytes_mode
        Whether to enable :ref:`bytes_mode` for backwards compatibility under Py2.
  fileno
        If not None the socket file descriptor is used to connect to an
        LDAP server.

  Additional keyword arguments (such as ``bytes_strictness``) are
  passed to ``LDAPObject``.
  filenor   )uritrace_level
trace_filetrace_stack_limit
bytes_moder0   r*   s          r-   r   r   A   s7    4 
	;
$5z
 


 
     c                 8    t          dt          j        |           S )zJ
  get_option(name) -> value

  Get the value of an LDAP global option.
  N)r.   r   r	   )options    r-   r	   r	   a   s     
T%"26	:	::r6   c                 :    t          dt          j        | |          S )zH
  set_option(name, value)

  Set the value of an LDAP global option.
  N)r.   r   r
   )r8   invalues     r-   r
   r
   j   s     
T%"26'	B	BBr6   c                 @     |t           fd|D                       z  S )ze
  Applies escape_func() to all items of `args' and returns a string based
  on format string `s'.
  c              3   .   K   | ]} |          V  d S )N ).0vescape_funcs     r-   	<genexpr>zescape_str.<locals>.<genexpr>x   s+      00a;;q>>000000r6   )tuple)r@   sr)   s   `  r-   r   r   s   s-    
 
U0000400000	00r6   c                 P    t          j        dt          j        |                     S )zZ
    Convert seconds since epoch to a string compliant to LDAP syntax GeneralizedTime
    %Y%m%d%H%M%SZ)timestrftimegmtime)secss    r-   r   r   {   s      =$+d*;*;<<<r6   c                 F    t          t          j        | d                    S )zD
    Convert LDAP syntax GeneralizedTime to seconds since epoch
    rE   )r   rF   strptime)dt_strs    r-   r   r      s     $-88999r6   )__doc__r   r   __all__sysr    rF   r   calendarr   r   ldap.dnr   r   ldap.ldapobjectr   r"   r.   stdoutr   r	   r
   r   r   r   r=   r6   r-   <module>rT      s^            " ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !             * * * * * * * * & & & & & &  F 3:D   @; ; ;C C C1 1 1= = =: : : : :r6   