summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2021-03-22 08:00:51 +0100
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2021-03-22 08:00:51 +0100
commitdb7ca1a1ea4df4021e3ef4ea56b433b1e8eadce0 (patch)
tree738dd2fac585d36c8037305a490f36edbf89c309
parent16f62d709c2150abca46c111d07c5d7052111370 (diff)
Support for older ruamel.yaml
-rw-r--r--lesana/templating.py9
1 files changed, 8 insertions, 1 deletions
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: