Skip to content

Instantly share code, notes, and snippets.

Last active August 2, 2023 13:07
  • Star 11 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save haakov/4228ff6a14486641add538483093e86b to your computer and use it in GitHub Desktop.
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)
Copy link


I am trying your and I am getting:

from . import block

ImportError: cannot import name 'block' from 'grc.converter' (unknown location)

Any advice appreciated.


Copy link

Try replacing

from . import block


from gnuradio.grc.converter import block

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment