
    #h+                         S SK r S SKJrJr  S SKJrJrJr  S SKrS SKJ	r	  SSK
Jr  SSKJr  S SKJr  SS	KJrJr  S S
KJr  S SKJr   " S S\5      rg)    N)datetime	timedelta)IterableListOptional)map   )	BaseAlarm)	Component)	Container)	get_arrowuid_gen)
TodoParser)TodoSerializerc                      \ rS rSrSr " S S5      r               S)S\S\S\S	\S
\S\S\S\S\	\
   S\4S jjr\S\\   4S j5       r\R                  S\\   4S j5       r\S\\   4S j5       r\R                  S\\   4S j5       r\S 5       r\R                  S 5       r\S 5       r\R                  S 5       r\S 5       r\R                  S 5       r\S\\   4S j5       r\R                  S\\   4S j5       rS\4S jrS\4S  jrS\4S! jrS\4S" jrS\4S# jrS\4S$ jrS\4S% jrS& rS' rS(rg)*Todo   zgA todo list entry.

Can have a start time and duration, or start and due time,
or only start/due time.
c                        \ rS rSrSr\r\rSr	g)	Todo.Meta   VTODO N)
__name__
__module____qualname____firstlineno__namer   parserr   
serializer__static_attributes__r       H/Users/user/Downloads/htwk/venv/lib/python3.13/site-packages/ics/todo.pyMetar      s    #
r!   r#   Nuiddescriptionlocationpercentpriorityr   urldurationalarmsstatusc                 ^   SU l         SU l        SU l        SU l        SU l        U(       d
  [        5       OUU l        U(       d  [        R                  " 5       O
[        U5      U l
        [        U5      U l        [        U5      U l        XPl        X`l        Xpl        Xl        Xl        Xl        Xl        [)        5       U l        [-        SS9U l        U(       a  U(       a  [1        S5      eU(       a  U(       d  [1        S5      eXl        OU(       a  Xl        Ub  [)        U5      U l        Xl        g)a4  Instantiates a new :class:`ics.todo.Todo`.

Args:
    uid (string): must be unique
    dtstamp (Arrow-compatible)
    completed (Arrow-compatible)
    created (Arrow-compatible)
    description (string)
    begin (Arrow-compatible)
    location (string)
    percent (int): 0-100
    priority (int): 0-9
    name (string) : rfc5545 SUMMARY property
    url (string)
    due (Arrow-compatible)
    duration (datetime.timedelta)
    alarms (:class:`ics.alarm.Alarm`)
    status (string)

Raises:
    ValueError: if `duration` and `due` are specified at the same time
Nr   )r   zNTodo() may not specify a duration and due date                at the same timezITodo() must specify a begin if a duration                    is specified)_percent	_priority_begin	_due_time	_durationr   r$   arrownowr   dtstamp	completedcreatedr%   beginr&   r'   r(   r   r)   listr+   r   extra
ValueErrorr*   duer,   )selfr5   r$   r6   r7   r%   r8   r&   r'   r(   r   r)   r<   r*   r+   r,   s                   r"   __init__Todo.__init__   s    N (,(,$'79S*1uyy{y7I"9- )&
  	'+vG,
"# #  "# # %MHv,DKr!   returnc                     U R                   $ N)r.   r=   s    r"   r'   Todo.percentj   s    }}r!   valuec                 b    U(       a"  [        U5      nUS:  d  US:  a  [        S5      eXl        g )Nr   d   zpercent must be [0, 100])intr;   r.   r=   rE   s     r"   r'   rD   n   s,    JEqyECK !;<<r!   c                     U R                   $ rB   )r/   rC   s    r"   r(   Todo.priorityv   s    ~~r!   c                 b    U(       a"  [        U5      nUS:  d  US:  a  [        S5      eXl        g )Nr   	   zpriority must be [0, 9])rH   r;   r/   rI   s     r"   r(   rK   z   s,    JEqyEAI !:;;r!   c                     U R                   $ )zGet or set the beginning of the todo.

|  Will return an :class:`Arrow` object.
|  May be set to anything that :func:`Arrow.get` understands.
|  If a due time is defined (not a duration), .begin must not
    be set to a superior value.
)r0   rC   s    r"   r8   
Todo.begin   s     {{r!   c                     [        U5      nU(       a+  U R                  (       a  XR                  :  a  [        S5      eXl        g )NzBegin must be before due time)r   r1   r;   r0   rI   s     r"   r8   rO      s/    % T^^(><==r!   c                     U R                   (       a  U R                  U R                   -   $ U R                  (       a  U R                  $ g)aV  Get or set the end of the todo.

|  Will return an :class:`Arrow` object.
|  May be set to anything that :func:`Arrow.get` understands.
|  If set to a non null value, removes any already
    existing duration.
|  Setting to None will have unexpected behavior if
    begin is not None.
|  Must not be set to an inferior value than self.begin.
N)r2   r8   r1   rC   s    r"   r<   Todo.due   s2     >>::..^^>>!r!   c                     [        U5      nU(       a+  U R                  (       a  XR                  :  a  [        S5      eXl        U(       a  S U l        g g )NzDue must be after begin)r   r0   r;   r1   r2   rI   s     r"   r<   rR      s>    % T[[U[[%8677!DN r!   c                     U R                   (       a  U R                   $ U R                  (       a  U R                  U R                  -
  $ g)zGet or set the duration of the todo.

|  Will return a timedelta object.
|  May be set to anything that timedelta() understands.
|  May be set with a dict ({"days":2, "hours":6}).
|  If set to a non null value, removes any already
    existing end time.
N)r2   r<   r8   rC   s    r"   r*   Todo.duration   s4     >>>>!XX88djj(( r!   c                     [        U[        5      (       a  [        S0 UD6nO&[        U[        5      (       a  UnOUb  [        U5      nXl        U(       a  S U l        g g )Nr   )
isinstancedictr   r2   r1   rI   s     r"   r*   rU      sR    eT""&&Ey))Ee$E!DN r!   c                     U R                   $ rB   )_statusrC   s    r"   r,   Todo.status   s    ||r!   c                     [        U[        5      (       a  UR                  5       nSnX;  a7  [        SSR	                  U Vs/ s H  n[        U5      PM     sn5      -  5      eXl        g s  snf )N)NzNEEDS-ACTION	COMPLETEDz
IN-PROCESS	CANCELLEDzstatus must be one of %sz, )rW   strupperr;   joinreprrZ   )r=   rE   statusesxs       r"   r,   r[      sb    eS!!KKMEQ 7$))V^D_V^QRT!WV^D_:``aa E`s   A+c                    U R                   c  gU R                  c(  U R                  c  SR                  U R                   5      $ U R                  c&  SR                  U R                   U R                  5      $ U R                  c&  SR                  U R                   U R                  5      $ SR                  U R                   U R                  U R                  5      $ )Nz<Todo>z<Todo '{}'>z<Todo '{}' begin:{}>z<Todo '{}' due:{}>z<Todo '{}' begin:{} due:{}>)r   r8   r<   formatrC   s    r"   __repr__Todo.__repr__   s    99::$(("2 ''		2288)00DJJGG::'..tyy$((CC,33DIItzz488TTr!   c                    [        U[        5      (       a  U R                  c]  UR                  cP  U R                  c  UR                  c  gU R                  c  gUR                  c  gU R                  UR                  :  $ U R                  UR                  :  $ [        U[        5      (       a   U R                  (       a  U R                  U:  $ [        SR                  [        U5      5      5      eNFTCannot compare Todo and {}rW   r   r<   r   r   NotImplementedErrorrf   typer=   others     r"   __lt__Todo.__lt__   s    eT""xxEII$599$); YY&ZZ' 99uzz1188eii''eX&&xxxx%''!(//U<> 	>r!   c                    [        U[        5      (       a  U R                  c]  UR                  cP  U R                  c  UR                  c  gU R                  c  gUR                  c  gU R                  UR                  :*  $ U R                  UR                  :*  $ [        U[        5      (       a   U R                  (       a  U R                  U:*  $ [        SR                  [        U5      5      5      eNTFrk   rl   ro   s     r"   __le__Todo.__le__       eT""xxEII$599$);YY&ZZ' 99

2288uyy((eX&&xxxx5((!(//U<> 	>r!   c                    [        U[        5      (       a  U R                  c]  UR                  cP  U R                  c  UR                  c  gU R                  c  gUR                  c  gU R                  UR                  :  $ U R                  UR                  :  $ [        U[        5      (       a   U R                  (       a  U R                  U:  $ [        SR                  [        U5      5      5      erj   rl   ro   s     r"   __gt__Todo.__gt__  s    eT""xxEII$599$); YY& ZZ'99uzz1188eii''eX&&xxxx%''!(//U<> 	>r!   c                    [        U[        5      (       a  U R                  c]  UR                  cP  U R                  c  UR                  c  gU R                  c  gUR                  c  gU R                  UR                  :  $ U R                  UR                  :  $ [        U[        5      (       a   U R                  (       a  U R                  U:  $ [        SR                  [        U5      5      5      ert   rl   ro   s     r"   __ge__Todo.__ge__#  rw   r!   c                     [        U[        5      (       a  U R                  UR                  :H  $ [        SR	                  [        U5      5      5      e)z9Two todos are considered equal if they have the same uid.rk   rW   r   r$   rm   rf   rn   ro   s     r"   __eq__Todo.__eq__5  A    eT""88uyy((!(//U<> 	>r!   c                     [        U[        5      (       a  U R                  UR                  :g  $ [        SR	                  [        U5      5      5      e)zDTwo todos are considered not equal if they do not have the same uid.rk   r   ro   s     r"   __ne__Todo.__ne__<  r   r!   c                     [         R                   " U 5      nUR                  R                  5       Ul        [         R                   " U R                  5      Ul        U$ )z)
Returns:
    Todo: an exact copy of self)copyr:   cloner+   )r=   r   s     r"   r   
Todo.cloneC  s>     		$kk'')yy-r!   c                 `    [        SR                  [        S U R                  5      5      5      $ )z3
Returns:
    int: hash of self. Based on self.uid. c                     S[        U 5      -  $ )Nz%.3d)ord)rd   s    r"   <lambda>Todo.__hash__.<locals>.<lambda>P  s    #a&r!   )rH   ra   r   r$   rC   s    r"   __hash__Todo.__hash__L  s$     27738$((CDEEr!   )r0   r1   r2   r.   r/   rZ   r+   r8   r6   r7   r%   r5   r<   r*   r:   r&   r   r'   r(   r,   r$   r)   )NNNNNNNNNNNNNNN) r   r   r   r   __doc__r#   r_   rH   r   r   r
   r>   propertyr   r'   setterr(   r8   r<   r*   r,   rg   boolrq   ru   ry   r|   r   r   r   r   r    r   r!   r"   r   r      sc   $ $  $(!% $!%! '+/3#JJ
 "J J J J J J %J "),J JX #   ^^Xc]   (3-   __hsm     \\   * 	ZZ" "  " __" "    ]]HSM  	U# 	U>t >$>t >$>t >$>t >$>t >>t >Fr!   r   )r   r   r   typingr   r   r   r3   	six.movesr   
alarm.baser
   	componentr   ics.grammar.parser   utilsr   r   ics.parsers.todo_parserr   ics.serializers.todo_serializerr   r   r   r!   r"   <module>r      s9     ( + +   !   ' % . :F9 Fr!   