
    }ft                         d dl Z d dlZd dlmZmZmZmZmZ d dlm	Z	 ddl
m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  G d de      Zy)    N)DictIterableOptionalSetUnion)	text_type   )	Component)Event)	Containercalendar_string_to_containers)Timeline)Todo)CalendarParser)CalendarSerializerc            	           e Zd ZdZ G d d      Z	 	 	 	 ddeeef   dee	   dee
   defd	Zed
        ZdefdZdee   fdZdedefdZdedefdZedee   fd       Zej.                  dee   ddfd       Zd Zy)Calendarz
    Represents an unique rfc5545 iCalendar.

    Attributes:

        events: a set of Event contained in the Calendar
        todos: a set of Todo contained in the Calendar
        timeline: a Timeline instance linked to this Calendar

    c                       e Zd ZdZeZeZy)Calendar.Meta	VCALENDARN)__name__
__module____qualname__namer   parserr   
serializer     L/var/www/feuerwehr-webapp/venv/lib/python3.12/site-packages/ics/icalendar.pyMetar      s    '
r   r    Nimportseventstodoscreatorc                    i | _         t               | _        t               | _        t	        d      | _        d| _        d| _        t        |       | _	        |[t        |t              r| j                  |       yt        |      }t        |      dk7  rt        d      | j                  |d          y|$| j                  j                  t        |             |$| j                  j                  t        |             || _        y)a  Instantiates a new Calendar.

        Args:
            imports (**str**): data to be imported into the Calendar,
            events (**Set[Event]**): Events to be added to the calendar
            todos (Set[Todo]): Todos to be added to the calendar
            creator (string): uid of the creator program.

        If ``imports`` is specified, every other argument will be ignored.
        r   )r   Nr	   zbMultiple calendars in one file are not supported by this method. Use ics.Calendar.parse_multiple()r   )
_timezonessetr"   r#   r   extrascalemethodr   timeline
isinstance	_populater   lenNotImplementedErrorupdate_creator)selfr!   r"   r#   r$   
containerss         r   __init__zCalendar.__init__!   s    $ !#"%% #
K0

 '9-w':7C
z?a'-|~ ~ z!}-!""3v;/ 

!!#e*-#DMr   c                 P    t        |      }|D cg c]  } | |       c}S c c}w )z"
        Parses an input string that may contain mutiple calendars
        and retruns a list of :class:`ics.event.Calendar`
        )r!   )r   )clsstringr3   cs       r   parse_multiplezCalendar.parse_multipleM   s&     36:
(231A333s   #returnc                     dj                  t        | j                        t        | j                        dkD  rdndt        | j                        t        | j                        dkD  rd      S d      S )Nz(<Calendar with {} event{} and {} todo{}>r	   s )formatr.   r"   r#   r2   s    r   __repr__zCalendar.__repr__V   s`    9VC$t{{+a/CR

Otzz?Q.C8	8 578	8r   c              #   t   K   t        j                  dt               | j                         E d{    y7 w)a5  Returns:
        iterable: an iterable version of seralize(), line per line
        (with line-endings).

        Example:
            Can be used to write calendar to a file:

            >>> c = Calendar(); c.events.add(Event(name="My cool event"))
            >>> open('my.ics', 'w').writelines(c)
        zUsing Calendar as Iterable is deprecated and will be removed in version 0.8. Use the explicit calendar.serialize_iter() instead.N)warningswarnDeprecationWarningserialize_iterr?   s    r   __iter__zCalendar.__iter__]   s2      	BCU	W &&(((s   .868otherc                     t        |t              st        dD ]'  }| j                  |      |j                  |      k7  s' y | j                  |j                  k(  xr | j
                  |j
                  k(  S )N)r(   r)   r*   r$   F)r,   r   r/   __getattribute__r"   r#   )r2   rG   attrs      r   __eq__zCalendar.__eq__m   si    %*%%; 	D$$T*e.D.DT.JJ	 u||+L$**2KLr   c                 &    | j                  |       S )N)rK   )r2   rG   s     r   __ne__zCalendar.__ne__v   s    ;;u%%%r   c                     | j                   S )zGet or set the calendar's creator.

        |  Will return a string.
        |  May be set to a string.
        |  Creator is the PRODID iCalendar property.
        |  It uniquely identifies the program that created the calendar.
        )r1   r?   s    r   r$   zCalendar.creatory   s     }}r   valuec                 x    t        |t              s#t        dj                  t	        |                  || _        y )Nz)Event.creator must be unicode data not {})r,   r   
ValueErrorr>   typer1   )r2   rO   s     r   r$   zCalendar.creator   s1    %+HOOPTUZP[\]]r   c                 F   t        j                   |       }|j                  j                         |_        t        j                   | j                        |_        t        j                   | j                        |_        t        j                   | j
                        |_        |S )zK
        Returns:
            Calendar: an exact deep copy of self
        )copyr(   cloner"   r#   r&   )r2   rU   s     r   rU   zCalendar.clone   sg    
 		$kk'')yy-ii

+99T__5r   )NNNN)r   r   r   __doc__r    r   strr   r   r   r   r4   classmethodr9   r@   rF   objectboolrK   rM   propertyr   r$   setterrU   r   r   r   r   r      s   	( ( *."& $*$sI~&*$ *$ ~	*$
 *$X 4 48# 8)(3- ) MF Mt M&F &t & #   ^^Xc] t  

r   r   )rT   rB   typingr   r   r   r   r   sixr   	componentr
   eventr   ics.grammar.parser   r   r+   r   todor   ics.parsers.icalendar_parserr   $ics.serializers.icalendar_serializerr   r   r   r   r   <module>re      s7      7 7     F   7 CDy Dr   