File: //var/opt/nydus/ops/primordial/__pycache__/fileutils.cpython-39.pyc
a
�,�h � @ s| d dl Z d dlZd dlZd dlZd dlmZmZmZ zd dlm Z W n e
yV Y n0 zd dlmZ W n e
yz Y n0 d dl
mZ d dlZzd dlZd dlZW n e
y� Y n0 d dlmZmZ dZdZe�e�Ze j ed �d
d�Zdeeeeef dd�d
d�Zedd�dd�Zedd�dd�Z eedd�dd�Z!deeee dd�dd�Z"d eeee ee dd�dd�Z#dS )!� N)�Any�Optional�Tuple)�getpwnam)�getgrnam)�rmtree)�get_file_group�
get_file_userg �?� )�in_time�returnc C s t | t�ddd� �� �S )zpReturn integer seconds since epoch.
:param in_time: Datetime
:returns: Integer seconds since epoch
i� � )�int�datetime�
total_seconds)r � r �E/opt/nydus/tmp/pip-target-wkfpz8uv/lib/python/primordial/fileutils.py�datetime_to_epoch_seconds# s r )�filename�timesr c C s: t | d�� t�| |� W d � n1 s,0 Y dS )a0 Set the atime and mtime of a file.
.. note:: Linux (MAYBE Windows) ONLY. This does not work on Mac OSX.
:param filename: The file to touch
:param times: a two-tuple of (atime, mtime) where these are integer seconds since epoch; see os.utimes
:raises OSError: if file doesn't exist
�aN)�open�os�utime)r r r r r �touch, s
r )�pathr c
C sD zt | � W n2 ty> } ztd| �|�W Y d}~n
d}~0 0 dS )zySimple rmtree wrapper
:param path: path to recursively remove
:raises: IOError if the path can't be removed
�Failed to remove %sN)r �OSError�IOError)r �er r r �rm_path: s r )r r c
C sF zt �| � W n2 ty@ } ztd| �|�W Y d}~n
d}~0 0 dS )zuSimple remove wrapper
:param filename: filename to remove
:raises: IOError if the file can't be removed
r N)r �remover r )r r r r r �rm_fileF s r"