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.
This commit is contained in:
Peter Scheibel 2019-11-01 14:02:08 -07:00 committed by GitHub
parent 24ec9f0ce3
commit 2e029fc2e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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: