
    i1                       d 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m	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZ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  er 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*  G d de           Z+dgZ,dS )zQThis implementes the VAVAILABILITY component.

This is specified in :rfc:`7953`.
    )annotationsN)datetime)TYPE_CHECKING)CONCEPTS_TYPE_SETTERLINKS_TYPE_SETTERRELATED_TO_TYPE_SETTERbusy_type_propertycategories_propertyclass_propertycontacts_propertydescription_propertyduration_propertylocation_propertyorganizer_propertypriority_propertyrfc_7953_dtend_propertyrfc_7953_dtstart_propertyrfc_7953_duration_propertyrfc_7953_end_propertysequence_propertysummary_propertyurl_property)get_example)InvalidCalendar   )	Component)Sequence)date)	Available)BUSYTYPECLASS)vCalAddressc                       e Zd ZdZdZdZdZdZdZe	Z
eZeZeZeZeZeZeZeZeZeZexZ Z!e"Z# e$d           Z%e&Z'e(Z)e*d6d	            Z+e,	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d7d8 fd1            Z-e,d9d:d5            Z. xZ/S );Availabilitya!  VAVAILABILITY component from :rfc:`7953`.

    This provides a grouping of component properties and
    subcomponents that describe the availability associated with a
    calendar user.

    Description:
        A "VAVAILABILITY" component indicates a period of time
        within which availability information is provided.  A
        "VAVAILABILITY" component can specify a start time and an end time
        or duration.  If "DTSTART" is not present, then the start time is
        unbounded.  If "DTEND" or "DURATION" are not present, then the end
        time is unbounded.  Within the specified time period, availability
        defaults to a free-busy type of "BUSY-UNAVAILABLE" (see
        Section 3.2), except for any time periods corresponding to
        "AVAILABLE" subcomponents.

        "AVAILABLE" subcomponents are used to indicate periods of free
        time within the time range of the enclosing "VAVAILABILITY"
        component.  "AVAILABLE" subcomponents MAY include recurrence
        properties to specify recurring periods of time, which can be
        overridden using normal iCalendar recurrence behavior (i.e., use
        of the "RECURRENCE-ID" property).

        If specified, the "DTSTART" and "DTEND" properties in
        "VAVAILABILITY" components and "AVAILABLE" subcomponents MUST be
        "DATE-TIME" values specified as either the date with UTC time or
        the date with local time and a time zone reference.

        The iCalendar object containing the "VAVAILABILITY" component MUST
        contain appropriate "VTIMEZONE" components corresponding to each
        unique "TZID" parameter value used in any DATE-TIME properties in
        all components, unless [RFC7809] is in effect.

        When used to publish available time, the "ORGANIZER" property
        specifies the calendar user associated with the published
        available time.

        If the "PRIORITY" property is specified in "VAVAILABILITY"
        components, it is used to determine how that component is combined
        with other "VAVAILABILITY" components.  See Section 4.

        Other calendar properties MAY be specified in "VAVAILABILITY" or
        "AVAILABLE" components and are considered attributes of the marked
        block of time.  Their usage is application specific.  For example,
        the "LOCATION" property might be used to indicate that a person is
        available in one location for part of the week and a different
        location for another part of the week (but see Section 9 for when
        it is appropriate to add additional data like this).

    Example:
        The following is an example of a "VAVAILABILITY" calendar
        component used to represent the availability of a user, always
        available Monday through Friday, 9:00 am to 5:00 pm in the
        America/Montreal time zone:

        .. code-block:: ics

            BEGIN:VAVAILABILITY
            ORGANIZER:mailto:bernard@example.com
            UID:0428C7D2-688E-4D2E-AC52-CD112E2469DF
            DTSTAMP:20111005T133225Z
            BEGIN:AVAILABLE
            UID:34EDA59B-6BB1-4E94-A66C-64999089C0AF
            SUMMARY:Monday to Friday from 9:00 to 17:00
            DTSTART;TZID=America/Montreal:20111002T090000
            DTEND;TZID=America/Montreal:20111002T170000
            RRULE:FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR
            END:AVAILABLE
            END:VAVAILABILITY

        You can get the same example from :meth:`example`:

        .. code-block: pycon

            >>> from icalendar import Availability
            >>> a = Availability.example()
            >>> a.organizer
            vCalAddress('mailto:bernard@example.com')

        The following is an example of a "VAVAILABILITY" calendar
        component used to represent the availability of a user available
        Monday through Thursday, 9:00 am to 5:00 pm, at the main office,
        and Friday, 9:00 am to 12:00 pm, in the branch office in the
        America/Montreal time zone between October 2nd and December 2nd
        2011:

        .. code-block:: ics

            BEGIN:VAVAILABILITY
            ORGANIZER:mailto:bernard@example.com
            UID:84D0F948-7FC6-4C1D-BBF3-BA9827B424B5
            DTSTAMP:20111005T133225Z
            DTSTART;TZID=America/Montreal:20111002T000000
            DTEND;TZID=America/Montreal:20111202T000000
            BEGIN:AVAILABLE
            UID:7B33093A-7F98-4EED-B381-A5652530F04D
            SUMMARY:Monday to Thursday from 9:00 to 17:00
            DTSTART;TZID=America/Montreal:20111002T090000
            DTEND;TZID=America/Montreal:20111002T170000
            RRULE:FREQ=WEEKLY;BYDAY=MO,TU,WE,TH
            LOCATION:Main Office
            END:AVAILABLE
            BEGIN:AVAILABLE
            UID:DF39DC9E-D8C3-492F-9101-0434E8FC1896
            SUMMARY:Friday from 9:00 to 12:00
            DTSTART;TZID=America/Montreal:20111006T090000
            DTEND;TZID=America/Montreal:20111006T120000
            RRULE:FREQ=WEEKLY
            LOCATION:Branch Office
            END:AVAILABLE
            END:VAVAILABILITY

        For more examples, have a look at :rfc:`5545`.

    VAVAILABILITY)	DTSTARTDTENDDURATIONDTSTAMPUIDSEQUENCESUMMARYDESCRIPTION	ORGANIZER)r&   r)   r*   )r)   r*   r    r!   CREATEDr-   r&   zLAST-MODIFIEDLOCATIONr.   PRIORITYr+   r,   URLr'   r(   )r'   r(   returnlist[Available]c                ,    |                      d          S )zAll VAVAILABLE sub-components.

        This is a shortcut to get all VAVAILABLE sub-components.
        Modifications do not change the calendar.
        Use :py:meth:`Component.add_component`.
        	AVAILABLE)walk)selfs    U/root/projects/butler/venv/lib/python3.11/site-packages/icalendar/cal/availability.py	availablezAvailability.available   s     yy%%%    N 	busy_typeBUSYTYPE | None
categoriesSequence[str]commentslist[str] | str | None
componentsSequence[Available] | Noneconceptsr   contactscreateddate | NoneclassificationCLASS | Nonedescription
str | Noneenddatetime | Nonelast_modifiedlinksr   location	organizervCalAddress | str | Nonepriority
int | Nonerefids
related_tor   sequencestampstartsummaryuidstr | uuid.UUID | Noneurlc          
        t                                          ||n|                                 |||||||          }||_        |	|_        ||nt          j                    |_        ||_        ||_	        ||_
        ||_        ||_        ||_        ||_        ||_        ||_        |D ]}|                    |           | j        rp|+t'          |t(                    r|j        t-          d          |
+t'          |
t(                    r|
j        t-          d          |                    ||
           ||_        |
|_        |S )aQ  Create a new event with all required properties.

        This creates a new Availability in accordance with :rfc:`7953`.

        Parameters:
            busy_type: The :attr:`busy_type` of the availability.
            categories: The :attr:`categories` of the availability.
            classification: The :attr:`classification` of the availability.
            comments: The :attr:`comments` of the availability.
            concepts: The :attr:`concepts` of the availability.
            contacts: The :attr:`contacts` of the availability.
            created: The :attr:`created` of the availability.
            description: The :attr:`description` of the availability.
            end: The :attr:`end` of the availability.
            last_modified: The :attr:`last_modified` of the
                availability.
            links: The :attr:`links` of the availability.
            location: The :attr:`location` of the availability.
            organizer: The :attr:`organizer` of the availability.
            refids: :attr:`refids` of the availability.
            related_to: :attr:`related_to` of the availability.
            sequence: The :attr:`sequence` of the availability.
            stamp: The :attr:`stamp` of the availability.
                If None, this is set to the current time.
            start: The :attr:`start` of the availability.
            summary: The :attr:`summary` of the availability.
            uid: The :attr:`uid` of the availability.
                If ``None``, this is set to a new :func:`uuid.uuid4`.
            url: The :attr:`url` of the availability.

        Returns:
            :class:`Availability`

        Raises:
            ~error.InvalidCalendar: If the content is not valid
                according to :rfc:`7953`.

        .. warning:: As time progresses, we will be stricter with the validation.
        N)rY   rG   rA   rO   rP   rW   rV   rE   z5Availability start must be a datetime with a timezonez3Availability end must be a datetime with a timezone)supernew_utc_nowr[   rK   uuiduuid4r\   rX   r?   rI   r^   r=   rR   rQ   rT   rF   add_component_validate_new
isinstancer   tzinfor   _validate_start_and_endrZ   rM   )clsr=   r?   rA   rC   rE   rF   rG   rI   rK   rM   rO   rP   rQ   rR   rT   rV   rW   rX   rY   rZ   r[   r\   r^   availabilitysubcomponent	__class__s                             r9   ra   zAvailability.new   s   F &+WW[[ ,%%#,,..'! &1 	&
 	&
  '#. "%/33tz|| (",&4#!*!* ( ( (& 	5 	5L&&|4444 	= uh// !38<3G%K   sH-- 141C%I   00<<<"r;   
rfc_7953_1namestrc                H    |                      t          d|                    S )z0Return the calendar example with the given name.availabilities)	from_icalr   )rj   ro   s     r9   examplezAvailability.exampleZ  s!     }}[)94@@AAAr;   )r3   r4   )Nr<   Nr<   NNNNNNNNNNNNNNNNNNN).r=   r>   r?   r@   rA   rB   rC   rD   rE   r   rF   rB   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rH   rP   r   rQ   rL   rR   rS   rT   rU   rV   rB   rW   r   rX   rU   rY   rH   rZ   rN   r[   rL   r\   r]   r^   rL   )rn   )ro   rp   r3   r$   )0__name__
__module____qualname____doc__ro   canonical_orderrequired
singletons	exclusiver   rR   r	   r=   r   r[   r   rK   r   rX   r   rI   r   r^   r   rQ   r
   r?   r   rT   r   rF   r   rZ   r&   r   r'   r   r(   r   durationr   rM   propertyr:   classmethodra   rt   __classcell__)rm   s   @r9   r$   r$   /   s{       s sj D
OHJ&I
 #I"IG&K H#N
C H$J H H//EG#E  00H)H
C& & & X&  &*$&+/13)-+/#'+"&#%)#'#.2#)--1#!!%"&*3j j j j j j [jX B B B B [B B B B Br;   r$   )-rx   
__future__r   rc   r   typingr   icalendar.attrr   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   icalendar.cal.examplesr   icalendar.errorr   	componentr   collections.abcr   r   icalendar.cal.availabler   icalendar.enumsr    r!   icalendar.propr"   r$   __all__r<   r;   r9   <module>r      s   
 # " " " " "                                                            * / . . . . . + + + + + +             +((((((111111////////******nB nB nB nB nB9 nB nB nBb	 
r;   