File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/find.cpython-310.pyc
o
�N�g�W � @ sh d Z ddlZddlZddlZddlZddlZddlZddlZddlm Z m
Z
ddlZddl
ZddlZddlZddlZddlmZ z
ddlZddlZW n eyS Y nw e�e�ZdZdZdZdejd ejd
ejdejdej d
ej!dej"ejdejd ejd
ejdej dej!d
ej"diZ#ej$dej%d�Z&ej'j(ej'j)ej'j*fZ+dd� Z,dd� Z-G dd� d�Z.G dd� de.�Z/G dd� de.�Z0G dd� de.�Z1G dd� de.�Z2G dd � d e.�Z3G d!d"� d"e.�Z4G d#d$� d$e.�Z5G d%d&� d&e.�Z6G d'd(� d(e.�Z7G d)d*� d*e.�Z8G d+d,� d,e.�Z9G d-d.� d.e3�Z:G d/d0� d0e.�Z;G d1d2� d2�Z<d3d4� Z=d5d6� Z>d7d8� Z?ed9k�r2e?� dS dS ):a�
Approximate the Unix find(1) command and return a list of paths that
meet the specified criteria.
The options include match criteria:
name = file-glob # case sensitive
iname = file-glob # case insensitive
regex = file-regex # case sensitive
iregex = file-regex # case insensitive
type = file-types # match any listed type
user = users # match any listed user
group = groups # match any listed group
size = [+-]number[size-unit] # default unit = byte
mtime = interval # modified since date
grep = regex # search file contents
and/or actions:
delete [= file-types] # default type = 'f'
exec = command [arg ...] # where {} is replaced by pathname
print [= print-opts]
and/or depth criteria:
maxdepth = maximum depth to transverse in path
mindepth = minimum depth to transverse before checking files or directories
The default action is 'print=path'.
file-glob:
* = match zero or more chars
? = match any char
[abc] = match a, b, or c
[!abc] or [^abc] = match anything except a, b, and c
[x-y] = match chars x through y
[!x-y] or [^x-y] = match anything except chars x through y
{a,b,c} = match a or b or c
file-regex:
a Python re (regular expression) pattern
file-types: a string of one or more of the following:
a: all file types
b: block device
c: character device
d: directory
p: FIFO (named pipe)
f: plain file
l: symlink
s: socket
users:
a space and/or comma separated list of user names and/or uids
groups:
a space and/or comma separated list of group names and/or gids
size-unit:
b: bytes
k: kilobytes
m: megabytes
g: gigabytes
t: terabytes
interval:
[<num>w] [<num>[d]] [<num>h] [<num>m] [<num>s]
where:
w: week
d: day
h: hour
m: minute
s: second
print-opts: a comma and/or space separated list of one or more of
the following:
group: group name
md5: MD5 digest of file contents
mode: file permissions (as as integer)
mtime: last modification time (as time_t)
name: file basename
path: file absolute path
size: file size in bytes
type: file type
user: user name
� N)�PIPE�Popen)�BufferedReader� � � �b�c�d�f�l�p�sa
^\s*
(?P<modifier>[+-]?)
(?: (?P<week> \d+ (?:\.\d*)? ) \s* [wW] )? \s*
(?: (?P<day> \d+ (?:\.\d*)? ) \s* [dD] )? \s*
(?: (?P<hour> \d+ (?:\.\d*)? ) \s* [hH] )? \s*
(?: (?P<minute> \d+ (?:\.\d*)? ) \s* [mM] )? \s*
(?: (?P<second> \d+ (?:\.\d*)? ) \s* [sS] )? \s*
$
)�flagsc C s| t �t| ��}|du rtd| � d���d}d}dD ]\}}|�|�dur5|t|�|��| 7 }|du r5|}q|||�d�fS )a
Convert an interval string like 1w3d6h into the number of seconds, time
resolution (1 unit of the smallest specified time unit) and the modifier(
'+', '-', or '').
w = week
d = day
h = hour
m = minute
s = second
Nzinvalid time interval: '�'r ))�secondr )�minute�<