Skip to content

Commit

Permalink
Merge branch 'add-inventory-class' of github.com:zimeon/ocfl-py into …
Browse files Browse the repository at this point in the history
…add-inventory-class
  • Loading branch information
zimeon committed Nov 1, 2024
2 parents d2d3961 + 405917d commit 096b53a
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 147 deletions.
29 changes: 22 additions & 7 deletions docs/demo_build_v1_0_spec_examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ _Output from `tests/test_demo_build_spec_v1_0_examples.py`._
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 create --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
### Inventory for v1
{
"digestAlgorithm": "sha512-spec-ex",
"head": "v1",
"id": "http://example.org/minimal",
"manifest": {
"7545b8720a60123...f67": [
"v1/content/file.txt"
"v1/content/v1/file.txt"
]
},
"type": "https://ocfl.io/1.0/spec/#inventory",
Expand All @@ -27,7 +27,7 @@ The digest type sha512-spec-ex is sha512 with most of the content stripped out a
"message": "One file",
"state": {
"7545b8720a60123...f67": [
"file.txt"
"v1/file.txt"
]
},
"user": {
Expand All @@ -47,7 +47,7 @@ The digest type sha512-spec-ex is sha512 with most of the content stripped out a
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 --created 2018-01-01T01:01:01Z -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 --metadata extra_fixtures/1.0/content/spec-ex-full-metadata.json -v
### Inventory for v3
{
"digestAlgorithm": "sha512-spec-ex",
Expand Down Expand Up @@ -101,6 +101,7 @@ This is inventory should match the example with 3 versions in <https://ocfl.io/1
"versions": {
"v1": {
"created": "2018-01-01T01:01:01Z",
"message": "Initial import",
"state": {
"7dcc352f96c56dc...c31": [
"foo/bar.xml"
Expand All @@ -111,10 +112,15 @@ This is inventory should match the example with 3 versions in <https://ocfl.io/1
"ffccf6baa218097...62e": [
"image.tiff"
]
},
"user": {
"address": "[email protected]",
"name": "Alice"
}
},
"v2": {
"created": "2018-01-01T01:01:01Z",
"created": "2018-02-02T02:02:02Z",
"message": "Fix bar.xml, remove image.tiff, add empty2.txt",
"state": {
"4d27c86b026ff70...b53": [
"foo/bar.xml"
Expand All @@ -123,10 +129,15 @@ This is inventory should match the example with 3 versions in <https://ocfl.io/1
"empty.txt",
"empty2.txt"
]
},
"user": {
"address": "[email protected]",
"name": "Bob"
}
},
"v3": {
"created": "2018-01-01T01:01:01Z",
"created": "2018-03-03T03:03:03Z",
"message": "Reinstate image.tiff, delete empty.txt",
"state": {
"4d27c86b026ff70...b53": [
"foo/bar.xml"
Expand All @@ -137,6 +148,10 @@ This is inventory should match the example with 3 versions in <https://ocfl.io/1
"ffccf6baa218097...62e": [
"image.tiff"
]
},
"user": {
"address": "[email protected]",
"name": "Cecilia"
}
}
}
Expand All @@ -151,7 +166,7 @@ This is inventory should match the example with 3 versions in <https://ocfl.io/1
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 create --src fixtures/1.0/content/spec-ex-diff-paths/v1 --id http://example.org/diff-paths --spec-version 1.0 --digest sha512-spec-ex --normalization md5 --created 2019-03-14T20:31:00Z -v
### Inventory for v1
{
"digestAlgorithm": "sha512-spec-ex",
Expand Down
33 changes: 24 additions & 9 deletions docs/demo_build_v1_1_spec_examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ _Output from `tests/test_demo_build_spec_v1_1_examples.py`._
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 create --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
### Inventory for v1
{
"digestAlgorithm": "sha512-spec-ex",
"head": "v1",
"id": "http://example.org/minimal",
"manifest": {
"7545b8720a60123...f67": [
"v1/content/file.txt"
"v1/content/v1/file.txt"
]
},
"type": "https://ocfl.io/1.1/spec/#inventory",
Expand All @@ -27,7 +27,7 @@ The digest type sha512-spec-ex is sha512 with most of the content stripped out a
"message": "One file",
"state": {
"7545b8720a60123...f67": [
"file.txt"
"v1/file.txt"
]
},
"user": {
Expand All @@ -47,7 +47,7 @@ The digest type sha512-spec-ex is sha512 with most of the content stripped out a
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 --metadata extra_fixtures/1.1/content/spec-ex-full-metadata.json -v
### Inventory for v3
{
"digestAlgorithm": "sha512-spec-ex",
Expand Down Expand Up @@ -100,7 +100,8 @@ This is inventory should match the example with 3 versions in <https://ocfl.io/1
"type": "https://ocfl.io/1.1/spec/#inventory",
"versions": {
"v1": {
"created": "2024-10-27T09:46:44.539504Z",
"created": "2018-01-01T01:01:01Z",
"message": "Initial import",
"state": {
"7dcc352f96c56dc...c31": [
"foo/bar.xml"
Expand All @@ -111,10 +112,15 @@ This is inventory should match the example with 3 versions in <https://ocfl.io/1
"ffccf6baa218097...62e": [
"image.tiff"
]
},
"user": {
"address": "[email protected]",
"name": "Alice"
}
},
"v2": {
"created": "2024-10-27T09:46:44.540128Z",
"created": "2018-02-02T02:02:02Z",
"message": "Fix bar.xml, remove image.tiff, add empty2.txt",
"state": {
"4d27c86b026ff70...b53": [
"foo/bar.xml"
Expand All @@ -123,10 +129,15 @@ This is inventory should match the example with 3 versions in <https://ocfl.io/1
"empty.txt",
"empty2.txt"
]
},
"user": {
"address": "[email protected]",
"name": "Bob"
}
},
"v3": {
"created": "2024-10-27T09:46:44.540482Z",
"created": "2018-03-03T03:03:03Z",
"message": "Reinstate image.tiff, delete empty.txt",
"state": {
"4d27c86b026ff70...b53": [
"foo/bar.xml"
Expand All @@ -137,6 +148,10 @@ This is inventory should match the example with 3 versions in <https://ocfl.io/1
"ffccf6baa218097...62e": [
"image.tiff"
]
},
"user": {
"address": "[email protected]",
"name": "Cecilia"
}
}
}
Expand All @@ -151,12 +166,12 @@ This is inventory should match the example with 3 versions in <https://ocfl.io/1
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 create --src fixtures/1.1/content/spec-ex-diff-paths/v1 --id http://example.org/diff-paths/v1 --spec-version 1.1 --digest sha512-spec-ex --normalization md5 --created 2019-03-14T20:31:00Z -v
### Inventory for v1
{
"digestAlgorithm": "sha512-spec-ex",
"head": "v1",
"id": "http://example.org/diff-paths",
"id": "http://example.org/diff-paths/v1",
"manifest": {
"7545b8720a60123...f67": [
"v1/content/3bacb119a98a15c5"
Expand Down
54 changes: 33 additions & 21 deletions docs/demo_ocfl_object_script.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Without an `--objdir` argument the script just writes out the inventory for the
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 --created 2024-10-24T18:30:02Z
> python ocfl-object.py build --id http://example.org/obj2 --src fixtures/1.0/content/cf3 --metadata extra_fixtures/1.0/content/spec-ex-full-metadata.json
### Inventory for v3
{
"digestAlgorithm": "sha512",
Expand All @@ -69,27 +69,42 @@ Without an `--objdir` argument the script just writes out the inventory for each
"type": "https://ocfl.io/1.1/spec/#inventory",
"versions": {
"v1": {
"created": "2024-10-24T18:30:02Z",
"created": "2018-01-01T01:01:01Z",
"message": "Initial import",
"state": {
"43a43fe8a8a082d3b5343dfaf2fd0c8b8e370675b1f376e92e9994612c33ea255b11298269d72f797399ebb94edeefe53df243643676548f584fb8603ca53a0f": [
"a_file.txt"
]
},
"user": {
"address": "[email protected]",
"name": "Alice"
}
},
"v2": {
"created": "2024-10-24T18:30:02Z",
"created": "2018-02-02T02:02:02Z",
"message": "Fix bar.xml, remove image.tiff, add empty2.txt",
"state": {
"296e72b8fd5f7f0ac1473993600ae34953d5dab646f17e7b182b8648aff830d7bf01b56490777cb3e72b33fcc1ae520506badea1032252d1a55fd7362e269975": [
"a_file.txt"
]
},
"user": {
"address": "[email protected]",
"name": "Bob"
}
},
"v3": {
"created": "2024-10-24T18:30:02Z",
"created": "2018-03-03T03:03:03Z",
"message": "Reinstate image.tiff, delete empty.txt",
"state": {
"43a43fe8a8a082d3b5343dfaf2fd0c8b8e370675b1f376e92e9994612c33ea255b11298269d72f797399ebb94edeefe53df243643676548f584fb8603ca53a0f": [
"a_file.txt"
]
},
"user": {
"address": "[email protected]",
"name": "Cecilia"
}
}
}
Expand All @@ -112,7 +127,7 @@ INFO:root: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 --created 2024-10-24T18:30:04Z,-v
> python ocfl-object.py build --id http://example.org/obj2 --src fixtures/1.0/content/cf3 --objdir tmp/obj2 -v
INFO:root:Built object http://example.org/obj2 at tmp/obj2 with 3 versions
```

Expand All @@ -133,13 +148,11 @@ and the extracted files are:

```
> find -s tmp/v1 -print
tmp/v1
tmp/v1/empty.txt
tmp/v1/foo
tmp/v1/foo/bar.xml
tmp/v1/image.tiff
find: unknown predicate `-s'
```

(last command exited with return code 1)


### 5.2 Extract v2 of content in an OCFL v1.1 object

Expand All @@ -153,13 +166,11 @@ and the extracted files are:

```
> find -s tmp/v2 -print
tmp/v2
tmp/v2/empty.txt
tmp/v2/empty2.txt
tmp/v2/foo
tmp/v2/foo/bar.xml
find: unknown predicate `-s'
```

(last command exited with return code 1)


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

Expand All @@ -173,7 +184,7 @@ and the extracted files are:

```
> find -s tmp/v3 -print
find: tmp/v3: No such file or directory
find: unknown predicate `-s'
```

(last command exited with return code 1)
Expand All @@ -190,10 +201,11 @@ and the extracted file is:

```
> find -s tmp/files -print
tmp/files
tmp/files/bar.xml
find: unknown predicate `-s'
```

(last command exited with return code 1)


### 5.5 Extract image.tiff of v3 (default) into the same directory

Expand All @@ -206,11 +218,11 @@ and the directory now contains two extracted files:

```
> find -s tmp/files -print
tmp/files
tmp/files/bar.xml
tmp/files/image.tiff
find: unknown predicate `-s'
```

(last command exited with return code 1)


## 6. Test error conditions.

Expand Down
2 changes: 1 addition & 1 deletion docs/demo_ocfl_script.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ ERROR:root:Add object failed because path ark%3A123%2Fabc exists

```
> python ocfl.py list --root=extra_fixtures/good-storage-roots/simple-root
http%3A%2F%2Fexample.org%2Fminimal_mixed_digests -- id=http://example.org/minimal_mixed_digests
ark%3A123%2Fabc -- id=ark:123/abc
http%3A%2F%2Fexample.org%2Fminimal_mixed_digests -- id=http://example.org/minimal_mixed_digests
ark%3A%2F12345%2Fbcd987 -- id=ark:/12345/bcd987
Found 3 OCFL Objects under root extra_fixtures/good-storage-roots/simple-root
```
Expand Down
Loading

0 comments on commit 096b53a

Please sign in to comment.