[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[minion-cvs] Give better error for right key in wrong section
Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv15237/lib/mixminion
Modified Files:
Config.py
Log Message:
Give better error for right key in wrong section
Index: Config.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Config.py,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- Config.py 25 Aug 2003 23:44:30 -0000 1.56
+++ Config.py 3 Sep 2003 15:49:58 -0000 1.57
@@ -65,8 +65,9 @@
import mixminion.Common
import mixminion.Crypto
-from mixminion.Common import MixError, LOG, ceilDiv, isPrintingAscii, \
- stripSpace, stringContains
+
+from mixminion.Common import MixError, LOG, ceilDiv, englishSequence, \
+ isPrintingAscii, stripSpace, stringContains
class ConfigError(MixError):
"""Thrown when an error is found in a configuration file."""
@@ -642,11 +643,18 @@
try:
rule, parseFn, default = secConfig[k]
except KeyError:
+ msg = "Unrecognized key %s on line %s"%(k,line)
+ acceptedIn = [ sn for sn,sc in self._syntax.items()
+ if sc.has_key(k) ]
+ acceptedIn.sort()
+ if acceptedIn:
+ msg += ". This key belongs in %s, but appears in %s."%(
+ englishSequence(acceptedIn, compound="or"),
+ secName)
if self._restrictKeys:
- raise ConfigError("Unrecognized key %s on line %s" %
- (k, line))
+ raise ConfigError(msg)
else:
- LOG.warn("Unrecognized key %s on line %s", k, line)
+ LOG.warn(msg)
continue
# Parse and validate the value of this entry.