From ca68195b5d12c5410cfac8d459a0b0902c4c72c7 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 1 Dec 2020 18:50:12 +0100 Subject: fpga: Remove Python2 support from build system - 2to3 was used to convert the Python scripts, except where the tool choked and manual intervention was required - All references to "python" where replaced with "python3" - buffer() was replaced by memoryview() --- fpga/usrp3/tools/scripts/viv_ip_xci_editor.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'fpga/usrp3/tools/scripts/viv_ip_xci_editor.py') diff --git a/fpga/usrp3/tools/scripts/viv_ip_xci_editor.py b/fpga/usrp3/tools/scripts/viv_ip_xci_editor.py index 1f5ddf2c5..b749b76da 100644 --- a/fpga/usrp3/tools/scripts/viv_ip_xci_editor.py +++ b/fpga/usrp3/tools/scripts/viv_ip_xci_editor.py @@ -1,7 +1,8 @@ -#!/usr/bin/python +#!/usr/bin/env python3 import argparse -import os, sys +import os +import sys import re # Parse command line options @@ -20,7 +21,7 @@ def get_options(): print('ERROR: Please specify the location for the XCI file to operate on\n') parser.print_help() sys.exit(1) - if (not os.path.isfile(args.xci_filepath)): + if not os.path.isfile(args.xci_filepath): print('ERROR: XCI File ' + args.xci_filepath + ' could not be accessed or is not a file.\n') parser.print_help() sys.exit(1) @@ -59,7 +60,7 @@ def main(): print(xci_info['DEVICE'] + xci_info['PACKAGE'] + xci_info['SPEEDGRADE']) elif args.action == 'retarget': # Write a new XCI file with modified target info - if (not os.path.isdir(args.output_dir)): + if not os.path.isdir(args.output_dir): print('ERROR: IP Build directory ' + args.output_dir + ' could not be accessed or is not a directory.') sys.exit(1) if not args.target: @@ -76,16 +77,16 @@ def main(): replace_dict['TEMPERATURE_GRADE'] = target_tok[4] if len(target_tok) > 5: replace_dict['SILICON_REVISION'] = target_tok[5] - out_xci_filename = os.path.join(os.path.abspath(args.output_dir), os.path.basename(args.xci_filepath)) + out_xci_filename = os.path.join(os.path.abspath(args.output_dir), os.path.basename(args.xci_filepath)) with open(out_xci_filename, 'w') as out_file: for r_line in xci_lines: w_line = r_line - m = re.search(get_match_str('(' + '|'.join(replace_dict.keys()) + ')'), r_line) + m = re.search(get_match_str('(' + '|'.join(list(replace_dict.keys())) + ')'), r_line) if m is not None: w_line = m.group(1) + replace_dict[m.group(2)] + m.group(4) +'\n' else: - m = re.search(get_empty_match_str('(' + '|'.join(replace_dict.keys()) + ')'), r_line) + m = re.search(get_empty_match_str('(' + '|'.join(list(replace_dict.keys())) + ')'), r_line) if m is not None: w_line = m.group(1) + '>' + replace_dict[m.group(2)] + '\n' out_file.write(w_line) -- cgit v1.2.3