Replace DIY with JSON

This commit is contained in:
Daniel Lindmark 2024-05-20 18:35:50 -05:00
parent d0438a99db
commit 1ed402ceac

View File

@ -2,7 +2,9 @@
# Uses py-allspice + AllSpice API to save all design review comments to a markdown file
from allspice import AllSpice, DesignReview, Repository
import argparse
import sys, os
import sys
import os
import json
print("Starting Test")
@ -63,10 +65,13 @@ def write_to_file(file_name, string):
# Get the repository object
repository = Repository.request(allspice, "AllSpice-Demos", "Actions-demo")
# Build a string of attributes, separated by newlines
attributes_string = os.linesep.join(f"Repository.{attribute}={repository.attribute}" for attribute in get_attributes(repository))
attributes = get_attributes(repository)
repository_dict = {attribute: getattr(repository, attribute) for attribute in attributes}
# Write the attributes to the file
write_to_file(file_name, attributes_string)
# Convert the repository dictionary to a JSON string
repository_json = json.dumps(repository_dict, indent=4)
# Write the JSON string to a file
write_to_file(file_name, repository_json)
print("End-of-file")