Skip to content

Commit

Permalink
Tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
zimeon committed Oct 11, 2024
1 parent 3248a78 commit 350d9e4
Show file tree
Hide file tree
Showing 13 changed files with 237 additions and 87 deletions.
7 changes: 4 additions & 3 deletions build_demo_docs.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/bash

python tests/test_demo_build_spec_v1_0_examples.py > docs/demo_build_v1_0_spec_examples.md
python tests/test_demo_build_spec_v1_1_examples.py > docs/demo_build_v1_1_spec_examples.md
python tests/test_demo_ocfl_script.py > docs/demo_ocfl_script.md
python tests/test_demo_ocfl_object_script.py > docs/demo_ocfl_object_script.md
python tests/test_demo_ocfl_store_script.py > docs/demo_ocfl_store_script.md
python tests/test_demo_ocfl_validate_script.py > docs/demo_ocfl_validate_script.md
python tests/test_demo_using_bagit_bags.py > docs/demo_using_bagit_bags.md
python tests/test_demo_ocfl_sidecar_script.py > docs/demo_ocfl_sidecar_script.md
python tests/test_demo_build_spec_v1_0_examples.py > docs/demo_build_v1_0_spec_examples.md
python tests/test_demo_build_spec_v1_1_examples.py > docs/demo_build_v1_1_spec_examples.md
3 changes: 2 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Documentation is limited to a set of example run outputs, mostly produced automa
* [OCFL Object and Storage Root validation script](demo_ocfl_validate_script.md)
* [OCFL Object manipulation using Bagit bags to import and export versions](demo_using_bagit_bags.md)
* [OCFL Sidecar creation and update script](demo_ocfl_sidecar_script.md)
* [Examples using `ocfl-object.py` to build the inventory examples used in the specification](demo_build_spec_examples.md)
* [Examples using `ocfl-object.py` to build the inventory examples used in the v1.0 specification](demo_build_v1_0_spec_examples.md)
* [Examples using `ocfl-object.py` to build the inventory examples used in the v1.1 specification](demo_build_v1_1_spec_examples.md)
* [Use of JSON Schema to do partial validation on `inventory.json`](demo_jsonschema_inventory_validation.md)

There is also a list of error and warning codes generated by `ocfl-validate.py`
Expand Down
20 changes: 10 additions & 10 deletions docs/demo_build_v1_0_spec_examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

_Output from `tests/test_demo_build_spec_v1_0_examples.py`._

## 1. Test for minumal example.
## 1. Test for minimal example.

### 1.1 Minimal example

The digest type sha512-spec-ex is sha512 with most of the content stripped out and replaced with an ellipsis. This is inventory should match the example in <https://ocfl.io/1.0/spec/#example-minimal-object>.

