Update crontab class to allow with context manager

with __enter__ and __exit__ methods added to the CronTab class you should be able to use the with context manager like so:

with CronTab(user=True) as cron:
    job = cron.new(command="...", comment="...")
    job.minute.every(1)
    for item in cron:
        print(item)

print("cron.write() called upon exit of the context")

Merge request reports

Loading