U
    H4f                     @   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   )	namespaceZnsmapr   ZIdc                 C   s4   t | }|jdtd}|dkr0t }|| |S )zUReturn the security header. If the header doesn't exist it will be
    created.

    zwsse:Security)
namespacesN)r   findNSMAPWSSEZSecurityappend)docheadersecurity r   3/tmp/pip-unpacked-wheel-04z2hmy8/zeep/wsse/utils.pyget_security_header   s    
r   c                 C   s>   | pt j  } | jtjdd} |r2|  ddS |  S d S )Nr   )tzinfomicrosecondz+00:00Z)datetimeutcnowreplacepytzutc	isoformat)	timestampZ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k	st | t}|s,t }| t| |S )zqEnsure given node has a wsu:Id attribute; add unique one if not.

    Return found/created attribute value.

    N)AssertionErrorgetID_ATTRr!   set)nodeZid_valr   r   r   	ensure_id+   s    
r'   )NN)r   uuidr   r   lxmlr   Zlxml.builderr   Zzeepr   Zzeep.wsdl.utilsr   r   ZWSUr   QNamer$   r   r   r!   r'   r   r   r   r   <module>   s   
	