o
    .j                     @   s   d dl Z d dlmZ d dlmZmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ e jdk r6d d	lmZ nd d	lmZ G d
d dZG dd deZG dd deZdS )    N)Iterable)ClassVarUnion)etree)_Elementnsmap)
to_unicode)      )Selfc                   @   s   e Zd ZU dZee dB ed< dZee	dB  ed< dZ
e	dB ed< dZedB ed< dZdde	dB de	eB dB ddfdd	Zd
ed ed  f dd fddZde	fddZdefddZdeddfddZdeee B defddZdS )BaseElementNchildrentagvalue
attributesnamereturnc                 C   sB   g | _ i | _t|}d | _|d ur|| jd< |d ur|| _d S d S )Nr   )r   r   r	   r   )selfr   r    r   I/home/thesage/.local/lib/python3.10/site-packages/caldav/elements/base.py__init__   s   

zBaseElement.__init__otherc                 C   s
   |  |S N)append)r   r   r   r   r   __add__#   s   
zBaseElement.__add__c                 C   s    t j|  dddd}t|dS )Nzutf-8T)encodingxml_declarationpretty_print)r   tostring
xmlelementstr)r   utf8r   r   r   __str__&   s   
zBaseElement.__str__c                 C   sr   | j d u r	td| jd u rtdtj| j td}| jd ur#| j|_| jD ]}||| j|  q&| 	| |S )Nz"Unexpected value None for self.tagz)Unexpected value None for self.attributesr   )
r   
ValueErrorr   r   Elementr   r   textsetxmlchildren)r   rootkr   r   r   r    ,   s   




zBaseElement.xmlelementr)   c                 C   s0   | j d u r	td| j D ]	}||  qd S Nz'Unexpected value None for self.children)r   r$   r   r    )r   r)   cr   r   r   r(   @   s
   

zBaseElement.xmlchildrenelementc                 C   s<   | j d u r	tdt|tr| j | | S | j | | S r+   )r   r$   
isinstancer   extendr   )r   r-   r   r   r   r   G   s   

zBaseElement.append)NN)__name__
__module____qualname__r   listr   __annotations__r   r   r!   r   r   dictcaldav_classbytesr   r   r   r   r#   r   r    r(   r   r   r   r   r   r      s   
 $
r   c                       s8   e Zd ZddedB ddf fddZ fddZ  ZS )	NamedBaseElementNr   r   c                       t  j|d d S )N)r   superr   )r   r   	__class__r   r   r   T      zNamedBaseElement.__init__c                    s"   | j dd u rtdt  S )Nr   zname attribute must be defined)r   get	Exceptionr;   r    )r   r<   r   r   r    W   s   
zNamedBaseElement.xmlelementr   )r0   r1   r2   r!   r   r    __classcell__r   r   r<   r   r8   S   s    r8   c                       s0   e Zd ZddeeB dB ddf fddZ  ZS )ValuedBaseElementNr   r   c                    r9   )N)r   r:   )r   r   r<   r   r   r   ^   r>   zValuedBaseElement.__init__r   )r0   r1   r2   r!   r7   r   rA   r   r   r<   r   rB   ]   s    (rB   )syscollections.abcr   typingr   r   lxmlr   
lxml.etreer   caldav.lib.namespacer   caldav.lib.python_utilitiesr	   version_infotyping_extensionsr   r   r8   rB   r   r   r   r   <module>   s   
A
