Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 923339 | Differences between
and this patch

Collapse All | Expand All

(-)a/whipper/common/yaml.py (+18 lines)
Line 0 Link Here
1
from ruamel.yaml import YAML as ruamel_YAML
2
from ruamel.yaml.compat import StringIO
3
4
# https://yaml.readthedocs.io/en/latest/example.html#output-of-dump-as-a-string
5
class YAML(ruamel_YAML):
6
    def __init__(self, *args, **kwargs):
7
        super().__init__()
8
        self.width = 4000
9
        self.default_flow_style = False
10
11
    def dump(self, data, stream=None, **kw):
12
        inefficient = False
13
        if stream is None:
14
            inefficient = True
15
            stream = StringIO()
16
        ruamel_YAML.dump(self, data, stream, **kw)
17
        if inefficient:
18
            return stream.getvalue()
(-)a/whipper/result/logger.py (-5 / +6 lines)
Lines 1-12 Link Here
1
import time
1
import time
2
import hashlib
2
import hashlib
3
import re
3
import re
4
import ruamel.yaml as yaml
5
from ruamel.yaml.comments import CommentedMap as OrderedDict
4
from ruamel.yaml.comments import CommentedMap as OrderedDict
6
5
7
import whipper
6
import whipper
8
7
9
from whipper.common import common
8
from whipper.common import common
9
from whipper.common.yaml import YAML
10
from whipper.result import result
10
from whipper.result import result
11
11
12
12
Lines 148-158 def logRip(self, ripResult, epoch): Link Here
148
        data["EOF"] = "End of status report"
148
        data["EOF"] = "End of status report"
149
        riplog["Conclusive status report"] = data
149
        riplog["Conclusive status report"] = data
150
150
151
        yaml = YAML(
152
            typ="rt",
153
            pure=True
154
        )
151
        riplog = yaml.dump(
155
        riplog = yaml.dump(
152
            riplog,
156
            riplog
153
            default_flow_style=False,
154
            width=4000,
155
            Dumper=yaml.RoundTripDumper
156
        )
157
        )
157
        # Add a newline after the "Log creation date" line
158
        # Add a newline after the "Log creation date" line
158
        riplog = re.sub(
159
        riplog = re.sub(
(-)a/whipper/test/test_result_logger.py (-8 / +6 lines)
Lines 3-10 Link Here
3
import os
3
import os
4
import re
4
import re
5
import unittest
5
import unittest
6
import ruamel.yaml
7
6
7
from whipper.common.yaml import YAML
8
from whipper.result.result import TrackResult, RipResult
8
from whipper.result.result import TrackResult, RipResult
9
from whipper.result.logger import WhipperLogger
9
from whipper.result.logger import WhipperLogger
10
10
Lines 163-178 def testLogger(self): Link Here
163
            ))
163
            ))
164
        )
164
        )
165
165
166
        yaml = ruamel.yaml.YAML()
166
        yaml = YAML(
167
            typ='rt',
168
            pure=True
169
        )
167
        parsedLog = yaml.load(actual)
170
        parsedLog = yaml.load(actual)
168
        self.assertEqual(
171
        self.assertEqual(
169
            actual,
172
            actual,
170
            ruamel.yaml.dump(
173
            yaml.dump(parsedLog)
171
                parsedLog,
172
                default_flow_style=False,
173
                width=4000,
174
                Dumper=ruamel.yaml.RoundTripDumper
175
            )
176
        )
174
        )
177
        log_body = "\n".join(actualLines[:-1]).encode()
175
        log_body = "\n".join(actualLines[:-1]).encode()
178
        self.assertEqual(
176
        self.assertEqual(

Return to bug 923339