Your IP : 216.73.216.85


Current Path : /opt/alt/python37/lib/python3.7/site-packages/clint/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/clint/__pycache__/resources.cpython-37.pyc

B


��]��@s�dZddlmZddlmZddlZddlmZmZddlm	Z	m
Zddlm
Z
mZdd	lmZmZd
ZGdd�de�Ze�ae�ae�ae�ad
d�ZGdd�de�ZdS)zh
clint.resources
~~~~~~~~~~~~~~~

This module contains all the application resource features of clint.

�)�absolute_import)�with_statementN)�remove�
removedirs)�isfile�join)�AppDirs�AppDirsError�)�mkdir_p�
is_collection)�init�user�site�cache�log�
NotConfiguredc@steZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zddd�Z	ddd�Z
ddd�Zd dd�Zd!dd�Z
dd�ZdS)"�AppDirzApplication Directory object.NcCs||_d|_|r|��dS)NF)�path�_exists�_create)�selfr�r�@/opt/alt/python37/lib/python3.7/site-packages/clint/resources.py�__init__ szAppDir.__init__cCs
d|jS)Nz
<app-dir: %s>)r)rrrr�__repr__(szAppDir.__repr__cCs"|dkr|js|��t�||�S)N)rrr�_raise_if_none)rr�object�__getattribute__)r�namerrrr,szAppDir.__getattribute__cCs|jst��dS)z?Raises if operations are carried out on an unconfigured AppDir.N)rr)rrrrr4szAppDir._raise_if_nonecCs"|��|jst|j�d|_dS)z&Creates current AppDir at AppDir.path.TN)rrrr)rrrrr:s
zAppDir._create�rcCs|��t|j|�}t||�S)z(Returns file object from given filename.)r�	path_joinr�open)r�filename�mode�fnrrrr"CszAppDir.openFc	CsF|��t|j|�}|rd}nd}t||��}|�|�WdQRXdS)z'Writes given content to given filename.�wb�wN)rr!rr"�write)rr#�content�binaryr%�flags�frrrr(LszAppDir.writec	CsF|��t|j|�}|rd}nd}t|d��}|�|�dSQRXdS)z(Appends given content to given filename.�ab�aTN)rr!rr"r()rr#r)r*r%r+r,rrr�append[s
z
AppDir.append�c
Csl|��t|j|�}yt|�r(t|�nt|�Wn4tk
rf}z|jtjkrRn|�Wdd}~XYnXdS)ziDeletes given file or directory. If no filename is passed, current
        directory is removed.
        N)	rr!rrrr�OSError�errno�ENOENT)rr#r%�whyrrr�deletejs
z
AppDir.deletec	CsZ|��t|j|�}|rd}nd}yt||��
}|��SQRXWntk
rTdSXdS)zXReturns contents of given file with AppDir.
        If file doesn't exist, returns None.�brr N)rr!rr"�read�IOError)rr#r*r%r+r,rrrr7}szAppDir.readcCs t|�rt|�}tt|j|��S)z4Returns AppDir instance for given subdirectory name.)rr!rr)rrrrr�sub�sz
AppDir.sub)N)r )F)F)r0)F)�__name__�
__module__�__qualname__�__doc__rrrrrr"r(r/r5r7r9rrrrrs
	
	



rcCs.t||�}|jt_|jt_|jt_|jt	_dS)N)
r�
user_data_dirrr�
site_data_dirr�user_cache_dirr�user_log_dirr)�vendorr�adrrrr
�s

r
c@seZdZdZdS)rzFApplication configuration required. Please run resources.init() first.N)r:r;r<r=rrrrr�sr)r=�
__future__rrr2�osrr�os.pathrrr!�appdirsrr	�utilsrr�__all__rrrrrrr
r8rrrrr�<module>	s~