Apply suggestions from code review

This commit is contained in:
Joe Rickerby
2020-03-05 18:28:16 +00:00
committed by GitHub
parent be9eae6828
commit 83452b75dd
+6
View File
@@ -7,12 +7,18 @@ import spam
def path_contains(parent, child):
''' returns True if `child` is inside `parent`.
Works around path-comparison bugs caused by short-paths on Windows e.g.
vssadm~1 instead of vssadministrator
'''
parent = os.path.abspath(parent)
child = os.path.abspath(child)
while child != os.path.dirname(child):
child = os.path.dirname(child)
if os.stat(parent) == os.stat(child):
# parent and child refer to the same directory on the filesystem
return True
return False