def _list_files(startpath, maxlevel=1): for root, _, files in os.walk(startpath): level = root.replace(startpath, "").count(os.sep) if level > maxlevel: continue indent = " " * 4 * (level) logger.debug(indent + os.path.basename(root) + "/") subindent = " " * 4 * (level + 1) for f in files: fsize = bytes2human(os.path.getsize(os.path.join(root, f))) logger.debug("%s%-12s%s", subindent, fsize, f)
def _list_files(startpath, maxlevel=1): for root, dirs, files in os.walk(startpath): level = root.replace(startpath, "").count(os.sep) if level > maxlevel: continue indent = " " * 4 * (level) logger.debug("{}{}/".format(indent, os.path.basename(root))) subindent = " " * 4 * (level + 1) for f in files: fsize = bytes2human(os.path.getsize(os.path.join(root, f))) logger.debug("{}{:12}{}".format(subindent, fsize, f))