1   
  2   
  3   
  4   
  5   
  6   
  7   
  8   
  9   
 10   
 11   
 12   
 13   
 14   
 15   
 16   
 17   
 18  import struct 
 19   
 20  import dns.exception 
 21  import dns.rdata 
 22  import dns.tokenizer 
 23  from dns._compat import text_type 
 24   
 25   
 26 -class ISDN(dns.rdata.Rdata): 
  27   
 28      """ISDN record 
 29   
 30      @ivar address: the ISDN address 
 31      @type address: string 
 32      @ivar subaddress: the ISDN subaddress (or '' if not present) 
 33      @type subaddress: string 
 34      @see: RFC 1183""" 
 35   
 36      __slots__ = ['address', 'subaddress'] 
 37   
 38 -    def __init__(self, rdclass, rdtype, address, subaddress): 
  48   
 49 -    def to_text(self, origin=None, relativize=True, **kw): 
  50          if self.subaddress: 
 51              return '"{}" "{}"'.format(dns.rdata._escapify(self.address), 
 52                                    dns.rdata._escapify(self.subaddress)) 
 53          else: 
 54              return '"%s"' % dns.rdata._escapify(self.address) 
  55   
 56      @classmethod 
 57 -    def from_text(cls, rdclass, rdtype, tok, origin=None, relativize=True): 
  58          address = tok.get_string() 
 59          t = tok.get() 
 60          if not t.is_eol_or_eof(): 
 61              tok.unget(t) 
 62              subaddress = tok.get_string() 
 63          else: 
 64              tok.unget(t) 
 65              subaddress = '' 
 66          tok.get_eol() 
 67          return cls(rdclass, rdtype, address, subaddress) 
  68   
 69 -    def to_wire(self, file, compress=None, origin=None): 
  70          l = len(self.address) 
 71          assert l < 256 
 72          file.write(struct.pack('!B', l)) 
 73          file.write(self.address) 
 74          l = len(self.subaddress) 
 75          if l > 0: 
 76              assert l < 256 
 77              file.write(struct.pack('!B', l)) 
 78              file.write(self.subaddress) 
  79   
 80      @classmethod 
 81 -    def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin=None): 
  100