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

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import dns.exception as dns
  5. import dns.rdata as dns
  6. import dns.name as dns
  7.  
  8. class RP(dns.rdata.Rdata):
  9.     __slots__ = [
  10.         'mbox',
  11.         'txt']
  12.     
  13.     def __init__(self, rdclass, rdtype, mbox, txt):
  14.         super(RP, self).__init__(rdclass, rdtype)
  15.         self.mbox = mbox
  16.         self.txt = txt
  17.  
  18.     
  19.     def to_text(self, origin = None, relativize = True, **kw):
  20.         mbox = self.mbox.choose_relativity(origin, relativize)
  21.         txt = self.txt.choose_relativity(origin, relativize)
  22.         return '%s %s' % (str(mbox), str(txt))
  23.  
  24.     
  25.     def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
  26.         mbox = tok.get_name()
  27.         txt = tok.get_name()
  28.         mbox = mbox.choose_relativity(origin, relativize)
  29.         txt = txt.choose_relativity(origin, relativize)
  30.         tok.get_eol()
  31.         return cls(rdclass, rdtype, mbox, txt)
  32.  
  33.     from_text = classmethod(from_text)
  34.     
  35.     def to_wire(self, file, compress = None, origin = None):
  36.         self.mbox.to_wire(file, None, origin)
  37.         self.txt.to_wire(file, None, origin)
  38.  
  39.     
  40.     def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
  41.         (mbox, cused) = dns.name.from_wire(wire[:current + rdlen], current)
  42.         current += cused
  43.         rdlen -= cused
  44.         if rdlen <= 0:
  45.             raise dns.exception.FormError
  46.         rdlen <= 0
  47.         (txt, cused) = dns.name.from_wire(wire[:current + rdlen], current)
  48.         if cused != rdlen:
  49.             raise dns.exception.FormError
  50.         cused != rdlen
  51.         if origin is not None:
  52.             mbox = mbox.relativize(origin)
  53.             txt = txt.relativize(origin)
  54.         
  55.         return cls(rdclass, rdtype, mbox, txt)
  56.  
  57.     from_wire = classmethod(from_wire)
  58.     
  59.     def choose_relativity(self, origin = None, relativize = True):
  60.         self.mbox = self.mbox.choose_relativity(origin, relativize)
  61.         self.txt = self.txt.choose_relativity(origin, relativize)
  62.  
  63.     
  64.     def _cmp(self, other):
  65.         v = cmp(self.mbox, other.mbox)
  66.         if v == 0:
  67.             v = cmp(self.txt, other.txt)
  68.         
  69.         return v
  70.  
  71.  
  72.