From 3936250b52c0ae328e342017f494f5a5dcfdd44f Mon Sep 17 00:00:00 2001 From: Eric Hanson Date: Sat, 10 Apr 2021 16:45:49 -0400 Subject: [PATCH 1/3] add readme --- README.md | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++ dsaps/cli.py | 6 ++--- 2 files changed, 77 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fecda7b..428b066 100644 --- a/README.md +++ b/README.md @@ -1 +1,76 @@ # dsaps + +This command line application provides several ways of interacting with the [DSpace](https://github.com/DSpace/DSpace) API. This application was written for DSpace 6.3, it has not been tested against other DSpace versions. + +## Installation +Clone the repository and install using [pipenv](https://github.com/pypa/pipenv): +``` +pipenv install +``` +After installation, run the application with: +``` +pipenv run dsaps +``` + +## Authentication + +To authenticate, use the following parameters + +Option (short) | Option (long)     | Description +------ | ------ | ----------- +N/A | --url | The DSpace API URL (e.g. https://dspace.mit.edu/rest), defaults to the DSPACE_URL environmental variable if nothing is specified +-e | --email | The email of the user for authentication. +-p | --password | The password for authentication. + +## Commands + +### additems +Adds items to a specified collection from a metadata CSV, a field mapping file, and a directory of files. May be run in conjunction with the newcollection CLI command. + +Option (short) | Option (long)             | Description +------ | ------ | ------- +-m | --metadata-csv | The path to the CSV file of metadata for the items. +-f | --field-map | The path to JSON field mapping file. +-d | --content-directory | The full path to the content, either a directory of files or a URL for the storage location. +-t | --file-type | The file type to be uploaded, if limited to one file type. +-r | --ingest-report| Create ingest report for updating other systems. +-c | --collection-handle | The handle of the collection to which items are being added. + + +#### Example Usage +``` +dsaps --url https://dspace.com/rest -e abc@def.com additems -m coll_metadata.csv +-f config/aspace_mapping.json -d /files/pdfs -t pdf -r -c 111.1/111111 +``` + +### newcollection +Posts a new collection to a specified community. Used in conjunction with the additems CLI command to populate the new collection with items. + +Option (short) | Option (long)            | Description +------ | ------ | ------- +-c | --community-handle | The handle of the community in which to create the collection. +-n | --collection-name | The name of the collection to be created. + +#### Example Usage +``` +dsaps --url https://dspace.com/rest -e abc@def.com newcollection -c 222.2/222222 +-n Test\ Collection additems -m coll_metadata.csv -f config/aspace_mapping.json +-d /files/pdfs -t pdf -r +``` + +### reconcile +Runs a reconciliation of the specified files and metadata that produces reports of files with no metadata, metadata with no files, metadata matched to files, and an updated version of the metadata CSV with only the records that have matching files. + + +Option (short) | Option (long)             | Description +------ | ------ | ------- +-m | --metadata-csv | The path of the CSV file of metadata. +-o | --output-directory | The path of the output files, include / at the end of the path. +-d | --content-directory | The full path to the content, either a directory of files or a URL for the storage location. +-t | --file-type | The file type to be uploaded. + +#### Example Usage +``` +dsaps --url https://dspace.com/rest -e abc@def.com reconcile -m coll_metadata.csv +-o /output -d /files/pdfs -t pdf +``` diff --git a/dsaps/cli.py b/dsaps/cli.py index ac79117..6d850ba 100644 --- a/dsaps/cli.py +++ b/dsaps/cli.py @@ -59,13 +59,11 @@ def main(ctx, url, email, password): @main.command() @click.option('-m', '--metadata-csv', required=True, - type=click.Path(exists=True, file_okay=True, dir_okay=False), + type=click.Path(exists=True), help='The path to the CSV file of metadata for the items.') -@click.option('--field-map', required=True, - type=click.Path(exists=True, file_okay=True, dir_okay=False), +@click.option('-f', '--field-map', required=True, type=click.Path(exists=True), help='The path to JSON field mapping file.') @click.option('-d', '--content-directory', required=True, - type=click.Path(exists=True, dir_okay=True, file_okay=False), help='The full path to the content, either a directory of files ' 'or a URL for the storage location.') @click.option('-t', '--file-type', From fd5d7ced2820c73bfe706a217d4aeefec4bcef61 Mon Sep 17 00:00:00 2001 From: Eric Hanson Date: Thu, 22 Apr 2021 16:42:51 -0400 Subject: [PATCH 2/3] Update cli.py Walking back inadvertent changes from a rebase --- dsaps/cli.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dsaps/cli.py b/dsaps/cli.py index 6d850ba..087fb6c 100644 --- a/dsaps/cli.py +++ b/dsaps/cli.py @@ -59,11 +59,13 @@ def main(ctx, url, email, password): @main.command() @click.option('-m', '--metadata-csv', required=True, - type=click.Path(exists=True), + type=click.Path(exists=True, file_okay=True, dir_okay=False), help='The path to the CSV file of metadata for the items.') -@click.option('-f', '--field-map', required=True, type=click.Path(exists=True), +@click.option('-f', '--field-map', required=True, + type=click.Path(exists=True, file_okay=True, dir_okay=False), help='The path to JSON field mapping file.') @click.option('-d', '--content-directory', required=True, + type=click.Path(exists=True, dir_okay=True, file_okay=False), help='The full path to the content, either a directory of files ' 'or a URL for the storage location.') @click.option('-t', '--file-type', From 083a6f952802a48e6547da7f1cb9dcb71aa631f2 Mon Sep 17 00:00:00 2001 From: Eric Hanson Date: Fri, 23 Apr 2021 14:40:47 -0400 Subject: [PATCH 3/3] Update README.md --- README.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 428b066..01e4fee 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,7 @@ Option (short) | Option (long)             | Description #### Example Usage ``` -dsaps --url https://dspace.com/rest -e abc@def.com additems -m coll_metadata.csv --f config/aspace_mapping.json -d /files/pdfs -t pdf -r -c 111.1/111111 +pipenv run dsaps --url https://dspace.com/rest -e abc@def.com -p ******** additems -m coll_metadata.csv -f config/aspace_mapping.json -d /files/pdfs -t pdf -r -c 111.1/111111 ``` ### newcollection @@ -53,9 +52,7 @@ Option (short) | Option (long)            | Description #### Example Usage ``` -dsaps --url https://dspace.com/rest -e abc@def.com newcollection -c 222.2/222222 --n Test\ Collection additems -m coll_metadata.csv -f config/aspace_mapping.json --d /files/pdfs -t pdf -r +pipenv run dsaps --url https://dspace.com/rest -e abc@def.com -p ******** newcollection -c 222.2/222222 -n Test\ Collection additems -m coll_metadata.csv -f config/aspace_mapping.json -d /files/pdfs -t pdf -r ``` ### reconcile @@ -71,6 +68,5 @@ Option (short) | Option (long)             | Description #### Example Usage ``` -dsaps --url https://dspace.com/rest -e abc@def.com reconcile -m coll_metadata.csv --o /output -d /files/pdfs -t pdf +pipenv run dsaps --url https://dspace.com/rest -e abc@def.com -p ******** reconcile -m coll_metadata.csv -o /output -d /files/pdfs -t pdf ```