관리-도구
편집 파일: utils.cpython-39.opt-1.pyc
a �)g� � @ sH d dl mZmZmZ eZd dlZd dlZd dd�Zddd�Z dd � Z dS )� )�absolute_import�division�print_functionNTc C s� |}t j�| �r�t �| t j�r�d}z�ztt| �}z0|�� }t�|tj�}t�|tj |t j B � W n typ Y n0 |�� }|r�|� � }t|�dkr�|}W n ty� Y n0 W |dur�|�� n|dur�|�� 0 |S )aS Return the contents of a given file path :args path: path to file to return contents from :args default: value to return if we could not read file :args strip: controls if we strip whitespace from the result or not :returns: String with file contents (optionally stripped) or 'default' value Nr )�os�path�exists�access�R_OK�open�fileno�fcntlZF_GETFLZF_SETFL� O_NONBLOCK� Exception�read�strip�len�close)r �defaultr �dataZdatafile�fd�flag� r �D/usr/lib/python3.9/site-packages/ansible/module_utils/facts/utils.py�get_file_content s. � r c C sT t | |d�}|rL|du r"|�� }qPt|�dkr@|�|��|�}qP|�|�}ng }|S )zget list of lines from file)r N� )r � splitlinesr �rstrip�split)r r Zline_sepr �retr r r �get_file_linesA s r c C s� i }z�t �| �}|j|j |d<