� ���g����ddlZddlZddlZddlmZddlmZmZddlm Z mZm Z ddl m Z ddl mZddlZddlmZmZejd��Zd �Zd �Zd �Zd �Zd �Zd�Zd�Zd�Zd�Zdefd�ZGd�de��Z d�Z!d�Z"d�Z#dS)�N)� defaultdict)�asdict� is_dataclass)�date�datetime�timezone)�Decimal)�UUID)�tzlocal�tzutc�posthogc�L�|jdup|j�|��duS)z1Determines if a given datetime.datetime is naive.N)�tzinfo� utcoffset)�dts �]/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/posthog/utils.py�is_naivers)�� �9�� � ?�� � 3� 3�B� 7� 7�4� ?�?�c�H�|j|j|jdzdzzdzzdz S)z2Determines total seconds with python < 2.7 compat.�ig��.A)� microseconds�seconds�days)�deltas r� total_secondsrs/�� � �%�-�%�*�r�/�D�2H�"H�C�!O� O�SV� V�Vrc���t|��rmtj��|z }t|��dkr"|�t �����S|�t �����S|S)z:Attempts to convert a naive datetime to an aware datetime.��r)rr�nowr�replacer r )rrs r�guess_timezoner!sn����|�|� .�� ����#�� �� � �!� #� #��:�:�W�Y�Y�:�/�/� /��:�:�U�W�W�:�-�-� -� �Irc�D�|�d��r |dd�S|S)N�/�����)�endswith)�hosts r�remove_trailing_slashr',s)�� �}�}�S�����C�R�C�y�� �Krc ��t|t��rt|��St|t��rt |��St|t jttj tttd��f��r|St|tttf��rt!|��S t#|d��r)t%|j��r|���}n8t#|d��r(t%|j��r|���}n4#t*$r'}t,�d|����Yd}~nd}~wwxYwt|t(��rt1|��St3|��r$t|t��st5|��St7|��S)N� model_dump�dictz)Could not serialize Pydantic-like model: )� isinstancer �floatr �str�six� string_types�bool�numbers�Numberrr�type�set�list�tuple� _clean_list�hasattr�callabler)r*� TypeError�log�debug� _clean_dictr�_clean_dataclass�_coerce_unicode)�item�es r�cleanrB2s����$�� � ���T�{�{���$������4�y�y���$��)�4����4�QU�VZ�Q[�Q[�\�]�]��� ��$��d�E�*�+�+�!��4� � � �  � �4�� &� &� �8�D�O�+D�+D� ��?�?�$�$�D�D� �T�6� "� "� �x�� �':�':� ��9�9�;�;�D��� � � � � � � �A�a�A�A�B�B�B� ��������� �����$����!��4� � � ��D���&�*�T�4�"8�"8�&���%�%�%� �4� � � s�A1D5�5 E&�?E!�!E&c��d�|D��S)Nc�,�g|]}t|����S�)rB)�.0r@s r� <listcomp>z_clean_list.<locals>.<listcomp>Ns�� *� *� *�D�E�$�K�K� *� *� *rrE)�list_s rr7r7Ms�� *� *�E� *� *� *�*rc ���i}tj|��D]R\}} t|��||<�#t$r-t�d||t |����Y�OwxYw|S)NzXDictionary values must be serializeable to JSON "%s" value %s of type %s is unsupported.)r.� iteritemsrBr:r;�warningr3)�dict_�data�k�vs rr=r=Qs��� �D�� �e�$�$� � ���1� ��A�h�h�D��G�G��� � � � �K�K�j����Q���  � � � � � ���� �Ks�0�4A'�&A'c�B�t|��}t|��}|S�N)rr=)� dataclass_rMs rr>r>`s!�� �*� � �D� �t� � �D� �Krc��� |�dd��}n^#t$rQ}d�|��}|�dd��t�d|��Yd}~dSd}~wwxYw|S)Nzutf-8�strict�:zError decoding: %s)�decode�AttributeError�joinr;rK)�cmplxr@� exceptions rr?r?fs�����|�|�G�X�.�.���� �����x�x� �"�"�� � � �G�X�&�&�&� � � �(�$�/�/�/��t�t�t�t�t����� ���� �Ks�� A4�AA/�/A4�returnc�\� tj|��dS#tj$rYdSwxYw)NTF)�re�compile�error)�values r�is_valid_regexraqs@��� � �5�����t�� �8�����u�u����s ��+�+c�(��eZdZ�fd�Z�fd�Z�xZS)�SizeLimitedDictc�H��t��j|i|��||_dSrQ)�super�__init__�max_size)�selfrg�args�kwargs� __class__s �rrfzSizeLimitedDict.__init__zs*��������$�)�&�)�)�)� �� � � rc���t|��|jkr|���t���||��dSrQ)�lenrg�clearre� __setitem__)rh�keyr`rks �rrozSizeLimitedDict.__setitem__~sC��� �t�9�9�� � %� %� �J�J�L�L�L� �����C��'�'�'�'�'r)�__name__� __module__� __qualname__rfro� __classcell__)rks@rrcrcysQ�������!�!�!�!�!�(�(�(�(�(�(�(�(�(rrcc�T�|j� |�tj���}|S)Nr)rr r�utc)�date_objs r�convert_to_datetime_awarerx�s'������#�#�8�<�#�8�8�� �Orc��t|�����t|�����vS)a� Check if a string contains another string, ignoring case. Args: source: The string to search within search: The substring to search for Returns: bool: True if search is a substring of source (case-insensitive), False otherwise Examples: >>> str_icontains("Hello World", "WORLD") True >>> str_icontains("Hello World", "python") False �r-�casefold)�source�searchs r� str_icontainsr~�s3��" �v�;�;� � � !� !�S��[�[�%9�%9�%;�%;� ;�;rc��t|�����t|�����kS)a� Check if a string equals another string, ignoring case. Args: value: The string to compare comparand: The string to compare with Returns: bool: True if value and comparand are equal (case-insensitive), False otherwise Examples: >>> str_iequals("Hello World", "hello world") True >>> str_iequals("Hello World", "hello") False rz)r`� comparands r� str_iequalsr��s3��" �u�:�:� � � � �C� �N�N�$;�$;�$=�$=� =�=r)$�loggingr1r]� collectionsr� dataclassesrrrrr�decimalr �uuidr r.� dateutil.tzr r � getLoggerr;rrr!r'rBr7r=r>r?r0rarcrxr~r�rErr�<module>r�s����������� � � � �#�#�#�#�#�#�,�,�,�,�,�,�,�,�-�-�-�-�-�-�-�-�-�-������������� � � � �&�&�&�&�&�&�&�&��g�� �"�"��@�@�@� W�W�W� ���"��� !�!�!�6+�+�+� � � ���� ����T����� (� (� (� (� (�k� (� (� (���� <�<�<�(>�>�>�>�>r
Memory