hwdef: Update scripts to parse CSV files properly

fails because of iterator not returning strings and 'dict' object has no attribute 'iterkeys'. Fixed so both scripts run.
This commit is contained in:
James O'Shannessy 2024-12-12 11:47:21 +11:00 committed by Peter Barker
parent 61ca071ba6
commit 4bc6115f1a
3 changed files with 5 additions and 5 deletions

View File

@ -28,7 +28,7 @@ def is_pin(str):
return False
def parse_adc_table(fname, table):
csvt = csv.reader(open(fname,'rb'))
csvt = csv.reader(open(fname,'r'))
i = 0
for row in csvt:
for col in row:

View File

@ -86,10 +86,10 @@ if len(sys.argv) != 2:
parse_af_table(sys.argv[1], table)
sys.stdout.write("AltFunction_map = {\n");
sys.stdout.write("AltFunction_map = {\n")
sys.stdout.write('\t# format is PIN:FUNCTION : AFNUM\n')
sys.stdout.write('\t# extracted from %s\n' % os.path.basename(sys.argv[1]))
for k in sorted(table.keys(), key=cmp_to_key(pin_compare)):
s = '"' + k + '"'
sys.stdout.write('\t%-20s\t:\t%s,\n' % (s, table[k]))
sys.stdout.write("}\n");
sys.stdout.write("}\n")

View File

@ -11,7 +11,7 @@ import sys, csv, os
def parse_dma_table(fname, table):
dma_num = 1
csvt = csv.reader(open(fname,'rb'))
csvt = csv.reader(open(fname,'r'))
i = 0
last_channel = -1
for row in csvt:
@ -78,7 +78,7 @@ sys.stdout.write("DMA_Map = {\n");
sys.stdout.write('\t# format is (DMA_TABLE, StreamNum, Channel)\n')
sys.stdout.write('\t# extracted from %s\n' % os.path.basename(sys.argv[1]))
for k in sorted(table.iterkeys()):
for k in sorted(table.keys()):
s = '"%s"' % k
sys.stdout.write('\t%-10s\t:\t[' % s)
for i in range(len(table[k])):