1 # Copyright (C) 2011 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 """DNS Wire Data Helper"""
23 # WireData is a string with stricter slicing
24 def __getitem__(self, key):
26 return WireData(super(WireData, self).__getitem__(key))
28 raise dns.exception.FormError
29 def __getslice__(self, i, j):
32 # handle the case where the right bound is unspecified
35 raise dns.exception.FormError
36 # If it's not an empty slice, access left and right bounds
37 # to make sure they're valid
39 super(WireData, self).__getitem__(i)
40 super(WireData, self).__getitem__(j - 1)
41 return WireData(super(WireData, self).__getslice__(i, j))
43 raise dns.exception.FormError
50 except dns.exception.FormError:
56 if not isinstance(wire, WireData):