~ubuntu-branches/debian/wheezy/calibre/wheezy

« back to all changes in this revision

Viewing changes to src/chardet/test.py

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2012-01-07 11:22:54 UTC
  • mfrom: (29.4.10 precise)
  • Revision ID: package-import@ubuntu.com-20120107112254-n1syr437o46ds802
Tags: 0.8.34+dfsg-1
* New upstream version. (Closes: #654751)
* debian/rules: Do not install calibre copy of chardet; instead, add
  build/binary python-chardet dependency.
* Add disable_plugins.py: Disable plugin dialog. It uses a totally
  non-authenticated and non-trusted way of installing arbitrary code.
  (Closes: #640026)
* debian/rules: Install with POSIX locale, to avoid installing translated
  manpages into the standard locations. (Closes: #646674)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import sys, glob
 
2
sys.path.insert(0, '..')
 
3
from chardet.universaldetector import UniversalDetector
 
4
 
 
5
count = 0
 
6
u = UniversalDetector()
 
7
for f in glob.glob(sys.argv[1]):
 
8
    print f.ljust(60),
 
9
    u.reset()
 
10
    for line in file(f, 'rb'):
 
11
        u.feed(line)
 
12
        if u.done: break
 
13
    u.close()
 
14
    result = u.result
 
15
    if result['encoding']:
 
16
        print result['encoding'], 'with confidence', result['confidence']
 
17
    else:
 
18
        print '******** no result'
 
19
    count += 1
 
20
print count, 'tests'