%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.9/site-packages/ansible/plugins/cache/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.9/site-packages/ansible/plugins/cache/__pycache__/__init__.cpython-39.pyc

a

�)g�/�@s�ddlmZmZmZeZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZddlmZddlmZddlmZmZddlmZdd	lmZdd
lmZddlmZe�ZGdd
�d
e�Z Gdd�de �Z!Gdd�de�Z"dS)�)�absolute_import�division�print_functionN)�abstractmethod)�MutableMapping)�	constants)�AnsibleError)�to_bytes�to_text)�
AnsiblePlugin)�cache_loader)�resource_from_fqcr)�DisplaycsteZdZeZ�fdd�Zedd��Zedd��Zedd��Z	ed	d
��Z
edd��Zed
d��Zedd��Z
�ZS)�BaseCacheModulecs tt|���|j||d�dS)N)Zvar_optionsZdirect)�superr�__init__Zset_options��self�args�kwargs��	__class__��B/usr/lib/python3.9/site-packages/ansible/plugins/cache/__init__.pyr.szBaseCacheModule.__init__cCsdS�Nr�r�keyrrr�get2szBaseCacheModule.getcCsdSrr�rr�valuerrr�set6szBaseCacheModule.setcCsdSrr�rrrr�keys:szBaseCacheModule.keyscCsdSrrrrrr�contains>szBaseCacheModule.containscCsdSrrrrrr�deleteBszBaseCacheModule.deletecCsdSrrr!rrr�flushFszBaseCacheModule.flushcCsdSrrr!rrr�copyJszBaseCacheModule.copy)�__name__�
__module__�__qualname__�displayZ_displayrrrr r"r#r$r%r&�
__classcell__rrrrr)s 





rcs�eZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zedd��Zedd��Z�ZS)�BaseFileCacheModulez8
    A caching module backed by file based storage.
    cs�z<tt|�j|i|��|�|�d��|_t|�d��|_Wn,tyh|�t	j
