How to use the pathvalidate.InvalidCharError 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 / pathvalidate / test / test_sqlite.py View on Github external
def test_exception_invalid_win_char(self, value):
        with pytest.raises(InvalidCharError):
            validate_sqlite_table_name(value)
github thombashi / pathvalidate / test / test_python_var_name.py View on Github external
def test_exception_invalid_first_char(self, value):
        with pytest.raises(InvalidCharError):
            validate_python_var_name(value)
github thombashi / SimpleSQLite / test / test_validator.py View on Github external
def test_exception_invalid_win_char(self, value):
        with pytest.raises(InvalidCharError):
            validate_sqlite_table_name(value)
github thombashi / pathvalidate / test / test_js_var_name.py View on Github external
def test_exception_invalid_char(self, value):
        with pytest.raises(InvalidCharError):
            validate_js_var_name(value)
github thombashi / SimpleSQLite / simplesqlite / loader / interface.py View on Github external
def _sanitize_table_name(self, table_name):
        try:
            pathvalidate.validate_sqlite_table_name(table_name)
            return table_name
        except pathvalidate.ReservedNameError:
            return "{:s}_{:s}".format(table_name, self.format_name)
        except pathvalidate.InvalidCharError as e:
            raise InvalidTableNameError(e)
github thombashi / pytablewriter / pytablewriter / sanitizer / _base.py View on Github external
def _validate(self, value):
        self._validate_null_string(value)

        unicode_var_name = _preprocess(value)

        if self._is_reserved_keyword(unicode_var_name):
            raise ReservedNameError(
                "{:s} is a reserved keyword by python".format(unicode_var_name),
                reusable_name=False,
                reserved_name=unicode_var_name,
            )

        match = self._invalid_var_name_re.search(unicode_var_name)
        if match is not None:
            raise InvalidCharError(
                "invalid char found in the variable name: '{}'".format(re.escape(match.group()))
            )

        match = self._invalid_var_name_head_re.search(unicode_var_name)
        if match is not None:
            raise InvalidCharError(
                "the first character of the variable name is invalid: '{}'".format(
                    re.escape(match.group())
                )
github thombashi / pytablewriter / pytablewriter / sanitizer / _base.py View on Github external
if self._is_reserved_keyword(unicode_var_name):
            raise ReservedNameError(
                "{:s} is a reserved keyword by python".format(unicode_var_name),
                reusable_name=False,
                reserved_name=unicode_var_name,
            )

        match = self._invalid_var_name_re.search(unicode_var_name)
        if match is not None:
            raise InvalidCharError(
                "invalid char found in the variable name: '{}'".format(re.escape(match.group()))
            )

        match = self._invalid_var_name_head_re.search(unicode_var_name)
        if match is not None:
            raise InvalidCharError(
                "the first character of the variable name is invalid: '{}'".format(
                    re.escape(match.group())
                )
github thombashi / pytablereader / pytablereader / _tabledata_sanitizer.py View on Github external
def _validate_header(self, header):
        try:
            pv.validate_sqlite_attr_name(header)
        except (pv.NullNameError, pv.ReservedNameError):
            pass
        except pv.InvalidCharError as e:
            raise InvalidHeaderNameError(e)