ThirdParty/CharDet/chardet/test.py

Sat, 02 Jan 2010 15:11:35 +0000

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 02 Jan 2010 15:11:35 +0000
changeset 12
1d8dd9706f46
parent 0
de9c2efb9d02
permissions
-rw-r--r--

First commit after changing to Python 3.1.

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')

eric ide

mercurial