-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFirst.py
More file actions
39 lines (29 loc) · 1.03 KB
/
Copy pathFirst.py
File metadata and controls
39 lines (29 loc) · 1.03 KB
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
import os
import copy
from pprint import pprint
def snapshot(chemin, profondeur=3, frequence=0, debug=False):
print(os.listdir(chemin))
if profondeur != 0:
for path, dirs, files in os.walk(chemin):
print(os.path.split(path))
capture = copy.deepcopy(files)
def walk2(chemin, profondeur):
dirs, nondirs = [], []
for name in os.listdir(chemin):
(dirs if os.path.isdir(os.path.join(chemin, name)) else nondirs).append(name)
yield chemin, dirs, nondirs
if profondeur > 0:
for name in dirs:
for x in walk2(os.path.join(chemin, name), profondeur-1):
yield x
def getFiles(chemin, profondeur):
chemins = []
for x in walk2(chemin, profondeur):
#print(x)
chemins.append(x)
return chemins
def myMain():
#snapshot("C:\\Users\Christine\Documents\Travail\ISEN\M1\Cryptographie",2)
pprint(getFiles("C:\\Users\Christine\Documents\Travail\ISEN\M1",2))
if __name__ == "__main__":
myMain()