home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1101 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  1.3 KB  |  45 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4.  
  5. class GetCharMap:
  6.     
  7.     def __init__(self, bug_handler, char_file):
  8.         self._GetCharMap__char_file = char_file
  9.         self._GetCharMap__bug_handler = bug_handler
  10.  
  11.     
  12.     def get_char_map(self, map):
  13.         if map == 'ansicpg0':
  14.             map = 'ansicpg1250'
  15.         
  16.         found_map = 0
  17.         map_dict = { }
  18.         self._GetCharMap__char_file.seek(0)
  19.         for line in self._GetCharMap__char_file.readlines():
  20.             if not line.strip():
  21.                 continue
  22.             
  23.             begin_element = '<%s>' % map
  24.             end_element = '</%s>' % map
  25.             if not found_map:
  26.                 if begin_element in line:
  27.                     found_map = 1
  28.                 
  29.             begin_element in line
  30.             if end_element in line:
  31.                 break
  32.             
  33.             fields = line.split(':')
  34.             fields[1].replace('\\colon', ':')
  35.             map_dict[fields[1]] = fields[3]
  36.         
  37.         if not found_map:
  38.             msg = 'no map found\n'
  39.             msg += 'map is "%s"\n' % (map,)
  40.             raise self._GetCharMap__bug_handler, msg
  41.         found_map
  42.         return map_dict
  43.  
  44.  
  45.