
    i5                    X   d Z ddlmZ ddlZddlmZmZmZ ddlmZ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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/m0Z0 ddl1m2Z2 er dd	l3m4Z4 dd
l5m6Z6 ddl7m8Z8m9Z9 ddl:m;Z; ddl<m=Z=  G d de0          Z>dgZ?dS )z:rfc:`5545` VTODO component.    )annotationsN)datedatetime	timedelta)TYPE_CHECKINGLiteral)$CONCEPTS_TYPE_SETTERLINKS_TYPE_SETTERRELATED_TO_TYPE_SETTERX_MOZ_LASTACK_propertyX_MOZ_SNOOZE_TIME_propertyattendees_propertycategories_propertyclass_propertycolor_propertyconferences_propertycontacts_propertycreate_single_propertydescription_propertyexdates_propertyget_duration_propertyget_end_property&get_start_end_duration_with_validationget_start_propertyimages_propertylocation_propertyorganizer_propertypriority_propertyproperty_del_durationproperty_doc_duration_templateproperty_get_durationproperty_set_durationrdates_propertyrrules_propertysequence_propertyset_duration_with_lockingset_end_with_lockingset_start_with_lockingstatus_propertysummary_propertyuid_propertyurl_property)	Component)get_example)SequenceAlarms)CLASSSTATUS)vCalAddress)
Conferencec                  f    e Zd ZdZdZdZdZdZdZ e	dde
efed	          Z e	d
de
efed          Z eeee ej        d                    Zd ZedUd            Zej        dVd            ZedUd            Zej        dWd            ZedXd            Zej        dYd            Z	 dZd[dZ	 d\d]d"Z	 dZd^d$ZeZeZ ed_d&            Z!e"Z#e$Z%e&Z'e(Z)e*Z+e,Z-e.Z/e0Z1e2Z3e4Z5e6Z7e8Z9e:Z;e<Z=e>Z?e@ZAeBZCeDZEeFZGd'd(lHmIZI eJ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d`da fdP            ZKeJdbdcdT            ZL xZMS )dTodoa  
    A "VTODO" calendar component is a grouping of component
    properties that represents an action item or assignment. For
    example, it can be used to represent an item of work assigned to
    an individual, such as "Prepare for the upcoming conference
    seminar on Internet Calendaring".

    Examples:
        Create a new Todo:

            >>> from icalendar import Todo
            >>> todo = Todo.new()
            >>> print(todo.to_ical())
            BEGIN:VTODO
            DTSTAMP:20250517T080612Z
            UID:d755cef5-2311-46ed-a0e1-6733c9e15c63
            END:VTODO

        Complete the example Todo.

        .. code-block:: pycon

            >>> from datetime import datetime, timezone
            >>> from icalendar import Todo, STATUS
            >>> todo = Todo.example()
            >>> todo["PERCENT-COMPLETE"] = 100
            >>> todo["COMPLETED"] = datetime(2007, 5, 1, 12, tzinfo=timezone.utc)
            >>> todo.status = STATUS.COMPLETED
            >>> print(todo.to_ical().decode())
            BEGIN:VTODO
            CATEGORIES:FAMILY,FINANCE
            CLASS:CONFIDENTIAL
            COMPLETED:2007-05-01 12:00:00+00:00
            DTSTAMP:20070313T123432Z
            DUE;VALUE=DATE:20070501
            PERCENT-COMPLETE:100
            STATUS:COMPLETED
            SUMMARY:Submit Quebec Income Tax Return for 2006
            UID:20070313T123432Z-456553@example.com
            END:VTODO

    VTODO)UIDDTSTAMP)r2   COLOR	COMPLETEDCREATEDDESCRIPTIONr:   DTSTARTGEOzLAST-MODIFIEDLOCATION	ORGANIZERzPERCENT-COMPLETEPRIORITYzRECURRENCE-IDSEQUENCEr3   SUMMARYr9   URLDUEDURATION)rG   rH   )ATTACHATTENDEE
