<reponame>freight-trust/releases<filename>software-manifests/translatedata.py
import json  # Base library
from xml.dom import minidom

from anytree import RenderTree  # pip3 install anytree
from anytree.importer import DictImporter
from anytree.importer import JsonImporter
from sbomify.sbomlibrary import SbomLibrary

tree = {}

with open("out.json", "r") as f:
    baseimporter = DictImporter(nodecls=SbomLibrary)
    importer = JsonImporter(dictimporter=baseimporter)
    tree = importer.read(f)

tree

# print(RenderTree(tree))
thestr = tree.toSWID()
print(thestr)
# reparsed = minidom.parseString(thestr)
# print(reparsed.toprettyxml(indent="  "))

import json  # Base library
from xml.dom import minidom

from anytree import RenderTree  # pip3 install anytree
from anytree.importer import DictImporter
from anytree.importer import JsonImporter
from sbomify.sbomlibrary import SbomLibrary

tree = {}

with open("out.json", "r") as f:
    baseimporter = DictImporter(nodecls=SbomLibrary)
    importer = JsonImporter(dictimporter=baseimporter)
    tree = importer.read(f)

tree

# print(RenderTree(tree))
thestr = tree.toSWID()
print(thestr)
# reparsed = minidom.parseString(thestr)
# print(reparsed.toprettyxml(indent="  "))
# Base library # pip3 install anytree # print(RenderTree(tree)) # reparsed = minidom.parseString(thestr) # print(reparsed.toprettyxml(indent="  "))