Skip to content

Commit

Permalink
Merge pull request #107 from ascmitc/committeeDraft_0.10
Browse files Browse the repository at this point in the history
Duplicate of PR #106 (aka "committee draft 0.10")
  • Loading branch information
ptrpfn committed Dec 15, 2021
2 parents 1e12c21 + e70b1d6 commit f767194
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 43 deletions.
3 changes: 2 additions & 1 deletion ascmhl/hashlist_xml_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ def _media_hash_xml_element(media_hash: MHLMediaHash):
path_element.attrib["lastmodificationdate"] = datetime_isostring(media_hash.last_modification_date)

hash_element = E.hash(path_element)
for hash_entry in media_hash.hash_entries:
sorted_hash_entries = sorted(media_hash.hash_entries, key=lambda hash_entry: hash_entry.hash_format)
for hash_entry in sorted_hash_entries:
entry_element = E(hash_entry.hash_format)
entry_element.text = hash_entry.hash_string
if hash_entry.action:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
<hashes>
<hash>
<path size="5" lastmodificationdate="2020-01-15T13:00:00+00:00">Clips/A002C006_141024_R2EC.mov</path>
<xxh64 action="verified" hashdate="2020-01-17T14:30:00+00:00">0ea03b369a463d9d</xxh64>
<md5 action="verified" hashdate="2020-01-17T14:30:00+00:00">f5ac8127b3b6b85cdc13f237c6005d80</md5>
<xxh64 action="verified" hashdate="2020-01-17T14:30:00+00:00">0ea03b369a463d9d</xxh64>
</hash>
<hash>
<path size="4" lastmodificationdate="2020-01-15T13:00:00+00:00">Clips/A002C007_141024_R2EC.mov</path>
<xxh64 action="verified" hashdate="2020-01-17T14:30:00+00:00">7680e5f98f4a80fd</xxh64>
<md5 action="verified" hashdate="2020-01-17T14:30:00+00:00">614dd0e977becb4c6f7fa99e64549b12</md5>
<xxh64 action="verified" hashdate="2020-01-17T14:30:00+00:00">7680e5f98f4a80fd</xxh64>
</hash>
<directoryhash>
<path lastmodificationdate="2020-01-15T13:00:00+00:00">Clips</path>
Expand All @@ -43,8 +43,8 @@
</directoryhash>
<hash>
<path size="58" lastmodificationdate="2020-01-15T13:00:00+00:00">Sidecar.txt</path>
<xxh64 action="verified" hashdate="2020-01-17T14:30:00+00:00">3ab5a4166b9bde44</xxh64>
<md5 action="verified" hashdate="2020-01-17T14:30:00+00:00">6425c5a180ca0f420dd2b25be4536a91</md5>
<xxh64 action="verified" hashdate="2020-01-17T14:30:00+00:00">3ab5a4166b9bde44</xxh64>
</hash>
</hashes>
</hashlist>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
</hashlist>
<hashlist sequencer="2">
<path>0002_A002R2EC_2020-01-17_143000.mhl</path>
<c4>c44nGYPw4hL2B9fKCixmtum59qhLxzRCeczuewyQR5hXCs4nnf5oD3T79aBi3KfbpZrnfCk41t7C6k6Ya1cAezEt8D</c4>
<c4>c422u4PnnuStBK5Q9Wv4uFHagkFaK9AfZNcM4nbXuCKWTUikSWWfeeszSUnM2omfCoKnsZHJZNptSBZsumZMJy6Woy</c4>
</hashlist>
</ascmhldirectory>
12 changes: 6 additions & 6 deletions tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,10 @@ def test_create_nested_new_format(fs, nested_mhl_histories):
nested_history = MHLHistory.load_from_path("/root/A/AA")
media_hash = nested_history.hash_lists[-1].media_hashes[0]

# assure that the first hash entry is the verification of the original hash
assert media_hash.hash_entries[0].action == "verified"
assert media_hash.hash_entries[0].hash_format == "xxh64"
# assure that there is a hash entry for the verification of the original hash (hash formats are sorted alphabetically)

