This commit is contained in:
Amber 2024-11-18 10:27:53 +01:00
parent 6c40853513
commit f38ef1bfff
2 changed files with 47 additions and 10 deletions

View File

@ -1,15 +1,16 @@
import os
def recursive_raw_diff(tree_a, tree_b, tree_a_tag, tree_b_tag, path, res):
a_keys_not_in_b = set(tree_a.keys()) - set(tree_b.keys())
# a_keys_not_in_b = set(tree_a.keys()) - set(tree_b.keys())
# b_keys_not_in_a = set(tree_b.keys()) - set(tree_a.keys())
## name last is a dir
if a_keys_not_in_b:
for key in a_keys_not_in_b:
print(f'node {path}{key} subtree added in {tree_a_tag}')
res[f'{path}{key}'] = {
tree_a_tag : 'x',
}
# manage below
# if a_keys_not_in_b:
# for key in a_keys_not_in_b:
# print(f'node {path}{key} subtree added in {tree_a_tag}')
# res[f'{path}{key}'] = {
# tree_a_tag : 'x',
# }
for key_a, hsh_a in tree_a.items():
hsh_b = tree_b.get(key_a)
@ -18,6 +19,9 @@ def recursive_raw_diff(tree_a, tree_b, tree_a_tag, tree_b_tag, path, res):
'''
already in `a_keys_not_in_b`
'''
res[f'{path}{key_a}'] = {
tree_a_tag : 'x',
}
continue

View File

@ -2,10 +2,43 @@ from lib.snapshot import diff
tree_a = {'taglioCapelli4.jpg': '5af62402ec7716e8d729b0683061f0c4', 'taglioCapelli5.jpg': '9c42961af589a279c4c828925291153b', 'pino.txt': 'd41d8cd98f00b204e9800998ecf8427e', 'taglioCapelli6.jpg': '4059905eab817c33ee48f912af80fdb7', 'spartiti_sepu': {'amber.py': 'a6ef147511264ecdc7d6061979892c44', 'bo.txt': 'd7aa6cbc6aa0ace3225ee1738b2d5c6b', 'ciao': {'amber.py': 'a6ef147511264ecdc7d6061979892c44', 'bo.txt': 'd7aa6cbc6aa0ace3225ee1738b2d5c6b'},'added_folder': {}}, 'preferiti.txt': 'af45981ef2be534dbb37f96833d3fd04'}
tree_b = {'taglioCapelli4.jpg': '5af62402ec7716e8d729b0683061f0c4', 'taglioCapelli5.jpg': '9c42961af589a279c4c828925291153b', 'pino.txt': 'd41d8cd98f00b204e9800998ecf8427e', 'taglioCapelli6.jpg': '4059905eab817c33ee48f912af80fdb7', 'spartiti_sepu': {'amber.py': 'a6ef147511264ecdc7d6061979892c44', 'bo.txt': 'd7aa6cbc6aa0ace3225ee1738b2d5c6b', 'added_folder': {'preferiti.txt' : 'af45981ef2be534dbb37f96833d3fd03'}}, 'preferiti.txt': 'af45981ef2be534dbb37f9fffffffff'}
tree_a = {
"taglioCapelli4.jpg": "5af62402ec7716e8d729b0683061f0c4",
"taglioCapelli5.jpg": "9c42961af589a279c4c828925291153b",
"pino.txt": "d41d8cd98f00b204e9800998ecf8427e",
"taglioCapelli6.jpg": "4059905eab817c33ee48f912af80fdb7",
"spartiti_sepu": {
"amber.py": "a6ef147511264ecdc7d6061979892c44",
"bo.txt": "d7aa6cbc6aa0ace3225ee1738b2d5c6b",
"ciao": {
"amber.py": "a6ef147511264ecdc7d6061979892c44",
"bo.txt": "d7aa6cbc6aa0ace3225ee1738b2d5c6b"
},
"added_folder": {}
},
"preferiti.txt": "af45981ef2be534dbb37f96833d3fd04"
}
tree_b = {
"taglioCapelli4.jpg": "5af62402ec7716e8d729b0683061f0c4",
"taglioCapelli5.jpg": "9c42961af589a279c4c828925291153b",
# "pino.txt": "d41d8cd98f00b204e9800998ecf8427e",
"pino" : {
"a" : {
},
"c" : {"5af62402ec7716e8d729b068fasdf"},
"d" : {"1234f02ec7716e8d729b068fasdf"},
},
"taglioCapelli6.jpg": "4059905eab817c33ee48f912af80fdb7",
"spartiti_sepu": {
"amber.py": "a6ef147511264ecdc7d6061979892c44",
"bo.txt": "d7aa6cbc6aa0ace3225ee1738b2d5c6b",
"added_folder": {
"preferiti.txt": "af45981ef2be534dbb37f96833d3fd03"
}
},
"preferiti.txt": "af45981ef2be534dbb37f9fffffffff"
}
def test_raw_diff():