-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdirs.py
80 lines (48 loc) · 1.66 KB
/
dirs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import os
def getSubDirs(dirname):
dirnames = []
# r=root, d=directories, f=files
for r, d, f in os.walk(dirname):
for filename in f:
if r not in dirnames:
dirnames.append(r)
dirnames = dirnames[1:]
dirnames = list(dict.fromkeys(dirnames))
# for d in dirnames:
# print(d)
# print(f'subdir size = {len(dirnames)}')
return dirnames
def getBaseDirs(dirname):
#ignoreList = [ 'Incomplete' ]
dirnames = []
# r=root, d=directories, f=files
for r, d, f in os.walk(dirname):
for filename in f:
print(f'filename is {filename}')
if r not in dirnames and 'Incomplete' not in r:
dirnames.append(r)
# All filenames are relative to baseDirname
#self.filenames.append(filename)
#print(f'Found file = {r}')
#if filename == "SHA512SUMS.txt":
# self.loadSha512(filename)
dirnames = list(dict.fromkeys(dirnames))
# for d in dirnames:
# print(d)
# print(f'dirnames size = {len(dirnames)}')
processing_dirs = []
subdirs = []
for d in dirnames:
# print('processing d ' + d)
subdirs.extend(getSubDirs(d))
if d not in processing_dirs and d not in subdirs:
processing_dirs.append(d)
# print(f'subdirs size = {len(subdirs)}')
# print(f'processed_dirs size = {len(processing_dirs)}')
# for d in processing_dirs:
# print(d)
# print(f'processed_dirs size = {len(processing_dirs)}')
# for d in subdirs:
# print(d)
# print(f'subdirs size = {len(subdirs)}')
return processing_dirs