
    iq                        d Z ddlmZ 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 dd
l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  G d de          ZdgZdS )zSelecting components by name.    )annotationsN)defaultdict)TYPE_CHECKINGSequence)EventAdapter)JournalAdapter)TodoAdapter)
Occurrence)Alarms)SelectComponents)Series)cached_property)	Component)ComponentAdapterc                  j    e Zd ZU dZeee e            gZde	d<   e
dd            ZdeefddZddZdS )ComponentsWithNamea  This is a component collecttion strategy.

    Components can be collected in different ways.
    This class allows extension of the functionality by
    - subclassing to filter the resulting components
    - composition to combine collection behavior (see AllKnownComponents)
    z/list[type[ComponentAdapter] | SelectComponents]component_adaptersreturn dict[str:type[ComponentAdapter]]c                $    d | j         D             S )z A mapping of component adapters.c                8    i | ]}|                                 |S  )component_name).0adapters     _/root/projects/butler/venv/lib/python3.11/site-packages/recurring_ical_events/selection/name.py
<dictcomp>z:ComponentsWithName._component_adapters.<locals>.<dictcomp>+   s3     
 
 
29G""$$g
 
 
    )r   )selfs    r   _component_adaptersz&ComponentsWithName._component_adapters(   s&    
 
=A=T
 
 
 	
r   Nnamestrr   type[ComponentAdapter] | Noneseriestype[Series]
occurrencetype[Occurrence]Nonec                    |D|| j         vr.t          d| dd                    | j                    d          | j         |         }|t          ur| G fdd|          }|| _        || _        || _        dS )ad  Create a new way of collecting components.

        name - the name of the component to collect ("VEVENT", "VTODO", "VJOURNAL")
        adapter - the adapter to use for these components with that name
        series - the series class that hold a series of components
        occurrence - the occurrence class that creates the resulting components
        N"zC" is an unknown name for a recurring component. I only know these: z, .c                      e Zd Z ZdS )+ComponentsWithName.__init__.<locals>.seriesN)__name__
__module____qualname__r&   )_occurrences   r   r$   r-   H   s        (


r   r$   )r    
ValueErrorjoinr
   _name_series_adapter)r   r!   r   r$   r&   r1   s        @r   __init__zComponentsWithName.__init__/   s     ?4333 Q Q Q*.))D4L*M*MQ Q Q  
 .t4GZ''$K) ) ) ) ) ) ) ) ) ) 
r   sourcer   suppress_errorstuple[Exception]Sequence[Series]c                   t          | j        t                    r| j                            ||          S t	          t
                    }|                    | j                  D ]7}|                     |          }||j                 	                    |           8g }|
                                D ]V}t          j        |          5  |	                    |                     |                     ddd           n# 1 swxY w Y   W|S )zCollect all components from the source component.

        suppress_errors - a list of errors that should be suppressed.
            A Series of events with such an error is removed from all results.
        N)
isinstancer6   r   collect_series_fromr   listwalkr4   uidappendvalues
contextlibsuppressr5   )r   r8   r9   
components	componentr   results          r   r>   z&ComponentsWithName.collect_series_fromO   s5    dm%566 	N=44V_MMM1<T1B1B
TZ00 	4 	4ImmI..Gw{#**73333$++-- 	8 	8J$_55 8 8dll:667778 8 8 8 8 8 8 8 8 8 8 8 8 8 8s   )C==D	D	)r   r   )
r!   r"   r   r#   r$   r%   r&   r'   r   r(   )r8   r   r9   r:   r   r;   )r.   r/   r0   __doc__r   r	   r   r   r   __annotations__r   r    r   r
   r7   r>   r   r   r   r   r      s           		K     
 
 
 _
 26%'1         @     r   r   )rI   
__future__r   rD   collectionsr   typingr   r   $recurring_ical_events.adapters.eventr   &recurring_ical_events.adapters.journalr   #recurring_ical_events.adapters.todor	    recurring_ical_events.occurrencer
   %recurring_ical_events.selection.alarmr   $recurring_ical_events.selection.baser   recurring_ical_events.seriesr   recurring_ical_events.utilr   icalendar.calr   (recurring_ical_events.adapters.componentr   r   __all__r   r   r   <module>rY      sR   # # " " " " " "     # # # # # # * * * * * * * * = = = = = = A A A A A A ; ; ; ; ; ; 7 7 7 7 7 7 8 8 8 8 8 8 A A A A A A / / / / / / 6 6 6 6 6 6 J''''''IIIIIII I I I I) I I IX  
 r   