1 | # python3
|
---|
2 |
|
---|
3 | import os
|
---|
4 | import fnmatch
|
---|
5 |
|
---|
6 | with open('report.txt','w',encoding='utf8') as report:
|
---|
7 | for path,dirs,files in os.walk('d:/dev/boost_1_50_0/boost'):
|
---|
8 | for file_ in fnmatch.filter(files,'*.hpp'):
|
---|
9 | filename = os.path.normpath(os.path.join(path,file_))
|
---|
10 | with open(filename,'rb') as testfile:
|
---|
11 | data = testfile.read()
|
---|
12 | try:
|
---|
13 | data.decode('ascii')
|
---|
14 | except UnicodeDecodeError as e:
|
---|
15 | line = data[:e.start].count(b'\n')
|
---|
16 | data = data.decode('latin-1').split('\n')
|
---|
17 | report.write('{}({}) : {}\n'.format(filename,line,data[line]))
|
---|