How to use the tabulator.helpers.detect_html function in tabulator

To help you get started, we’ve selected a few tabulator 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 frictionlessdata / tabulator-py / tests / test_helpers.py View on Github external
def test_detect_html(sample):
    text, is_html = sample
    assert helpers.detect_html(text) is is_html
github frictionlessdata / tabulator-py / tabulator / stream.py View on Github external
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)
github frictionlessdata / tabulator-py / tabulator / table.py View on Github external
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[