home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1675 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  2.3 KB  |  50 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 NSAP(dns.rdata.Rdata):
  9.     __slots__ = [
  10.         'address']
  11.     
  12.     def __init__(self, rdclass, rdtype, address):
  13.         super(NSAP, self).__init__(rdclass, rdtype)
  14.         self.address = address
  15.  
  16.     
  17.     def to_text(self, origin = None, relativize = True, **kw):
  18.         return '0x%s' % self.address.encode('hex_codec')
  19.  
  20.     
  21.     def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
  22.         address = tok.get_string()
  23.         t = tok.get_eol()
  24.         if address[0:2] != '0x':
  25.             raise dns.exception.SyntaxError, 'string does not start with 0x'
  26.         address[0:2] != '0x'
  27.         address = address[2:].replace('.', '')
  28.         if len(address) % 2 != 0:
  29.             raise dns.exception.SyntaxError, 'hexstring has odd length'
  30.         len(address) % 2 != 0
  31.         address = address.decode('hex_codec')
  32.         return cls(rdclass, rdtype, address)
  33.  
  34.     from_text = classmethod(from_text)
  35.     
  36.     def to_wire(self, file, compress = None, origin = None):
  37.         file.write(self.address)
  38.  
  39.     
  40.     def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
  41.         address = wire[current:current + rdlen]
  42.         return cls(rdclass, rdtype, address)
  43.  
  44.     from_wire = classmethod(from_wire)
  45.     
  46.     def _cmp(self, other):
  47.         return cmp(self.address, other.address)
  48.  
  49.  
  50.