Update sdk/platform-tools to version 26.0.0.
[android_tools.git] / sdk / platform-tools / systrace / catapult / telemetry / third_party / web-page-replay / third_party / dns / rdtypes / IN / DHCID.py
blob2d35234bf04ca025638438698c4097ae078e8ec0
1 # Copyright (C) 2006, 2007, 2009, 2010 Nominum, Inc.
3 # Permission to use, copy, modify, and distribute this software and its
4 # documentation for any purpose with or without fee is hereby granted,
5 # provided that the above copyright notice and this permission notice
6 # appear in all copies.
8 # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 import dns.exception
18 class DHCID(dns.rdata.Rdata):
19 """DHCID record
21 @ivar data: the data (the content of the RR is opaque as far as the
22 DNS is concerned)
23 @type data: string
24 @see: RFC 4701"""
26 __slots__ = ['data']
28 def __init__(self, rdclass, rdtype, data):
29 super(DHCID, self).__init__(rdclass, rdtype)
30 self.data = data
32 def to_text(self, origin=None, relativize=True, **kw):
33 return dns.rdata._base64ify(self.data)
35 def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
36 chunks = []
37 while 1:
38 t = tok.get().unescape()
39 if t.is_eol_or_eof():
40 break
41 if not t.is_identifier():
42 raise dns.exception.SyntaxError
43 chunks.append(t.value)
44 b64 = ''.join(chunks)
45 data = b64.decode('base64_codec')
46 return cls(rdclass, rdtype, data)
48 from_text = classmethod(from_text)
50 def to_wire(self, file, compress = None, origin = None):
51 file.write(self.data)
53 def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
54 data = wire[current : current + rdlen]
55 return cls(rdclass, rdtype, data)
57 from_wire = classmethod(from_wire)
59 def _cmp(self, other):
60 return cmp(self.data, other.data)