genuuid 838 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env python
  2. import re
  3. import sys
  4. def scan_path(path):
  5. bug = uuid = None
  6. with open(path, 'r') as fd:
  7. for line in fd:
  8. match = re.match('\*', line)
  9. if match:
  10. bug = uuid = None
  11. match = re.search('\[\[bug:([0-9]+)\]\[#[0-9]+\]\]', line)
  12. if match:
  13. bug = match.group(1)
  14. elif bug:
  15. match = re.search(':ID:\s+(.+?)\s*$', line)
  16. if match:
  17. uuid = match.group(1)
  18. print "UPDATE bugs SET cf_uuid='%s' WHERE bug_id=%s;" % (uuid, bug)
  19. scan_path('/Users/johnw/src/ledger/plan/TODO')
  20. scan_path('/Users/johnw/src/ledger/plan/TODO-3.0')
  21. scan_path('/Users/johnw/src/ledger/plan/TODO-2.6.2')
  22. scan_path('/Users/johnw/src/ledger/plan/TODO-2.6.1')
  23. ### genuuid ends here