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

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import struct
  5. import dns.rdata as dns
  6. import dns.rdatatype as dns
  7.  
  8. class SSHFP(dns.rdata.Rdata):
  9.     __slots__ = [
  10.         'algorithm',
  11.         'fp_type',
  12.         'fingerprint']
  13.     
  14.     def __init__(self, rdclass, rdtype, algorithm, fp_type, fingerprint):
  15.         super(SSHFP, self).__init__(rdclass, rdtype)
  16.         self.algorithm = algorithm
  17.         self.fp_type = fp_type
  18.         self.fingerprint = fingerprint
  19.  
  20.     
  21.     def to_text(self, origin = None, relativize = True, **kw):
  22.         return '%d %d %s' % (self.algorithm, self.fp_type, dns.rdata._hexify(self.fingerprint, chunksize = 128))
  23.  
  24.     
  25.     def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
  26.         algorithm = tok.get_uint8()
  27.         fp_type = tok.get_uint8()
  28.         fingerprint = tok.get_string()
  29.         fingerprint = fingerprint.decode('hex_codec')
  30.         tok.get_eol()
  31.         return cls(rdclass, rdtype, algorithm, fp_type, fingerprint)
  32.  
  33.     from_text = classmethod(from_text)
  34.     
  35.     def to_wire(self, file, compress = None, origin = None):
  36.         header = struct.pack('!BB', self.algorithm, self.fp_type)
  37.         file.write(header)
  38.         file.write(self.fingerprint)
  39.  
  40.     
  41.     def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
  42.         header = struct.unpack('!BB', wire[current:current + 2])
  43.         current += 2
  44.         rdlen -= 2
  45.         fingerprint = wire[current:current + rdlen]
  46.         return cls(rdclass, rdtype, header[0], header[1], fingerprint)
  47.  
  48.     from_wire = classmethod(from_wire)
  49.     
  50.     def _cmp(self, other):
  51.         hs = struct.pack('!BB', self.algorithm, self.fp_type)
  52.         ho = struct.pack('!BB', other.algorithm, other.fp_type)
  53.         v = cmp(hs, ho)
  54.         if v == 0:
  55.             v = cmp(self.fingerprint, other.fingerprint)
  56.         
  57.         return v
  58.  
  59.  
  60.