```
> python ocfl-object.py --build --src fixtures/1.0/content/spec-ex-minimal --id http://example.org/minimal --spec-version 1.0 --digest sha512-spec-ex --created 2018-10-02T12:00:00Z --message One file --name Alice --address [email protected] -v
> python ocfl-object.py build --src fixtures/1.0/content/spec-ex-minimal --id http://example.org/minimal --spec-version 1.0 --digest sha512-spec-ex --created 2018-10-02T12:00:00Z --message One file --name Alice --address [email protected] -v
WARNING:ocfl.object:### Inventory for v1{
"digestAlgorithm": "sha512-spec-ex",
"head": "v1",
Expand Down Expand Up @@ -47,7 +47,7 @@ WARNING:ocfl.object:### Inventory for v1{
This is inventory should match the example with 3 versions in <https://ocfl.io/1.0/spec/#example-versioned-object>.

```
> python ocfl-object.py --build --src fixtures/1.0/content/spec-ex-full --spec-version 1.0 --id ark:/12345/bcd987 --fixity md5 --fixity sha1 --digest sha512-spec-ex -v
> python ocfl-object.py build --src fixtures/1.0/content/spec-ex-full --spec-version 1.0 --id ark:/12345/bcd987 --fixity md5 --fixity sha1 --digest sha512-spec-ex -v
WARNING:ocfl.object:### Inventory for v1{
"digestAlgorithm": "sha512-spec-ex",
"fixity": {
Expand Down Expand Up @@ -90,7 +90,7 @@ WARNING:ocfl.object:### Inventory for v1{
"type": "https://ocfl.io/1.0/spec/#inventory",
"versions": {
"v1": {
"created": "2024-10-01T12:11:51.144164Z",
"created": "2024-10-11T07:04:27.308760Z",
"state": {
"7dcc352f96c56dc...c31": [
"foo/bar.xml"
Expand Down Expand Up @@ -157,7 +157,7 @@ WARNING:ocfl.object:### Inventory for v2{
"type": "https://ocfl.io/1.0/spec/#inventory",
"versions": {
"v1": {
"created": "2024-10-01T12:11:51.144164Z",
"created": "2024-10-11T07:04:27.308760Z",
"state": {
"7dcc352f96c56dc...c31": [
"foo/bar.xml"
Expand All @@ -171,7 +171,7 @@ WARNING:ocfl.object:### Inventory for v2{
}
},
"v2": {
"created": "2024-10-01T12:11:51.145036Z",
"created": "2024-10-11T07:04:27.309573Z",
"state": {
"4d27c86b026ff70...b53": [
"foo/bar.xml"
Expand Down Expand Up @@ -236,7 +236,7 @@ WARNING:ocfl.object:### Inventory for v3{
"type": "https://ocfl.io/1.0/spec/#inventory",
"versions": {
"v1": {
"created": "2024-10-01T12:11:51.144164Z",
"created": "2024-10-11T07:04:27.308760Z",
"state": {
"7dcc352f96c56dc...c31": [
"foo/bar.xml"
Expand All @@ -250,7 +250,7 @@ WARNING:ocfl.object:### Inventory for v3{
}
},
"v2": {
"created": "2024-10-01T12:11:51.145036Z",
"created": "2024-10-11T07:04:27.309573Z",
"state": {
"4d27c86b026ff70...b53": [
"foo/bar.xml"
Expand All @@ -262,7 +262,7 @@ WARNING:ocfl.object:### Inventory for v3{
}
},
"v3": {
"created": "2024-10-01T12:11:51.145505Z",
"created": "2024-10-11T07:04:27.310019Z",
"state": {
"4d27c86b026ff70...b53": [
"foo/bar.xml"
Expand All @@ -288,7 +288,7 @@ WARNING:ocfl.object:### Inventory for v3{
This is inventory should match the example showing how content paths may differ from logical paths in <https://ocfl.io/1.0/spec/#example-object-diff-paths>.

```
> python ocfl-object.py --build --src fixtures/1.0/content/spec-ex-diff-paths --id http://example.org/diff-paths --spec-version 1.0 --digest sha512-spec-ex --normalization md5 --created 2019-03-14T20:31:00Z -v
> python ocfl-object.py build --src fixtures/1.0/content/spec-ex-diff-paths --id http://example.org/diff-paths --spec-version 1.0 --digest sha512-spec-ex --normalization md5 --created 2019-03-14T20:31:00Z -v
WARNING:ocfl.object:### Inventory for v1{
"digestAlgorithm": "sha512-spec-ex",
"head": "v1",
Expand Down
20 changes: 10 additions & 10 deletions docs/demo_build_v1_1_spec_examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

_Output from `tests/test_demo_build_spec_v1_1_examples.py`._

## 1. Test for minumal example.
## 1. Test for minimal example.

### 1.1 Minimal example

The digest type sha512-spec-ex is sha512 with most of the content stripped out and replaced with an ellipsis. This is inventory should match the example in <https://ocfl.io/1.1/spec/#example-minimal-object>.

```
> python ocfl-object.py --build --src fixtures/1.1/content/spec-ex-minimal --id http://example.org/minimal --spec-version 1.1 --digest sha512-spec-ex --created 2018-10-02T12:00:00Z --message One file --name Alice --address [email protected] -v
> python ocfl-object.py build --src fixtures/1.1/content/spec-ex-minimal --id http://example.org/minimal --spec-version 1.1 --digest sha512-spec-ex --created 2018-10-02T12:00:00Z --message One file --name Alice --address [email protected] -v
WARNING:ocfl.object:### Inventory for v1{
"digestAlgorithm": "sha512-spec-ex",
"head": "v1",
Expand Down Expand Up @@ -47,7 +47,7 @@ WARNING:ocfl.object:### Inventory for v1{
This is inventory should match the example with 3 versions in <https://ocfl.io/1.1/spec/#example-versioned-object>.

```
> python ocfl-object.py --build --src fixtures/1.1/content/spec-ex-full --spec-version 1.1 --id ark:/12345/bcd987 --fixity md5 --fixity sha1 --digest sha512-spec-ex -v
> python ocfl-object.py build --src fixtures/1.1/content/spec-ex-full --spec-version 1.1 --id ark:/12345/bcd987 --fixity md5 --fixity sha1 --digest sha512-spec-ex -v
WARNING:ocfl.object:### Inventory for v1{
"digestAlgorithm": "sha512-spec-ex",
"fixity": {
Expand Down Expand Up @@ -90,7 +90,7 @@ WARNING:ocfl.object:### Inventory for v1{
"type": "https://ocfl.io/1.1/spec/#inventory",
"versions": {
"v1": {
"created": "2024-10-01T12:11:51.675916Z",
"created": "2024-10-11T07:04:27.845344Z",
"state": {
"7dcc352f96c56dc...c31": [
"foo/bar.xml"
Expand Down Expand Up @@ -157,7 +157,7 @@ WARNING:ocfl.object:### Inventory for v2{
"type": "https://ocfl.io/1.1/spec/#inventory",
"versions": {
"v1": {
"created": "2024-10-01T12:11:51.675916Z",
"created": "2024-10-11T07:04:27.845344Z",
"state": {
"7dcc352f96c56dc...c31": [
"foo/bar.xml"
Expand All @@ -171,7 +171,7 @@ WARNING:ocfl.object:### Inventory for v2{
}
},
"v2": {
"created": "2024-10-01T12:11:51.676579Z",
"created": "2024-10-11T07:04:27.846110Z",
"state": {
"4d27c86b026ff70...b53": [
"foo/bar.xml"
Expand Down Expand Up @@ -236,7 +236,7 @@ WARNING:ocfl.object:### Inventory for v3{
"type": "https://ocfl.io/1.1/spec/#inventory",
"versions": {
"v1": {
"created": "2024-10-01T12:11:51.675916Z",
"created": "2024-10-11T07:04:27.845344Z",
"state": {
"7dcc352f96c56dc...c31": [
"foo/bar.xml"
Expand All @@ -250,7 +250,7 @@ WARNING:ocfl.object:### Inventory for v3{
}
},
"v2": {
"created": "2024-10-01T12:11:51.676579Z",
"created": "2024-10-11T07:04:27.846110Z",
"state": {
"4d27c86b026ff70...b53": [
"foo/bar.xml"
Expand All @@ -262,7 +262,7 @@ WARNING:ocfl.object:### Inventory for v3{
}
},
"v3": {
"created": "2024-10-01T12:11:51.677024Z",
"created": "2024-10-11T07:04:27.846566Z",
"state": {
"4d27c86b026ff70...b53": [
"foo/bar.xml"
Expand All @@ -288,7 +288,7 @@ WARNING:ocfl.object:### Inventory for v3{
This is inventory should match the example showing how content paths may differ from logical paths in <https://ocfl.io/1.1/spec/#example-object-diff-paths>.

```
> python ocfl-object.py --build --src fixtures/1.1/content/spec-ex-diff-paths --id http://example.org/diff-paths --spec-version 1.1 --digest sha512-spec-ex --normalization md5 --created 2019-03-14T20:31:00Z -v
> python ocfl-object.py build --src fixtures/1.1/content/spec-ex-diff-paths --id http://example.org/diff-paths --spec-version 1.1 --digest sha512-spec-ex --normalization md5 --created 2019-03-14T20:31:00Z -v
WARNING:ocfl.object:### Inventory for v1{
"digestAlgorithm": "sha512-spec-ex",
"head": "v1",
Expand Down
57 changes: 36 additions & 21 deletions docs/demo_ocfl_object_script.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ocfl-object.py is part of ocfl-py version 1.9.0
Without an `--objdir` argument the script just writes out the inventory for the object that would have been created.

```
> python ocfl-object.py --create --id http://example.org/obj1 --src fixtures/1.0/content/cf1/v1
> python ocfl-object.py create --id http://example.org/obj1 --src fixtures/1.0/content/cf1/v1
WARNING:ocfl.object:### Inventory for v1{
"digestAlgorithm": "sha512",
"head": "v1",
Expand All @@ -34,7 +34,7 @@ WARNING:ocfl.object:### Inventory for v1{
"type": "https://ocfl.io/1.1/spec/#inventory",
"versions": {
"v1": {
"created": "2024-10-01T12:11:52.198398Z",
"created": "2024-10-11T07:04:22.583276Z",
"state": {
"43a43fe8a8a082d3b5343dfaf2fd0c8b8e370675b1f376e92e9994612c33ea255b11298269d72f797399ebb94edeefe53df243643676548f584fb8603ca53a0f": [
"a_file.txt"
Expand All @@ -52,7 +52,7 @@ WARNING:ocfl.object:### Inventory for v1{
Without an `--objdir` argument the script just writes out the inventory for each version in the object that would have been created.

```
> python ocfl-object.py --build --id http://example.org/obj2 --src fixtures/1.0/content/cf3
> python ocfl-object.py build --id http://example.org/obj2 --src fixtures/1.0/content/cf3
WARNING:ocfl.object:### Inventory for v1{
"digestAlgorithm": "sha512",
"head": "v1",
Expand All @@ -65,7 +65,7 @@ WARNING:ocfl.object:### Inventory for v1{
"type": "https://ocfl.io/1.1/spec/#inventory",
"versions": {
"v1": {
"created": "2024-10-01T12:11:52.343080Z",
"created": "2024-10-11T07:04:22.727134Z",
"state": {
"43a43fe8a8a082d3b5343dfaf2fd0c8b8e370675b1f376e92e9994612c33ea255b11298269d72f797399ebb94edeefe53df243643676548f584fb8603ca53a0f": [
"a_file.txt"
Expand All @@ -90,15 +90,15 @@ WARNING:ocfl.object:### Inventory for v2{
"type": "https://ocfl.io/1.1/spec/#inventory",
"versions": {
"v1": {
"created": "2024-10-01T12:11:52.343080Z",
"created": "2024-10-11T07:04:22.727134Z",
"state": {
"43a43fe8a8a082d3b5343dfaf2fd0c8b8e370675b1f376e92e9994612c33ea255b11298269d72f797399ebb94edeefe53df243643676548f584fb8603ca53a0f": [
"a_file.txt"
]
}
},
"v2": {
"created": "2024-10-01T12:11:52.343591Z",
"created": "2024-10-11T07:04:22.727775Z",
"state": {
"296e72b8fd5f7f0ac1473993600ae34953d5dab646f17e7b182b8648aff830d7bf01b56490777cb3e72b33fcc1ae520506badea1032252d1a55fd7362e269975": [
"a_file.txt"
Expand All @@ -123,23 +123,23 @@ WARNING:ocfl.object:### Inventory for v3{
"type": "https://ocfl.io/1.1/spec/#inventory",
"versions": {
"v1": {
"created": "2024-10-01T12:11:52.343080Z",
"created": "2024-10-11T07:04:22.727134Z",
"state": {
"43a43fe8a8a082d3b5343dfaf2fd0c8b8e370675b1f376e92e9994612c33ea255b11298269d72f797399ebb94edeefe53df243643676548f584fb8603ca53a0f": [
"a_file.txt"
]
}
},
"v2": {
"created": "2024-10-01T12:11:52.343591Z",
"created": "2024-10-11T07:04:22.727775Z",
"state": {
"296e72b8fd5f7f0ac1473993600ae34953d5dab646f17e7b182b8648aff830d7bf01b56490777cb3e72b33fcc1ae520506badea1032252d1a55fd7362e269975": [
"a_file.txt"
]
}
},
"v3": {
"created": "2024-10-01T12:11:52.343826Z",
"created": "2024-10-11T07:04:22.728036Z",
"state": {
"43a43fe8a8a082d3b5343dfaf2fd0c8b8e370675b1f376e92e9994612c33ea255b11298269d72f797399ebb94edeefe53df243643676548f584fb8603ca53a0f": [
"a_file.txt"
Expand All @@ -157,7 +157,7 @@ WARNING:ocfl.object:### Inventory for v3{
### 3.1 New object with just v1

```
> python ocfl-object.py --create --id http://example.org/obj1 --src fixtures/1.0/content/cf1/v1 --objdir tmp/obj1 -v
> python ocfl-object.py create --id http://example.org/obj1 --src fixtures/1.0/content/cf1/v1 --objdir tmp/obj1 -v
INFO:ocfl.object:Created OCFL object http://example.org/obj1 in tmp/obj1
```

Expand All @@ -167,7 +167,7 @@ INFO:ocfl.object:Created OCFL object http://example.org/obj1 in tmp/obj1
### 4.1 New object with three versions

```
> python ocfl-object.py --build --id http://example.org/obj2 --src fixtures/1.0/content/cf3 --objdir tmp/obj2 -v
> python ocfl-object.py build --id http://example.org/obj2 --src fixtures/1.0/content/cf3 --objdir tmp/obj2 -v
INFO:ocfl.object:Built object http://example.org/obj2 with 3 versions
```

Expand All @@ -177,7 +177,7 @@ INFO:ocfl.object:Built object http://example.org/obj2 with 3 versions
### 5.1 Extract v1 of an OCFL v1.0 object

```
> python ocfl-object.py --extract v1 --objdir fixtures/1.0/good-objects/spec-ex-full --dstdir tmp/v1 -v
> python ocfl-object.py extract --objver v1 --objdir fixtures/1.0/good-objects/spec-ex-full --dstdir tmp/v1 -v
INFO:ocfl.object:Extracted v1 into tmp/v1
Extracted content for v1 in tmp/v1
```
Expand All @@ -186,12 +186,22 @@ Extracted content for v1 in tmp/v1
### 5.2 Extract v2 of content in the same OCFL v1.1 object

```
> python ocfl-object.py --extract v2 --objdir fixtures/1.1/good-objects/spec-ex-full --dstdir tmp/v2 -v
> python ocfl-object.py extract --objver v2 --objdir fixtures/1.1/good-objects/spec-ex-full --dstdir tmp/v2 -v
INFO:ocfl.object:Extracted v2 into tmp/v2
Extracted content for v2 in tmp/v2
```


### 5.3 Extract head version (v3) of content in the same OCFL v1.1 object

```
> python ocfl-object.py extract --objver head --objdir fixtures/1.1/good-objects/spec-ex-full --dstdir tmp/head -v
INFO:ocfl.object:Object at fixtures/1.1/good-objects/spec-ex-full has head v3
INFO:ocfl.object:Extracted v3 into tmp/head
Extracted content for v3 in tmp/head
```


## 6. Test error conditions.

### 6.1 No valid command argument
Expand All @@ -200,32 +210,37 @@ With no argument and error and suggections are shown.

```
> python ocfl-object.py
Error - Exactly one command (create, build, update, show, validate, extract) must be specified
ERROR:root:No command, nothing to do (use -h to show help)
```

(last command exited with return code 1)


### 6.2 No source directory (--srcdir)

The `--create` action requires a source.
The `create` command requires a source.

```
> python ocfl-object.py --create
Error - Must specify either --srcdir or --srcbag containing v1 files when creating an OCFL object!
> python ocfl-object.py create --objdir TMP/v1
ERROR:root:Must specify either --srcdir or --srcbag containing v1 files when creating an OCFL object!
```

(last command exited with return code 1)


### 6.3 No identifier

The `--create` action requires an identifier.
The `show` command requires --objdir.

```
> python ocfl-object.py --create --srcdir tmp
Error - Identifier is not set!
> python ocfl-object.py show --srcdir tmp
usage: ocfl-object.py show [-h] [--verbose] [--debug] [--quiet] --objdir
OBJDIR [--spec-version SPEC_VERSION]
[--digest DIGEST] [--fixity FIXITY] [--id ID]
[--skip SKIP] [--normalization NORMALIZATION]
[--no-forward-delta] [--no-dedupe] [--lax-digests]
ocfl-object.py show: error: the following arguments are required: --objdir/--obj
```

(last command exited with return code 1)
(last command exited with return code 2)

Loading

0 comments on commit 350d9e4

Please sign in to comment.