From: Tomas Gavenciak Date: Sat, 18 Sep 2010 07:13:31 +0000 (+0200) Subject: Fixes in config and config parsing X-Git-Tag: python-dummy-working~19 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=e9b511e32341f3712df0c285553378a140eaeb97;p=eval.git Fixes in config and config parsing Module name error, better exception information --- diff --git a/t/moe/config.py b/t/moe/config.py index 1de6799..dacaf42 100644 --- a/t/moe/config.py +++ b/t/moe/config.py @@ -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): diff --git a/t/moe/config_parser.py b/t/moe/config_parser.py index ce723ba..6dec8c9 100644 --- a/t/moe/config_parser.py +++ b/t/moe/config_parser.py @@ -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)