(self)
Return the value for reverse lookup/PTR records as RfC 2317 look alike.

        RfC 2317 is an ugly hack which only works for sub-/24 e.g. not
        for /23. Do not use it. Better set up a Zone for every
        address. See reverseName for a way to arcive that.

        >>> print IP('195.185.1.1').reverseName()
        1.1.185.195.in-addr.arpa.
        >>> print IP('195.185.1.0/28').reverseName()
        0-15.1.185.195.in-addr.arpa.
Return the value for reverse lookup/PTR records as RfC 2317 look alike.
Return the value for reverse lookup / PTR records as RfC 2317 look alike .
def reverseName(self):
        """Return the value for reverse lookup/PTR records as RfC 2317 look alike.

        RfC 2317 is an ugly hack which only works for sub-/24 e.g. not
        for /23. Do not use it. Better set up a Zone for every
        address. See reverseName for a way to arcive that.

        >>> print IP('195.185.1.1').reverseName()
        1.1.185.195.in-addr.arpa.
        >>> print IP('195.185.1.0/28').reverseName()
        0-15.1.185.195.in-addr.arpa.
        """

        if self._ipversion == 4:
            s = self.strFullsize(0)
            s = s.split('.')
            s.reverse()
            first_byte_index = int(4 - (self._prefixlen / 8))
            if self._prefixlen % 8 != 0:
                nibblepart = "%s-%s" % (s[3 - (self._prefixlen / 8)],
                                        intToIp(self.ip + self.len() - 1, 4).split('.')[-1])
                if nibblepart[-1] == 'l':
                    nibblepart = nibblepart[:-1]
                nibblepart += '.'
            else:
                nibblepart = ""

            s = '.'.join(s[first_byte_index:])
            return "%s%s.in-addr.arpa." % (nibblepart, s)

        elif self._ipversion == 6:
            s = hex(self.ip)[2:].lower()
            if s[-1] == 'l':
                s = s[:-1]
            if self._prefixlen % 4 != 0:
                nibblepart = "%s-%s" % (s[self._prefixlen:],
                                        hex(self.ip + self.len() - 1)[2:].lower())
                if nibblepart[-1] == 'l':
                    nibblepart = nibblepart[:-1]
                nibblepart += '.'
            else:
                nibblepart = ""
            s = list(s)
            s.reverse()
            s = '.'.join(s)
            first_nibble_index = int(32 - (self._prefixlen / 4)) * 2
            return "%s%s.ip6.int." % (nibblepart, s[first_nibble_index:])
        else:
            raise ValueError("only IPv4 and IPv6 supported")
def reverseName ( self ) : if self . _ipversion == 4 : s = self . strFullsize ( 0 ) s = s . split ( '.' ) s . reverse ( ) first_byte_index = int ( 4 - ( self . _prefixlen / 8 ) ) if self . _prefixlen % 8 != 0 : nibblepart = "%s-%s" % ( s [ 3 - ( self . _prefixlen / 8 ) ] , intToIp ( self . ip + self . len ( ) - 1 , 4 ) . split ( '.' ) [ - 1 ] ) if nibblepart [ - 1 ] == 'l' : nibblepart = nibblepart [ : - 1 ] nibblepart += '.' else : nibblepart = "" s = '.' . join ( s [ first_byte_index : ] ) return "%s%s.in-addr.arpa." % ( nibblepart , s ) elif self . _ipversion == 6 : s = hex ( self . ip ) [ 2 : ] . lower ( ) if s [ - 1 ] == 'l' : s = s [ : - 1 ] if self . _prefixlen % 4 != 0 : nibblepart = "%s-%s" % ( s [ self . _prefixlen : ] , hex ( self . ip + self . len ( ) - 1 ) [ 2 : ] . lower ( ) ) if nibblepart [ - 1 ] == 'l' : nibblepart = nibblepart [ : - 1 ] nibblepart += '.' else : nibblepart = "" s = list ( s ) s . reverse ( ) s = '.' . join ( s ) first_nibble_index = int ( 32 - ( self . _prefixlen / 4 ) ) * 2 return "%s%s.ip6.int." % ( nibblepart , s [ first_nibble_index : ] ) else : raise ValueError ( "only IPv4 and IPv6 supported" )