home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1649 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  2.9 KB  |  84 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.tokenizer as dns
  7.  
  8. class ISDN(dns.rdata.Rdata):
  9.     __slots__ = [
  10.         'address',
  11.         'subaddress']
  12.     
  13.     def __init__(self, rdclass, rdtype, address, subaddress):
  14.         super(ISDN, self).__init__(rdclass, rdtype)
  15.         self.address = address
  16.         self.subaddress = subaddress
  17.  
  18.     
  19.     def to_text(self, origin = None, relativize = True, **kw):
  20.         if self.subaddress:
  21.             return '"%s" "%s"' % (dns.rdata._escapify(self.address), dns.rdata._escapify(self.subaddress))
  22.         return '"%s"' % dns.rdata._escapify(self.address)
  23.  
  24.     
  25.     def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
  26.         address = tok.get_string()
  27.         t = tok.get()
  28.         if t[0] != dns.tokenizer.EOL and t[0] != dns.tokenizer.EOF:
  29.             tok.unget(t)
  30.             subaddress = tok.get_string()
  31.         else:
  32.             tok.unget(t)
  33.             subaddress = ''
  34.         tok.get_eol()
  35.         return cls(rdclass, rdtype, address, subaddress)
  36.  
  37.     from_text = classmethod(from_text)
  38.     
  39.     def to_wire(self, file, compress = None, origin = None):
  40.         l = len(self.address)
  41.         byte = chr(l)
  42.         file.write(byte)
  43.         file.write(self.address)
  44.         l = len(self.subaddress)
  45.         if l > 0:
  46.             byte = chr(l)
  47.             file.write(byte)
  48.             file.write(self.subaddress)
  49.         
  50.  
  51.     
  52.     def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
  53.         l = ord(wire[current])
  54.         current += 1
  55.         rdlen -= 1
  56.         if l > rdlen:
  57.             raise dns.exception.FormError
  58.         l > rdlen
  59.         address = wire[current:current + l]
  60.         current += l
  61.         rdlen -= l
  62.         if rdlen > 0:
  63.             l = ord(wire[current])
  64.             current += 1
  65.             rdlen -= 1
  66.             if l != rdlen:
  67.                 raise dns.exception.FormError
  68.             l != rdlen
  69.             subaddress = wire[current:current + l]
  70.         else:
  71.             subaddress = ''
  72.         return cls(rdclass, rdtype, address, subaddress)
  73.  
  74.     from_wire = classmethod(from_wire)
  75.     
  76.     def _cmp(self, other):
  77.         v = cmp(self.address, other.address)
  78.         if v == 0:
  79.             v = cmp(self.subaddress, other.subaddress)
  80.         
  81.         return v
  82.  
  83.  
  84.