File: genuuid

package info (click to toggle)
ledger 3.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,964 kB
  • sloc: cpp: 39,393; python: 4,476; perl: 1,309; sh: 477; lisp: 435; yacc: 103; makefile: 58
file content (31 lines) | stat: -rwxr-xr-x 978 bytes parent folder | download
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