Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_exception_invalid_win_char(self, value):
with pytest.raises(InvalidCharError):
validate_sqlite_table_name(value)
def test_exception_invalid_first_char(self, value):
with pytest.raises(InvalidCharError):
validate_python_var_name(value)
def test_exception_invalid_win_char(self, value):
with pytest.raises(InvalidCharError):
validate_sqlite_table_name(value)
def test_exception_invalid_char(self, value):
with pytest.raises(InvalidCharError):
validate_js_var_name(value)
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)
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())
)
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())
)
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)