o
    g                     @   s   d dl Z d dlmZ d dlZd dlmZ d dlmZ d dlm	Z	 d dl
mZ e	je	jdZeed de	jid	Zeed
 d
e	jid	Zeed
 dZdd ZdddZdd Zdd ZdS )    N)uuid4)etree)ElementMaker)ns)get_or_create_header)wssewsur   )	namespacensmapr   Idc                 C   s4   t | }|jdtd}|du rt }|| |S )zUReturn the security header. If the header doesn't exist it will be
    created.

    zwsse:Security)
namespacesN)r   findNSMAPWSSESecurityappend)docheadersecurity r   H/home/ubuntu/webapp/venv/lib/python3.10/site-packages/zeep/wsse/utils.pyget_security_header   s   
r   c                 C   s@   | p	t j t jj} | jtjdd} |r|  ddS |  S )Nr   )tzinfomicrosecondz+00:00Z)datetimenowtimezoneutcreplacepytz	isoformat)	timestampzulu_timestampr   r   r   get_timestamp   s
   r$   c                   C   s   d t S )Nzid-{0})formatr   r   r   r   r   get_unique_id'   s   r&   c                 C   s0   | dusJ |  t}|st }| t| |S )zqEnsure given node has a wsu:Id attribute; add unique one if not.

    Return found/created attribute value.

    N)getID_ATTRr&   set)nodeid_valr   r   r   	ensure_id+   s   
r,   )NN)r   uuidr   r    lxmlr   lxml.builderr   zeepr   zeep.wsdl.utilsr   r   WSUr   QNamer(   r   r$   r&   r,   r   r   r   r   <module>   s    
	