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_detect_html(sample):
text, is_html = sample
assert helpers.detect_html(text) is is_html
def __detect_html(self):
# Prepare text
text = ''
for row_number, headers, row in self.__sample_extended_rows:
for value in row:
if isinstance(value, six.string_types):
text += value
# Detect html content
html_source = helpers.detect_html(text)
if html_source:
message = 'Format has been detected as HTML (not supported)'
raise exceptions.FormatError(message)
try:
(number, headers, row) = next(self.__parser.extended_rows)
if headers is not None:
keyed_source = True
self.__sample_extended_rows.append((number, headers, row))
except StopIteration:
break
# Detect html content
if not keyed_source:
text = ''
for number, headers, row in self.__sample_extended_rows:
for value in row:
if isinstance(value, six.string_types):
text += value
html_source = helpers.detect_html(text)
if html_source:
msg = 'Source has been detected as HTML (not supported)'
raise exceptions.TabulatorException(msg)
# Extract headers
if self.__headers_row:
for number, headers, row in self.__sample_extended_rows:
if number == self.__headers_row:
if keyed_source:
self.__headers_list = headers
else:
self.__headers_list = row
# Remove headers from sample
if not keyed_source:
self.__sample_extended_rows = self.__sample_extended_rows[