Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- encoding: utf-8 -*-
- """I have a TaskPaper file I keep in Dropbox that contains some tasks for my
- daily routine.
- This script runs once a day and resets every item on that list, removing
- the @done tag and replacing the file.
- """
- import os
- import re
- # Path to the file containing my daily tasks
- ROUTINE_FILE = os.path.join(
- os.environ['HOME'], 'Dropbox', 'taskpaper', 'tasks_daily.taskpaper')
- # Regex for matching a @done tag
- DONE_REGEX = re.compile(r' @done(?:\([^\)]+\))?')
- def remove_done_tag(line):
- """Given a line from a TaskPaper document, remove any @done tags."""
- return DONE_REGEX.sub('', line).rstrip()
- def main():
- new_lines = []
- with open(ROUTINE_FILE, 'r') as infile:
- for line in infile:
- new_lines.append(remove_done_tag(line))
- with open(ROUTINE_FILE, 'w') as outfile:
- outfile.write('\n'.join(new_lines))
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement