@ -96,6 +96,14 @@ options:
choices : [ ' no ' , ' yes ' ]
choices : [ ' no ' , ' yes ' ]
description :
description :
- If false the patterns are file globs ( shell ) if true they are python regexes .
- If false the patterns are file globs ( shell ) if true they are python regexes .
depth :
required : false
default : null
description :
- Set the maximum number of levels to decend into . Setting recurse
to false will override this value , which is effectively depth 1.
Default is unlimited depth .
version_added : " 2.6 "
notes :
notes :
- For Windows targets , use the M ( win_find ) module instead .
- For Windows targets , use the M ( win_find ) module instead .
'''
'''
@ -328,6 +336,7 @@ def main():
follow = dict ( type = ' bool ' , default = ' no ' ) ,
follow = dict ( type = ' bool ' , default = ' no ' ) ,
get_checksum = dict ( type = ' bool ' , default = ' no ' ) ,
get_checksum = dict ( type = ' bool ' , default = ' no ' ) ,
use_regex = dict ( type = ' bool ' , default = ' no ' ) ,
use_regex = dict ( type = ' bool ' , default = ' no ' ) ,
depth = dict ( type = ' int ' , default = None ) ,
) ,
) ,
supports_check_mode = True ,
supports_check_mode = True ,
)
)
@ -366,6 +375,13 @@ def main():
if os . path . isdir ( npath ) :
if os . path . isdir ( npath ) :
''' ignore followlinks for python version < 2.6 '''
''' ignore followlinks for python version < 2.6 '''
for root , dirs , files in ( sys . version_info < ( 2 , 6 , 0 ) and os . walk ( npath ) ) or os . walk ( npath , followlinks = params [ ' follow ' ] ) :
for root , dirs , files in ( sys . version_info < ( 2 , 6 , 0 ) and os . walk ( npath ) ) or os . walk ( npath , followlinks = params [ ' follow ' ] ) :
if params [ ' depth ' ] :
depth = root . replace ( npath . rstrip ( os . path . sep ) , ' ' ) . count ( os . path . sep )
if files or dirs :
depth + = 1
if depth > params [ ' depth ' ] :
del ( dirs [ : ] )
continue
looked = looked + len ( files ) + len ( dirs )
looked = looked + len ( files ) + len ( dirs )
for fsobj in ( files + dirs ) :
for fsobj in ( files + dirs ) :
fsname = os . path . normpath ( os . path . join ( root , fsobj ) )
fsname = os . path . normpath ( os . path . join ( root , fsobj ) )