def relativeWalk(path, startPath = None):
if startPath == None: startPath = path
# strxfrm -> local aware sorting - https://docs.python.org/3/howto/sorting.html#odd-and-ends
for entry in sorted(os.scandir(path), key = lambda x: locale.strxfrm(x.name)):
try:
#print(entry.path, " ----- ", entry.name)
if entry.is_file():
yield os.path.relpath(entry.path, startPath), False
elif entry.is_dir():
yield os.path.relpath(entry.path, startPath), True
yield from relativeWalk(entry.path, startPath)
else:
logging.error("Encountered an object which is neither directory nor file: " + entry.path)
except OSError as e:
logging.error(e)
# Possible actions:
# copy (always from source to target),
# delete (always in target)
# hardlink (always from compare directory to target directory)
# rename (always in target) (2-variate) (only needed for move detection)
# hardlink2 (alway from compare directory to target directory) (2-variate) (only needed for move detection)
评论列表
文章目录