def _validate_python(self, value, state=None):
        try:
            if not value:
                raise ValueError
            octets = value.split('.', 5)
            # Only 4 octets?
            if len(octets) != 4:
                raise ValueError
            # Correct octets?
            for octet in octets:
                if octet.startswith('0') and octet != '0':
                    if not self.leading_zeros:
                        raise Invalid(
                            self.message('leadingZeros', state), value, state)
                    # strip zeros so this won't be an octal number
                    octet = octet.lstrip('0')
                if not 0 <= int(octet) < 256:
                    raise Invalid(
                        self.message('illegalOctets', state, octet=octet),
                        value, state)
        # Splitting faild: wrong syntax
        except ValueError:
            raise Invalid(self.message('badFormat', state), value, state)
dataset/ETHPy150Open formencode/formencode/formencode/validators.py/IPAddress._validate_python/original