summaryrefslogtreecommitdiff
path: root/kanbanscripts/review.py
blob: a17cccccab8bf416919441b86f0d0c4ef2cf979c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/python
import os
from os.path import abspath, dirname
from operator import itemgetter

"""
    parse my gtd folder
    pull out files that start with the project name which is in []
    loop through and grab the project and then all the associated
    tasks (rest of the file name)
    print the results out to a file called @project.txt
"""
# assuming that this script is in ~/bin this will work:
BASE_DIR = abspath(dirname(dirname(__file__))) + '/'
project_list = []
inprogress = False
for root, dirnames, filenames in os.walk('%sgtd' % (BASE_DIR)):
    for f in filenames:
        if not f.startswith('@') and not f.startswith('.') and not f.startswith('Notes & Settings') and not f.startswith('projx') and not f.startswith("errands"):

            name = f[f.find("[") + 1:f.find("]")]
            task = f[f.find("]") + 2:-4]

            if f.find("]") > 5:
                inprogress = True
                task = "* " + task
            with open('%sgtd/%s' % (BASE_DIR, f), "r") as fl:
                for line in fl:
                    for part in line.split():
                        if "@waiting" in part:
                            task = task + " -- " + line.rstrip()
            project_list.append({
                "file": f,
                "name": name,
                "task": task,
                "inprogress": inprogress,
            })
    break

newlist = sorted(project_list, key=itemgetter('name', 'task'))

projects_file = open("/Users/sng/gtd/@projects.txt", 'w')
l_name = ''

for p in newlist:
    if l_name == p['name']:
        print >> projects_file, "\t" + p['task']
    else:
        print >> projects_file, "\n" + p['name']
        print >> projects_file, "\t" + p['task']
        l_name = p['name']