From db7ca1a1ea4df4021e3ef4ea56b433b1e8eadce0 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Mon, 22 Mar 2021 08:00:51 +0100 Subject: Support for older ruamel.yaml --- lesana/templating.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lesana/templating.py b/lesana/templating.py index 95c6146..ff21d14 100644 --- a/lesana/templating.py +++ b/lesana/templating.py @@ -25,7 +25,14 @@ def to_yaml(data): """ if isinstance(data, str): if len(data) > 75 or "\n" in data: - data = ruamel.yaml.scalarstring.LiteralScalarString(data + "\n") + try: + data = ruamel.yaml.scalarstring.LiteralScalarString( + data + "\n" + ) + except AttributeError: + data = ruamel.yaml.scalarstring.PreservedScalarString( + data + "\n" + ) elif isinstance(data, decimal.Decimal): data = str(data) elif data is None: -- cgit v1.2.3