-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4_5.py
More file actions
33 lines (26 loc) · 893 Bytes
/
4_5.py
File metadata and controls
33 lines (26 loc) · 893 Bytes
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
import os
from os import stat
import json
di_sizes = {100: (0, []), 1000: (0, []), 10000: (0, []), 100000: (0, [])}
dir_path = '/run/user/1000/gvfs/smb-share:server=keenetic-2254.local,share=server/Project/GeekBrains/homework/7/some_data'
def get_info_file(size):
'''get file stats'''
count, tp = di_sizes[size]
count += 1
tp.append(path.split('.')[-1])
tp = list(set(tp))
di_sizes[size] = (count, tp)
files = os.listdir(dir_path)
for file in files:
path = os.path.join(dir_path, file)
if 0 < stat(path).st_size < 100:
get_info_file(100)
elif 100 < stat(path).st_size < 1000:
get_info_file(1000)
elif 1000 < stat(path).st_size < 10000:
get_info_file(10000)
elif 10000 < stat(path).st_size < 100000:
get_info_file(100000)
print(di_sizes)
with open('summary.json', 'w') as file:
json.dump(di_sizes, file)