summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCasey Dahlin <cdahlin@redhat.com>2009-01-19 23:47:23 -0500
committerCasey Dahlin <cdahlin@redhat.com>2009-01-19 23:47:23 -0500
commit132ec3528cc0ed2b86056339f80a918904eb5b99 (patch)
tree0de1dc3df2db330b63b2f5c48e979aa22b7e41ba
parenta79618db8a4337d7b0f1b97aa5b8deed688043bd (diff)
downloadupstate-132ec3528cc0ed2b86056339f80a918904eb5b99.tar.gz
upstate-132ec3528cc0ed2b86056339f80a918904eb5b99.tar.xz
upstate-132ec3528cc0ed2b86056339f80a918904eb5b99.zip
Allow value negation with ! for KVPairs
-rw-r--r--confparse.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/confparse.py b/confparse.py
index a5cecf2..0885299 100644
--- a/confparse.py
+++ b/confparse.py
@@ -466,6 +466,8 @@ class KVPair(ParseTreeNode):
"""
A key value pair, specified in the form:
key: value
+ or:
+ key: ! value
"""
def __init__(self, toks):
"""
@@ -476,12 +478,17 @@ class KVPair(ParseTreeNode):
if not toks[0].isword():
raise ParseError("Expected name before %s token" % toks[0])
self.name = toks[0]
+ self.truth = True
del toks[0]
toks.assert_full()
if not toks[0].isoper(":"):
raise ParseError("Expected `:` before %s token" % toks[0])
del toks[0]
toks.trim_leading_whitespace()
+ if toks[0].isoper("!"):
+ self.truth = False
+ del toks[0]
+ toks.trim_leading_whitespace()
if not toks[0].isword():
raise ParseError("Expected value before %s token" % toks[0])
self.value = toks[0]