in Shared_Processors/SubDirectoryList.py [0:0]
def main(self):
sip_dirs = ["usr", "usr/local", "private", "private/etc", "Library"]
format_string = "%s" % self.env["suffix_string"]
# search_string = ' \'{0}\''
search_string = "{0}"
dir_list = list()
file_list = list()
if not os.path.isdir(self.env["root_path"]):
raise ProcessorError("Can't find root path!")
for dirName, subdirList, fileList in os.walk(self.env["root_path"]):
relative_path = os.path.relpath(dirName, self.env["root_path"])
# We need to remove the SIP folders so Chef doesn't try to create them
if not relative_path == "." and not (relative_path in sip_dirs):
dir_list.append(relative_path)
# search_string.format(format_string.join(dirName)).strip()
for fname in fileList:
if ".DS_Store" in fname:
continue
# print('\t%s' % fname)
relpath = os.path.relpath(
os.path.join(fname, dirName), self.env["root_path"]
)
self.output("Relative path: %s" % relpath)
if relpath == ".":
# we want to avoid prepending './' to files at root dir
relpath = ""
# print "Real relative path: %s" % relpath
file_list.append(os.path.join(relpath, fname))
self.env["found_directories"] = search_string.format(
format_string.join(dir_list)
).strip()
self.env["found_filenames"] = search_string.format(
format_string.join(file_list)
).strip()