From 789fdb0cb6514859630b533cb53289f30c4426fe Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Fri, 18 Jun 2010 14:13:24 -0400 Subject: add util.get_cfg_option_list_or_str This is useful for getting a config option that is either string or a list as a list --- cloudinit/util.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'cloudinit/util.py') diff --git a/cloudinit/util.py b/cloudinit/util.py index 0cee8e17..7f5c1db4 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -53,6 +53,11 @@ def get_cfg_option_str(yobj, key, default=None): if not yobj.has_key(key): return default return yobj[key] +def get_cfg_option_list_or_str(yobj, key, default=None): + if not yobj.has_key(key): return default + if isinstance(yobj[key],list): return yobj[key] + return([yobj[key]]) + # merge values from src into cand. # if src has a key, cand will not override def mergedict(src,cand): -- cgit v1.2.3