home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import dns.exception as dns
- import dns.rdata as dns
- import dns.tokenizer as dns
-
- class TXTBase(dns.rdata.Rdata):
- __slots__ = [
- 'strings']
-
- def __init__(self, rdclass, rdtype, strings):
- super(TXTBase, self).__init__(rdclass, rdtype)
- if isinstance(strings, str):
- strings = [
- strings]
-
- self.strings = strings[:]
-
-
- def to_text(self, origin = None, relativize = True, **kw):
- txt = ''
- prefix = ''
- for s in self.strings:
- txt += '%s"%s"' % (prefix, dns.rdata._escapify(s))
- prefix = ' '
-
- return txt
-
-
- def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
- strings = []
- while None:
- (ttype, s) = tok.get()
- if ttype == dns.tokenizer.EOL or ttype == dns.tokenizer.EOF:
- break
-
- if ttype != dns.tokenizer.QUOTED_STRING and ttype != dns.tokenizer.IDENTIFIER:
- raise dns.exception.SyntaxError, 'expected a string'
- if len(s) > 255:
- raise dns.exception.SyntaxError, 'string too long'
- len(s) > 255
- strings.append(s)
- continue
- if len(strings) == 0:
- raise dns.exception.UnexpectedEnd
- len(strings) == 0
- return cls(rdclass, rdtype, strings)
-
- from_text = classmethod(from_text)
-
- def to_wire(self, file, compress = None, origin = None):
- for s in self.strings:
- l = len(s)
- byte = chr(l)
- file.write(byte)
- file.write(s)
-
-
-
- def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
- strings = []
- while rdlen > 0:
- l = ord(wire[current])
- current += 1
- rdlen -= 1
- if l > rdlen:
- raise dns.exception.FormError
- l > rdlen
- s = wire[current:current + l]
- current += l
- rdlen -= l
- strings.append(s)
- return cls(rdclass, rdtype, strings)
-
- from_wire = classmethod(from_wire)
-
- def _cmp(self, other):
- return cmp(self.strings, other.strings)
-
-
-