
    i                    t    d Z ddlmZ ddlmZmZ ddlmZmZ ddlm	Z	 ddl
mZ  e            ZddZdddZdS )z)Utility functions for icalendar-searcher.    )annotations)IterableIterator)datedatetime)tee)TypesFactorydt_valuedate | datetimereturnr   c                    | dS t          | d          rBt          | d          s2ddlm} t          j        | |j                                                  S |                                 S )zPConvert date to datetime for comparison, or return datetime as-is with timezone.Nyearhourr   )time)hasattrr   r   combinemin
astimezone)r
   r   s     S/root/projects/butler/venv/lib/python3.11/site-packages/icalendar_searcher/utils.py_normalize_dtr      sy    tx   A6)B)B A!!!!!!$(33>>@@@        Fgr   _debug_print_peekboolbool | Iterablec                    t          | t                    st          |           o| S t          |           \  }}	 t	          |          }|rt          |           |S # t          $ r Y dS w xY w)a{  This method will return False if it's not possible to get an
    item from the iterable (which can only be done by utilizing
    `next`).  It will then return a new iterator that behaves like
    the original iterator (like if `next` wasn't used).

    Uses itertools.tee to create two independent iterators: one for
    checking if the iterator is empty, and one to return.
    F)
isinstancer   r   r   nextprintStopIteration)r   r   check_it	result_itmy_values        r   _iterable_or_falser$   %   s     a"" Aww}1 a&&Hi>> 	(OOO   uus   !A 
A*)A*N)r
   r   r   r   )F)r   r   r   r   r   r   )__doc__
__future__r   collections.abcr   r   r   r   	itertoolsr   icalendar.propr	   types_factoryr   r$    r   r   <module>r,      s    / / " " " " " " . . . . . . . . # # # # # # # #       ' ' ' ' ' '
 
! ! ! !$      r   