Skip to content

Commit

Permalink
Merge fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zimeon committed Nov 3, 2024
2 parents 3d28708 + 8596b99 commit d6879c9
Show file tree
Hide file tree
Showing 60 changed files with 3,103 additions and 1,898 deletions.
4 changes: 3 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

## 2024-XX-XX v2.0.0

* SIGNIFICANT REWORKING to align better with specification language and approach. Includes refactoring, command line tool changes, and API changes.
* SIGNIFICANTLY REWRITTEN AND REFACTORED to align better with the specification language and approach. Includes refactoring, command line tool changes, and many API changes. The InventoryValidator class is relatively unchanged, however
* Improved docstrings in many places
* Change from "1.0" to "1.1" as default specification version
* Adjust for removed `E023_missing_file` fixture (https://github.com/OCFL/fixtures/pull/99)
* Add note of specification version number in validation output
* Ignore `logs` directory if present in object root (extra fixture https://github.com/OCFL/fixtures/issues/108)
* Changed Object.show() method to Object.tree() that returns string
* Change validator to use `force_spec_version` to validate against a specific version and remove old `extract_spec_version` with that becoming the default behavior unless force is specified
* Code style change to use double quotes for strings unless there is a good reason to use single quotes
* Drop Python 3.6 and 3.7 from testing, add 3.11

## 2022-04-26 v1.3.0
Expand Down
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ If submitting a pull request:
* [Checks already implemented in `pycodestyle` and `pydocstyle`](http://pylint.pycqa.org/en/latest/faq.html#i-am-using-another-popular-linter-alongside-pylint-which-messages-should-i-disable-to-avoid-duplicates)
* A FIXME doesn't generate and error, but please avoid anyway (W0511)
* See `.github/workflows/action.yml` for current exclusions
* Please don't repeat code
* Other style choices not enforced:
* Use double quotes (") and triple-double quotes (""") for strings unless
there is reason to avoid having to quote these inside
* Please don't repeat code
* Please cover the code with tests
26 changes: 18 additions & 8 deletions compactify_spec_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,27 @@
Takes the long digests and replaces them with first 6 characters,
an ellipsis, and then the last 6 characters. Input from stdin
and output to stdout.
Typical usage:
> cat example.json | ./compactify_spec_examples.py > example_comp.json
"""
import re
import sys

txt = sys.stdin.read()

txt = re.sub(r'''sha512-spec-ex''', 'sha512', txt)
txt = re.sub(r'''"([\da-f]{6})([\da-f]{119})([\da-f]{3})"''', r'''"\1...\3"''', txt)
txt = re.sub(r'''\s+\[\s+"''', ' [ "', txt, flags=re.MULTILINE)
txt = re.sub(r'''"\s+\](\s+)}(,)?''', r'''" ]\1}\2''', txt, flags=re.MULTILINE)
txt = re.sub(r'''\s+],''', ' ],', txt, flags=re.MULTILINE)
txt = re.sub(r'''(\[[^\n,\]]+,)\s+''', r'''\1 ''', txt, flags=re.MULTILINE)
def compactify():
"""Read from stdin and return compactified example to stdout."""
txt = sys.stdin.read()
#
txt = re.sub(r'''sha512-spec-ex''', 'sha512', txt)
txt = re.sub(r'''"([\da-f]{6})([\da-f]{119})([\da-f]{3})"''', r'''"\1...\3"''', txt)
txt = re.sub(r'''\s+\[\s+"''', ' [ "', txt, flags=re.MULTILINE)
txt = re.sub(r'''"\s+\](\s+)}(,)?''', r'''" ]\1}\2''', txt, flags=re.MULTILINE)
txt = re.sub(r'''\s+],''', ' ],', txt, flags=re.MULTILINE)
txt = re.sub(r'''(\[[^\n,\]]+,)\s+''', r'''\1 ''', txt, flags=re.MULTILINE)
#
print(txt)


print(txt)
if __name__ == "__main__":
compactify()
31 changes: 23 additions & 8 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 -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 @@ -100,7 +100,8 @@ This is inventory should match the example with 3 versions in <https://ocfl.io/1
"type": "https://ocfl.io/1.0/spec/#inventory",
"versions": {
"v1": {
"created": "2024-10-24T18:30:33.138005Z",
"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-24T18:30:33.138439Z",
"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-24T18:30:33.138771Z",
"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-24T18:30:33.910644Z",
"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-24T18:30:33.911054Z",
"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-24T18:30:33.911365Z",
"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
Loading

0 comments on commit d6879c9

Please sign in to comment.