Last active
March 25, 2021 02:33
-
-
Save Neradoc/68bf1e61932663e98f91101fee2393cc to your computer and use it in GitHub Desktop.
Compare `files.json` files generated by Circuitpython `build_board_info.py`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
liste = set() | |
def print_once(text): | |
global liste | |
if text not in liste: | |
liste.add(text) | |
print(text) | |
def compare_files(oldfile_name,newfile_name): | |
with open(f"{oldfile_name}.json","r") as p1,\ | |
open(f"{newfile_name}.json","r") as p2: | |
oldfile = json.load(p1) | |
newfile = json.load(p2) | |
print(oldfile_name,len(oldfile),newfile_name,len(newfile)) | |
language_differences = 0 | |
index = 0 | |
for board in newfile: | |
id = board['id'] | |
#print(board['id']) | |
#print(board) | |
for fboard in oldfile: | |
if fboard['id'] == id: | |
break | |
else: | |
print("Board disappeared:",id) | |
continue | |
# print("compare boards") | |
assert board.keys() == fboard.keys() | |
# ignore downloads | |
versions = board['versions'] | |
fversions = fboard['versions'] | |
vv = [v['version'] for v in versions] | |
fv = [v['version'] for v in fversions] | |
if len(versions) != len(fversions): | |
print(id) | |
print(fv,vv) | |
for version in versions: | |
for fversion in fversions: | |
if fversion['version'] == version['version']: | |
break | |
else: | |
print("No version found for "+version['version']) | |
continue | |
assert fversion['extensions'] == version['extensions'] | |
assert fversion['stable'] == version['stable'] | |
diff_modules = set(fversion['modules']) ^ set(version['modules']) | |
diff_languages = set(fversion['languages']) ^ set(version['languages']) | |
if len(diff_modules) > 0: | |
print_once(id) | |
print("\t",diff_modules) | |
if len(diff_languages) > 0: | |
if len(diff_languages - {'hi', 'ko', 'cs', 'en_GB', 'el'}) > 0: | |
print_once(id) | |
print("\t",diff_languages) | |
else: | |
language_differences += 1 | |
for board in oldfile: | |
for fboard in oldfile: | |
if fboard['id'] == id: | |
break | |
else: | |
print("New board:",id) | |
continue | |
print(f" language updates: {language_differences}") | |
""" | |
RELEASE_TAG=6.2.0-beta.4 python3 build_board_info.py > test_beta4.json | |
""" | |
compare_files("main_one", "test_latest_one") | |
compare_files("main_beta4", "test_beta4") | |
compare_files("main_beta5", "test_beta5") | |
compare_files("main_630", "test_630") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment