Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gorefs.json similar to gorefs.yaml #1815

Draft
wants to merge 1 commit into
base: spatil/push-consolidated-gorefs
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions scripts/goref_parser/parser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from email import header
import os
import sys
import json
import logging

sys.path.append("../parser/goref.py")
Expand All @@ -10,6 +10,7 @@
from utils import get_html_string, merge_dicts

import yaml
import ruamel.yaml
import markdown


Expand All @@ -22,7 +23,14 @@
for file_name in os.listdir("metadata/gorefs/"):
if any(
non_goref in file_name
for non_goref in ["README-editors.md", "Makefile", "README.md"]
for non_goref in [
"README-editors.md",
"Makefile",
"README.md",
"gorefs.yaml",
"gorefs.json",
"gorefs.schema.json",
]
):
continue

Expand Down Expand Up @@ -68,4 +76,9 @@
# export combined list of yamldown dicts compiled from all gorefs
# and export to YAML
with open("gorefs.yaml", "w") as outfile:
yaml.dump_all(combined_dict_list, outfile, sort_keys=False)
yaml.dump(combined_dict_list, outfile, sort_keys=False)

# convert the dumped YAML file into JSON
with open("gorefs.yaml", "r") as yaml_in, open("gorefs.json", "w") as json_out:
yaml_object = ruamel.yaml.safe_load(yaml_in)
json.dump(yaml_object, json_out, indent=4)