Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Standalone GNU Radio XML -> YAML block converter script
# Short script for converting GNU Radio XML blocks to YAML blocks
# without having to start GRC
# Please note that this program _WILL_ overwrite files.
# How to use:
# 1. Save this file to grc/converter/
# 2. Navigate back to the GNU Radio project root
# 3. Run: python3 -m grc.converter.cmdline_converter [name.xml]
# 4. Your YAML file has been created, called [name.block.yml]
# You can also specify the output filename:
# python3 -m grc.converter.cmdline_converter [input.xml] [output.block.yml]
import sys
from . import block
if not (1 < len(sys.argv) < 4):
print("Navigate to the project root and run the following:")
print(" python3 -m grc.converter.cmdline_converter [input.xml]")
if len(sys.argv) == 3:
output = open(sys.argv[-1], "w")
input = block.from_xml(sys.argv[-2])
output_filename = sys.argv[-1].split(".")[0] + ".block.yml"
output = open(output_filename, "w")
input = block.from_xml(sys.argv[-1])
block.dump(input, output)
print("Dumped to " + output_filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.