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:
parent
24ec9f0ce3
commit
2e029fc2e5
1 changed files with 4 additions and 1 deletions
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
import ruamel.yaml.error as yaml_error
|
import ruamel.yaml.error as yaml_error
|
||||||
|
|
||||||
|
from ordereddict_backport import OrderedDict
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -166,7 +168,7 @@ class MirrorCollection(Mapping):
|
||||||
"""A mapping of mirror names to mirrors."""
|
"""A mapping of mirror names to mirrors."""
|
||||||
|
|
||||||
def __init__(self, mirrors=None, scope=None):
|
def __init__(self, mirrors=None, scope=None):
|
||||||
self._mirrors = dict(
|
self._mirrors = OrderedDict(
|
||||||
(name, Mirror.from_dict(mirror, name))
|
(name, Mirror.from_dict(mirror, name))
|
||||||
for name, mirror in (
|
for name, mirror in (
|
||||||
mirrors.items() if mirrors is not None else
|
mirrors.items() if mirrors is not None else
|
||||||
|
@ -178,6 +180,7 @@ def to_json(self, stream=None):
|
||||||
def to_yaml(self, stream=None):
|
def to_yaml(self, stream=None):
|
||||||
return syaml.dump(self.to_dict(True), stream)
|
return syaml.dump(self.to_dict(True), stream)
|
||||||
|
|
||||||
|
# TODO: this isn't called anywhere
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_yaml(stream, name=None):
|
def from_yaml(stream, name=None):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue