def __countFiles(self, which=None):
# this will count links AND sockets
#self.total_files = sum((len(f) for _, _, f in os.walk(self.cwd)))
total_files = 0
i = 0
for path, _, filenames in os.walk(self.cwd):
for filename in filenames:
if i >= len(self.wait_symbols): i = 0
print 'Counting Files.... %s \r' % self.wait_symbols[i],
i += 1
filename_path = os.path.join(path, filename)
if os.path.islink(filename_path):
# TODO: may be we should use 'and' instead of 'or' ??
if self.cwd not in os.path.realpath(filename_path) or not self.args.symlinks:
continue
if os.path.exists(filename_path) and os.access(filename_path, os.R_OK) and not S_ISSOCK(os.stat(filename_path).st_mode):
total_files += 1
if which == 'dst': print 'Counting DST Files.....Done \r'
elif which == 'src': print 'Counting SRC Files.....Done \r'
else: print 'Counting Files.........Done \r'
return total_files
# ------------------------------------------------------------------
评论列表
文章目录