How to use the pathvalidate.NullNameError function in pathvalidate

To help you get started, we’ve selected a few pathvalidate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thombashi / SimpleSQLite / test / test_validator.py View on Github external
        [[None, NullNameError], ["", NullNameError], [1, TypeError], [True, TypeError]],
    )
    def test_exception_type(self, value, expected):
        with pytest.raises(expected):
            validate_sqlite_table_name(value)
github thombashi / pathvalidate / test / test_excel.py View on Github external
            [None, NullNameError],
            ["", NullNameError],
            [1, TypeError],
            [True, TypeError],
            ["a" * 32, InvalidLengthError],
        ],
    )
    def test_exception(self, value, expected):
        with pytest.raises(expected):
            validate_excel_sheet_name(value)
github thombashi / pathvalidate / test / test_js_var_name.py View on Github external
            ["", NullNameError],
            ["123", ValueError],
            [1, TypeError],
            [True, TypeError],
        ],
    )
    def test_exception_type(self, value, expected):
        with pytest.raises(expected):
            validate_js_var_name(value)
github thombashi / pathvalidate / test / test_python_var_name.py View on Github external
            ["", NullNameError],
            ["123", ValueError],
            [1, TypeError],
            [True, TypeError],
        ],
    )
    def test_exception_type(self, value, expected):
        with pytest.raises(expected):
            validate_python_var_name(value)
github thombashi / pathvalidate / test / test_sqlite.py View on Github external
        [[None, NullNameError], ["", NullNameError], [1, TypeError], [True, TypeError]],
    )
    def test_exception_type(self, value, expected):
        with pytest.raises(expected):
            validate_sqlite_attr_name(value)
github thombashi / SimpleSQLite / simplesqlite / query.py View on Github external
def to_query(self):
        name = self.sanitize(self._value)
        need_quote = self.__RE_NEED_QUOTE.search(name) is not None

        try:
            validate_sqlite_attr_name(name)
        except InvalidReservedNameError:
            need_quote = True
        except (ValidReservedNameError, NullNameError, InvalidCharError):
            pass

        if need_quote:
            sql_name = '"{:s}"'.format(name)
        elif self.__RE_NEED_BRACKET.search(name):
            sql_name = "[{:s}]".format(name)
        elif name == "join":
            sql_name = "[{:s}]".format(name)
        else:
            sql_name = name

        if typepy.is_not_null_string(self.__operation):
            sql_name = "{:s}({:s})".format(self.__operation, sql_name)

        return sql_name
github thombashi / SimpleSQLite / simplesqlite / _sanitizer.py View on Github external
def _validate_header(self, header):
        try:
            validate_sqlite_attr_name(header)
        except (NullNameError, ReservedNameError):
            pass
        except InvalidCharError as e:
            raise InvalidHeaderNameError(e)
github thombashi / pytablereader / pytablereader / _tabledata_sanitizer.py View on Github external
def __sanitize_table_name(self):
        preprocessed_table_name = self._preprocess_table_name()

        try:
            self._validate_table_name(preprocessed_table_name)
            new_table_name = preprocessed_table_name
        except InvalidTableNameError:
            new_table_name = self._sanitize_table_name(
                preprocessed_table_name)
            self._validate_table_name(new_table_name)
        except pv.NullNameError as e:
            raise InvalidTableNameError(e)

        return new_table_name
github thombashi / pytablewriter / pytablewriter / sanitizer / _base.py View on Github external
if is_require_remove_head:
            sanitized_var_name = self._invalid_var_name_head_re.sub("", sanitized_var_name)
        else:
            match = self._invalid_var_name_head_re.search(sanitized_var_name)
            if match is not None:
                sanitized_var_name = match.end() * replacement_text + self._invalid_var_name_head_re.sub(
                    "", sanitized_var_name
                )

        try:
            self._validate(sanitized_var_name)
        except ReservedNameError as e:
            if e.reusable_name is False:
                sanitized_var_name += "_"
        except NullNameError:
            pass

        return sanitized_var_name
github thombashi / SimpleSQLite / simplesqlite / _func.py View on Github external
def validate_table_name(name):
    """
    :param str name: Table name to validate.
    :raises NameValidationError: |raises_validate_table_name|
    """

    try:
        validate_sqlite_table_name(name)
    except (InvalidCharError, InvalidReservedNameError) as e:
        raise NameValidationError(e)
    except NullNameError:
        raise NameValidationError("table name is empty")
    except ValidReservedNameError:
        pass