
    Vh[                    6    d dl mZ d dlZd dlZddZddZd Zy)    )annotationsNc                z   |}t         j                  j                  |       rt        j                  | t         j                        rd}	 t        |       }	 |j                         }t        j                  |t        j                        }t        j                  |t        j                  |t         j                  z         |j                         }|r|j                         }t        |      dk(  r|}||j                          |S |S # t        $ r Y Sw xY w# t        $ r Y 0w xY w# ||j                          w w xY w)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fcntlF_GETFLF_SETFL
O_NONBLOCK	Exceptionreadstriplenclose)r   defaultr   datadatafilefdflags          P/home/dcms/DCMS/lib/python3.12/site-packages/ansible/module_utils/facts/utils.pyget_file_contentr      s    D	ww~~d		$ 8	!DzH__&{{2u}}5Btbmm/CD
 ==?Dzz|4yA~ # K4K'    		 #  $sI   	D A*D ?2D 	DD DD 	D"D% !D""D% %D:c                    t        | |      }|rW||j                         }|S t        |      dk(  r"|j                  |      j	                  |      }|S |j	                  |      }|S g }|S )zget list of lines from file)r      )r   
splitlinesr   rstripsplit)r   r   line_sepr   rets        r   get_file_linesr#   @   s{    D.D//#C J 8}!kk(+11(;
 J jj* J J    c                   i }	 t        j                  |       }|j                  |j                  z  |d<   |j                  |j                  z  |d<   |j
                  |d<   |j                  |d<   |j                  |d<   |d   |d   z
  |d<   |j                  |d<   |j                  |d<   |d   |d   z
  |d	<   |S # t        $ r Y |S w xY w)
N
size_totalsize_available
block_sizeblock_totalblock_available
block_usedinode_totalinode_available
inode_used)	r   statvfsf_frsizef_blocksf_bavailf_bsizef_filesf_favailOSError)
mountpoint
mount_sizestatvfs_results      r   get_mount_sizer:   P   s    JJ/#1#:#:^=T=T#T
< '5'>'>.BYBY'Z
#$ $2#9#9
< $2$;$;
=!(6(?(?
$%#-m#<zJ[?\#\
<  %3$:$:
=!(6(?(?
$%#-m#<zJ[?\#\
<    s   B4B: :	CC)NT)TN)
__future__r   r   r   r   r#   r:    r$   r   <module>r=      s      #  	'T r$   