# assure that the second hash entry is the new md5 hash
assert media_hash.hash_entries[1].action == "verified" # formerly 'new'
assert media_hash.hash_entries[1].hash_format == "md5"
assert media_hash.hash_entries[0].action == "verified" # formerly 'new'
assert media_hash.hash_entries[0].hash_format == "md5"

assert media_hash.hash_entries[1].action == "verified"
assert media_hash.hash_entries[1].hash_format == "xxh64"
20 changes: 11 additions & 9 deletions tests/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ def test_info(fs, simple_mhl_history):
result = runner.invoke(ascmhl.commands.info, ["-sf", "/root/Stuff.txt"])
assert (
result.output
== "Info with history at path: /root\nStuff.txt:\n Generation 1 (2020-01-15T13:00:00+00:00) xxh64:"
" 94c399c2a9a21f9a (original)\n Generation 2 (2020-01-16T09:15:00+00:00) xxh64: 94c399c2a9a21f9a"
" (verified)\n Generation 3 (2020-01-16T09:15:00+00:00) xxh64: 94c399c2a9a21f9a (verified)\n Generation 3"
" (2020-01-16T09:15:00+00:00) md5: 9eb84090956c484e32cb6c08455a667b (verified)\n Generation 4"
" (2020-01-16T09:15:00+00:00) xxh64: 94c399c2a9a21f9a (verified)\n"
== "Info with history at path: /root\nStuff.txt:\n"
" Generation 1 (2020-01-15T13:00:00+00:00) xxh64: 94c399c2a9a21f9a (original)\n"
" Generation 2 (2020-01-16T09:15:00+00:00) xxh64: 94c399c2a9a21f9a (verified)\n"
" Generation 3 (2020-01-16T09:15:00+00:00) md5: 9eb84090956c484e32cb6c08455a667b (verified)\n"
" Generation 3 (2020-01-16T09:15:00+00:00) xxh64: 94c399c2a9a21f9a (verified)\n"
" Generation 4 (2020-01-16T09:15:00+00:00) xxh64: 94c399c2a9a21f9a (verified)\n"
)
assert result.exit_code == 0

