]> mj.ucw.cz Git - eval.git/commitdiff
Fixes in config and config parsing
authorTomas Gavenciak <gavento@ucw.cz>
Sat, 18 Sep 2010 07:13:31 +0000 (09:13 +0200)
committerTomas Gavenciak <gavento@ucw.cz>
Sat, 18 Sep 2010 07:13:31 +0000 (09:13 +0200)
Module name error, better exception information

t/moe/config.py
t/moe/config_parser.py

index 1de679904a3b8a92f1ed3fdf19ffdb02408042dd..dacaf42a7a1450e45fa505c266cb7fecc1b01e1d 100644 (file)
@@ -103,8 +103,8 @@ class ConfigTree(object):
 
   def parse(self, s, source=None, level=0):
     """Parse `s` (stream/string) into the tree, see `moe.confparser.ConfigParser` for details."""
-    import moe.confparser
-    p = moe.confparser.ConfigParser(text, self, source=source, level=level)
+    import moe.config_parser
+    p = moe.config_parser.ConfigParser(s, self, source=source, level=level)
     p.parse()
 
   def parse_file(self, filename, desc=None, level=0):
@@ -288,7 +288,7 @@ class ConfigVar(ConfigElem):
     "Handle the case when fixed, raise exc. on different evaluation"
     val = super(ConfigVar,self).value(depth)
     if self.fixed and self.fixed_val != val:
-      raise VariableFixedError("value of var %s was fixed to %r but evaluated to %r", self.name, self.fixed_val, val)
+      raise VariableFixedError("value of var %r was fixed to %r but evaluated to %r", self.name, self.fixed_val, val)
     return val
 
   def add_operation(self, operation):
index ce723baf8ff52900e6cc6aefa1ee1214fd2d6b33..6dec8c9cd2a13d91e6a91b5ba32c5d7a8c933a7e 100644 (file)
@@ -236,8 +236,10 @@ class ConfigParser(object):
       op = 'SET'
     elif self.nexts(self.c_append):
       op = 'APPEND'
+    elif self.eof():
+      self.syntax_error('Unexpected end of file.')
     else:
-      self.syntax_error('Unknown operation.')
+      self.syntax_error('Unknown operation: %r...', self.peek(10))
     self.p_WS()
     exp = self.p_EXPRESSION()
     vname = (self.prefix+self.c_varname_sep+varname).lstrip(self.c_varname_sep)