home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import sys
-
- class CheckEncoding:
-
- def __init__(self, bug_handler):
- self._CheckEncoding__bug_handler = bug_handler
-
-
- def __get_position_error(self, line, encoding, line_num):
- char_position = 0
- for char in line:
- char_position += 1
-
- try:
- char.decode(encoding)
- continue
- except UnicodeError:
- msg = None
- sys.stderr.write('line: %s char: %s\n' % (line_num, char_position))
- sys.stderr.write(str(msg) + '\n')
- continue
-
-
-
-
-
- def check_encoding(self, path, encoding = 'us-ascii'):
- read_obj = open(path, 'r')
- line_to_read = 1
- line_num = 0
- while line_to_read:
- line_num += 1
- line_to_read = read_obj.readline()
- line = line_to_read
-
- try:
- line.decode(encoding)
- continue
- except UnicodeError:
- if len(line) < 1000:
- self._CheckEncoding__get_position_error(line, encoding, line_num)
- else:
- sys.stderr.write('line: %d has bad encoding\n' % line_num)
- len(line) < 1000
-
-
- None<EXCEPTION MATCH>UnicodeError
-
-
- if __name__ == '__main__':
- check_encoding_obj = CheckEncoding()
- check_encoding_obj.check_encoding(sys.argv[1])
-
-