From 2e029fc2e5fe58a1fb627e4856ab99a2abe17107 Mon Sep 17 00:00:00 2001 From: Peter Scheibel Date: Fri, 1 Nov 2019 14:02:08 -0700 Subject: [PATCH] Bugfix: respect order of mirrors in mirrors.yaml (#13544) Commands like "spack mirror list" were displaying mirrors in a different order than what was listed in the corresponding mirrors.yaml file. This restores commands to iterate over mirrors in the order that they appear in the config file. --- lib/spack/spack/mirror.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/spack/spack/mirror.py b/lib/spack/spack/mirror.py index 0c5e2a9cc2..21d34b579e 100644 --- a/lib/spack/spack/mirror.py +++ b/lib/spack/spack/mirror.py @@ -21,6 +21,8 @@ import ruamel.yaml.error as yaml_error +from ordereddict_backport import OrderedDict + try: from collections.abc import Mapping except ImportError: @@ -166,7 +168,7 @@ class MirrorCollection(Mapping): """A mapping of mirror names to mirrors.""" def __init__(self, mirrors=None, scope=None): - self._mirrors = dict( + self._mirrors = OrderedDict( (name, Mirror.from_dict(mirror, name)) for name, mirror in ( mirrors.items() if mirrors is not None else @@ -178,6 +180,7 @@ def to_json(self, stream=None): def to_yaml(self, stream=None): return syaml.dump(self.to_dict(True), stream) + # TODO: this isn't called anywhere @staticmethod def from_yaml(stream, name=None): try: