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

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import codecs
  5. import binascii
  6.  
  7. def uu_encode(input, errors = 'strict', filename = '<data>', mode = 438):
  8.     StringIO = StringIO
  9.     import cStringIO
  10.     b2a_uu = b2a_uu
  11.     import binascii
  12.     infile = StringIO(str(input))
  13.     outfile = StringIO()
  14.     read = infile.read
  15.     write = outfile.write
  16.     write('begin %o %s\n' % (mode & 511, filename))
  17.     chunk = read(45)
  18.     while chunk:
  19.         write(b2a_uu(chunk))
  20.         chunk = read(45)
  21.     write(' \nend\n')
  22.     return (outfile.getvalue(), len(input))
  23.  
  24.  
  25. def uu_decode(input, errors = 'strict'):
  26.     StringIO = StringIO
  27.     import cStringIO
  28.     a2b_uu = a2b_uu
  29.     import binascii
  30.     infile = StringIO(str(input))
  31.     outfile = StringIO()
  32.     readline = infile.readline
  33.     write = outfile.write
  34.     while None:
  35.         s = readline()
  36.         if not s:
  37.             raise ValueError, 'Missing "begin" line in input data'
  38.         if s[:5] == 'begin':
  39.             break
  40.             continue
  41.         continue
  42.         while None:
  43.             s = readline()
  44.             if not s or s == 'end\n':
  45.                 break
  46.             
  47.             
  48.             try:
  49.                 data = a2b_uu(s)
  50.             except binascii.Error:
  51.                 v = None
  52.                 nbytes = ((ord(s[0]) - 32 & 63) * 4 + 5) / 3
  53.                 data = a2b_uu(s[:nbytes])
  54.  
  55.             continue
  56.             if not s:
  57.                 raise ValueError, 'Truncated input data'
  58.             s
  59.             return (outfile.getvalue(), len(input))
  60.  
  61.  
  62. class Codec(codecs.Codec):
  63.     
  64.     def encode(self, input, errors = 'strict'):
  65.         return uu_encode(input, errors)
  66.  
  67.     
  68.     def decode(self, input, errors = 'strict'):
  69.         return uu_decode(input, errors)
  70.  
  71.  
  72.  
  73. class IncrementalEncoder(codecs.IncrementalEncoder):
  74.     
  75.     def encode(self, input, final = False):
  76.         return uu_encode(input, self.errors)[0]
  77.  
  78.  
  79.  
  80. class IncrementalDecoder(codecs.IncrementalDecoder):
  81.     
  82.     def decode(self, input, final = False):
  83.         return uu_decode(input, self.errors)[0]
  84.  
  85.  
  86.  
  87. class StreamWriter(Codec, codecs.StreamWriter):
  88.     pass
  89.  
  90.  
  91. class StreamReader(Codec, codecs.StreamReader):
  92.     pass
  93.  
  94.  
  95. def getregentry():
  96.     return codecs.CodecInfo(name = 'uu', encode = uu_encode, decode = uu_decode, incrementalencoder = IncrementalEncoder, incrementaldecoder = IncrementalDecoder, streamreader = StreamReader, streamwriter = StreamWriter)
  97.  
  98.