o
    Žõ±j:  ã                   @   s^   d dl mZ d dlmZ d dlmZ d dlmZ defdd„Z	dd	„ Z
d
e	fdefdd„ZdS )é    )ÚSMBDirectory)ÚSMBConnection)ÚSMBFile)ÚminidomÚdatac                 Ã   s   �d S )N© )r   r   r   ú�/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/aiosmb/commons/utils/cpasswd.pyÚdummy_print_cb   s   €r	   c              
   C   s€   g }t  |¡}|jd j}dd„ }|jD ])}dd„ |jD ƒD ]}| d¡D ]}||dƒ}	||dƒ}
| |	|
| |d	œ¡ q%qq|S )
Nr   c                 S   s   |   |¡d ur|   |¡S dS )NÚ )ÚgetAttribute)ÚelementÚ	attributer   r   r   Ú<lambda>   ó    zparse_cpasswd.<locals>.<lambda>c                 S   s   g | ]
}t |tjƒr|‘qS r   )Ú
isinstancer   ÚElement)Ú.0Úcr   r   r   Ú
<listcomp>   r   z!parse_cpasswd.<locals>.<listcomp>Ú
PropertiesÚuserNameÚ	cpassword)Úusernamer   ÚfilenameÚxmltype)r   ÚparseStringÚ
childNodesÚtagNameÚgetElementsByTagNameÚappend)r   r   ÚresultsÚrootr   Úread_or_emptyÚtopnodeÚtaskÚpropertyr   r   r   r   r   Úparse_cpasswd
   s$   




üýÿ
r&   é   Ú
connectionc                 C  s¬  �z¹d| j  ¡ df }t |¡}|j| |d�2 zŸ3 d H W \}}}|d ur%q|dkr¶|j d¡du r¶||jƒI d H  t |j¡}| 	| ¡I d H \}	}|d urNq| 
¡ I d H \}
}|d ur\q| ¡ I d H  |
jddd	�}
|
 ¡  d
¡du rtqzt|j|
ƒ}W n ty— } z|d| ƒI d H  W Y d }~qd }~ww |D ]}| d
d¡dkr¥qš|d |d |d
 |d d fV  qšq6 W d S  tyÕ } zd d d d |fV  W Y d }~d S d }~ww )Nz\\%s\%sÚSYSVOL)ÚdepthÚfilez.xmlTzutf-8Úignore)Úerrorsr   Fz[-] Error parsing xml file: %sr
   r   r   r   )ÚtargetÚget_hostname_or_ipr   Úfrom_uncpathÚlist_rÚfullpathÚendswithÚunc_pathr   ÚopenÚreadÚcloseÚdecodeÚlowerÚfindr&   Ú	ExceptionÚget)r(   r*   Úprint_cbÚuncpathÚsysvolÚpathÚotypeÚerrr+   Ú_r   r    ÚeÚresultr   r   r   Úfind_cpasswd   sL   €
 €þ"€æ€ÿrF   N)Ú#aiosmb.commons.interfaces.directoryr   Úaiosmb.connectionr   Úaiosmb.commons.interfaces.filer   Úxml.domr   Ústrr	   r&   rF   r   r   r   r   Ú<module>   s    