-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from ResearchObject/add-cli
add simple CLI and user guide
- Loading branch information
Showing
5 changed files
with
82 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
# ro-crate-uploader | ||
RO-Crate uploader for Zenodo | ||
|
||
[User Guide](docs/user_guide.md) | ||
[Developer Guide](docs/developer_guide.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import argparse | ||
from rocrate.rocrate import ROCrate | ||
|
||
from rocrate_upload.upload import ( | ||
build_zenodo_metadata_from_crate, | ||
ensure_crate_zipped, | ||
upload_crate_to_zenodo, | ||
) | ||
|
||
|
||
def cli_entry(): | ||
parser = argparse.ArgumentParser( | ||
description="Takes a RO-Crate directory as input and uploads it to Zenodo" | ||
) | ||
|
||
parser.add_argument( | ||
"ro_crate_directory", | ||
help="RO-Crate directory to upload.", | ||
type=str, | ||
action="store", | ||
) | ||
parser.add_argument( | ||
"-s", | ||
"--sandbox", | ||
help="Upload to Zenodo sandbox rather than Zenodo production", | ||
action="store_true", | ||
) | ||
parser.add_argument( | ||
"-p", | ||
"--publish", | ||
help="Publish the record after uploading.", | ||
action="store_true", | ||
) | ||
args = parser.parse_args() | ||
|
||
crate = ROCrate(args.ro_crate_directory) | ||
|
||
metadata = build_zenodo_metadata_from_crate(crate) | ||
crate_zip_path = ensure_crate_zipped(crate) | ||
record = upload_crate_to_zenodo( | ||
crate_zip_path, metadata, sandbox=args.sandbox, publish=args.publish | ||
) | ||
print(f'Created record {record["id"]} ({record["links"]["html"]})') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters