How to use the tabulator.exceptions 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 / formats / test_ods.py View on Github external
def test_stream_ods_sheet_by_index_not_existent_2():
    with pytest.raises(exceptions.SourceError) as excinfo:
        Stream('data/table.ods', sheet='not-existent').open()
    assert 'sheet "not-existent"' in str(excinfo.value)
github frictionlessdata / tabulator-py / tests / parsers / test_ndjson.py View on Github external
def test_ndjson_scalar():
    stream = StringIO(
        '1\n'
        '2\n'
    )

    loader = Mock(load=Mock(return_value=stream))
    parser = NDJSONParser(loader)
    parser.open(None)

    with pytest.raises(exceptions.SourceError):
        list(parser.extended_rows)
github frictionlessdata / tabulator-py / tabulator / parsers / datapackage.py View on Github external
def open(self, source, encoding=None):
        self.close()
        package = datapackage.DataPackage(source)
        if isinstance(self.__resource_pointer, six.string_types):
            self.__resource = package.get_resource(self.__resource_pointer)
        else:
            try:
                self.__resource = package.resources[self.__resource_pointer]
            except (TypeError, IndexError):
                pass
        if not self.__resource:
            message = 'Data package "%s" doesn\'t have resource "%s"'
            raise exceptions.SourceError(message % (source, self.__resource_pointer))
        self.__resource.infer()
        self.__encoding = self.__resource.descriptor.get('encoding')
        self.__fragment = self.__resource.name
        self.reset()
github frictionlessdata / tabulator-py / tabulator / parsers / sql.py View on Github external
def __init__(self, loader, force_parse=False, table=None, order_by=None):

        # Ensure table
        if table is None:
            raise exceptions.TabulatorException('Format `sql` requires `table` option.')

        # Set attributes
        self.__loader = loader
        self.__table = table
        self.__order_by = order_by
        self.__force_parse = force_parse
        self.__engine = None
        self.__extended_rows = None
        self.__encoding = None