From 7d5a292d293e9ae4b06b6ee00926fe46b1d7ad73 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Sat, 16 Jun 2012 13:15:34 -0700 Subject: Add comment as to why this cfg class is useful --- cloudinit/cfg.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cloudinit/cfg.py b/cloudinit/cfg.py index dd8f7baf..215ed855 100644 --- a/cloudinit/cfg.py +++ b/cloudinit/cfg.py @@ -20,6 +20,14 @@ import io from ConfigParser import (NoSectionError, NoOptionError, RawConfigParser) +# This config parser will not throw when sections don't exist +# and you are setting values on those sections which is useful +# when writing to new options that may not have corresponding +# sections. Also it can default other values when doing gets +# so that if those sections/options do not exist you will +# get a default instead of an error. Another useful case where +# you can avoid catching exceptions that you typically don't +# care about... class DefaultingConfigParser(RawConfigParser): DEF_INT = 0 -- cgit v1.2.3