� =��g�9���ddlZddlZddlZddlmZmZmZddlmZddl m Z ddl m Z ddl mZmZmZmZddlmZddlmZmZmZdd lmZmZdd lmZdd lmZejd kr ddl Z n#e!$r esddl"Z YnwxYwddl"Z dd l#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*erddl+Z+edee e,fde-e,effd���Z.ede de fd���Z/e d=dee,dee,de0e e,ffd���Z1 d=de0e,dfdee,dee,fd�Z2ed���de,de-e,effd���Z3de-e,efdee4e&fd �Z5d!e,dee4e&fd"�Z6d!e,dee4e&fd#�Z7d$edefd%�Z8ede fd&���Z9ed'e defd(���Z: d=de d'e d)ee*de;fd*�Z<de d'e de fd+�Z=d,e,d'e d-e-e efde;fd.�Z>d/e,d0ee e,de;fd1�Z?d2ee d'e d3e e,d4e e,d5ee e,d6ee e,d)e*d-ee-e efd7e;d8e;dee fd9�Z@d:ejAdeejAd;ffd<�ZBdS)>�N)�Iterable�Iterator�Sequence)� lru_cache)�Path)�Pattern)� TYPE_CHECKING�Any�Optional�Union)� mypyc_attr)�InvalidSpecifier� Specifier� SpecifierSet)�InvalidVersion�Version)�PathSpec)�GitWildMatchPatternError)�� )�"jupyter_dependencies_are_installed)� TargetVersion)�err)�Report�path�returnc�~�t|d��5}tj|��cddd��S#1swxYwYdS)N�rb)�open�tomllib�load)r�fs �[/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/black/files.py� _load_tomlr$#s~�� �d�D� � ��Q��|�A�����������������������s �2�6�6c�*�|���S�N)�resolve�rs r#�_cached_resolver))s�� �<�<�>�>���srcs�stdin_filenamec�D����t�fd�|D����}|s.tttj������g}d�|D��}d�|D��}t t jd�|D���d����}|g|j�RD]�}|dz � ��r|d fcS|d z � ��r|d fcS|d z � ��r0t|d z ��}d |� di��vr|d fcS��|dfS)aQReturn a directory containing .git, .hg, or pyproject.toml. pyproject.toml files are only considered if they contain a [tool.black] section and are ignored otherwise. That directory will be a common parent of all files and directories passed in `srcs`. If no directory in the tree contains a marker that would specify it's the project root, the root of the file system is returned. Returns a two-tuple with the first element as the project root path and the second element as a string describing the method by which the project root was discovered. Nc3�,�K�|]}|dkr�n|V��dS)�-N�)�.0�sr,s �r#� <genexpr>z$find_project_root.<locals>.<genexpr>Bs/�����E�E�1�q�C�x�x�^�^�Q�E�E�E�E�E�Er*c�j�g|]0}tttj��|������1Sr0)r)r�cwd)r1�srcs r#� <listcomp>z%find_project_root.<locals>.<listcomp>Fs0��H�H�H�C���d�h�j�j�#�!6�!6�7�7�H�H�Hr*c�j�g|]0}t|j��|���r|gngz��1Sr0)�list�parents�is_dir)r1rs r#r7z%find_project_root.<locals>.<listcomp>JsG�����CG��T�\���� � � � �=�t�f�f�2�>���r*c3�4K�|]}t|��V��dSr&)�set)r1r:s r#r3z$find_project_root.<locals>.<genexpr>Os(����C�C�G�3�w�<�<�C�C�C�C�C�Cr*c��|jSr&)�partsr(s r#�<lambda>z#find_project_root.<locals>.<lambda>Ps����r*)�keyz.gitz.git directoryz.hgz .hg directory�pyproject.toml�black�toolzfile system root)�tuple�strr)rr5�maxr=� intersectionr:�existsr;�is_filer$�get)r+r,� path_srcs� src_parents� common_base� directory�pyproject_tomls ` r#�find_project_rootrQ.s����&�!��E�E�E�E��E�E�E�E�E�� �2��O�D�H�J�J�/�/�0�0�1��H�H�4�H�H�H�I���KT����K�� ��C�C�{�C�C�C�D� #� #����K� "�8�K�$7�8�8� 3� 3� � �� � &� &� (� (� /��.�.� .� .� .� �� � %� %� '� '� .��o�-� -� -� -� �(� (� 1� 1� 3� 3� 3�'� �4D�(D�E�E�N��.�,�,�V�R�8�8�8�8� �"2�2�2�2�2�� �(� (�(r*�path_search_start.c�B�t||��\}}|dz }|���rt|��S t��}|���rt|��ndS#tt f$r}t d|����Yd}~dSd}~wwxYw)z;Find the absolute filepath to a pyproject.toml if it existsrBNz-Ignoring user configuration directory due to )rQrJrF�find_user_pyproject_toml�PermissionError� RuntimeErrorr)rRr,�path_project_root�_�path_pyproject_toml�path_user_pyproject_toml�es r#�find_pyproject_tomlr\bs���-�->��O�O���q�+�.>�>���"�"�$�$�(��&�'�'�'� �#;�#=�#=� �(�/�/�1�1� �C�(� )� )� )�� �� �\� *���� � A�A� A� A�B�B�B��t�t�t�t�t��������s�2A0�0B�B�BT)� patchable� path_configc���t|��}|�di���di��}d�|���D��}d|vr t|��}|�d�|D��|d<|S)z�Parse a pyproject toml file, pulling out relevant parts for Black. If parsing fails, will raise a tomllib.TOMLDecodeError. rDrCc�j�i|]0\}}|�dd���dd��|��1S)z--�r/rX)�replace)r1�k�vs r#� <dictcomp>z(parse_pyproject_toml.<locals>.<dictcomp>�s<�� R� R� R�4�1�a�a�i�i��b�!�!�)�)�#�s�3�3�Q� R� R� Rr*�target_versionNc�@�g|]}|j�����Sr0)�name�lower�r1rds r#r7z(parse_pyproject_toml.<locals>.<listcomp>�s"��'X�'X�'X�1��� � ���'X�'X�'Xr*)r$rK�items�infer_target_version)r^rP�config�inferred_target_versions r#�parse_pyproject_tomlroxs���  � �,�,�N�+�/�/���;�;�?�?���L�L�F� R� R�6�<�<�>�>� R� R� R�F��v�%�%�"6�~�"F�"F�� "� .�'X�'X�@W�'X�'X�'X�F�#� $� �Mr*rPc���|�di��}|�dd��}|�G t|��S#t$rYnwxYw t|��S#ttf$rYnwxYwdS)a#Infer Black's target version from the project metadata in pyproject.toml. Supports the PyPA standard format (PEP 621): https://packaging.python.org/en/latest/specifications/declaring-project-metadata/#requires-python If the target version cannot be inferred, returns None. �projectzrequires-pythonN)rK�parse_req_python_versionr�parse_req_python_specifierr)rP�project_metadata�requires_pythons r#rlrl�s���&�)�)�)�R�8�8��&�*�*�+<�d�C�C�O��"� �+�O�<�<� <��� � � � �D� ���� �-�o�>�>� >�� �.�1� � � � �D� ���� �4s!�?� A � A �A�A3�2A3ruc��t|��}|jddkrdS t|jd��gS#ttf$rYdSwxYw)z�Parse a version string (i.e. ``"3.7"``) to a list of TargetVersion. If parsing fails, will raise a packaging.version.InvalidVersion error. If the parsed version cannot be mapped to a valid TargetVersion, returns None. rrN�)r�releaser� IndexError� ValueError)ru�versions r#rrrr�sl�� �o�&�&�G���q��Q����t���g�o�a�0�1�1�2�2�� � � #�����t�t����s�?�A�Ac����tt|����}|sdSd�tD���t|������}|r�fd�|D��SdS)z�Parse a specifier string (i.e. ``">=3.7,<3.10"``) to a list of TargetVersion. If parsing fails, will raise a packaging.specifiers.InvalidSpecifier error. If the parsed specifier cannot be mapped to a valid TargetVersion, returns None. Nc�$�i|] }d|j��|��S)z3.)�valuerjs r#rez.parse_req_python_specifier.<locals>.<dictcomp>�s"��C�C�C��.�q�w�.�.�!�C�C�Cr*c� ��g|] }�|�� Sr0r0)r1rd�target_version_maps �r#r7z.parse_req_python_specifier.<locals>.<listcomp>�s���C�C�C�!�"�1�%�C�C�Cr*)�strip_specifier_setrrr9�filter)ru� specifier_set�compatible_versionsr�s @r#rsrs�s���� (� �_�(E�(E�F�F�M� ���t�C�C�]�C�C�C��%)�-�*>�*>�?Q�*R�*R�%S�%S���D�C�C�C�C�/B�C�C�C�C� �4r*r�c�l�g}|D�]}dt|��vr|�|���*|jdvrOt|j��}t |j�|j�d|j����}|�|����|jdkrat|j��}t|j ��dkrt d|j�d|j����}|�|����|�|����td� d�|D������S) z�Strip minor versions for some specifiers in the specifier set. For background on version specifiers, see PEP 440: https://peps.python.org/pep-0440/#version-specifiers �*)z~=z==�>=z===�.�>�r��,c3�4K�|]}t|��V��dSr&)rF)r1r2s r#r3z&strip_specifier_set.<locals>.<genexpr>�s(���� <� <�A��Q��� <� <� <� <� <� <r*) rF�append�operatorrr{r�major�minor�lenrxr�join)r�� specifiersr2r{�strippeds r#r�r��sB�� �J� � !� !�� �#�a�&�&�=�=� � � �a� � � � � �Z�4� 4� 4��a�i�(�(�G� �A�J�!O�� �!O�!O�� �!O�!O�P�P�H� � � �h� '� '� '� '� �Z�3� � ��a�i�(�(�G��7�?�#�#�a�'�'��B�7�=�B�B�7�=�B�B�C�C�� � � �a� � � � � � � �a� � � � � ���� <� <�� <� <� <�<�<� =� =�=r*c���tjdkrtj��dz }nDtj�dd��}t|�����dz }t|��S)a:Return the path to the top-level user configuration for black. This looks for ~\.black on Windows and ~/.config/black on Linux and other Unix systems. May raise: - RuntimeError: if the current user has no homedir - PermissionError: if the current process cannot access the user's homedir �win32z.black�XDG_CONFIG_HOMEz ~/.configrC) �sys�platformr�home�os�environrK� expanduserr))�user_config_path� config_roots r#rTrT�si�� �|�w����9�;�;��1����j�n�n�%6� �D�D� �� �,�,�7�7�9�9�G�C�� �+� ,� ,�,r*�rootc�8�|dz }g}|���rB|�d���5}|���}ddd��n #1swxYwY tjd|��S#t $r}t d|�d|�����d}~wwxYw)z8Return a PathSpec matching gitignore content if present.z .gitignorezutf-8)�encodingN� gitwildmatchzCould not parse z: )rJr� readlinesr� from_linesrr)r�� gitignore�lines�gfr[s r#� get_gitignorer��s����|�#�I��E������#� �^�^�W�^� -� -� #���L�L�N�N�E� #� #� #� #� #� #� #� #� #� #� #���� #� #� #� #���"�>�5�9�9�9�� #���� � /�y� /� /�A� /� /�0�0�0� ��������s)�A�A�A�A4�4 B�>B�B�reportc�� t|��}n3#t$r&}|r|�|d|����Yd}~dSd}~wwxYw |�|��n,#t$r|r|�|d|����YdSwxYwdS)z� Returns whether the path is a symbolic link that points outside the root directory. Also returns True if we failed to resolve the path. zcannot be read because NTz'is a symbolic link that points outside F)r)�OSError� path_ignored� relative_torz)rr�r�� resolved_pathr[s r#�$resolves_outside_root_or_cannot_statr��s����'��-�-� � �� ���� � E� � � ��&C��&C�&C� D� D� D��t�t�t�t�t�����������!�!�$�'�'�'�'�� ���� � X� � � ��&V�PT�&V�&V� W� W� W��t�t����� �5s$�� A�=�A�A�%B�Bc�(�� |�������S#t$rYnwxYwt�fd�|jD��d��}|�|�|��St |������S)Nc3�B�K�|]}t|���k�|V��dSr&)r))r1�pr�s �r#r3z,best_effort_relative_path.<locals>.<genexpr>s5�����N�N�a�?�1�3E�3E��3M�3M��3M�3M�3M�3M�N�Nr*)�absoluter�rz�nextr:r))rr�� root_parents ` r#�best_effort_relative_pathr�s���� ��}�}���*�*�4�0�0�0�� � � � � �� �����N�N�N�N�4�<�N�N�N�PT�U�U�K������ �,�,�,� �4� � � ,� ,�T� 2� 2�2s �&*� 7�7�root_relative_path�gitignore_dictc��||z }|���D]p\}} |�|�����}|���r|dz}n#t$rYnwxYw|�|��rdS�qdS)N�/TF)rkr��as_posixr;rz� match_file)r�r�r�r�gitignore_path�pattern� relative_paths r#�_path_is_ignoredr�$s��� �$� $�D�$2�#7�#7�#9�#9������ � �,�,�^�<�<�E�E�G�G�M��{�{�}�}� 4� -�� 3� ���� � � � �E�E� ���� � � �m� ,� ,� ��4�4� � �5s�AA!�! A/�.A/�normalized_pathr�c�|�|r|�|��nd}t|o|�d����S)Nr)�search�bool�group)r�r��matchs r#�path_is_excludedr�8s<��07� @�G�N�N�?� +� +� +�D�E� ��(�%�+�+�a�.�.� )� )�)r*�paths�include�exclude�extend_exclude� force_exclude�verbose�quietc #��K�|���s Jd|�����|D�]�} | ���sJ�| �|�����} |r(t| ||��r|�| d���jd| z} | ���r| dz } t | |��r|�| d����t | |��r|�| d����t | |��r|�| d����t| ||��r��| ���rP|�i|�|| z t| ��i�} nd} t| � ��||||||| || �� � Ed{V����t| � ��r?| j d krt|p| � ��s���|r|�| ��nd } | r| V����dS) a7Generate all files under `path` whose paths are not excluded by the `exclude_regex`, `extend_exclude`, or `force_exclude` regexes, but are included by the `include` regex. Symbolic links pointing outside of the `root` directory are ignored. `report` is where output about exclusions goes. z/INTERNAL ERROR: `root` must be absolute but is z!matches a .gitignore file contentr�z(matches the --exclude regular expressionz/matches the --extend-exclude regular expressionz.matches the --force-exclude regular expressionN)r�r�z.ipynb)�warnT)� is_absoluter�r�r�r�r;r�r�r��gen_python_files�iterdirrJ�suffixrr�)r�r�r�r�r�r�r�r�r�r��childr��new_gitignore_dict� include_matchs r#r�r�@s�����, � � � � �W�W�W�QU�W�W�W�W� ��?�?��� � �"�"�"�"�"�"�.�.�t�4�4�=�=�?�?�� � �.� ��n� � � � � � ��'J� K� K� K� �!�#5�5�� �<�<�>�>� &� �#� %� � �.�� 8� 8� � � � ��'Q� R� R� R� � �.�� ?� ?� � � � ��H� � � � � �.� � >� >� � � � ��'W� X� X� X� � /��t�V� D� D� � � �<�<�>�>� ��)�&�$�&��5�L�-��"6�"6�&�&�"�"� &*�"�'�� � ���������"��� � � � � � � � � � � ��]�]�_�_� ��|�x�'�'�0R��)�E� �1�1�1�'��BI�S�G�N�N�+=�>�>�>�t�M�� �� � � ��?�?r*r"zcolorama.AnsiToWin32c�T� ddlm}||dddd���S#t$r|cYSwxYw)at Wrap stream with colorama's wrap_stream so colors are shown on Windows. If `colorama` is unavailable, the original stream is returned unmodified. Otherwise, the `wrap_stream()` function determines whether the stream needs to be wrapped for a Windows environment and will accordingly either return an `AnsiToWin32` wrapper or the original stream. r)� wrap_streamNFT)�convert�strip� autoreset�wrap)�colorama.initialiser�� ImportError)r"r�s r#�wrap_stream_for_windowsr��s]��U�3�3�3�3�3�3� �{�1�d�%�5�t�T�T�T�T�� �����������s �� '�'r&)C�ior�r��collections.abcrrr� functoolsr�pathlibr�rer�typingr r r r �mypy_extensionsr �packaging.specifiersrrr�packaging.versionrr�pathspecr�pathspec.patterns.gitwildmatchr� version_infor r��tomli�black.handle_ipynb_magicsr� black.moder� black.outputr� black.reportr�coloramarF�dictr$r)rErQr\ror9rlrrrsr�rTr�r�r�r�r�r�r�� TextIOWrapperr�r0r*r#�<module>r�s��� � � � � � � � � � � � �8�8�8�8�8�8�8�8�8�8�������������������6�6�6�6�6�6�6�6�6�6�6�6�&�&�&�&�&�&�J�J�J�J�J�J�J�J�J�J�5�5�5�5�5�5�5�5�������C�C�C�C�C�C���w���$������� �$�$�$�� $� #� #� #� #���$���� ����H�H�H�H�H�H�$�$�$�$�$�$����������������O�O�O� ��U�4��9�%��$�s�C�x�.���� ���  ��$��4���� ��� �9=�0)�0)� �3�-�0)�)1�#��0)� �4��9��0)�0)�0)� ��0)�hIM����S�#�X���8@�� �� �c�]�����, ��d�����c��d�3��8�n�������"���c��N�� �d�=�!�"�����2 �c� �h�t�M�?R�6S� � � � ������m�AT�8U�����">�|�>� �>�>�>�>�2 �-�$�-�-�-� ��-�& � �� �� � � � �� �" $��� �� �� �V� �� � ����0 3�D� 3�� 3�� 3� 3� 3� 3���� ����x��(�� � ����(*��*� �g�c�l� #�*� �*�*�*�*�V� �D�>�V� �V��S�\�V��S�\� V� �W�S�\�*� V� �G�C�L�)� V� �V��T�$��.�1�2�V��V� �V��d�^�V�V�V�V�rU� ��U� �2� �3� 3�4�U�U�U�U�U�Us�%A*�* A8�7A8
Memory