a
    “I_  ã                   @   sl   d Z dZddlZddlmZ ddlmZ dZdZdZ	d	Z
d
d„ Zddgfdd„Zddgfdd„Zdd„ ZdS )z/Functions for setting up a Samba configuration.ZrestructuredTexté    N)Úread_and_sub_file)Ú	setup_dirZFULLZ	SUBDOMAINZNT4SYNCZDRSc                 C   s   t j tƒ | ¡S )zGReturn an absolute path to the provision tempate file specified by file)ÚosÚpathÚjoinr   )Úfile© r   ú8/usr/lib/python3/dist-packages/samba/provision/common.pyÚ
setup_path(   s    r
   zrelax:0c                 C   s(   t |tƒsJ ‚t||ƒ}|  ||¡ dS )a  Setup a ldb in the private dir.

    :param ldb: LDB file to import data into
    :param ldif_path: Path of the LDIF file to load
    :param subst_vars: Optional variables to subsitute in LDIF.
    :param nocontrols: Optional list of controls, can be None for no controls
    N)Ú
isinstanceÚstrr   Zadd_ldif©ÚldbÚ	ldif_pathÚ
subst_varsZcontrolsÚdatar   r   r	   Úsetup_add_ldif-   s    
r   c                 C   s   t ||ƒ}|  ||¡ dS )z°Modify a ldb in the private dir.

    :param ldb: LDB object.
    :param ldif_path: LDIF file path.
    :param subst_vars: Optional dictionary with substitution variables.
    N)r   Zmodify_ldifr   r   r   r	   Úsetup_modify_ldif:   s    
r   c                 C   sH   | dusJ ‚|   ¡  zt| ||ƒ W n   |  ¡  ‚ Y n
0 |  ¡  dS )a6  Import a LDIF a file into a LDB handle, optionally substituting
    variables.

    :note: Either all LDIF data will be added or none (using transactions).

    :param ldb: LDB file to import into.
    :param ldif_path: Path to the LDIF file.
    :param subst_vars: Dictionary with substitution variables.
    N)Ztransaction_startr   Ztransaction_cancelZtransaction_commit)r   r   r   r   r   r	   Ú	setup_ldbE   s    
r   )Ú__doc__Z__docformat__r   Zsambar   Zsamba.paramr   Z	FILL_FULLZFILL_SUBDOMAINZFILL_NT4SYNCZFILL_DRSr
   r   r   r   r   r   r   r	   Ú<module>   s   