mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Removed 'datasette skeleton', closes #476
This commit is contained in:
parent
2600858388
commit
503fee891b
2 changed files with 0 additions and 120 deletions
|
|
@ -117,77 +117,6 @@ def publish():
|
||||||
pm.hook.publish_subcommand(publish=publish)
|
pm.hook.publish_subcommand(publish=publish)
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
|
||||||
@click.argument("files", type=click.Path(exists=True), nargs=-1, required=True)
|
|
||||||
@click.option(
|
|
||||||
"-m",
|
|
||||||
"--metadata",
|
|
||||||
default="metadata.json",
|
|
||||||
help="Name of metadata file to generate",
|
|
||||||
)
|
|
||||||
@click.option(
|
|
||||||
"sqlite_extensions",
|
|
||||||
"--load-extension",
|
|
||||||
envvar="SQLITE_EXTENSIONS",
|
|
||||||
multiple=True,
|
|
||||||
type=click.Path(exists=True, resolve_path=True),
|
|
||||||
help="Path to a SQLite extension to load",
|
|
||||||
)
|
|
||||||
def skeleton(files, metadata, sqlite_extensions):
|
|
||||||
"Generate a skeleton metadata.json file for specified SQLite databases"
|
|
||||||
if os.path.exists(metadata):
|
|
||||||
click.secho(
|
|
||||||
"File {} already exists, will not over-write".format(metadata),
|
|
||||||
bg="red",
|
|
||||||
fg="white",
|
|
||||||
bold=True,
|
|
||||||
err=True,
|
|
||||||
)
|
|
||||||
sys.exit(1)
|
|
||||||
app = Datasette(files, sqlite_extensions=sqlite_extensions)
|
|
||||||
databases = {}
|
|
||||||
for database_name, info in app.inspect().items():
|
|
||||||
databases[database_name] = {
|
|
||||||
"title": None,
|
|
||||||
"description": None,
|
|
||||||
"description_html": None,
|
|
||||||
"license": None,
|
|
||||||
"license_url": None,
|
|
||||||
"source": None,
|
|
||||||
"source_url": None,
|
|
||||||
"queries": {},
|
|
||||||
"tables": {
|
|
||||||
table_name: {
|
|
||||||
"title": None,
|
|
||||||
"description": None,
|
|
||||||
"description_html": None,
|
|
||||||
"license": None,
|
|
||||||
"license_url": None,
|
|
||||||
"source": None,
|
|
||||||
"source_url": None,
|
|
||||||
"units": {},
|
|
||||||
}
|
|
||||||
for table_name in (info.get("tables") or {})
|
|
||||||
},
|
|
||||||
}
|
|
||||||
open(metadata, "w").write(
|
|
||||||
json.dumps(
|
|
||||||
{
|
|
||||||
"title": None,
|
|
||||||
"description": None,
|
|
||||||
"description_html": None,
|
|
||||||
"license": None,
|
|
||||||
"license_url": None,
|
|
||||||
"source": None,
|
|
||||||
"source_url": None,
|
|
||||||
"databases": databases,
|
|
||||||
},
|
|
||||||
indent=4,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
click.echo("Wrote skeleton to {}".format(metadata))
|
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.option("--all", help="Include built-in default plugins", is_flag=True)
|
@click.option("--all", help="Include built-in default plugins", is_flag=True)
|
||||||
@click.option(
|
@click.option(
|
||||||
|
|
|
||||||
|
|
@ -182,52 +182,3 @@ Spatialite tables are automatically hidden) using ``"hidden": true``::
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Generating a metadata skeleton
|
|
||||||
------------------------------
|
|
||||||
|
|
||||||
Tracking down the names of all of your databases and tables and formatting them
|
|
||||||
as JSON can be a little tedious, so Datasette provides a tool to help you
|
|
||||||
generate a "skeleton" JSON file::
|
|
||||||
|
|
||||||
datasette skeleton database1.db database2.db
|
|
||||||
|
|
||||||
This will create a ``metadata.json`` file looking something like this::
|
|
||||||
|
|
||||||
{
|
|
||||||
"title": null,
|
|
||||||
"description": null,
|
|
||||||
"description_html": null,
|
|
||||||
"license": null,
|
|
||||||
"license_url": null,
|
|
||||||
"source": null,
|
|
||||||
"source_url": null,
|
|
||||||
"databases": {
|
|
||||||
"database1": {
|
|
||||||
"title": null,
|
|
||||||
"description": null,
|
|
||||||
"description_html": null,
|
|
||||||
"license": null,
|
|
||||||
"license_url": null,
|
|
||||||
"source": null,
|
|
||||||
"source_url": null,
|
|
||||||
"queries": {},
|
|
||||||
"tables": {
|
|
||||||
"example_table": {
|
|
||||||
"title": null,
|
|
||||||
"description": null,
|
|
||||||
"description_html": null,
|
|
||||||
"license": null,
|
|
||||||
"license_url": null,
|
|
||||||
"source": null,
|
|
||||||
"source_url": null,
|
|
||||||
"units": {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"database2": ...
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
You can replace any of the ``null`` values with a JSON string to populate that
|
|
||||||
piece of metadata.
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue