def setUpClass(cls): cls.default = CronExpression() cls.wildcard = CronExpression(expr='* * * * * * *') def keywords(): for k,v in CronExpression.KEYWORDS.items(): yield k.strip('@'), CronExpression(expr=v) cls.keywords = dict(keywords())
def decorator(func): @functools.wraps(func) def f(): try: return on_success(func(*args, **fkwargs)) except Exception as e: return on_failure(e) f.cron = CronExpression(**kwargs) f.ctx = ctx f.name = func.name = '.'.join((func.__module__ or '__main__', func.__name__)) f.reboot = kwargs.get('expr', '') == '@reboot' crontab.register(f.name, f) return f
def test_keywords(self): for k,v in self.keywords.items(): assert CronExpression(expr='@{0}'.format(k)) == v
def keywords(): for k,v in CronExpression.KEYWORDS.items(): yield k.strip('@'), CronExpression(expr=v)
def __eq__(self, other): if isinstance(other, basestring): other = CronExpression(expr=other) if not isinstance(other, CronExpression): return False return all(getattr(other, k) == v for (k, v) in self.__dict__.items())