From 1a6b3e6c171deb56740596ae61954bd0aa885ebd Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Thu, 1 Apr 2021 23:07:26 +0100 Subject: [PATCH] use OrderedDict to restore exact order from JSON file --- src/soc/config/pinouts.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/soc/config/pinouts.py b/src/soc/config/pinouts.py index d152d00e..a1828c6a 100644 --- a/src/soc/config/pinouts.py +++ b/src/soc/config/pinouts.py @@ -2,6 +2,8 @@ import os import sys import json from pprint import pprint +from collections import OrderedDict + def _byteify(data, ignore_dicts = False): # if this is a unicode string, return its string representation @@ -16,7 +18,7 @@ def _byteify(data, ignore_dicts = False): # if this is a dictionary, return dictionary of byteified keys and values # but only if we haven't already byteified it if isinstance(data, dict) and not ignore_dicts: - return dict((_byteify(key, ignore_dicts=True), + return OrderedDict((_byteify(key, ignore_dicts=True), _byteify(value, ignore_dicts=True)) for key, value in data.iteritems()) # if it's anything else, return it in its original form @@ -26,7 +28,7 @@ def _byteify(data, ignore_dicts = False): def get_pinspecs(chipname=None, subset=None): chip = load_pinouts(chipname) pinmap = chip['pins.map'] - specs = {} + specs = OrderedDict() # preserve order for k, bus in chip['pins.specs'].items(): k, num = k.lower().split(":") name = '%s%s' % (k, num) -- 2.30.2