summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-08-28 14:01:24 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-08-28 14:01:24 -0400
commit0549e87e44fca8e586cd03c5e1dc9875e1f9b5fd (patch)
tree30c8cecbd68f5a9f25c7d85b197bbc527732f344 /src
parent0b6a3f40e0ae7a4cfdaef92b8d616488c4d3e376 (diff)
downloadbcfg2-0549e87e44fca8e586cd03c5e1dc9875e1f9b5fd.tar.gz
bcfg2-0549e87e44fca8e586cd03c5e1dc9875e1f9b5fd.tar.bz2
bcfg2-0549e87e44fca8e586cd03c5e1dc9875e1f9b5fd.zip
better stringification of Option objects
Diffstat (limited to 'src')
-rw-r--r--src/lib/Bcfg2/Options.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/lib/Bcfg2/Options.py b/src/lib/Bcfg2/Options.py
index 72a7108e9..6a50d3313 100644
--- a/src/lib/Bcfg2/Options.py
+++ b/src/lib/Bcfg2/Options.py
@@ -83,6 +83,29 @@ class Option(object):
else:
return value
+ def __str__(self):
+ rv = ["%s: " % self.__class__.__name__, self.desc]
+ if self.cmd or self.cf:
+ rv.append(" (")
+ if self.cmd:
+ if self.odesc:
+ if self.long:
+ rv.append("%s=%s" % (self.cmd, self.odesc))
+ else:
+ rv.append("%s %s" % (self.cmd, self.odesc))
+ else:
+ rv.append("%s" % self.cmd)
+
+ if self.cf:
+ if self.cmd:
+ rv.append("; ")
+ rv.append("[%s].%s" % self.cf)
+ if self.cmd or self.cf:
+ rv.append(")")
+ if hasattr(self, "value"):
+ rv.append(": %s" % self.value)
+ return "".join(rv)
+
def buildHelpMessage(self):
vals = []
if not self.cmd:
@@ -171,8 +194,8 @@ class OptionSet(dict):
if sys.argv[1] == 'init':
return
else:
- print("Warning! Unable to read specified configuration file: %s" %
- self.cfile)
+ print("Warning! Unable to read specified configuration file: %s"
+ % self.cfile)
def buildGetopt(self):
return ''.join([opt.buildGetopt() for opt in list(self.values())])