1 from __future__ import with_statement
3 from dbuscron.bus import DbusBus
7 head, tail = args[0], args[1:]
9 for t in product(*tail):
15 class CrontabParser(object):
16 __fields_sep = re.compile(r'\s+')
17 __envvar_sep = re.compile(r'\s*=\s*')
30 def __init__(self, fname):
31 self.__bus = DbusBus()
32 self.__filename = fname
33 self.__environ = dict()
40 # bus type sender interface path member destination args command
41 with open(self.__filename) as f:
45 if not line or line.startswith('#'):
48 parts = self.__fields_sep.split(line, 8)
50 parts = self.__envvar_sep(line, 1)
52 self.__environ[parts[0]] = parts[1]
55 rule = [('s','S'), ('signal','method_call','method_return','error'), (None,), (None,), (None,), (None,), (None,), (None,)]
59 rule[p] = parts[p].split(',')
63 for r in product(*rule):
66 r[0] = self.__bus.system
68 r[0] = self.__bus.session
73 r[7] = r[7].split(';')
76 for i, f in enumerate(self.__fields):
80 class OptionsParser(dict):
81 def __init__(self, opts, args=None):
82 super(OptionsParser, self).__init__()
88 from getopt import getopt
89 go, _ = getopt(args, opts)
93 withval = k+':' in opts
97 if isinstance(self[k], list):
100 self[k] = [ self[k], v ]
106 self[k] = v if withval else 1
108 def __getitem__(self, k):
109 if not self.has_key(k):
111 return super(OptionsParser, self).__getitem__(k)
113 def __getattr__(self, k):