File: test.py

package info (click to toggle)
python3-chardet 2.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 692 kB
  • sloc: python: 5,635; makefile: 9
file content (20 lines) | stat: -rwxr-xr-x 530 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import sys, glob
sys.path.insert(0, '..')
from chardet.universaldetector import UniversalDetector

count = 0
u = UniversalDetector()
for f in glob.glob(sys.argv[1]):
    print(f.ljust(60), end=' ')
    u.reset()
    for line in open(f, 'rb'):
        u.feed(line)
        if u.done: break
    u.close()
    result = u.result
    if result['encoding']:
        print(result['encoding'], 'with confidence', result['confidence'])
    else:
        print('******** no result')
    count += 1
print(count, 'tests')