a )g @sHddlmZmZmZeZddlZddlZd ddZd ddZ dd Z dS) )absolute_importdivisionprint_functionNTcCs|}tj|rt|tjrd}zztt|}z0|}t|tj}t|tj |tj BWnt ypYn0| }|r| }t|dkr|}Wnt yYn0W|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)ospathexistsaccessR_OKopenfilenofcntlZF_GETFLZF_SETFL O_NONBLOCK Exceptionreadstriplenclose)rdefaultrdataZdatafilefdflagrD/usr/lib/python3.9/site-packages/ansible/module_utils/facts/utils.pyget_file_contents.      rcCsTt||d}|rL|dur"|}qPt|dkr@|||}qP||}ng}|S)zget list of lines from file)rN)r splitlinesrrstripsplit)rrZline_seprretrrrget_file_linesAs    rcCsi}zt|}|j|j|d<|j|j|d<|j|d<|j|d<|j|d<|d|d|d<|j|d<|j|d<|d|d|d <WntyYn0|S) NZ size_totalZsize_availableZ block_sizeZ block_totalZblock_availableZ block_usedZ inode_totalZinode_availableZ inode_used) rstatvfsf_frsizef_blocksf_bavailf_bsizef_filesf_favailOSError)Z mountpointZ mount_sizestatvfs_resultrrrget_mount_sizeQs       r))NT)TN) Z __future__rrrtypeZ __metaclass__r rrrr)rrrrs  *