-
Notifications
You must be signed in to change notification settings - Fork 1
/
analyze_dist.py
44 lines (31 loc) · 970 Bytes
/
analyze_dist.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
import os
import glob
# from bs4 import BeautifulSoup
print('start analyze_dist')
# here = os.path.dirname(os.path.abspath(__file__))
here = os.path.dirname(__file__)
dist = os.path.join(here, '..', '..', 'dist')
def analyze_type(ext):
"""
"""
print('\n')
print('-'*20, ext.upper())
li_path = glob.glob(dist+f'/**/*.{ext}', recursive=True)
print(f'nb {ext} files = {len(li_path)}')
dic = {}
for path in li_path:
# print('\t', path)
with open(path, 'r', encoding='utf-8') as f:
content = f.read()
if not content in dic:
dic[content] = []
dic[content].append(path)
print(f'nb unique content = {len(dic.keys())}')
print(f'\nnb files for content:')
for k, e in enumerate(dic.keys()):
print(f'\tfile#{k+1}\tnb characters={len(e)}')
for f in dic[e]:
print(f'\t\t{f}')
print(f'\ndone {ext}')
analyze_type('html')
analyze_type('js')