summaryrefslogtreecommitdiff
path: root/representer.py
diff options
context:
space:
mode:
authorJacob Floyd <cognifloyd@gmail.com>2022-03-07 01:02:21 -0600
committerJacob Floyd <cognifloyd@gmail.com>2022-03-07 01:02:21 -0600
commit9b00a89d94a38a31af24e32031ade5a9e50b9371 (patch)
treeec70562129e01cf534b70e8ab5d66a2e54599093 /representer.py
parent93219905074f2db276572bccaf886e260355fbb5 (diff)
downloadruamel.yaml-9b00a89d94a38a31af24e32031ade5a9e50b9371.tar.gz
Preserve Octal format in YAML 1.1 docs
Diffstat (limited to 'representer.py')
-rw-r--r--representer.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/representer.py b/representer.py
index 820559b..c57d9aa 100644
--- a/representer.py
+++ b/representer.py
@@ -634,7 +634,10 @@ class RoundTripRepresenter(SafeRepresenter):
else:
s = format(data, 'o')
anchor = data.yaml_anchor(any=True)
- return self.insert_underscore('0o', s, data._underscore, anchor=anchor)
+ prefix = '0o'
+ if getattr(self.serializer, 'use_version', None) == (1, 1):
+ prefix = '0'
+ return self.insert_underscore(prefix, s, data._underscore, anchor=anchor)
def represent_hex_int(self, data):
# type: (Any) -> Any