1 from __future__ import with_statement
3 from dbuscron.bus import DbusBus
6 from itertools import product
10 head, tail = args[0], args[1:]
12 for t in product(*tail):
18 class CrontabParser(object):
19 __fields_sep = re.compile(r'\s+')
20 __envvar_sep = re.compile(r'\s*=\s*')
33 def __init__(self, fname):
34 self.__bus = DbusBus()
35 self.__filename = fname
36 self.__environ = dict()
43 # bus type sender interface path member destination args command
44 with open(self.__filename) as f:
48 if not line or line.startswith('#'):
51 parts = self.__fields_sep.split(line, 8)
53 parts = self.__envvar_sep(line, 1)
55 self.__environ[parts[0]] = parts[1]
58 rule = [('s','S'), ('signal','method_call','method_return','error'), (None,), (None,), (None,), (None,), (None,), (None,)]
62 rule[p] = parts[p].split(',')
66 for r in product(*rule):
69 r[0] = self.__bus.system
71 r[0] = self.__bus.session
76 r[7] = r[7].split(';')
79 for i, f in enumerate(self.__fields):