summaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2018-11-09 10:47:11 +0100
committerAnthon van der Neut <anthon@mnt.org>2018-11-09 10:47:11 +0100
commit68ea6b9ef755296c169b5416fe46ac48250e3c62 (patch)
tree8a44637378f20053b3c22ed342bdb2d13805dc97 /main.py
parent11e092f5746f4437628a4131ea8727db6c4c5692 (diff)
downloadruamel.yaml-68ea6b9ef755296c169b5416fe46ac48250e3c62.tar.gz
fix issue #194 object attributes always sorted0.15.77
Test for this issue in: https://bitbucket.org/ruamel/yaml.data/src/default/object/control_base_representer_mapping_sort.yaml *When this change indeed resolves your problem, please **Close** this issue*. *(You can do so using the WorkFlow pull-down (close to the top right of this page))*
Diffstat (limited to 'main.py')
-rw-r--r--main.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/main.py b/main.py
index 35613ef..851ae83 100644
--- a/main.py
+++ b/main.py
@@ -148,6 +148,7 @@ class YAML(object):
self.sequence_dash_offset = 0
self.compact_seq_seq = None
self.compact_seq_map = None
+ self.sort_base_mapping_type_on_output = None # default: sort
self.top_level_colon_align = None
self.prefix_colon = None
@@ -289,15 +290,14 @@ class YAML(object):
# type: () -> Any
attr = '_' + sys._getframe().f_code.co_name
if not hasattr(self, attr):
- setattr(
- self,
- attr,
- self.Representer(
- default_style=self.default_style,
- default_flow_style=self.default_flow_style,
- dumper=self,
- ),
+ repres = self.Representer(
+ default_style=self.default_style,
+ default_flow_style=self.default_flow_style,
+ dumper=self,
)
+ if self.sort_base_mapping_type_on_output is not None:
+ repres.sort_base_mapping_type_on_output = self.sort_base_mapping_type_on_output
+ setattr(self, attr, repres)
return getattr(self, attr)
# separate output resolver?