CATEGORIESCOMMENTCONTACTEXDATERSTATUSRELATED	RESOURCESRDATERRULEr?   dtzOThe "DTSTART" property for a "VTODO" specifies the inclusive start of the Todo.rG   z`The "DUE" property for a "VTODO" calendar component specifies the non-inclusive end of the Todo.)	componentc                &    t          | ddd          S )z=Verify the calendar validity and return the right attributes.r?   rG   r8   )r   selfs    M/root/projects/butler/venv/lib/python3.11/site-packages/icalendar/cal/todo.py_get_start_end_durationzTodo._get_start_end_duration   s    5dIugVVV    returndate | datetimec                     t          |           S )a  The start of the VTODO.

        Invalid values raise an InvalidCalendar.
        If there is no start, we also raise an IncompleteComponent error.

        You can get the start, end and duration of a Todo as follows:

        >>> from datetime import datetime
        >>> from icalendar import Todo
        >>> todo = Todo()
        >>> todo.start = datetime(2021, 1, 1, 12)
        >>> todo.end = datetime(2021, 1, 1, 12, 30) # 30 minutes
        >>> todo.duration  # 1800 seconds == 30 minutes
        datetime.timedelta(seconds=1800)
        >>> print(todo.to_ical())
        BEGIN:VTODO
        DTSTART:20210101T120000
        DUE:20210101T123000
        END:VTODO
        )r   rW   s    rY   startz
Todo.start   s    , "$'''r[   r_   date | datetime | Nonec                    || _         dS )zSet the start.N)r?   )rX   r_   s     rY   r_   z
Todo.start   s     r[   c                "    t          | d          S )zThe end of the todo.

        Invalid values raise an InvalidCalendar error.
        If there is no end, we also raise an IncompleteComponent error.
        rG   )r   rW   s    rY   endzTodo.end   s      e,,,r[   rc   c                    || _         dS )zSet the end.N)rG   )rX   rc   s     rY   rc   zTodo.end   s     r[   r   c                     t          |           S )a  The duration of the VTODO.

        Returns the DURATION property if set, otherwise calculated from start and end.
        You can set the duration to automatically adjust the end time while keeping
        start locked.

        Setting the duration will:

        1.  Keep the start time locked (unchanged)
        2.  Adjust the end time to start + duration
        3.  Remove any existing DUE property
        4.  Set the DURATION property
        )r   rW   s    rY   durationzTodo.duration   s     %T***r[   valuec                    t          |t                    s%t          dt          |          j         d          |                     |d           d S )NzUse timedelta, not .r_   )locked)
isinstancer   	TypeErrortype__name__set_duration)rX   rg   s     rY   rf   zTodo.duration   sY    %++ 	KI$u++2FIIIJJJ 	%00000r[   rf   timedelta | Nonerj   Literal['start', 'end']c                *    t          | ||d           dS )zSet the duration of the event relative to either start or end.

        Parameters:
            duration: The duration to set, or None to convert to DURATION property
            locked: Which property to keep unchanged ('start' or 'end')
        rG   N)r&   )rX   rf   rj   s      rY   ro   zTodo.set_duration   s     	"$&%@@@@@r[   N!Literal['duration', 'end'] | Nonec                *    t          | ||d           dS )zSet the start with explicit locking behavior.

        Parameters:
            start: The start time to set
            locked: Which property to keep unchanged ('duration', 'end', or None
                for auto-detect)
        rG   N)r(   )rX   r_   rj   s      rY   	set_startzTodo.set_start   s     	tUFE:::::r[   Literal['start', 'duration']c                *    t          | ||d           dS )zSet the end of the component, keeping either the start or the duration same.

        Parameters:
            end: The end time to set
            locked: Which property to keep unchanged ('start' or 'duration')
        rG   N)r'   )rX   rc   rj   s      rY   set_endzTodo.set_end	  s     	T366666r[   r1   c                $    ddl m}  ||           S )a  Compute the alarm times for this component.

        >>> from datetime import datetime
        >>> from icalendar import Todo
        >>> todo = Todo()  # empty without alarms
        >>> todo.start = datetime(2024, 10, 26, 10, 21)
        >>> len(todo.alarms.times)
        0

        Note that this only uses DTSTART and DUE, but ignores
        RDATE, EXDATE, and RRULE properties.
        r   r0   )icalendar.alarmsr1   )rX   r1   s     rY   alarmszTodo.alarms  s$     	,+++++vd||r[   r   )RECURRENCE_ID 	attendeeslist[vCalAddress] | None
categoriesSequence[str]classificationCLASS | Nonecolor
str | Nonecommentslist[str] | str | Noneconceptsr	   contactsconferenceslist[Conference] | Nonecreateddate | Nonedescriptionlast_modifiedlinksr
   location	organizervCalAddress | str | Nonepriority
int | Nonerecurrence_idrefids
related_tor   sequencestampstatusSTATUS | Nonesummaryuidstr | uuid.UUID | Noneurlc          
        t                                          ||n|                                 |	||||||          }||_        |
|_        ||nt          j                    |_        ||_        ||_	        ||_
        ||_        ||_        ||_        ||_        ||_        ||_        ||_        ||_        ||_        ||_        ||_        ||_        | j        r|                     ||           |S )a  Create a new TODO with all required properties.

        This creates a new Todo in accordance with :rfc:`5545`.

        Parameters:
            attendees: The :attr:`attendees` of the todo.
            categories: The :attr:`categories` of the todo.
            classification: The :attr:`classification` of the todo.
            color: The :attr:`color` of the todo.
            comments: The :attr:`~icalendar.Component.comments` of the todo.
            concepts: The :attr:`~icalendar.Component.concepts` of the todo.
            contacts: The :attr:`contacts` of the todo.
            conferences: The :attr:`conferences` of the todo.
            created: The :attr:`~icalendar.Component.created` of the todo.
            description: The :attr:`description` of the todo.
            end: The :attr:`end` of the todo.
            last_modified: The :attr:`~icalendar.Component.last_modified` of the todo.
            links: The :attr:`~icalendar.Component.links` of the todo.
            location: The :attr:`location` of the todo.
            organizer: The :attr:`organizer` of the todo.
            recurrence_id: The :attr:`RECURRENCE_ID` of the todo.
            refids: :attr:`~icalendar.Component.refids` of the todo.
            related_to: :attr:`~icalendar.Component.related_to` of the todo.
            sequence: The :attr:`sequence` of the todo.
            stamp: The :attr:`~icalendar.Component.DTSTAMP` of the todo.
                If None, this is set to the current time.
            start: The :attr:`start` of the todo.
            status: The :attr:`status` of the todo.
            summary: The :attr:`summary` of the todo.
            uid: The :attr:`uid` of the todo.
                If None, this is set to a new :func:`uuid.uuid4`.
            url: The :attr:`url` of the todo.

        Returns:
            :class:`Todo`

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

        .. warning:: As time progresses, we will be stricter with the validation.
        N)r   r   r   r   r   r   r   r   )supernew_utc_nowr   r   uuiduuid4r   r_   rc   r   r   r   r   r   r   r   r   r   r   r~   r   r|   _validate_new_validate_start_and_end)clsr~   r   r   r   r   r   r   r   r   r   rc   r   r   r   r   r   r   r   r   r   r   r_   r   r   r   r   todo	__class__s                               rY   r   zTodo.new>  s   R WW[[ ,%%#,,..'! ! 	
 	
 &/33tz||

$ ,"   "&* 	4''s333r[   examplenamestrc                H    |                      t          d|                    S )z,Return the todo example with the given name.todos)	from_icalr.   )r   r   s     rY   r   zTodo.example  s      }}[$77888r[   )r\   r]   )r_   r`   )rc   r`   )r\   r   )rg   r   )r_   )rf   rp   rj   rq   )N)r_   r]   rj   rs   )rc   r]   rj   rv   )r\   r1   )Nr}   NNNNNNNNNNNNNNNNNNNNNNNN)4r~   r   r   r   r   r   r   r   r   r   r   r	   r   r   r   r   r   r   r   r   rc   r`   r   r   r   r
   r   r   r   r   r   r   r   r`   r   r   r   r   r   r   r   r   r_   r`   r   r   r   r   r   r   r   r   )r   )r   r   r\   r7   )Nrn   
__module____qualname____doc__r   required
singletons	exclusivemultipler   r   r   r?   rG   propertyr!   r"   r   r    formatrH   rZ   r_   setterrc   rf   ro   ru   rx   r   X_MOZ_SNOOZE_TIMEr   X_MOZ_LASTACKr{   r   r   r%   r   r   r   r#   rdatesr   exdatesr$   rrulesr+   r   r*   r   r   r   r   r   r,   r   r   r   r   r   r   r   r   r   r)   r   r   r~   r   imagesr   r   icalendar.attrr|   classmethodr   r   __classcell__)r   s   @rY   r7   r7   ;   sR       ) )V DHJ.IH %$	4Y G !
 	4j C x-&-@@@	 HW W W ( ( ( X(. \   \ - - - X- 	Z   Z + + + X+  _1 1 1 _1 MT	A 	A 	A 	A 	A SW
; 
; 
; 
; 
; LS	7 	7 	7 	7 	7 3*M   X" E H$JFGF
CG&K#N
C"I H H HF"IF&K,,,,,, /3$&'+ +/)-+//3#"&&*%)#'#.2#04)--1#!(, $"&*9g g g g g g [gR 9 9 9 9 [9 9 9 9 9r[   r7   )@r   
__future__r   r   r   r   r   typingr   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   icalendar.cal.componentr-   icalendar.cal.examplesr.   collections.abcr/   rz   r1   icalendar.enumsr2   r3   icalendar.propr4   icalendar.prop.conferencer5   r7   __all__r}   r[   rY   <module>r      s   " " " " " " " "  . . . . . . . . . . ) ) ) ) ) ) ) )% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %L . - - - - - . . . . . . 5((((((''''''--------******444444p9 p9 p9 p9 p99 p9 p9 p9f (r[   