X-Git-Url: https://git.jsancho.org/?p=datasette-pytables.git;a=blobdiff_plain;f=datasette_pytables%2F__init__.py;h=8516315cd49bbf4bf4507590d3e47e5a4878a1b1;hp=a3b1844af528e46abbfef28644687b33477ea8af;hb=d9e3d4c6f66634a32236b238ce04cefff17f79b1;hpb=d1a26f37d5239c452df2ec6bef410b798b87ac4f diff --git a/datasette_pytables/__init__.py b/datasette_pytables/__init__.py index a3b1844..8516315 100644 --- a/datasette_pytables/__init__.py +++ b/datasette_pytables/__init__.py @@ -1,3 +1,26 @@ +import tables + def inspect(path): "Open file and return tables info" - return [], [] + h5tables = {} + views = [] + h5file = tables.open_file(path) + + for table in filter(lambda node: not(isinstance(node, tables.group.Group)), h5file): + colnames = [] + if isinstance(table, tables.table.Table): + colnames = table.colnames + + h5tables[table._v_pathname] = { + 'name': table._v_pathname, + 'columns': colnames, + 'primary_keys': [], + 'count': table.nrows, + 'label_column': None, + 'hidden': False, + 'fts_table': None, + 'foreign_keys': {'incoming': [], 'outgoing': []}, + } + + h5file.close() + return h5tables, views