�|_tt	j�|_Yn0t|j
�|_i|_|��dS)NZ_uri�_timeout)rr,r�_get_cache_connection�
get_option�
_cache_dir�floatr-�KeyError�CZCACHE_PLUGIN_CONNECTIONZCACHE_PLUGIN_TIMEOUTr
r(�plugin_name�_cache�validate_cache_connectionrrrrrSszBaseFileCacheModule.__init__cCs2|r.ztj�tj�|��WSty,Yn0dSr)�os�path�
expanduser�
expandvars�	TypeError)r�sourcerrrr.`s
z)BaseFileCacheModule._get_cache_connectionc
Cs�|jstd|j��tj�|j�sxzt�|j�Wq�ttfyt}z&td|j|jt	|�f��WYd}~q�d}~00n8tj
tjtjfD]&}t�
|j|�s�td|j|jf��q�dS)Nzwerror, '%s' cache plugin requires the 'fact_caching_connection' config option to be set (to a writeable directory path)zCerror in '%s' cache plugin while trying to create cache dir %s : %szeerror in '%s' cache, configured path (%s) does not have necessary permissions (rwx), disabling plugin)r0rr4r7r8�exists�makedirs�OSError�IOErrorr	�R_OK�W_OK�X_OK�access)r�e�xrrrr6gs�2�z-BaseFileCacheModule.validate_cache_connectioncCs2|�d�}|r d|j||f}nd|j|f}|S)N�_prefixz%s/%s%sz%s/%s)r/r0)rr�prefix�	cachefilerrr�_get_cache_file_namews

z(BaseFileCacheModule._get_cache_file_namec
Cs"||jv�r|�|�s|dkr"t�|�|�}z|�|�}||j|<Wn�ty�}z<t�d|j|t	|�f�|�
|�td|��WYd}~n�d}~0tt
fy�}z*t�d|j|t	|�f�t�WYd}~nBd}~0t�y}z td|t	|�f��WYd}~n
d}~00|j�|�S)z� This checks the in memory cache first as the fact was not expired at 'gather time'
        and it would be problematic if the key did expire after some long running tasks and
        user gets 'undefined' error in the same play �zlerror in '%s' cache plugin while trying to read %s : %s. Most likely a corrupt file, so erasing and failing.z�The cache file %s was corrupt, or did not otherwise contain valid data. It has been removed, so you can re-run your command now.Nz7error in '%s' cache plugin while trying to read %s : %sz*Error while decoding the cache file %s: %s)r5�has_expiredr2rJ�_load�
ValueErrorr*�warningr4r	r$rr?r@�	Exceptionr)rrrIrrErrrrs*

�
�*zBaseFileCacheModule.getcCs(||j|<|�|�}tjtj�|�d�\}}z�z|�||�WnBtt	fy�}z&t
�d|j|t
|�f�WYd}~n
d}~00zt�||�WnDtt	fy�}z(t
�d|j||t
|�f�WYd}~n
d}~00Wzt�|�Wnty�Yn0n&zt�|�Wnt�y Yn00dS)N)�dirz=error in '%s' cache plugin while trying to write to '%s' : %szAerror in '%s' cache plugin while trying to move '%s' to '%s' : %s)r5rJ�tempfileZmkstempr7r8�dirname�_dumpr?r@r*rOr4r	�rename�unlink)rrrrIZtmpfile_handleZtmpfile_pathrErrrr �s(

04�zBaseFileCacheModule.setc
Cs�|jdkrdS|�|�}zt�|�}Wnjttfy�}zN|jtjkrTWYd}~dSt�	d|j
|t|�f�WYd}~dSWYd}~n
d}~00t��|j
|jkr�dS||jvr�|j|=dS)NrF�7error in '%s' cache plugin while trying to stat %s : %sT)r-rJr7�statr?r@�errno�ENOENTr*rOr4r	�time�st_mtimer5)rrrI�strErrrrL�s

$
zBaseFileCacheModule.has_expiredcCsb|�d�}t|�}g}t�|j�D]:}|�d�s"|�|�s<q"||d�}|�|�s"|�|�q"|S)NrG�.)r/�lenr7�listdirr0�
startswithrL�append)rrHZ
prefix_lengthr"�krrrr"�s

zBaseFileCacheModule.keysc
Cs�|�|�}||jvrdS|�|�r&dSzt�|�WdSttfy�}z@|jtjkrdWYd}~dSt	�
d|j|t|�f�WYd}~n
d}~00dS)NTFrW)
rJr5rLr7rXr?r@rYrZr*rOr4r	)rrrIrErrrr#�s



zBaseFileCacheModule.containsc	CsPz|j|=WntyYn0zt�|�|��WnttfyJYn0dSr)r5r2r7�removerJr?r@rrrrr$�szBaseFileCacheModule.deletecCs"i|_|��D]}|�|�qdSr)r5r"r$rrrrr%�szBaseFileCacheModule.flushcCs&t�}|��D]}|�|�||<q|Sr)�dictr"r)r�retrrrrr&�szBaseFileCacheModule.copycCsdS)a�
        Read data from a filepath and return it as a value

        :arg filepath: The filepath to read from.
        :returns: The value stored in the filepath

        This method reads from the file on disk and takes care of any parsing
        and transformation of the data before returning it.  The value
        returned should be what Ansible would expect if it were uncached data.

        .. note:: Filehandles have advantages but calling code doesn't know
            whether this file is text or binary, should be decoded, or accessed via
            a library function.  Therefore the API uses a filepath and opens
            the file inside of the method.
        Nr)r�filepathrrrrM�szBaseFileCacheModule._loadcCsdS)z�
        Write data to a filepath

        :arg value: The value to store
        :arg filepath: The filepath to store it at
        Nr)rrrgrrrrTszBaseFileCacheModule._dump)r'r(r)�__doc__rr.r6rJrr rLr"r#r$r%r&rrMrTr+rrrrr,Os"


r,c@s�eZdZdZd(dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zd)dd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�ZdS)*�CachePluginAdjudicatorzC
    Intermediary between a cache dictionary and a CacheModule
    �memorycKs<i|_i|_tj|fi|��|_|js2td|��||_dS)Nz%Unable to load the cache plugin (%s).)r5�
_retrievedrr�_pluginr�_plugin_name)rr4rrrrrszCachePluginAdjudicator.__init__cCs|j|jkr|��dSr)rkr5�	set_cacher!rrr�update_cache_if_changed)sz.CachePluginAdjudicator.update_cache_if_changedcCs6|j��D]}|j�||j|�q
t�|j�|_dSr)r5r"rlr r&�deepcopyrk)rZtop_level_cache_keyrrrrn-sz CachePluginAdjudicator.set_cachecCs&|j��D]}|j�|�|j|<q
dSr)rlr"rr5rrrr�load_whole_cache2sz'CachePluginAdjudicator.load_whole_cachecCs
t|j�Sr)r
r5r!rrr�__repr__6szCachePluginAdjudicator.__repr__cCst|���Sr)�iterr"r!rrr�__iter__9szCachePluginAdjudicator.__iter__cCst|���Sr)r_r"r!rrr�__len__<szCachePluginAdjudicator.__len__cCs6d}t||jv||jv|jdk|j�|�g�r2d}|S)NFrjT)�allr5rkrmrlr#)rr�loadrrr�_do_load_key?s
�z#CachePluginAdjudicator._do_load_keycCsN|�|�rDz|j�|�|j|<Wnty2Yn0|j||j|<|j|Sr�rxrlrr5r2rkrrrr�__getitem__Js
z"CachePluginAdjudicator.__getitem__Nc
Csd|�|�rVz|j�|�|j|<Wn$tyD}zWYd}~nd}~00|j||j|<|j�||�Srry)rr�defaultrErrrrTs
zCachePluginAdjudicator.getcCs
|j��Sr)r5�itemsr!rrrr|^szCachePluginAdjudicator.itemscCs
|j��Sr)r5�valuesr!rrrr}aszCachePluginAdjudicator.valuescCs
|j��Sr)r5r"r!rrrr"dszCachePluginAdjudicator.keyscGs"|r|j�||d�S|j�|�S)Nr)r5�pop)rrrrrrr~gszCachePluginAdjudicator.popcCs|j|=dSr�r5rrrr�__delitem__lsz"CachePluginAdjudicator.__delitem__cCs||j|<dSrrrrrr�__setitem__osz"CachePluginAdjudicator.__setitem__cCs|j��i|_dSr)rlr%r5r!rrrr%rs
zCachePluginAdjudicator.flushcCs|j�|�dSr)r5�update)rrrrrr�vszCachePluginAdjudicator.update)rj)N)r'r(r)rhrrornrqrrrtrurxrzrr|r}r"r~r�r�r%r�rrrrris&




ri)#Z
__future__rrr�typeZ
__metaclass__r&rYr7rRr[�abcr�collections.abcrZansiblerr3Zansible.errorsrZansible.module_utils._textr	r
Zansible.pluginsrZansible.plugins.loaderrZansible.utils.collection_loaderr
Zansible.utils.displayrr*rr,rirrrr�<module>s(&M

Zerion Mini Shell 1.0