@ -6,6 +6,7 @@ __metaclass__ = type
from os import path , walk
from os import path , walk
import re
import re
import pathlib
import ansible . constants as C
import ansible . constants as C
from ansible . errors import AnsibleError
from ansible . errors import AnsibleError
@ -182,16 +183,15 @@ class ActionModule(ActionBase):
alphabetical order . Do not iterate pass the set depth .
alphabetical order . Do not iterate pass the set depth .
The default depth is unlimited .
The default depth is unlimited .
"""
"""
current_depth = 0
sorted_walk = list ( walk ( self . source_dir , onerror = self . _log_walk , followlinks = True ) )
sorted_walk = list ( walk ( self . source_dir , onerror = self . _log_walk , followlinks = True ) )
sorted_walk . sort ( key = lambda x : x [ 0 ] )
sorted_walk . sort ( key = lambda x : x [ 0 ] )
for current_root , current_dir , current_files in sorted_walk :
for current_root , current_dir , current_files in sorted_walk :
current_depth + = 1
# Depth 1 is the root, relative_to omits the root
if current_depth < = self . depth or self . depth == 0 :
current_depth = len ( pathlib . Path ( current_root ) . relative_to ( self . source_dir ) . parts ) + 1
current_files . sort ( )
if self . depth != 0 and current_depth > self . depth :
yield ( current_root , current_files )
continue
else :
current_files . sort ( )
break
yield ( current_root , current_files )
def _ignore_file ( self , filename ) :
def _ignore_file ( self , filename ) :
""" Return True if a file matches the list of ignore_files.
""" Return True if a file matches the list of ignore_files.