do not sort projections alphabetically (#23649)
* do not sort projections alphabetically * add assertion for ordered dict
This commit is contained in:
parent
2a7fa295fb
commit
2202ce27fa
@ -9,6 +9,7 @@
|
|||||||
import shutil
|
import shutil
|
||||||
import copy
|
import copy
|
||||||
import six
|
import six
|
||||||
|
import ruamel.yaml as yaml
|
||||||
|
|
||||||
from ordereddict_backport import OrderedDict
|
from ordereddict_backport import OrderedDict
|
||||||
|
|
||||||
@ -478,9 +479,12 @@ def __eq__(self, other):
|
|||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
ret = syaml.syaml_dict([('root', self.root)])
|
ret = syaml.syaml_dict([('root', self.root)])
|
||||||
if self.projections:
|
if self.projections:
|
||||||
projections_dict = syaml.syaml_dict(
|
# projections guaranteed to be ordered dict if true-ish
|
||||||
sorted(self.projections.items()))
|
# for python2.6, may be syaml or ruamel.yaml implementation
|
||||||
ret['projections'] = projections_dict
|
# so we have to check for both
|
||||||
|
types = (OrderedDict, syaml.syaml_dict, yaml.comments.CommentedMap)
|
||||||
|
assert isinstance(self.projections, types)
|
||||||
|
ret['projections'] = self.projections
|
||||||
if self.select:
|
if self.select:
|
||||||
ret['select'] = self.select
|
ret['select'] = self.select
|
||||||
if self.exclude:
|
if self.exclude:
|
||||||
|
Loading…
Reference in New Issue
Block a user