diff options
author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2021-03-22 08:00:51 +0100 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2021-03-22 08:00:51 +0100 |
commit | db7ca1a1ea4df4021e3ef4ea56b433b1e8eadce0 (patch) | |
tree | 738dd2fac585d36c8037305a490f36edbf89c309 | |
parent | 16f62d709c2150abca46c111d07c5d7052111370 (diff) |
Support for older ruamel.yaml
-rw-r--r-- | lesana/templating.py | 9 |
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: |