Ticket #7265: gen_non_ascii.py

File gen_non_ascii.py, 667 bytes (added by metolone@…, 10 years ago)

Python script to find non-ascii characters in boost headers.

Line 
1# python3
2
3import os
4import fnmatch
5
6with 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]))