hashing is done

This commit is contained in:
2019-12-11 06:33:24 -05:00
parent d7d85c7d9d
commit 1ae519bb40
3 changed files with 73 additions and 9 deletions

View File

@@ -9,6 +9,9 @@ class File(object):
self.path_rel = pathlib.PurePosixPath(self.orig_path)
self.path_full = pathlib.PurePosixPath(self.fullpath)
def __str(self):
return(self.fullpath)
class Directory(object):
def __init__(self, dir_path):
@@ -19,25 +22,35 @@ class Directory(object):
self.files = []
self.dirs = []
def populateFilesDirs(self, recursive = False):
def __str__(self):
return(self.fullpath)
def populateFilesDirs(self, recursive = False, native = False):
if not recursive:
for i in os.listdir(self.fullpath):
if os.path.isdir(os.path.join(self.fullpath, i)):
self.dirs.append(i)
elif os.path.isfile(os.path.join(self.fullpath, i)):
self.files.append(i)
if not native:
self.files.append(i)
else:
self.files.append(File(i))
else:
for root, dirs, files in os.walk(self.fullpath):
for f in files:
fpath = os.path.join(root, f)
relfpath = pathlib.PurePosixPath(fpath).relative_to(self.path_full)
self.files.append(relfpath)
relfpath = str(pathlib.PurePosixPath(fpath).relative_to(self.path_full))
if not native:
self.files.append(relfpath)
else:
self.files.append(relfpath)
for d in dirs:
dpath = os.path.join(root, d)
reldpath = pathlib.PurePosixPath(dpath).relative_to(self.path_full)
reldpath = str(pathlib.PurePosixPath(dpath).relative_to(self.path_full))
self.dirs.append(reldpath)
if root not in self.dirs:
self.dirs.append(dirs)
self.dirs.sort()
self.files.sort()
self.dirs.append(root)
if not native:
self.dirs.sort()
self.files.sort()
return(None)