Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/files/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/files/find.pyo

�
�Udac@`sddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlmZdded
�Zd�Zd�Zd�Zd�Zd�Zedkre�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontstableinterfacetstatustcoretsupported_bys�
---
module: find
author: Brian Coca (@bcoca)
version_added: "2.0"
short_description: Return a list of files based on specific criteria
description:
    - Return a list of files based on specific criteria. Multiple criteria are AND'd together.
    - For Windows targets, use the M(win_find) module instead.
options:
    age:
        description:
            - Select files whose age is equal to or greater than the specified time.
            - Use a negative age to find files equal to or less than the specified time.
            - You can choose seconds, minutes, hours, days, or weeks by specifying the
              first letter of any of those words (e.g., "1w").
        type: str
    patterns:
        default: []
        description:
            - One or more (shell or regex) patterns, which type is controlled by C(use_regex) option.
            - The patterns restrict the list of files to be returned to those whose basenames match at
              least one of the patterns specified. Multiple patterns can be specified using a list.
            - The pattern is matched against the file base name, excluding the directory.
            - When using regexen, the pattern MUST match the ENTIRE file name, not just parts of it. So
              if you are looking to match all files ending in .default, you'd need to use '.*\.default'
              as a regexp and not just '\.default'.
            - This parameter expects a list, which can be either comma separated or YAML. If any of the
              patterns contain a comma, make sure to put them in a list to avoid splitting the patterns
              in undesirable ways.
            - Defaults to '*' when C(use_regex=False), or '.*' when C(use_regex=True).
        type: list
        aliases: [ pattern ]
    excludes:
        description:
            - One or more (shell or regex) patterns, which type is controlled by C(use_regex) option.
            - Items whose basenames match an C(excludes) pattern are culled from C(patterns) matches.
              Multiple patterns can be specified using a list.
        type: list
        aliases: [ exclude ]
        version_added: "2.5"
    contains:
        description:
            - A regular expression or pattern which should be matched against the file content.
        type: str
    paths:
        description:
            - List of paths of directories to search. All paths must be fully qualified.
        type: list
        required: true
        aliases: [ name, path ]
    file_type:
        description:
            - Type of file to select.
            - The 'link' and 'any' choices were added in Ansible 2.3.
        type: str
        choices: [ any, directory, file, link ]
        default: file
    recurse:
        description:
            - If target is a directory, recursively descend into the directory looking for files.
        type: bool
        default: no
    size:
        description:
            - Select files whose size is equal to or greater than the specified size.
            - Use a negative size to find files equal to or less than the specified size.
            - Unqualified values are in bytes but b, k, m, g, and t can be appended to specify
              bytes, kilobytes, megabytes, gigabytes, and terabytes, respectively.
            - Size is not evaluated for directories.
    age_stamp:
        description:
            - Choose the file property against which we compare age.
        type: str
        choices: [ atime, ctime, mtime ]
        default: mtime
    hidden:
        description:
            - Set this to C(yes) to include hidden files, otherwise they will be ignored.
        type: bool
        default: no
    follow:
        description:
            - Set this to C(yes) to follow symlinks in path for systems with python 2.6+.
        type: bool
        default: no
    get_checksum:
        description:
            - Set this to C(yes) to retrieve a file's SHA1 checksum.
        type: bool
        default: no
    use_regex:
        description:
            - If C(no), the patterns are file globs (shell).
            - If C(yes), they are python regexes.
        type: bool
        default: no
    depth:
        description:
            - Set the maximum number of levels to descend into.
            - Setting recurse to C(no) will override this value, which is effectively depth 1.
            - Default is unlimited depth.
        type: int
        version_added: "2.6"
seealso:
- module: win_find
s
- name: Recursively find /tmp files older than 2 days
  find:
    paths: /tmp
    age: 2d
    recurse: yes

- name: Recursively find /tmp files older than 4 weeks and equal or greater than 1 megabyte
  find:
    paths: /tmp
    age: 4w
    size: 1m
    recurse: yes

- name: Recursively find /var/tmp files with last access time greater than 3600 seconds
  find:
    paths: /var/tmp
    age: 3600
    age_stamp: atime
    recurse: yes

- name: Find /var/log files equal or greater than 10 megabytes ending with .old or .log.gz
  find:
    paths: /var/log
    patterns: '*.old,*.log.gz'
    size: 10m

# Note that YAML double quotes require escaping backslashes but yaml single quotes do not.
- name: Find /var/log files equal or greater than 10 megabytes ending with .old or .log.gz via regex
  find:
    paths: /var/log
    patterns: "^.*?\\.(?:old|log\\.gz)$"
    size: 10m
    use_regex: yes

- name: Find /var/log all directories, exclude nginx and mysql
  find:
    paths: /var/log
    recurse: no
    file_type: directory
    excludes: 'nginx,mysql'

# When using patterns that contain a comma, make sure they are formatted as lists to avoid splitting the pattern
- name: Use a single pattern that contains a comma formatted as a list
  find:
    paths: /var/log
    file_type: file
    use_regex: yes
    patterns: ['^_[0-9]{2,4}_.*.log$']

- name: Use multiple patterns that contain a comma formatted as a YAML list
  find:
    paths: /var/log
    file_type: file
    use_regex: yes
    patterns:
      - '^_[0-9]{2,4}_.*.log$'
      - '^[a-z]{1,5}_.*log$'

sk
files:
    description: All matches found with the specified criteria (see stat module for full output of each dictionary)
    returned: success
    type: list
    sample: [
        { path: "/var/tmp/test1",
          mode: "0644",
          "...": "...",
          checksum: 16fac7be61a6e4591a33ef4b729c5c3302307523
        },
        { path: "/var/tmp/test2",
          "...": "..."
        },
        ]
matched:
    description: Number of matches
    returned: success
    type: int
    sample: 14
examined:
    description: Number of filesystem objects looked at
    returned: success
    type: int
    sample: 34
N(t
AnsibleModulecC`s|dkr|dkrtS|r�|rj|dkrjx�|D](}tj|�}|j|�r;tSq;Wq{|r{|r{xf|D][}tj|�}|j|�r}x0|D](}tj|�}|j|�r�tSq�WtSq}Wq{n�|r|dkrx�|D]}tj||�r�tSq�Wn]|r{|r{xN|D]C}tj||�r1x$|D]}tj||�rPtSqPWtSq1WntS(sfilter using glob patternsN(tNonetTruetretcompiletmatchtFalsetfnmatch(tftpatternstexcludest	use_regextptrte((s>/usr/lib/python2.7/site-packages/ansible/modules/files/find.pytpfilter�s:





cC`sz|dkrtS|dkrC||jd|�t|�krCtS|dkrv||jd|�t|�krvtStS(sfilter files older than ageisst_%sN(R	R
t__getattribute__tabsR(tsttnowtaget	timestamp((s>/usr/lib/python2.7/site-packages/ansible/modules/files/find.pyt	agefilter	s//cC`s^|dkrtS|dkr5|jt|�kr5tS|dkrZ|jt|�krZtStS(sfilter files greater than sizeiN(R	R
tst_sizeRR(Rtsize((s>/usr/lib/python2.7/site-packages/ansible/modules/files/find.pyt
sizefilters!!cC`st|dkrtStj|�}y=t|��+}x!|D]}|j|�r8tSq8WWdQXWntk
ronXtS(s
    Filter files which contain the given expression
    :arg fsname: Filename to scan for lines matching a pattern
    :arg pattern: Pattern to look for inside of line
    :rtype: bool
    :returns: True if one of the lines in fsname matches the pattern. Otherwise False
    N(R	R
RRtopenR
t	ExceptionR(tfsnametpatterntprogRtline((s>/usr/lib/python2.7/site-packages/ansible/modules/files/find.pyt
contentfilters

cC`skd}d}ytj|j�j}Wntk
r8nXytj|j�j}Wntk
renXidt	j
|j�d6t	j|j�d6t	j
|j�d6t	j|j�d6t	j|j�d6t	j|j�d6t	j|j�d	6t	j|j�d
6|jd6|jd6|jd
6|jd6|jd6|jd6|jd6|jd6|jd6|d6|d6t|jt	j@�d6t|jt	j@�d6t|jt	j@�d6t|jt	j@�d6t|jt	j@�d6t|jt	j @�d6t|jt	j!@�d6t|jt	j"@�d6t|jt	j#@�d6t|jt	j$@�d6t|jt	j%@�d 6S(!Nts%04otmodetisdirtischrtisblktisregtisfifotislnktissocktuidtgidR tinodetdevtnlinktatimetmtimetctimetgr_nametpw_nametwusrtrusrtxusrtwgrptrgrptxgrptwothtrothtxothtisuidtisgid(&tpwdtgetpwuidtst_uidR;R#tgrptgetgrgidtst_gidR:tstattS_IMODEtst_modetS_ISDIRtS_ISCHRtS_ISBLKtS_ISREGtS_ISFIFOtS_ISLNKtS_ISSOCKRtst_inotst_devtst_nlinktst_atimetst_mtimetst_ctimetbooltS_IWUSRtS_IRUSRtS_IXUSRtS_IWGRPtS_IRGRPtS_IXGRPtS_IWOTHtS_IROTHtS_IXOTHtS_ISUIDtS_ISGID(RR;R:((s>/usr/lib/python2.7/site-packages/ansible/modules/files/find.pytstatinfo8sR










c!C`s�tdtdtdddtdddgd	d
�dtdddgdd
gd	d
�dtddddgd	d
�dtdd
�dtdd
dddddddg�dtdd
�dtdd
ddddddg�dtdd
�dtdddt�dtdddt�d tdddt�d!tdddt�d"tdddt�d#tdd$��d%t�}|j}|ds�|d"r�d&g|d<q�d'g|d<ng}|ddkr�d}n�tjd(|dj��}id)d*6d+d,6d-d.6d/d06d1d26}|rIt	|j
d)��|j|j
d3�d)�}n|jd|dd4d5�|ddkr|d}n�tjd6|dj��}id)d76d8d96dKd,6dLd;6dMd=6}|r�t	|j
d)��|j|j
d3�d)�}n|jd|dd4d>�t
j
�}d?}	d@}
xG|dD];}tjjtjj|��}tjj|�rbxtjdNkr�tj|�p�tj|dB|d �D]�\}}
}|d#r"|j|jtjj�d?�jtjj�}|s�|
r|d)7}n||d#kr"|
2q�q"n|
t|�t|
�}
x||
D]}tjjtjj||��}tjj|�jdC�r�|dr�qGnytj|�}Wn"t k
r�|	dD|7}	qGnXi|d6}|ddkr�t!||d|d|d"�rIt"||||d�rI|j#t$|��t%j&|j'�rn|d!rn|j(|�|dE<n|j)|�qIqGt%j*|j'�r|ddkrt!||d|d|d"�rIt"||||d�rI|j#t$|��|j)|�qIqGt%j&|j'�r�|ddkr�t!||d|d|d"�rIt"||||d�rIt+||�rIt,||d�rI|j#t$|��|d!r�|j(|�|dE<n|j)|�qIqGt%j-|j'�rG|ddkrGt!||d|d|d"�rIt"||||d�rI|j#t$|��|j)|�qIqGqGW|ds�Pq�q�Wq5|	dF|7}	q5Wt|�}|j.dG|dHtd4|	dI|dJ|
�dS(ONt
argument_spectpathsttypetlisttrequiredtaliasestnametpathtelementststrRtdefaultR%Rtexcludetcontainst	file_typetfiletchoicestanyt	directorytlinkRt	age_stampR8R7R9R trecurseR]thiddentfollowtget_checksumRtdepthtinttsupports_check_modes.*t*s^(-?\d+)(s|m|h|d|w)?$itsi<tmithi�Qtdi�:	twitmsgsfailed to process ages^(-?\d+)(b|k|m|g|t)?$tbitkitgittsfailed to process sizeR)iitfollowlinkst.sO%s was skipped as it does not seem to be a valid file or it cannot be accessed
tchecksumsT%s was skipped as it does not seem to be a valid directory or it cannot be accessed
tfilestchangedtmatchedtexaminedii@I(iii(/RtdictR
RtparamsR	RR
tlowerR�tgrouptgett	fail_jsonttimetosRqt
expandusert
expandvarsR+tsystversion_infotwalktreplacetrstriptseptcounttlentnormpathtjointbasenamet
startswithtlstatR#RRtupdateRiRMRSROtsha1tappendRPR!R(RUt	exit_json(tmoduleR�tfilelistRR�tseconds_per_unitR tbytes_per_unitRR�tlookedtnpathtroottdirsR�R�tfsobjR$RRR�((s>/usr/lib/python2.7/site-packages/ansible/modules/files/find.pytmainhs�'$'$		

	)1	)1G
0
	!&

:":"!"
":
t__main__(t
__future__RRRRlt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNRRJR�RGRRMR�R�tansible.module_utils.basicRR	RRRR!R(RiR�t__name__(((s>/usr/lib/python2.7/site-packages/ansible/modules/files/find.pyt<module>
s0


l>'				0	}

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]