From 39db31b5aef63df4a2eafc04cc4ac04b5b49a4c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Fantone?= Date: Mon, 25 May 2020 14:16:33 +0100 Subject: [PATCH] Add missing ensure_list util function --- powerdnsadmin/lib/utils.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/powerdnsadmin/lib/utils.py b/powerdnsadmin/lib/utils.py index 1169402..82e6b6b 100644 --- a/powerdnsadmin/lib/utils.py +++ b/powerdnsadmin/lib/utils.py @@ -5,6 +5,7 @@ import requests import hashlib import ipaddress +from collections.abc import Iterable from distutils.version import StrictVersion from urllib.parse import urlparse from datetime import datetime, timedelta @@ -212,6 +213,14 @@ def pretty_json(data): return json.dumps(data, sort_keys=True, indent=4) +def ensure_list(l): + if not l: + l = [] + elif not isinstance(l, Iterable) or isinstance(l, str): + l = [l] + + yield from l + class customBoxes: boxes = { "reverse": (" ", " "),