� u��gd0���ddlZddlZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z m Z mZmZmZmZmZmZddlmZmZddlmZeedfZeje��Zd eed eefd �ZGd �d ��Z d-dededeed eefd�Z e dedeed eee ee effd���Z! d.dedededede"deed eee"eeffd�Z# d/dedededeed eee"eff d�Z$deeeeefde"d eeeeffd �Z%ded eefd!�Z& d0d#ed$e"d%e"d efd&�Z' d1deed(ee ed)e"de"d*e"deed e"fd+�Z( d2deed(ee ed)e"d*e"deed e eeeff d,�Z)dS)3�N)� OrderedDict)�contextmanager)�IO�Dict�Iterable�Iterator�Mapping�Optional�Tuple�Union�)�Binding� parse_stream)�parse_variableszos.PathLike[str]�mappings�returnc#�tK�|D]2}|jr%t�d|jj��|V��3dS)Nz;python-dotenv could not parse statement starting at line %s)�error�logger�warning�original�line)r�mappings �[/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/dotenv/main.py�with_warn_for_invalid_linesrsX�������� �=� � �N�N�M�� �%� � � �� � � � � ��c�&�eZdZ ddeedeeededeeded ed dfd �Ze d e eefd ���Z d e eeeffd �Z d e eeeeffd�Zd efd�Zded eefd�ZdS)�DotEnvNFT� dotenv_path�stream�verbose�encoding� interpolate�overriderc�h�||_||_d|_||_||_||_||_dS�N)rr �_dictr!r"r#r$)�selfrr r!r"r#r$s r�__init__zDotEnv.__init__#s;��/:���)/�� �9=�� �$�� �'/�� �!,���&�� � � rc#�vK�|jr^tj�|j��r:t |j|j���5}|V�ddd��dS#1swxYwYdS|j� |jV�dS|jr"t� d|jpd��tj d��V�dS)N�r"z3python-dotenv could not find configuration file %s.�.env�) r�os�path�isfile�openr"r r!r�info�io�StringIO)r(r s r� _get_streamzDotEnv._get_stream4s���� � � "�����t�/?� @� @� "��d�&���?�?�?� �6�� � � � � � � � � � � � � � � ���� � � � � � � �[� $��+� � � � � ��|� �� � �I��$�.������+�b�/�/� !� !� !� !� !s� A�A�"Ac���|jr|jS|���}|jr)tt ||j�����|_nt|��|_|jS)zReturn dotenv as dict)r$)r'�parser#r�resolve_variablesr$)r(� raw_valuess r�dictz DotEnv.dictCsj�� �:� ��:� ��Z�Z�\�\� � � � 1�$�!�*�t�}�E�E�E���D�J�J�%�Z�0�0�D�J��z�rc#��K�|���5}tt|����D]}|j�|j|jfV�� ddd��dS#1swxYwYdSr&)r5rr�key�value)r(r rs rr7z DotEnv.parseSs����� � � � � � 5�6�6�|�F�7K�7K�L�L� 5� 5���;�*�!�+�w�}�4�4�4�4�� 5� 5� 5� 5� 5� 5� 5� 5� 5� 5� 5� 5� 5���� 5� 5� 5� 5� 5� 5s�7A�A �#A c���|���sdS|������D],\}}|tjvr|js�|�|tj|<�-dS)zI Load the current dotenv as system environment variable. FNT)r:�itemsr.�environr$)r(�k�vs r�set_as_environment_variablesz#DotEnv.set_as_environment_variablesYsj���y�y�{�{� ��5��I�I�K�K�%�%�'�'� "� "�D�A�q��B�J���t�}����}� !�� �1� ���trr<c��|���}||vr||S|jr!t�d||j��dS)� zKey %s not found in %s.N)r:r!rrr)r(r<�datas r�getz DotEnv.gethsL���y�y�{�{�� �$�;�;���9� � �<� M� �N�N�4�c�4�;K� L� L� L��tr)NFNTT)�__name__� __module__� __qualname__r �StrPathr�str�boolr)rrr5rr:r r7rCrG�rrrr"s\������%)��"&� ��'�'��g�&�'���C��!�'�� '� �3�-� '� � '��'� �'�'�'�'�"� "�X�b��g�.� "� "� "��^� "��d�3��� �-�.����� 5�x��c�8�C�=�&8� 9�:�5�5�5�5� �d� � � � � �s� �x��}� � � � � � rr�utf-8r� key_to_getr"c�L�t|d|����|��S)z Get the value of a given key from the given .env. Returns `None` if the key isn't found or doesn't have a value. T)r!r")rrG)rrPr"s r�get_keyrRus'�� �+�t�h� ?� ?� ?� C� C�J� O� O�Orr/c#�K�tj|�����tjd|d���5}d} t ||���5}||fV�ddd��n #1swxYwYn#t $r }|}Yd}~nd}~wwxYwddd��n #1swxYwY|�tj|j |��dStj |j ��|d�)N�wF)�moder"�deleter+) �pathlib�Path�touch�tempfile�NamedTemporaryFiler1� BaseException�shutil�move�namer.�unlink)r/r"�destr�source�errs r�rewriterd�sx����  �L��������� � $�#��� O� O� O��SW��� ��d�X�.�.�.� %�&��t�n�$�$�$� %� %� %� %� %� %� %� %� %� %� %���� %� %� %� %���� � � ��E�E�E�E�E�E����� ���� ������������������ �}�� �D�I�t�$�$�$�$�$� � �$�)������s`�B�A4�A(� A4�(A, �,A4�/A, �0A4�3B�4 B �>B�B�B � B�B� B�alwaysF� key_to_set� value_to_set� quote_mode�exportc��|dvrtd|�����|dkp|dko|��� }|r*d�|�dd����}n|}|r d|�d |�d �}n|�d |�d �}t ||� ��5\} } d } d } t t | ����D]d} | j|kr| �|��d } �%| �| j j ��| j j � d �� } �e| s,| r| �d ��| �|��ddd��n #1swxYwYd ||fS)z� Adds or Updates a key/value to the given .env If the .env path given doesn't exist, fails instead of risking creating an orphan .env somewhere in the filesystem )re�auto�neverzUnknown quote_mode: rerkz'{}'�'z\'zexport �=� r+FTN) � ValueError�isalnum�format�replacerdrrr<�writer�string�endswith)rrfrgrhrir"�quote� value_out�line_outrbra�replaced�missing_newliners r�set_keyr|�s����4�4�4��<� �<�<�=�=�=� �(� "� ��f��;�\�%9�%9�%;�%;�!;� � �!��M�M�,�"6�"6�s�E�"B�"B�C�C� � � � � �1�7�Z�7�7�)�7�7�7��� �0�0�9�0�0�0�� ��x� 0� 0� 0� !�N�V�T�����2�<��3G�3G�H�H� M� M�G��{�j�(�(�� � �8�$�$�$����� � �7�+�2�3�3�3�&-�&6�&=�&F�&F�t�&L�&L�"L���� !�� !�� � �4� � � � �J�J�x� � � � !� !� !� !� !� !� !� !� !� !� !���� !� !� !� !� ��\� )�)s� B7E�E�E� key_to_unsetc���tj�|��st�d|��d|fSd}t ||���5\}}t t|����D]/}|j|krd}�|� |j j ���0 ddd��n #1swxYwY|s t�d||��d|fS||fS)z� Removes a given key from the given `.env` file. If the .env path given doesn't exist, fails. If the given key doesn't exist in the .env, fails. z(Can't delete from %s - it doesn't exist.NFr+Tz/Key %s not removed from %s - key doesn't exist.) r.r/�existsrrrdrrr<rtrru)rr}rhr"�removedrbrars r� unset_keyr��s:�� �7�>�>�+� &� &�"����A�;�O�O�O��\�!�!��G� ��x� 0� 0� 0�4�N�V�T�2�<��3G�3G�H�H� 4� 4�G��{�l�*�*����� � �7�+�2�3�3�3�3�  4�4�4�4�4�4�4�4�4�4�4�4����4�4�4�4� �"���� =�|�[� � � ��\�!�!� �L� � s�AB/�/B3�6B3�valuesr$c�j��i}|D]�\}}|�d}n�t|��}i�|r5��tj����|��n4��|����tj��d��fd�|D����}|||<��|S)Nr-c3�B�K�|]}|����V��dSr&)�resolve)�.0�atom�envs �r� <genexpr>z$resolve_variables.<locals>.<genexpr>�s/�����A�A�4�T�\�\�#�.�.�A�A�A�A�A�Ar)r�updater.r@�join)r�r$� new_valuesr_r=�result�atomsr�s @rr8r8�s����,.�J��"�"� ��e� �=��F�F�#�E�*�*�E�,.�C�� '�� � �2�:�&�&�&�� � �:�&�&�&�&�� � �:�&�&�&�� � �2�:�&�&�&��W�W�A�A�A�A�5�A�A�A�A�A�F�!� �4��� �rc#��K�tj�|��std���tj�|��rtj�|��}d}tj�|��}||kr\|V�tj�tj�|tjj����}||}}||k�ZdSdS)zL Yield directories starting from the given directory up to the root zStarting path not foundN) r.r/r�IOErrorr0�dirname�abspathr��pardir)r/�last_dir� current_dir� parent_dirs r� _walk_to_rootr�s����� �7�>�>�$� � �1��/�0�0�0� �w�~�~�d���%��w���t�$�$���H��'�/�/�$�'�'�K� �k� !� !������W�_�_�R�W�\�\�+�r�w�~�%N�%N�O�O� � +�Z�+�� �k� !� !� !� !� !� !rr,�filename�raise_error_if_not_found�usecwdc�&�d�}d�}|s*|��s |��sttdd��rtj��}n�tj��}t }|jj|ks)tj� |jj��sI|j �J�|j }|jj|k� tj� |jj���I|jj}tj� tj� |����}t|��D]E} tj�| |��} tj�| ��r| cS�F|rt!d���dS)z� Search in increasingly higher folders for the given file Returns path to the file if found, or an empty string otherwise c�r� tddddg���}n#t$rYdSwxYwt|d�� S)z<Decide whether this is running in a REPL or IPython notebook�__main__N�__file__)�fromlistF)� __import__�ModuleNotFoundError�hasattr)�mains r�_is_interactivez$find_dotenv.<locals>._is_interactivesV�� ��j�$�� �|�L�L�L�D�D��"� � � ��5�5� �����4��,�,�,�,s �� %�%c�,�tj��duSr&)�sys�gettracerNrr� _is_debuggerz!find_dotenv.<locals>._is_debugger's���|�~�~�T�)�)r�frozenFNzFile not foundr-)�getattrr�r.�getcwd� _getframer��f_code� co_filenamer/r�f_backr�r�r�r�r0r�) r�r�r�r�r�r/�frame� current_file�frame_filenamer�� check_paths r� find_dotenvr�s���-�-�-�*�*�*��@���"�"�@�l�l�n�n�@���X�u�8U�8U�@��y�{�{���� ����� ��l�&�,�6�6�b�g�n�n� �L� $�? �? �6��<�+�+�+��L�E� �l�&�,�6�6�b�g�n�n� �L� $�? �? �6� ��1���w���r�w���~�>�>�?�?�� ��&�&�����W�\�\�'�8�4�4� � �7�>�>�*� %� %� �� � � � � �(��&�'�'�'� �2rTr r!r#c�x�|�|�t��}t||||||���}|���S)a�Parse a .env file and then load all the variables found as environment variables. Parameters: dotenv_path: Absolute or relative path to .env file. stream: Text stream (such as `io.StringIO`) with .env content, used if `dotenv_path` is `None`. verbose: Whether to output a warning the .env file is missing. override: Whether to override the system environment variables with the variables from the `.env` file. encoding: Encoding to be used to read the file. Returns: Bool: True if at least one environment variable is set else False If both `dotenv_path` and `stream` are `None`, `find_dotenv()` is used to find the .env file with it's default parameters. If you need to change the default parameters of `find_dotenv()`, you can explicitly call `find_dotenv()` and pass the result to this function as `dotenv_path`. N�rr r!r#r$r")r�rrC)rr r!r$r#r"�dotenvs r� load_dotenvr�EsQ��4��v�~�!�m�m� � ������� ���F� � .� .� 0� 0�0rc�t�|�|�t��}t||||d|������S)a� Parse a .env file and return its content as a dict. The returned dict will have `None` values for keys without values in the .env file. For example, `foo=bar` results in `{"foo": "bar"}` whereas `foo` alone results in `{"foo": None}` Parameters: dotenv_path: Absolute or relative path to the .env file. stream: `StringIO` object with .env content, used if `dotenv_path` is `None`. verbose: Whether to output a warning if the .env file is missing. encoding: Encoding to be used to read the file. If both `dotenv_path` and `stream` are `None`, `find_dotenv()` is used to find the .env file. NTr�)r�rr:)rr r!r#r"s r� dotenv_valuesr�msK��.��v�~�!�m�m� � �������  � � � �d�f�f� r)rO)reFrO)rerO)r,FF)NNFFTrO)NNFTrO)*r3�loggingr.rWr]r�rZ� collectionsr� contextlibr�typingrrrrr r r r �parserrr� variablesrrLrK� getLoggerrHrrrrRrdrMr|r�r8r�r�r�r�rNrr�<module>r�s��� � � � ����� � � � ����� � � � � � � � �����#�#�#�#�#�#�%�%�%�%�%�%�P�P�P�P�P�P�P�P�P�P�P�P�P�P�P�P�P�P�P�P�)�)�)�)�)�)�)�)�&�&�&�&�&�&� ��'�'� (�� �� �8� $� $���(�7�*;����@Q�����P�P�P�P�P�P�P�P�l&� P� P�� P�� P��s�m� P��c�]� P� P� P� P��� ���s�m���e�B�s�G�R��W�$�%�&�������2��%� -*�-*��-*��-*��-*�� -*� � -*� �s�m� -*� �8�D�>�3�� #�$�-*�-*�-*�-*�f�%� !�!��!��!��!��s�m� !�  �8�D�>�3� �� !�!�!�!�B� �U�3��� �-�.� /���� �S�(�3�-� � �����28��8��� �8�8�8�8�&�%*��.�.��.�"�.� �.� � .�.�.�.�d&*� $����%� %1�%1��'�"�%1� �R��W� �%1��%1�� %1� � %1� �s�m� %1� �%1�%1�%1�%1�R&*� $���%� ! �! ��'�"�! � �R��W� �! ��! �� ! � �s�m� ! �  �#�x��}� �� ! �! �! �! �! �! r
Memory