From: Konstantin Stepanov Date: Sun, 12 Dec 2010 01:04:27 +0000 (+0200) Subject: CrontabParser raises an exception on syntax error in config file X-Git-Tag: v1.1.0~16 X-Git-Url: https://vcs.maemo.org/git/?p=dbuscron;a=commitdiff_plain;h=78113c793b69920f281e1ad53daf6128f7e0047e CrontabParser raises an exception on syntax error in config file --- diff --git a/dbuscron/parser.py b/dbuscron/parser.py index 0d26c85..e38f097 100644 --- a/dbuscron/parser.py +++ b/dbuscron/parser.py @@ -12,6 +12,9 @@ def product(*args): else: yield () +class CrontabParserError(SyntaxError): + pass + class CrontabParser(object): __fields_sep = re.compile(r'\s+') __envvar_sep = re.compile(r'\s*=\s*') @@ -38,8 +41,10 @@ class CrontabParser(object): def __iter__(self): # bus type sender interface path member destination args command + lineno = 0 with open(self.__filename) as f: for line in f: + lineno += 1 line = line.strip() if not line or line.startswith('#'): @@ -50,7 +55,9 @@ class CrontabParser(object): parts = self.__envvar_sep(line, 1) if len(parts) == 2: self.__environ[parts[0]] = parts[1] - continue + continue + + raise SyntaxError('Unexpected number of records at line #%d.' % (lineno)) rule = [('s','S'), ('signal','method_call','method_return','error'), (None,), (None,), (None,), (None,), (None,), (None,)]