File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/files.cpython-310.pyc
o
;jZ� � @ s� d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl
Z
ddlZddlZddl
ZddlZddlZddlZddlZddlmZmZmZ ddlmZ zddlZdZW n eyi dZY nw eed�rsejZnddlZG dd � d �Z d
d� Ze�!e"�Z#dZ$dZ%d
e% Z&dZ'ddddddd�Z(dd� e(�)� D �Z*dd� Z+dd� Z,dd� Z-dd� Z.d\d!d"�Z/d#d$� Z0d]d%d&�Z1ej2d^d)d*��Z3ed^d+d,��Z4d-d.� Z5ej2d/d0� �Z6d1d2� Z7ej2d3d4� �Z8ej2d5d6� �Z9d_d7d8�Z:d9d:� Z;d;d<� Z<ed=�d>d=� �Z=d`d?d@�Z>dAdB� Z?d]dCdD�Z@edE�dadGdH��ZAedI�dJdK� �ZBdLdM� ZCedN�dOdN� �ZDdPdQ� ZEdRdS� ZFdTdU� ZGdVdW� ZHd]dXdY�ZIdZd[� ZJdS )bz"
Functions for working with files
� N)�CommandExecutionError�
FileLockError�MinionError)�jinja_filterTF�asynccontextmanagerc @ s( e Zd ZdZdd� Zdd� Zdd� ZdS ) �_AsyncGeneratorContextManagerzA
Async context manager backport for Python < 3.7
c C s ||i |��| _ d S �N)�_gen)�self�func�args�kwargs� r �D/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/files.py�__init__. s z&_AsyncGeneratorContextManager.__init__c � s. �z | j �� I d H W S ty td�d �w )Nzgenerator didn't yield)r � __anext__�StopAsyncIteration�RuntimeError)r
r r r �
__aenter__1 s �
�z(_AsyncGeneratorContextManager.__aenter__c
� s� �|d u rz
| j �� I d H W td�� ty Y d S w |d u r$|� }z| j �|||�I d H W d S ty< Y dS tyd } z||u rNW Y d }~dS t|t�r_|j|u r_W Y d }~dS � d }~w ty{ } z||u rvW Y d }~dS � d }~ww )Nzgenerator didn't stopTF)r r r r �athrow�
isinstance� __cause__� Exception)r
�exc_type� exc_value� traceback�excr r r � __aexit__7 s: ����
���z'_AsyncGeneratorContextManager.__aexit__N)�__name__�
__module__�__qualname__�__doc__r r r r r r r r ) s
r c s t �� �� fdd��}|S )z8
asynccontextmanager decorator backport
c s t � | |�S r )r )r r
�r r r �helperY s z#asynccontextmanager.<locals>.helper)� functools�wraps)r r# r r"