
    i                    h    d Z ddlmZ ddlZddlmZ ddlmZ erddlm	Z	  G d de          Z
dgZdS )	zA factory to create components.    )annotationsN)TYPE_CHECKING)CaselessDict	Componentc                  2     e Zd ZdZ fdZddZdd
Z xZS )ComponentFactorya  Registered components from :rfc:`7953` and :rfc:`5545`.

    To get a component, use this class as shown below.

    .. code-block:: pycon

        >>> from icalendar import ComponentFactory
        >>> factory = ComponentFactory()
        >>> event_class = factory.get_component_class('VEVENT')
        >>> event_class()
        VEVENT({})

    Automatically creates custom component classes for unknown names (X-components,
    IANA-components). Custom components are never dropped per :rfc:`5545`.

    .. code-block:: pycon

        >>> factory = ComponentFactory()
        >>> custom_class = factory.get_component_class('X-VENDOR')
        >>> custom_class()
        X-VENDOR({})

    If a component class is not yet supported, it can be either created
    using :meth:`get_component_class` or added manually as a subclass of
    :class:`~icalendar.cal.component.Component`.
    See :doc:`/how-to/custom-components` for details.
    c                |    t                      j        |i | ddlm} ddlm} ddlm} ddlm	} ddl
m} ddlm} ddlm}	 dd	lm}
m}m} dd
lm} |                     |           |                     |           |                     |           |                     |	           |                     |           |                     |
           |                     |           |                     |           |                     |           |                     |           |                     |           dS )z#Set keys to upper for initial dict.r   )Alarm)Availability)	Available)Calendar)Event)FreeBusy)Journal)TimezoneTimezoneDaylightTimezoneStandard)TodoN)super__init__icalendar.cal.alarmr   icalendar.cal.availabilityr   icalendar.cal.availabler   icalendar.cal.calendarr   icalendar.cal.eventr   icalendar.cal.free_busyr   icalendar.cal.journalr   icalendar.cal.timezoner   r   r   icalendar.cal.todor   add_component_class)selfargskwargsr   r   r   r   r   r   r   r   r   r   r   	__class__s                 Z/root/projects/butler/venv/lib/python3.11/site-packages/icalendar/cal/component_factory.pyr   zComponentFactory.__init__+   s   $)&)))------;;;;;;555555333333------444444111111	
 	
 	
 	
 	
 	
 	
 	
 	
 	

 	,+++++  ***  '''  &&&  )))  ***  ***  !1222  !1222  '''  +++  .....    clstype[Component]returnNonec                    || |j         <   dS )zpAdd a component class to the factory.

        Parameters:
            cls: The component class to add.
        N)name)r"   r(   s     r&   r!   z$ComponentFactory.add_component_classH   s     SXr'   r-   strc                    |                      |          }|Uddlm} t          t	          j        dd|          |fd|                                i          }|                     |           |S )a  Get the component class from the factory.

        This also creates and adds the component class if it does not exist.

        Parameters:
            name: The name of the component, for example, ``"VCALENDAR"``.

        Returns:
            The registered component class.
        Nr   r   z[^\w]+ r-   )geticalendar.cal.componentr   typeresubupperr!   )r"   r-   component_classr   s       r&   get_component_classz$ComponentFactory.get_component_classP   sz     ((4.."999999"y"d++i\FDJJLL;Q O $$_555r'   )r(   r)   r*   r+   )r-   r.   r*   r)   )__name__
__module____qualname____doc__r   r!   r8   __classcell__)r%   s   @r&   r	   r	      sj         8/ / / / /:          r'   r	   )r<   
__future__r   r4   typingr   icalendar.caselessdictr   	icalendarr   r	   __all__ r'   r&   <module>rD      s    % % " " " " " " 				             / / / / / / $######U U U U U| U U Up 
r'   