Dashboard
PHP:
8.2.30
OS:
Linux
User:
dh_nv8b2m
/
/
usr
/
local
/
lib
/
python3.10
/
dist-packages
/
ansible
/
utils
/
__pycache__
📤 Upload
📝 New File
📁 New Folder
Close
Editing: path.cpython-310.pyc
o O�h� � @ s� d dl mZ d dlZd dlZd dlmZ d dlmZ d dlm Z m Z mZ ddgZdd d�Z dd d�Zdd� Zddd�Zddd�ZdS )� )�annotationsN)�EEXIST)�AnsibleError)�to_bytes� to_native�to_text�unfrackpath� makedirs_safeTc C s� t |ddd�}|du rt t�� dd�}ntj�|�r tj�|�}tj�tj�t | dd���}tj�|�s;tj� ||�}|rCtj� |�}ttj�|�dd�S )a� Returns a path that is free of symlinks (if follow=True), environment variables, relative path traversals and symbols (~) :arg path: A byte or text string representing a path to be canonicalized :arg follow: A boolean to indicate of symlinks should be resolved or not :raises UnicodeDecodeError: If the canonicalized version of the path contains non-utf8 byte sequences. :rtype: A text string (unicode on pyyhon2, str on python3). :returns: An absolute path with symlinks, environment variables, and tilde expanded. Note that this does not check whether a path exists. example:: '$HOME/../../var/mail' becomes '/var/spool/mail' �surrogate_or_strict�passthru)�errors� nonstringN�r ) r �os�getcwd�path�isfile�dirname� expanduser� expandvars�isabs�join�realpathr �normpath)r �follow�basedir� b_basedir�b_final_path� r �=/usr/local/lib/python3.10/dist-packages/ansible/utils/path.pyr s c C s� t | �}t|�}tj�|�sFz|rt�||� W dS t�|� W dS tyE } z|jtkr:t dt |�t |�f ��W Y d}~dS d}~ww dS )a� A *potentially insecure* way to ensure the existence of a directory chain. The "safe" in this function's name refers only to its ability to ignore `EEXIST` in the case of multiple callers operating on the same part of the directory chain. This function is not safe to use under world-writable locations when the first level of the path to be created contains a predictable component. Always create a randomly-named element first if there is any chance the parent directory might be world-writable (eg, /tmp) to prevent symlink hijacking and potential disclosure or modification of sensitive file contents. :arg path: A byte or text string representing a directory chain to be created :kwarg mode: If given, the mode to set the directory to :raises AnsibleError: If the directory cannot be created and does not already exist. :raises UnicodeDecodeError: if the path is not decodable in the utf-8 encoding. z*Unable to create local directories(%s): %sN)r r r r �exists�makedirs�OSError�errnor r r )r �mode�rpath�b_rpath�er r r r @ s ����c C sh t | dd�} d}tj�| �r| }n| dv rt�� }ntj�| �r&tj�| �}|r.tj�|�}t|dd�S )z- returns directory for inventory or playbook r r N)N� �.) r r r �isdirr r r �abspathr )�source�dnamer r r r \ s r Fc C s� z^t j�| �r\z#t j�| �rt�| � nt j�| �r#t �| � W W dS W W dS W W dS ty[ } z%|rOddl m } |� }|�d�t |��� W Y d}~W dS W Y d}~W dS d}~ww W dS tyh Y dS w )a Removes temporary file or directory. Optionally display a warning if unable to remove the file or directory. :arg path: Path to file or directory to be removed :kwarg warn: Whether or not to display a warning when the file or directory cannot be removed r )�Displayz#Unable to remove temporary file {0}N)r r r r* �shutil�rmtreer �unlink� Exception�ansible.utils.displayr. �display�formatr )r �warnr'