Files
revng-revng/python/revng/cli/model_dump/__main__.py
T
Giacomo Vercesi 1cc8c2c20c Fix pyYAML type error
Remove code in revng.cli.model_dump and override_by_name that was used
when the model had tags. The code subclassed the default pyYAML loader
to ignore unknown tags to allow reading the model data easily. Since the
model no longer has tags this code is dead and can be removed.
2022-06-13 18:35:37 +02:00

43 lines
912 B
Python

#
# This file is distributed under the MIT License. See LICENSE.md for details.
#
import argparse
import json
import sys
import yaml
from . import remap_metaaddress
def log(message):
sys.stderr.write(message + "\n")
def main():
parser = argparse.ArgumentParser(description="Extract and process rev.ng model.")
parser.add_argument(
"--remap",
action="store_true",
help="Remap MetaAddresses. Implies --json.",
)
args = parser.parse_args()
if args.remap:
args.json = True
# Consume YAML generated from revng-efa-extractcfg
input_file = sys.stdin
# Decode YAML
parsed_text = yaml.load(input_file, Loader=yaml.SafeLoader)
# Remap MetaAddress
if args.remap:
parsed_text = remap_metaaddress(parsed_text)
# Dump as JSON
print(json.dumps(parsed_text, indent=2, sort_keys=True, check_circular=False))
return 0