Expand Down Expand Up @@ -80,9 +81,10 @@ def test_nested_info(fs, nested_mhl_histories):
result = runner.invoke(ascmhl.commands.info, ["-sf", "/root/Stuff.txt"])
assert (
result.output
== "Info with history at path: /root\nStuff.txt:\n Generation 1 (2020-01-15T13:00:00+00:00) xxh64:"
" 94c399c2a9a21f9a (original)\n Generation 2 (2020-01-16T09:15:00+00:00) xxh64: 94c399c2a9a21f9a"
" (verified)\n Generation 3 (2020-01-16T09:15:00+00:00) xxh64: 94c399c2a9a21f9a (verified)\n Generation 3"
" (2020-01-16T09:15:00+00:00) md5: 9eb84090956c484e32cb6c08455a667b (verified)\n"
== "Info with history at path: /root\nStuff.txt:\n"
" Generation 1 (2020-01-15T13:00:00+00:00) xxh64: 94c399c2a9a21f9a (original)\n"
" Generation 2 (2020-01-16T09:15:00+00:00) xxh64: 94c399c2a9a21f9a (verified)\n"
" Generation 3 (2020-01-16T09:15:00+00:00) md5: 9eb84090956c484e32cb6c08455a667b (verified)\n"
" Generation 3 (2020-01-16T09:15:00+00:00) xxh64: 94c399c2a9a21f9a (verified)\n"
)
assert result.exit_code == 0
31 changes: 15 additions & 16 deletions xsd/ASCMHL.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
</complexType>
<complexType name="HashesType">
<choice minOccurs="1" maxOccurs="unbounded">
<element name="hash" type="ascmhl:HashType" maxOccurs="unbounded"/>
<element name="hash" type="ascmhl:HashType"/>
<element name="directoryhash" type="ascmhl:DirectoryHashType"/>
</choice>
</complexType>
Expand All @@ -92,15 +92,14 @@
</simpleContent>
</complexType>
</element>
<choice maxOccurs="unbounded">
<sequence>
<element name="c4" type="ascmhl:HashFormatType" minOccurs="0"/>
<element name="md5" type="ascmhl:HashFormatType" minOccurs="0"/>
<element name="sha1" type="ascmhl:HashFormatType" minOccurs="0"/>
<element name="c4" type="ascmhl:HashFormatType" minOccurs="0"/>
<element name="xxh32" type="ascmhl:HashFormatType" maxOccurs="1" minOccurs="0"/>
<element name="xxh64" type="ascmhl:HashFormatType" maxOccurs="1" minOccurs="0"/>
<element name="xxh3" type="ascmhl:HashFormatType" maxOccurs="1" minOccurs="0"/>
<element name="xxh128" type="ascmhl:HashFormatType" maxOccurs="1" minOccurs="0"/>
</choice>
<element name="xxh128" type="ascmhl:HashFormatType" minOccurs="0"/>
<element name="xxh3" type="ascmhl:HashFormatType" minOccurs="0"/>
<element name="xxh64" type="ascmhl:HashFormatType" minOccurs="0"/>
</sequence>
<element name="previousPath" type="ascmhl:RelativePathType" minOccurs="0"/>
<element minOccurs="0" name="metadata" type="ascmhl:MetadataType"/>
</sequence>
Expand Down Expand Up @@ -139,14 +138,14 @@
</simpleContent>
</complexType>
<complexType name="DirectoryHashFormatContainerType">
<choice minOccurs="1" maxOccurs="unbounded">
<element name="md5" type="ascmhl:HashFormatType"/>
<element name="sha1" type="ascmhl:HashFormatType"/>
<element name="c4" type="ascmhl:HashFormatType"/>
<element name="xxh3" type="ascmhl:HashFormatType"/>
<element name="xxh64" type="ascmhl:HashFormatType"/>
<element name="xxh128" type="ascmhl:HashFormatType"/>
</choice>
<sequence>
<element name="c4" type="ascmhl:HashFormatType" minOccurs="0"/>
<element name="md5" type="ascmhl:HashFormatType" minOccurs="0"/>
<element name="sha1" type="ascmhl:HashFormatType" minOccurs="0"/>
<element name="xxh128" type="ascmhl:HashFormatType" minOccurs="0"/>
<element name="xxh3" type="ascmhl:HashFormatType" minOccurs="0"/>
<element name="xxh64" type="ascmhl:HashFormatType" minOccurs="0"/>
</sequence>
</complexType>
<complexType name="ReferencesType">
<sequence>
Expand Down
17 changes: 10 additions & 7 deletions xsd/examples/0001_TEST01_2019-10-11_155603.mhl
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,21 @@
<path size="5" lastmodificationdate="2019-10-11T15:56:03+02:00">Clips/A002C007_141024_R2EC.mov</path>
<xxh64 action="original">7680e5f98f4a80fd</xxh64>
</hash>
<directoryhash>
<path lastmodificationdate="2019-10-11T15:56:01+02:00">Clips/</path>
<content>
<xxh64>7680e5f98f4a80fd</xxh64>
</content>
<metadata>test2</metadata>
</directoryhash>
<hash>
<path size="58" lastmodificationdate="2019-10-11T15:56:03+02:00">Sidecar.txt</path>
<xxh64 action="failed">3ab5a4166b9bde44</xxh64>
<metadata bar="Foo" />
</hash>
<directoryhash>
<path lastmodificationdate="2019-10-11T15:56:01+02:00">Clips/</path>
<content>
<xxh64>7680e5f98f4a80fd</xxh64>
</content>
<structure>
<xxh64>8f4a80fd7680e5f9</xxh64>
</structure>
<metadata>test2</metadata>
</directoryhash>
</hashes>
<metadata>
test
Expand Down

0 comments on commit f767194

Please sign in to comment.