summaryrefslogtreecommitdiff
path: root/tools/genuuid
blob: 784da6acdca8c9c2cf2e0fd542c7bb99b4f2a0d1 (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
#!/usr/bin/env python3

import re
import sys

def scan_path(path):
    bug = uuid = None
    try:
        with open(path, 'r') as fd:
            for line in fd:
                match = re.match(r'\*', line)
                if match:
                    bug = uuid = None

                match = re.search(r'\[\[bug:([0-9]+)\]\[#[0-9]+\]\]', line)
                if match:
                    bug = match.group(1)
                elif bug:
                    match = re.search(r':ID:\s+(.+?)\s*$', line)
                    if match:
                        uuid = match.group(1)
                        print(f"UPDATE bugs SET cf_uuid='{uuid}' WHERE bug_id={bug};")
    except FileNotFoundError:
      print(f'{path}: No such file or directory')

scan_path('/Users/johnw/src/ledger/plan/TODO')
scan_path('/Users/johnw/src/ledger/plan/TODO-3.0')
scan_path('/Users/johnw/src/ledger/plan/TODO-2.6.2')
scan_path('/Users/johnw/src/ledger/plan/TODO-2.6.1')

### genuuid ends here