Debian Codegraph @

tools/genuuid

raw
1 #!/usr/bin/env python3
2
3 import re
4 import sys
5
6 def scan_path(path):
7 bug = uuid = None
8 try:
9 with open(path, 'r') as fd:
10 for line in fd:
11 match = re.match(r'\*', line)
12 if match:
13 bug = uuid = None
14
15 match = re.search(r'\[\[bug:([0-9]+)\]\[#[0-9]+\]\]', line)
16 if match:
17 bug = match.group(1)
18 elif bug:
19 match = re.search(r':ID:\s+(.+?)\s*$', line)
20 if match:
21 uuid = match.group(1)
22 print(f"UPDATE bugs SET cf_uuid='{uuid}' WHERE bug_id={bug};")
23 except FileNotFoundError:
24 print(f'{path}: No such file or directory')
25
26 scan_path('/Users/johnw/src/ledger/plan/TODO')
27 scan_path('/Users/johnw/src/ledger/plan/TODO-3.0')
28 scan_path('/Users/johnw/src/ledger/plan/TODO-2.6.2')
29 scan_path('/Users/johnw/src/ledger/plan/TODO-2.6.1')
30
31 ### genuuid ends here