� I�g|7����dZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z dZ ejde ��Zd �Zd �Zdd �Zd �Zd�Zde��fd�Zd�Zd�Zdd�ZdS)z> My own variation on function-specific inspect-like features. �N)�islice)�open�)�pformatzAargs varargs varkw defaults kwonlyargs kwonlydefaults annotations� FullArgSpecc� �d} |j}|j}tj�|��s�d�t j|��d��}d}|�d��r>tj d|��� ��\}}t|��}d|z}|||fSt|��5}|j}tt!||dz d����}ddd��n #1swxYwYd�t j|����||fS#t%|d��r+t'|j�����|d fcYSt+|��|d fcYSxYw) al Attempts to retrieve a reliable function code hash. The reason we don't use inspect.getsource is that it caches the source, whereas we want this to be modified on the fly when the function is modified. Returns ------- func_code: string The function code source_file: string The path to the file in which the function is defined. first_line: int The first line of the code in the source file. Notes ------ This function does a bit more magic than inspect, and is thus more robust. N�rrz <doctest z\<doctest (.*\.rst)\[(.*)\]\>z <doctest %s>�__code__�����)r � co_filename�os�path�exists�join�inspect�getsourcelines� startswith�re�match�groups�int�open_py_source�co_firstlineno�listr�getblock�hasattr�str�__hash__�repr)�func� source_file�code� source_code�line_no�source_file_obj� first_line� source_liness �c/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/joblib/func_inspect.py� get_func_coder)s���*�K�/��}���&� ��w�~�~�k�*�*� 5��'�'�'�"8��">�">�q�"A�B�B�K��G��%�%�k�2�2� ;�')�x�4�k�(C�(C�CI�6�8�8�%� �W��g�,�,��,�{�:� �� �W�4� 4� �K� (� (� O�O��,�J���� �Q��� M� M�N�N�L� O� O� O� O� O� O� O� O� O� O� O���� O� O� O� O��w�w�w�'� �5�5�6�6� �Z�O�O�� /� �4�� $� $� /��t�}�-�-�/�/�0�0�+�r�A� A� A� A� ��:�:�{�B�.� .� .� .���s<�B3D1�8D1�)C<�0 D1�<D�D1�D�,D1�1;F�.Fc��ddl}t|d��r|j}nddl}|jj}dD]!}|�|||����}�"|S)z2Windows cannot encode some characters in filename.rN�quote)�<�>�!�:�\)�urllibrr+� urllib.parse�parse�replace)�stringr1r+�chars r(�_clean_win_charsr7Qso���M�M�M��v�w���#�� ��� ����� �"��*�3�3������e�e�D�k�k�2�2��� �M�Tc��t|d��r|j}nE tj|��}n/#t$r"t|d��r |jj}nd}YnwxYw|�d}|dk�r. t j�tj |����}n #d}YnxYw|��|� t j ��}|d� d��rG|d� d ��}d � |dd �|d d�z��|d<n3t|��d kr |d � d ��rd|d <d � |��}|�d��r |dd�}|d z|z}|� d��}t|d��r|j}nt|d��r|j}nd}|r-t|d��r||jvr|j||urd|z}t|d��r@|j|kr5|�|j� d��dd���tj|��r1t|d��r!|j}|�|j��t jdkr|rt3|��}d�|D��}||fS)a� Return the function import path (as a list of module names), and a name for the function. Parameters ---------- func: callable The func to inspect resolv_alias: boolean, optional If true, possible local aliases are indicated. win_characters: boolean, optional If true, substitute special characters using urllib.quote This is useful in Windows, as it cannot encode some filenames � __module__� __class__�unknownNr �__main__r z<ipython-input�-�������� ipykernel_� ipykernelz.py������.� func_name�__name__� func_globalsz%s-alias� __qualname__�im_class�ntc�,�g|]}t|����S�)r7)�.0�ss r(� <listcomp>z!get_func_name.<locals>.<listcomp>�s!��6�6�6�!�"�1�%�%�6�6�6r8)rr:r� getmodule� TypeErrorr;r r�abspath� getsourcefile�split�seprr�len�endswithrFrGrHrI�extend�ismethodrJ�append�namer7) r � resolv_alias�win_characters�module�filename�parts�splittedr\�klasss r(� get_func_namerd_s���t�\�"�"� #����� #��&�t�,�,�F�F��� #� #� #��t�[�)�)� #���2���"����  #���� �~��� ���� ��w���w�'<�T�'B�'B�C�C�H�H�� ��H�H�H���� � ��N�N�2�6�*�*�E��R�y�#�#�$4�5�5� (�!��9�?�?�3�/�/���H�H�X�b�q�b�\�H�Q�R�R�L�%@�A�A��b� � ��U���a���E�"�I�$8�$8��$F�$F�� (��b� ��x�x����H�� � ��'�'� )�#�C�R�C�=���c�\�H�,�F� �\�\�#� � �F��t�[�!�!���~��� ��z� "� "���}������)� �4�� (� (� )�T�T�5F�-F�-F��$�T�*�d�2�2�!�D�(���t�^�$�$�9��):�d�)B�)B� � � �d�'�-�-�c�2�2�3�B�3�7�8�8�8������*� �4�� $� $� *��M�E� �M�M�%�.� )� )� )� �w�$���>����%�%��6�6�v�6�6�6�� �4�<�s�/�)A�A�*1B�B"c�.�d�||��S)z.Helper function to output a function signaturez{}{})�format)� function_name�arg_sigs r(�_signature_strri�s�� �=�=��� 0� 0�0r8c���d}t|��dd�}d�d�|���D����}|�|||��S)z)Helper function to output a function callz {0}({1}, {2})rr �, c3�*K�|]\}}|�d|��V��dS)�=NrM)rN�k�vs r(� <genexpr>z'_function_called_str.<locals>.<genexpr>�sE����7�7�#�q�!�'(�a�a���+�7�7�7�7�7�7r8)rr�itemsrf)rg�args�kwargs� template_str�args_str� kwargs_strs r(�_function_called_strrw�sq��"�L��D�z�z�!�B�$��H����7�7�'-�|�|�~�~�7�7�7�7�7�J� � � �}�h�)� +� +�+r8rMc �^�t|��}t|t��r#td|�dt |���d����t j|��s4t j|��s |rtj d|zd���||d�St j |��}g}g}g}d}d} |j � ��D]�} | j | jur|�| j��nn| j | jur5|�| j��|�| j��n+| j | jur| j}n| j | jur| j} | j| jur|�| j����t j|��rK|jg|z}t j |j��} t1t3| j ����} | g|z}t5|d � ��\} }t7��}d }t9|��D]�\}}|t;|��krF||vr ||||<�(td |�d t=||���dt?|||���d����|t;|��z }||vr ||||<�� ||||<��#t@tBf$r9}tdt=||���dt?|||���d���|�d}~wwxYwt7��}tE|�#����D],\}}||vr|||<�| �|||<�tId|�d|�d����| �||d<|�||dzd�}||d<|D]>}||vr|�%|���td|�dt=||�������|S)a� Filters the given args and kwargs using a list of arguments to ignore, and a function specification. Parameters ---------- func: callable Function giving the argument specification ignore_lst: list of strings List of arguments to ignore (either a name of an argument in the function spec, or '*', or '**') *args: list Positional arguments passed to the function. **kwargs: dict Keyword arguments passed to the function Returns ------- filtered_args: list List of filtered positional and keyword arguments. z2ignore_lst must be a list of parameters to ignore z (type z ) was givenz4Cannot inspect object %s, ignore list will not work.r?)� stacklevel)�*�**NF)r]r zKeyword-only parameter 'z)' was passed as positional parameter for z: z was called.zWrong number of arguments for zIgnore list for z,() contains an unexpected keyword argument '�'r{rrzzIgnore list: argument 'z' is not defined for function )&r� isinstancer� ValueError�typerrZ� isfunction�warnings�warn� signature� parameters�values�kind�POSITIONAL_OR_KEYWORDr[r\� KEYWORD_ONLY�VAR_POSITIONAL� VAR_KEYWORD�default�empty�__self__�__func__�next�iterrd�dict� enumeraterWrirw� IndexError�KeyError�sortedrqrR�pop)r � ignore_lstrrrsrh� arg_names� arg_defaults�arg_kwonlyargs� arg_varargs� arg_varkw�param�class_method_sig� self_name�_r\�arg_dict� arg_position�arg_name�position�e� varkwargs� arg_value�varargs�items r(� filter_argsr��s���* ��:�:�D��*�c�"�"�G��j�(2� � �D��4D�4D�4D�4D� F�G�G� G� � �T� "� "�)�7�+=�d�+C�+C�)� � <� �M�&�(,�-�9:� <� <� <� <���(�(�(����%�%�G��I��L��N��K��I��#�*�*�,�,� /� /�� �:��4� 4� 4� � � �U�Z� (� (� (� (� �Z�5�-� -� -� � � �U�Z� (� (� (� � !� !�%�*� -� -� -� -� �Z�5�/� /� /��*�K�K� �Z�5�,� ,� ,�� �I� �=�� � +� +� � � �� � .� .� .������� ,�� � �4�'��#�,�T�]�;�;����.�9�:�:�;�;� ��K�)�+� ��D�u�5�5�5�G�A�t��v�v�H��L�"+�I�"6�"6���� �h� �#�d�)�)� #� #��~�-�-�%)�,�%7���"�"� �j� �x�x�%�d�G�4�4�4�4�+�D�$��?�?�?�?� A����$�c�)�n�n�4�H��6�!�!�%+�H�%5���"�"� �)5�h�)?�H�X�&�&��"�H�-����$�*�*�$��8�8�8�8�/��d�F�C�C�C�C�E��� � ������������I�%�f�l�l�n�n�5�5�H�H���)� �x� � �!*�H�X� � � � "�"+�I�h� � ��)�7;�t�t�X�X�X�G�H�H� H���"�������|�a�'�(�(�)����� ����� �8� � � �L�L�� � � � ��*� $��� .�t�W� =� =� =�?��� � �Os� J(�(K2�94K-�-K2c�h�t|d���}t|��dkr d|dd�z}|S)Nr?)�indenti�z%s...i�)rrW)�arg� formatted_args r(� _format_argr�Is@���C��*�*�*�M� �=���D� � ��-����"5�5� � �r8c���t|��\}}d�|D��}|r+|�|��d�|��}n|}t��}d}|D]@}t |��} |dkrd| z} t | ��}|�| ���A|�d�|���D����d�|��}|�d|�d �} || fS) Nc��g|]}|�|��SrMrM)rN�ms r(rPz$format_signature.<locals>.<listcomp>Ss�� %� %� %�A�1� %�a� %� %� %r8rEr�Pz %sc�<�g|]\}}|�dt|������S)rm)r�)rNro�is r(rPz$format_signature.<locals>.<listcomp>as-��M�M�M�d�a��q�q�q�+�a�.�.�.�1�M�M�Mr8rk�(�))rdr[rrr�rWrYrq) r rrrsr_r\� module_path�arg_str�previous_lengthr�r�r�s r(�format_signaturer�Ps�� ��&�&�L�F�D� %� %�� %� %� %�F� ��� � �d�����h�h�v�&�&� � �� ��f�f�G��O��&�&��#�C�(�(� � �R� � �"�]�2�M��m�,�,�����}�%�%�%�%� �N�N�M�M�f�l�l�n�n�M�M�M�N�N�N��i�i�� � �G� �D�D�'�'�'�*�I� � � !�!r8�Memoryc�F�t|g|�Ri|��\}}d�d|�d|�d|��}|S)zi Returns a nicely formatted statement displaying the function call with the given arguments. �P________________________________________________________________________________z [z ] Calling z... )r�)r rrrs� object_namerr��msgs r(� format_callr�hsI��'�t�=�d�=�=�=�f�=�=�O�D�)�*2�(�(�K�K�K�*.�$�$� � � ;�C� �Jr8)TT)r�)�__doc__rr�rr � collections� itertoolsr�tokenizerr�loggerr�full_argspec_fields� namedtuple�full_argspec_typer)r7rdrirwr�r�r�r�r�rMr8r(�<module>r�sM������������ � � � � � � � �����������+�+�+�+�+�+�������4��*�K�*�=�:M�N�N��5/�5/�5/�p � � �W�W�W�W�t1�1�1� +�+�+�(*�$�$�&�&�}�}�}�}�@���"�"�"�0�����r8
Memory