From 775c7c3a00cfed4f49e10e2ea3216c5d0aee94e6 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Wed, 29 Jun 2022 17:13:58 -0700 Subject: [PATCH] Swap order of bucket database_file for s3-ocr index, closes #9 --- README.md | 6 +++--- s3_ocr/cli.py | 4 ++-- tests/test_s3_ocr.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 568e86b..e9a747e 100644 --- a/README.md +++ b/README.md @@ -224,10 +224,10 @@ This design for the tool, with the `.s3-ocr.json` files tracking jobs that have ## Creating a SQLite index of your OCR results -The `s3-ocr index ` command creates a SQLite database contaning the results of the OCR, and configure SQLite full-text search for the text: +The `s3-ocr index ` command creates a SQLite database contaning the results of the OCR, and configure SQLite full-text search for the text: ``` -% s3-ocr index index.db sfms-history +% s3-ocr index sfms-history index.db Fetching job details [####################################] 100% Populating pages table [####################----------------] 55% 00:03:18 ``` @@ -262,7 +262,7 @@ cog.out( ) ]]] --> ``` -Usage: s3-ocr index [OPTIONS] DATABASE BUCKET +Usage: s3-ocr index [OPTIONS] BUCKET DATABASE Create a SQLite database with OCR results for files in a bucket diff --git a/s3_ocr/cli.py b/s3_ocr/cli.py index a8274ef..e01ace8 100644 --- a/s3_ocr/cli.py +++ b/s3_ocr/cli.py @@ -281,14 +281,14 @@ def text(bucket, key, divider, **boto_options): @cli.command +@click.argument("bucket") @click.argument( "database", type=click.Path(file_okay=True, dir_okay=False, allow_dash=False), required=True, ) -@click.argument("bucket") @common_boto3_options -def index(database, bucket, **boto_options): +def index(bucket, database, **boto_options): "Create a SQLite database with OCR results for files in a bucket" db = sqlite_utils.Database(database) if not db["pages"].exists(): diff --git a/tests/test_s3_ocr.py b/tests/test_s3_ocr.py index 66aac7e..7ea50d9 100644 --- a/tests/test_s3_ocr.py +++ b/tests/test_s3_ocr.py @@ -71,7 +71,7 @@ def test_index(s3, tmpdir): runner = CliRunner() with runner.isolated_filesystem(): result = runner.invoke( - cli, ["index", index_db, "my-bucket"], catch_exceptions=False + cli, ["index", "my-bucket", index_db], catch_exceptions=False ) assert result.exit_code == 0 db = sqlite_utils.Database(index_db)